зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1298783
- Implement adding pages to highlights blocklist r=Grisha
MozReview-Commit-ID: 5dCLHx2UJ5 --HG-- extra : rebase_source : f4ed88a8133b677a4a2aff91790cb11ffb8bfc56
This commit is contained in:
Родитель
d360e38495
Коммит
00b1aee19e
|
@ -176,6 +176,13 @@ public abstract class BrowserDB {
|
|||
*/
|
||||
public abstract CursorLoader getHighlights(Context context, int limit);
|
||||
|
||||
/**
|
||||
* Block a page from the highlights list.
|
||||
*
|
||||
* @param url The page URL. Only pages exactly matching this URL will be blocked.
|
||||
*/
|
||||
public abstract void blockActivityStreamSite(ContentResolver cr, String url);
|
||||
|
||||
public static BrowserDB from(final Context context) {
|
||||
return from(GeckoProfile.get(context));
|
||||
}
|
||||
|
|
|
@ -133,6 +133,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
|
||||
static final int HIGHLIGHTS = 1300;
|
||||
|
||||
static final int ACTIVITY_STREAM_BLOCKLIST = 1400;
|
||||
|
||||
static final String DEFAULT_BOOKMARKS_SORT_ORDER = Bookmarks.TYPE
|
||||
+ " ASC, " + Bookmarks.POSITION + " ASC, " + Bookmarks._ID
|
||||
+ " ASC";
|
||||
|
@ -297,6 +299,8 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
URI_MATCHER.addURI(BrowserContract.AUTHORITY, "topsites", TOPSITES);
|
||||
|
||||
URI_MATCHER.addURI(BrowserContract.AUTHORITY, "highlights", HIGHLIGHTS);
|
||||
|
||||
URI_MATCHER.addURI(BrowserContract.AUTHORITY, ActivityStreamBlocklist.TABLE_NAME, ACTIVITY_STREAM_BLOCKLIST);
|
||||
}
|
||||
|
||||
private static class ShrinkMemoryReceiver extends BroadcastReceiver {
|
||||
|
@ -649,6 +653,12 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
break;
|
||||
}
|
||||
|
||||
case ACTIVITY_STREAM_BLOCKLIST: {
|
||||
trace("Insert on ACTIVITY_STREAM_BLOCKLIST: " + uri);
|
||||
id = insertActivityStreamBlocklistSite(uri, values);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
Table table = findTableFor(match);
|
||||
if (table == null) {
|
||||
|
@ -1878,6 +1888,17 @@ public class BrowserProvider extends SharedBrowserDatabaseProvider {
|
|||
return db.insertOrThrow(TABLE_THUMBNAILS, null, values);
|
||||
}
|
||||
|
||||
private long insertActivityStreamBlocklistSite(final Uri uri, final ContentValues values) {
|
||||
final String url = values.getAsString(ActivityStreamBlocklist.URL);
|
||||
trace("Inserting url into highlights blocklist, URL: " + url);
|
||||
|
||||
final SQLiteDatabase db = getWritableDatabase(uri);
|
||||
values.put(ActivityStreamBlocklist.CREATED, System.currentTimeMillis());
|
||||
|
||||
beginWrite(db);
|
||||
return db.insertOrThrow(TABLE_ACTIVITY_STREAM_BLOCKLIST, null, values);
|
||||
}
|
||||
|
||||
private long insertUrlAnnotation(final Uri uri, final ContentValues values) {
|
||||
final String url = values.getAsString(UrlAnnotations.URL);
|
||||
trace("Inserting url annotations for URL: " + url);
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.mozilla.gecko.AppConstants;
|
|||
import org.mozilla.gecko.Telemetry;
|
||||
import org.mozilla.gecko.annotation.RobocopTarget;
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.db.BrowserContract.ActivityStreamBlocklist;
|
||||
import org.mozilla.gecko.db.BrowserContract.Bookmarks;
|
||||
import org.mozilla.gecko.db.BrowserContract.Combined;
|
||||
import org.mozilla.gecko.db.BrowserContract.ExpirePriority;
|
||||
|
@ -118,6 +119,7 @@ public class LocalBrowserDB extends BrowserDB {
|
|||
private final Uri mTopSitesUriWithProfile;
|
||||
private final Uri mHighlightsUriWithProfile;
|
||||
private final Uri mSearchHistoryUri;
|
||||
private final Uri mActivityStreamBlockedUriWithProfile;
|
||||
|
||||
private LocalSearches searches;
|
||||
private LocalTabsAccessor tabsAccessor;
|
||||
|
@ -145,6 +147,7 @@ public class LocalBrowserDB extends BrowserDB {
|
|||
mTopSitesUriWithProfile = DBUtils.appendProfile(profile, TopSites.CONTENT_URI);
|
||||
mHighlightsUriWithProfile = DBUtils.appendProfile(profile, Highlights.CONTENT_URI);
|
||||
mThumbnailsUriWithProfile = DBUtils.appendProfile(profile, Thumbnails.CONTENT_URI);
|
||||
mActivityStreamBlockedUriWithProfile = DBUtils.appendProfile(profile, ActivityStreamBlocklist.CONTENT_URI);
|
||||
|
||||
mSearchHistoryUri = BrowserContract.SearchHistory.CONTENT_URI;
|
||||
|
||||
|
@ -1843,4 +1846,12 @@ public class LocalBrowserDB extends BrowserDB {
|
|||
|
||||
return new CursorLoader(context, uri, null, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blockActivityStreamSite(ContentResolver cr, String url) {
|
||||
final ContentValues values = new ContentValues();
|
||||
values.put(ActivityStreamBlocklist.URL, url);
|
||||
cr.insert(mActivityStreamBlockedUriWithProfile, values);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче