From da3e030722f8703a27595e31a87428ca5df1f213 Mon Sep 17 00:00:00 2001 From: Leon Scroggins Date: Tue, 2 Mar 2010 16:01:49 -0500 Subject: Do not insert duplicate urls into the browser database. Move the logic for finding similar URLs to frameworks/base, and use it in addBookmark. In BrowserActivity, call smartUrlFilter before calling updateVisitedHistory, so the '/' will be appended before adding to the database. Part of fix for http://b/issue?id=2442391 Depends on a change to frameworks/base --- src/com/android/browser/Bookmarks.java | 38 +--------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'src/com/android/browser/Bookmarks.java') diff --git a/src/com/android/browser/Bookmarks.java b/src/com/android/browser/Bookmarks.java index 8d98f8995..2cbd85122 100644 --- a/src/com/android/browser/Bookmarks.java +++ b/src/com/android/browser/Bookmarks.java @@ -35,12 +35,6 @@ import java.util.Date; * This class is purely to have a common place for adding/deleting bookmarks. */ /* package */ class Bookmarks { - private static final String WHERE_CLAUSE - = "url = ? OR url = ? OR url = ? OR url = ?"; - private static final String WHERE_CLAUSE_SECURE = "url = ? OR url = ?"; - - private static String[] SELECTION_ARGS; - // We only want the user to be able to bookmark content that // the browser can handle directly. private static final String acceptableBookmarkSchemes[] = { @@ -71,38 +65,8 @@ import java.util.Date; Bitmap thumbnail, boolean retainIcon) { // Want to append to the beginning of the list long creationTime = new Date().getTime(); - // First we check to see if the user has already visited this - // site. They may have bookmarked it in a different way from - // how it's stored in the database, so allow different combos - // to map to the same url. - boolean secure = false; - String compareString = url; - if (compareString.startsWith("http://")) { - compareString = compareString.substring(7); - } else if (compareString.startsWith("https://")) { - compareString = compareString.substring(8); - secure = true; - } - if (compareString.startsWith("www.")) { - compareString = compareString.substring(4); - } - if (secure) { - SELECTION_ARGS = new String[2]; - SELECTION_ARGS[0] = "https://" + compareString; - SELECTION_ARGS[1] = "https://www." + compareString; - } else { - SELECTION_ARGS = new String[4]; - SELECTION_ARGS[0] = compareString; - SELECTION_ARGS[1] = "www." + compareString; - SELECTION_ARGS[2] = "http://" + compareString; - SELECTION_ARGS[3] = "http://" + SELECTION_ARGS[1]; - } - Cursor cursor = cr.query(Browser.BOOKMARKS_URI, - Browser.HISTORY_PROJECTION, - secure ? WHERE_CLAUSE_SECURE : WHERE_CLAUSE, - SELECTION_ARGS, - null); ContentValues map = new ContentValues(); + Cursor cursor = Browser.getVisitedLike(cr, url); if (cursor.moveToFirst() && cursor.getInt( Browser.HISTORY_PROJECTION_BOOKMARK_INDEX) == 0) { // This means we have been to this site but not bookmarked -- cgit v1.2.3