Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.preferences; | 5 package org.chromium.chrome.browser.preferences; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
| 9 import android.preference.PreferenceManager; | 9 import android.preference.PreferenceManager; |
| 10 import android.util.Log; | 10 import android.util.Log; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 public static final int SUPERVISED_USER_FILTERING_WARN = 1; | 34 public static final int SUPERVISED_USER_FILTERING_WARN = 1; |
| 35 public static final int SUPERVISED_USER_FILTERING_BLOCK = 2; | 35 public static final int SUPERVISED_USER_FILTERING_BLOCK = 2; |
| 36 | 36 |
| 37 private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion"; | 37 private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion"; |
| 38 private static final int MIGRATION_CURRENT_VERSION = 4; | 38 private static final int MIGRATION_CURRENT_VERSION = 4; |
| 39 | 39 |
| 40 private static final String HTTPS_SCHEME = "https"; | 40 private static final String HTTPS_SCHEME = "https"; |
| 41 | 41 |
| 42 // Object to notify when "clear browsing data" completes. | 42 // Object to notify when "clear browsing data" completes. |
| 43 private OnClearBrowsingDataListener mClearBrowsingDataListener; | 43 private OnClearBrowsingDataListener mClearBrowsingDataListener; |
| 44 // Object to notify when we finished fetching important sites. | |
| 45 private ImportantSitesCallback mImportantSitesCallback; | |
| 44 private static final String LOG_TAG = "PrefServiceBridge"; | 46 private static final String LOG_TAG = "PrefServiceBridge"; |
| 45 | 47 |
| 46 // Constants related to the Contextual Search preference. | 48 // Constants related to the Contextual Search preference. |
| 47 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; | 49 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; |
| 48 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; | 50 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; |
| 49 | 51 |
| 50 // The key to store whether the Location Permission was automatically added for the search | 52 // The key to store whether the Location Permission was automatically added for the search |
| 51 // engine set as default. | 53 // engine set as default. |
| 52 public static final String LOCATION_AUTO_ALLOWED = "search_engine_location_a uto_allowed"; | 54 public static final String LOCATION_AUTO_ALLOWED = "search_engine_location_a uto_allowed"; |
| 53 | 55 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 73 } | 75 } |
| 74 | 76 |
| 75 /** | 77 /** |
| 76 * Interface for a class that is listening to clear browser data events. | 78 * Interface for a class that is listening to clear browser data events. |
| 77 */ | 79 */ |
| 78 public interface OnClearBrowsingDataListener { | 80 public interface OnClearBrowsingDataListener { |
| 79 public abstract void onBrowsingDataCleared(); | 81 public abstract void onBrowsingDataCleared(); |
| 80 } | 82 } |
| 81 | 83 |
| 82 /** | 84 /** |
| 85 * Interface for a class that is fetching important site information. | |
| 86 */ | |
| 87 public interface ImportantSitesCallback { | |
| 88 /** | |
| 89 * Called by native code to populate the set of important registerable d omains. | |
|
Theresa
2016/04/21 16:05:28
Technically this isn't called by native code (it's
dmurph
2016/04/21 18:53:25
Done.
| |
| 90 * See net/base/registry_controlled_domains/registry_controlled_domain.h for more details on | |
| 91 * registrable domains and the current list of effective eTLDs. | |
| 92 * @param domains important registerable domains. | |
| 93 */ | |
| 94 public abstract void setImportantRegisterableDomains(String[] domains); | |
| 95 } | |
| 96 | |
| 97 /** | |
| 83 * Interface to a class that receives callbacks instructing it to inform the user about other | 98 * Interface to a class that receives callbacks instructing it to inform the user about other |
| 84 * forms of browsing history. | 99 * forms of browsing history. |
| 85 */ | 100 */ |
| 86 public interface OtherFormsOfBrowsingHistoryListener { | 101 public interface OtherFormsOfBrowsingHistoryListener { |
| 87 /** | 102 /** |
| 88 * Called by the web history service when it discovers that other forms of browsing history | 103 * Called by the web history service when it discovers that other forms of browsing history |
| 89 * exist. | 104 * exist. |
| 90 */ | 105 */ |
| 91 @CalledByNative("OtherFormsOfBrowsingHistoryListener") | 106 @CalledByNative("OtherFormsOfBrowsingHistoryListener") |
| 92 public abstract void enableDialogAboutOtherFormsOfBrowsingHistory(); | 107 public abstract void enableDialogAboutOtherFormsOfBrowsingHistory(); |
| (...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 * It can be null, but many operations (e.g. navigation) are | 738 * It can be null, but many operations (e.g. navigation) are |
| 724 * ill-advised while browsing data is being cleared. | 739 * ill-advised while browsing data is being cleared. |
| 725 * @param listener A listener to call back when the clearing is finished. | 740 * @param listener A listener to call back when the clearing is finished. |
| 726 * @param dataTypes An array of browsing data types to delete, represented a s values from | 741 * @param dataTypes An array of browsing data types to delete, represented a s values from |
| 727 * the shared enum {@link org.chromium.chrome.browser.BrowsingDataType} . | 742 * the shared enum {@link org.chromium.chrome.browser.BrowsingDataType} . |
| 728 * @param timePeriod The time period for which to delete the data, represent ed as a value from | 743 * @param timePeriod The time period for which to delete the data, represent ed as a value from |
| 729 * the shared enum {@link org.chromium.chrome.browser.TimePeriod}. | 744 * the shared enum {@link org.chromium.chrome.browser.TimePeriod}. |
| 730 */ | 745 */ |
| 731 public void clearBrowsingData( | 746 public void clearBrowsingData( |
| 732 OnClearBrowsingDataListener listener, int[] dataTypes, int timePerio d) { | 747 OnClearBrowsingDataListener listener, int[] dataTypes, int timePerio d) { |
| 748 clearBrowsingDataExcludingDomains(listener, dataTypes, timePeriod, new S tring[0]); | |
| 749 } | |
| 750 | |
| 751 /** | |
| 752 * Same as above, but now we can specify a list of domains to exclude from c learing browsing | |
| 753 * data. | |
| 754 * Do not use this method unless caller knows what they're doing. Not all ba ckends are supported | |
| 755 * yet, and more data than expected could be deleted. See crbug.com/113621. | |
| 756 */ | |
| 757 public void clearBrowsingDataExcludingDomains(OnClearBrowsingDataListener li stener, | |
|
Theresa
2016/04/21 16:05:28
add JavaDocs for the params (or at least the extra
dmurph
2016/04/21 18:53:25
Done.
dmurph
2016/04/21 18:53:25
Done.
| |
| 758 int[] dataTypes, int timePeriod, String[] origins) { | |
| 733 assert mClearBrowsingDataListener == null; | 759 assert mClearBrowsingDataListener == null; |
| 734 mClearBrowsingDataListener = listener; | 760 mClearBrowsingDataListener = listener; |
| 735 nativeClearBrowsingData(dataTypes, timePeriod); | 761 nativeClearBrowsingData(dataTypes, timePeriod, origins); |
| 736 } | 762 } |
| 737 | 763 |
| 738 /* | 764 /* |
| 739 * Whether browser history can be deleted by the user. | 765 * Whether browser history can be deleted by the user. |
| 740 */ | 766 */ |
| 741 public boolean canDeleteBrowsingHistory() { | 767 public boolean canDeleteBrowsingHistory() { |
| 742 return nativeCanDeleteBrowsingHistory(); | 768 return nativeCanDeleteBrowsingHistory(); |
| 743 } | 769 } |
| 744 | 770 |
| 745 @CalledByNative | 771 @CalledByNative |
| 746 private void browsingDataCleared() { | 772 private void browsingDataCleared() { |
| 747 if (mClearBrowsingDataListener != null) { | 773 if (mClearBrowsingDataListener != null) { |
| 748 mClearBrowsingDataListener.onBrowsingDataCleared(); | 774 mClearBrowsingDataListener.onBrowsingDataCleared(); |
| 749 mClearBrowsingDataListener = null; | 775 mClearBrowsingDataListener = null; |
| 750 } | 776 } |
| 751 } | 777 } |
| 752 | 778 |
| 753 /** | 779 /** |
| 780 * This fetches sites (registerable domains) that we consider important. Thi s combines many | |
| 781 * pieces of information, including site engagement and permissions. The cal lback is called | |
| 782 * with the list of important registerable domains. | |
| 783 * | |
| 784 * See net/base/registry_controlled_domains/registry_controlled_domain.h for more details on | |
| 785 * registrable domains and the current list of effective eTLDs. | |
| 786 * @param callback the callback that will be used to set the list of importa nt sites. | |
|
Theresa
2016/04/21 16:05:28
nit: capitalize The
dmurph
2016/04/21 18:53:25
Done.
| |
| 787 */ | |
| 788 public void fetchImportantSites(ImportantSitesCallback callback) { | |
| 789 assert mImportantSitesCallback == null; | |
| 790 mImportantSitesCallback = callback; | |
| 791 nativeFetchImportantSites(); | |
| 792 } | |
| 793 | |
| 794 @CalledByNative | |
| 795 private void importantSitesFetched(String[] domains) { | |
| 796 if (mImportantSitesCallback != null) { | |
| 797 mImportantSitesCallback.setImportantRegisterableDomains(domains); | |
| 798 mImportantSitesCallback = null; | |
| 799 } | |
| 800 } | |
| 801 | |
| 802 /** | |
| 754 * Requests that the web history service finds out if we should inform the u ser about the | 803 * Requests that the web history service finds out if we should inform the u ser about the |
| 755 * existence of other forms of browsing history. The response will be asynch ronous, through | 804 * existence of other forms of browsing history. The response will be asynch ronous, through |
| 756 * {@link OtherFormsOfBrowsingHistoryListener}. | 805 * {@link OtherFormsOfBrowsingHistoryListener}. |
| 757 */ | 806 */ |
| 758 public void requestInfoAboutOtherFormsOfBrowsingHistory( | 807 public void requestInfoAboutOtherFormsOfBrowsingHistory( |
| 759 OtherFormsOfBrowsingHistoryListener listener) { | 808 OtherFormsOfBrowsingHistoryListener listener) { |
| 760 nativeRequestInfoAboutOtherFormsOfBrowsingHistory(listener); | 809 nativeRequestInfoAboutOtherFormsOfBrowsingHistory(listener); |
| 761 } | 810 } |
| 762 | 811 |
| 763 public void setAllowCookiesEnabled(boolean allow) { | 812 public void setAllowCookiesEnabled(boolean allow) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1043 private native boolean nativeGetPrintingManaged(); | 1092 private native boolean nativeGetPrintingManaged(); |
| 1044 private native boolean nativeGetSupervisedUserSafeSitesEnabled(); | 1093 private native boolean nativeGetSupervisedUserSafeSitesEnabled(); |
| 1045 private native void nativeSetTranslateEnabled(boolean enabled); | 1094 private native void nativeSetTranslateEnabled(boolean enabled); |
| 1046 private native void nativeSetAutoDetectEncodingEnabled(boolean enabled); | 1095 private native void nativeSetAutoDetectEncodingEnabled(boolean enabled); |
| 1047 private native void nativeResetTranslateDefaults(); | 1096 private native void nativeResetTranslateDefaults(); |
| 1048 private native void nativeMigrateJavascriptPreference(); | 1097 private native void nativeMigrateJavascriptPreference(); |
| 1049 private native boolean nativeGetBrowsingDataDeletionPreference(int dataType) ; | 1098 private native boolean nativeGetBrowsingDataDeletionPreference(int dataType) ; |
| 1050 private native void nativeSetBrowsingDataDeletionPreference(int dataType, bo olean value); | 1099 private native void nativeSetBrowsingDataDeletionPreference(int dataType, bo olean value); |
| 1051 private native int nativeGetBrowsingDataDeletionTimePeriod(); | 1100 private native int nativeGetBrowsingDataDeletionTimePeriod(); |
| 1052 private native void nativeSetBrowsingDataDeletionTimePeriod(int timePeriod); | 1101 private native void nativeSetBrowsingDataDeletionTimePeriod(int timePeriod); |
| 1053 private native void nativeClearBrowsingData(int[] dataTypes, int timePeriod) ; | 1102 private native void nativeClearBrowsingData( |
| 1103 int[] dataTypes, int timePeriod, String[] blacklistDomains); | |
| 1054 private native void nativeRequestInfoAboutOtherFormsOfBrowsingHistory( | 1104 private native void nativeRequestInfoAboutOtherFormsOfBrowsingHistory( |
| 1055 OtherFormsOfBrowsingHistoryListener listener); | 1105 OtherFormsOfBrowsingHistoryListener listener); |
| 1056 private native boolean nativeCanDeleteBrowsingHistory(); | 1106 private native boolean nativeCanDeleteBrowsingHistory(); |
| 1107 private native void nativeFetchImportantSites(); | |
| 1057 private native void nativeSetAllowCookiesEnabled(boolean allow); | 1108 private native void nativeSetAllowCookiesEnabled(boolean allow); |
| 1058 private native void nativeSetBackgroundSyncEnabled(boolean allow); | 1109 private native void nativeSetBackgroundSyncEnabled(boolean allow); |
| 1059 private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled); | 1110 private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled); |
| 1060 private native void nativeSetDoNotTrackEnabled(boolean enabled); | 1111 private native void nativeSetDoNotTrackEnabled(boolean enabled); |
| 1061 private native void nativeSetFullscreenAllowed(boolean allowed); | 1112 private native void nativeSetFullscreenAllowed(boolean allowed); |
| 1062 private native void nativeSetRememberPasswordsEnabled(boolean allow); | 1113 private native void nativeSetRememberPasswordsEnabled(boolean allow); |
| 1063 private native void nativeSetPasswordManagerAutoSigninEnabled(boolean enable d); | 1114 private native void nativeSetPasswordManagerAutoSigninEnabled(boolean enable d); |
| 1064 private native void nativeSetProtectedMediaIdentifierEnabled(boolean enabled ); | 1115 private native void nativeSetProtectedMediaIdentifierEnabled(boolean enabled ); |
| 1065 private native boolean nativeGetAllowLocationEnabled(); | 1116 private native boolean nativeGetAllowLocationEnabled(); |
| 1066 private native boolean nativeGetNotificationsEnabled(); | 1117 private native boolean nativeGetNotificationsEnabled(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1100 private native String nativeGetSupervisedUserSecondCustodianName(); | 1151 private native String nativeGetSupervisedUserSecondCustodianName(); |
| 1101 private native String nativeGetSupervisedUserSecondCustodianEmail(); | 1152 private native String nativeGetSupervisedUserSecondCustodianEmail(); |
| 1102 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL( ); | 1153 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL( ); |
| 1103 private native boolean nativeGetMetricsReportingEnabled(); | 1154 private native boolean nativeGetMetricsReportingEnabled(); |
| 1104 private native void nativeSetMetricsReportingEnabled(boolean enabled); | 1155 private native void nativeSetMetricsReportingEnabled(boolean enabled); |
| 1105 private native boolean nativeHasSetMetricsReporting(); | 1156 private native boolean nativeHasSetMetricsReporting(); |
| 1106 private native void nativeSetClickedUpdateMenuItem(boolean clicked); | 1157 private native void nativeSetClickedUpdateMenuItem(boolean clicked); |
| 1107 private native boolean nativeGetClickedUpdateMenuItem(); | 1158 private native boolean nativeGetClickedUpdateMenuItem(); |
| 1108 private native void nativeSetSupervisedUserId(String supervisedUserId); | 1159 private native void nativeSetSupervisedUserId(String supervisedUserId); |
| 1109 } | 1160 } |
| OLD | NEW |