Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java

Issue 1757163002: [ImportantSites] JNI bindings for CBD filtering and Important Sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
index 25953f931889d2c80aead61edeec3b117f2d01d1..441e376f37e56d8304421bbdcbb401e6cb45ede6 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
@@ -41,6 +41,8 @@ public final class PrefServiceBridge {
// Object to notify when "clear browsing data" completes.
private OnClearBrowsingDataListener mClearBrowsingDataListener;
+ // Object to notify when we finished fetching important sites.
+ private ImportantSitesCallback mImportantSitesCallback;
private static final String LOG_TAG = "PrefServiceBridge";
// Constants related to the Contextual Search preference.
@@ -80,6 +82,19 @@ public final class PrefServiceBridge {
}
/**
+ * Interface for a class that is fetching important site information.
+ */
+ public interface ImportantSitesCallback {
Ted C 2016/04/21 20:18:16 You might want to consider just using a plan base/
dmurph 2016/04/21 20:31:23 That could work too. I was just modelling the curr
Ted C 2016/04/21 21:23:39 For callbacks I have a slight preference towards n
dmurph 2016/04/22 18:06:22 Due to passing the callback directly to CPP, I'm g
Ted C 2016/04/22 18:37:48 Indeed!
+ /**
+ * Called when the list of important registerable domains has been fetched from cpp.
+ * See net/base/registry_controlled_domains/registry_controlled_domain.h for more details on
+ * registrable domains and the current list of effective eTLDs.
+ * @param domains Important registerable domains.
+ */
+ public abstract void setImportantRegisterableDomains(String[] domains);
+ }
+
+ /**
* Interface to a class that receives callbacks instructing it to inform the user about other
* forms of browsing history.
*/
@@ -730,9 +745,26 @@ public final class PrefServiceBridge {
*/
public void clearBrowsingData(
OnClearBrowsingDataListener listener, int[] dataTypes, int timePeriod) {
+ clearBrowsingDataExcludingDomains(listener, dataTypes, timePeriod, new String[0]);
+ }
+
+ /**
+ * Same as above, but now we can specify a list of domains to exclude from clearing browsing
+ * data.
+ * Do not use this method unless caller knows what they're doing. Not all backends are supported
+ * yet, and more data than expected could be deleted. See crbug.com/113621.
+ * @param listener A listener to call back when the clearing is finished.
+ * @param dataTypes An array of browsing data types to delete, represented as values from
+ * the shared enum {@link org.chromium.chrome.browser.BrowsingDataType}.
+ * @param timePeriod The time period for which to delete the data, represented as a value from
+ * the shared enum {@link org.chromium.chrome.browser.TimePeriod}.
+ * @param blacklistDomains A list of registerable domains that we don't clear data for.
+ */
+ public void clearBrowsingDataExcludingDomains(OnClearBrowsingDataListener listener,
+ int[] dataTypes, int timePeriod, String[] blacklistDomains) {
assert mClearBrowsingDataListener == null;
mClearBrowsingDataListener = listener;
- nativeClearBrowsingData(dataTypes, timePeriod);
+ nativeClearBrowsingData(dataTypes, timePeriod, blacklistDomains);
}
/*
@@ -751,6 +783,29 @@ public final class PrefServiceBridge {
}
/**
+ * This fetches sites (registerable domains) that we consider important. This combines many
+ * pieces of information, including site engagement and permissions. The callback is called
+ * with the list of important registerable domains.
+ *
+ * See net/base/registry_controlled_domains/registry_controlled_domain.h for more details on
+ * registrable domains and the current list of effective eTLDs.
+ * @param callback The callback that will be used to set the list of important sites.
+ */
+ public void fetchImportantSites(ImportantSitesCallback callback) {
+ assert mImportantSitesCallback == null;
+ mImportantSitesCallback = callback;
+ nativeFetchImportantSites();
+ }
+
+ @CalledByNative
+ private void importantSitesFetched(String[] domains) {
+ if (mImportantSitesCallback != null) {
+ mImportantSitesCallback.setImportantRegisterableDomains(domains);
+ mImportantSitesCallback = null;
+ }
+ }
+
+ /**
* Requests that the web history service finds out if we should inform the user about the
* existence of other forms of browsing history. The response will be asynchronous, through
* {@link OtherFormsOfBrowsingHistoryListener}.
@@ -1050,10 +1105,12 @@ public final class PrefServiceBridge {
private native void nativeSetBrowsingDataDeletionPreference(int dataType, boolean value);
private native int nativeGetBrowsingDataDeletionTimePeriod();
private native void nativeSetBrowsingDataDeletionTimePeriod(int timePeriod);
- private native void nativeClearBrowsingData(int[] dataTypes, int timePeriod);
+ private native void nativeClearBrowsingData(
+ int[] dataTypes, int timePeriod, String[] blacklistDomains);
private native void nativeRequestInfoAboutOtherFormsOfBrowsingHistory(
OtherFormsOfBrowsingHistoryListener listener);
private native boolean nativeCanDeleteBrowsingHistory();
+ private native void nativeFetchImportantSites();
private native void nativeSetAllowCookiesEnabled(boolean allow);
private native void nativeSetBackgroundSyncEnabled(boolean allow);
private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled);

Powered by Google App Engine
This is Rietveld 408576698