From 9c8d886bb776ab98fc3b8aa26134c7a2611a6076 Mon Sep 17 00:00:00 2001 From: Leon Clarke Date: Thu, 24 Sep 2009 15:20:10 +0100 Subject: [PATCH] Coloring clicked-on links Following review comments Merging in ben's change Whitespace --- core/java/android/provider/Browser.java | 26 +++++++++++++++++++++++ core/java/android/webkit/WebViewCore.java | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/core/java/android/provider/Browser.java b/core/java/android/provider/Browser.java index 028d3d7b2d09f..4600b49c3b82c 100644 --- a/core/java/android/provider/Browser.java +++ b/core/java/android/provider/Browser.java @@ -273,6 +273,32 @@ public class Browser { } } + /** + * Returns all the URLs in the history. + * Requires {@link android.Manifest.permission#READ_HISTORY_BOOKMARKS} + * @param cr The ContentResolver used to access the database. + * @hide pending API council approval + */ + public static final String[] getVisitedHistory(ContentResolver cr) { + try { + String[] projection = new String[] { "url" }; + Cursor c = cr.query(BOOKMARKS_URI, + projection, + "visits > 0", + null, null); + String[] str = new String[c.getCount()]; + int i = 0; + while (c.moveToNext()) { + str[i] = c.getString(0); + i++; + } + c.deactivate(); + return str; + } catch (IllegalStateException e) { + return new String[0]; + } + } + /** * If there are more than MAX_HISTORY_COUNT non-bookmark history * items in the bookmark/history table, delete TRUNCATE_N_OLDEST diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java index c87e5a5915735..f617401f5e3e0 100644 --- a/core/java/android/webkit/WebViewCore.java +++ b/core/java/android/webkit/WebViewCore.java @@ -30,6 +30,7 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Process; +import android.provider.Browser; import android.util.Log; import android.util.SparseBooleanArray; import android.view.KeyEvent; @@ -310,6 +311,10 @@ final class WebViewCore { }); } + protected String[] populateVisitedLinks() { + return Browser.getVisitedHistory(mContext.getContentResolver()); + } + /** * Shows a prompt to ask the user to set the Geolocation permission state * for the given origin.