Bug 1291751 - Allow filter() on just bookmarks or history
filter() previously operated on both bookmarks and history at the same time, i.e. by
using the combined table. For the AS detail-view search functionality we want
to be able to search on just history, or just bookmarks. For now it's probably
best to implement this by filtering out history or bookmarks as appropriate in
the existing search (the specs aren't finalised yet, and this provides a good
interim solution). In future we might want to have optimised specific
queries for history and bookmarks separately, but we'll want to have telemetry
data on how often these views are even used before investing in that.
MozReview-Commit-ID: BjRcHcdw5t4
--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDB.java
@@ -32,17 +32,19 @@ import android.graphics.drawable.BitmapD
* {@link GeckoProfile#setBrowserDBFactory(BrowserDB.Factory)}.
*/
public interface BrowserDB {
public interface Factory {
public BrowserDB get(String profileName, File profileDir);
}
public static enum FilterFlags {
- EXCLUDE_PINNED_SITES
+ EXCLUDE_PINNED_SITES,
+ EXCLUDE_BOOKMARKS,
+ EXCLUDE_HISTORY
}
public abstract Searches getSearches();
public abstract TabsAccessor getTabsAccessor();
public abstract URLMetadata getURLMetadata();
@RobocopTarget UrlAnnotations getUrlAnnotations();
/**
--- a/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/LocalBrowserDB.java
@@ -630,16 +630,22 @@ public class LocalBrowserDB implements B
if (flags.contains(FilterFlags.EXCLUDE_PINNED_SITES)) {
selection = Combined.URL + " NOT IN (SELECT " +
Bookmarks.URL + " FROM bookmarks WHERE " +
DBUtils.qualifyColumn("bookmarks", Bookmarks.PARENT) + " = ? AND " +
DBUtils.qualifyColumn("bookmarks", Bookmarks.IS_DELETED) + " == 0)";
selectionArgs = new String[] { String.valueOf(Bookmarks.FIXED_PINNED_LIST_ID) };
}
+ if (flags.contains(FilterFlags.EXCLUDE_BOOKMARKS)) {
+ selection = DBUtils.concatenateWhere(selection, Combined.HISTORY_ID + " != -1");
+ }
+ if (flags.contains(FilterFlags.EXCLUDE_HISTORY)) {
+ selection = DBUtils.concatenateWhere(selection, Combined.BOOKMARK_ID + " NOT NULL");
+ }
return filterAllSites(cr,
new String[] { Combined._ID,
Combined.URL,
Combined.TITLE,
Combined.BOOKMARK_ID,
Combined.HISTORY_ID },
constraint,