mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1025062 - Part 1: Add filter flag to exclude pinned sites in searches (r=rnewman)
This commit is contained in:
parent
0b934bf002
commit
64f3c41280
@ -6,6 +6,7 @@
|
||||
package org.mozilla.gecko.db;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract.ExpirePriority;
|
||||
@ -35,6 +36,10 @@ public class BrowserDB {
|
||||
public static String KEYWORD = "keyword";
|
||||
}
|
||||
|
||||
public static enum FilterFlags {
|
||||
EXCLUDE_PINNED_SITES
|
||||
}
|
||||
|
||||
private static BrowserDBIface sDb = null;
|
||||
private static SuggestedSites sSuggestedSites;
|
||||
|
||||
@ -42,7 +47,8 @@ public class BrowserDB {
|
||||
public void invalidateCachedState();
|
||||
|
||||
@RobocopTarget
|
||||
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit);
|
||||
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit,
|
||||
EnumSet<FilterFlags> flags);
|
||||
|
||||
// This should only return frecent sites. BrowserDB.getTopSites will do the
|
||||
// work to combine that list with the pinned sites list.
|
||||
@ -176,7 +182,13 @@ public class BrowserDB {
|
||||
|
||||
@RobocopTarget
|
||||
public static Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
|
||||
return sDb.filter(cr, constraint, limit);
|
||||
return filter(cr, constraint, limit, EnumSet.noneOf(FilterFlags.class));
|
||||
}
|
||||
|
||||
@RobocopTarget
|
||||
public static Cursor filter(ContentResolver cr, CharSequence constraint, int limit,
|
||||
EnumSet<FilterFlags> flags) {
|
||||
return sDb.filter(cr, constraint, limit, flags);
|
||||
}
|
||||
|
||||
private static void appendUrlsFromCursor(List<String> urls, Cursor c) {
|
||||
|
@ -11,6 +11,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
@ -32,6 +33,7 @@ import org.mozilla.gecko.db.BrowserContract.ReadingListItems;
|
||||
import org.mozilla.gecko.db.BrowserContract.SyncColumns;
|
||||
import org.mozilla.gecko.db.BrowserContract.Thumbnails;
|
||||
import org.mozilla.gecko.db.BrowserContract.URLColumns;
|
||||
import org.mozilla.gecko.db.BrowserDB.FilterFlags;
|
||||
import org.mozilla.gecko.distribution.Distribution;
|
||||
import org.mozilla.gecko.favicons.decoders.FaviconDecoder;
|
||||
import org.mozilla.gecko.favicons.decoders.LoadFaviconResult;
|
||||
@ -507,7 +509,19 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit) {
|
||||
public Cursor filter(ContentResolver cr, CharSequence constraint, int limit,
|
||||
EnumSet<FilterFlags> flags) {
|
||||
String selection = "";
|
||||
String[] selectionArgs = null;
|
||||
|
||||
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) };
|
||||
}
|
||||
|
||||
return filterAllSites(cr,
|
||||
new String[] { Combined._ID,
|
||||
Combined.URL,
|
||||
@ -517,7 +531,8 @@ public class LocalBrowserDB implements BrowserDB.BrowserDBIface {
|
||||
Combined.HISTORY_ID },
|
||||
constraint,
|
||||
limit,
|
||||
null);
|
||||
null,
|
||||
selection, selectionArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,10 +5,12 @@
|
||||
package org.mozilla.gecko.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserDB.FilterFlags;
|
||||
import org.mozilla.gecko.db.BrowserProvider;
|
||||
import org.mozilla.gecko.db.LocalBrowserDB;
|
||||
import org.mozilla.gecko.util.FileUtils;
|
||||
@ -270,7 +272,8 @@ public class testBrowserProviderPerf extends BaseRobocopTest {
|
||||
// Make sure we're querying the right profile.
|
||||
final LocalBrowserDB db = new LocalBrowserDB(mProfile);
|
||||
|
||||
final Cursor before = db.filter(mResolver, KNOWN_PREFIX, limit);
|
||||
final Cursor before = db.filter(mResolver, KNOWN_PREFIX, limit,
|
||||
EnumSet.noneOf(FilterFlags.class));
|
||||
try {
|
||||
mAsserter.is(before.getCount(), 0, "Starts empty");
|
||||
} finally {
|
||||
@ -295,7 +298,8 @@ public class testBrowserProviderPerf extends BaseRobocopTest {
|
||||
|
||||
// Time the query.
|
||||
final long start = SystemClock.uptimeMillis();
|
||||
final Cursor c = db.filter(mResolver, KNOWN_PREFIX, limit);
|
||||
final Cursor c = db.filter(mResolver, KNOWN_PREFIX, limit,
|
||||
EnumSet.noneOf(FilterFlags.class));
|
||||
|
||||
try {
|
||||
final int count = c.getCount();
|
||||
|
Loading…
Reference in New Issue
Block a user