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.text.TextUtils; | 10 import android.text.TextUtils; |
(...skipping 21 matching lines...) Expand all Loading... |
32 public static final String EXCEPTION_SETTING_BLOCK = "block"; | 32 public static final String EXCEPTION_SETTING_BLOCK = "block"; |
33 public static final String EXCEPTION_SETTING_DEFAULT = "default"; | 33 public static final String EXCEPTION_SETTING_DEFAULT = "default"; |
34 | 34 |
35 // These values must match the native enum values in | 35 // These values must match the native enum values in |
36 // SupervisedUserURLFilter::FilteringBehavior | 36 // SupervisedUserURLFilter::FilteringBehavior |
37 public static final int SUPERVISED_USER_FILTERING_ALLOW = 0; | 37 public static final int SUPERVISED_USER_FILTERING_ALLOW = 0; |
38 public static final int SUPERVISED_USER_FILTERING_WARN = 1; | 38 public static final int SUPERVISED_USER_FILTERING_WARN = 1; |
39 public static final int SUPERVISED_USER_FILTERING_BLOCK = 2; | 39 public static final int SUPERVISED_USER_FILTERING_BLOCK = 2; |
40 | 40 |
41 private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion"; | 41 private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion"; |
42 private static final int MIGRATION_CURRENT_VERSION = 1; | 42 private static final int MIGRATION_CURRENT_VERSION = 2; |
43 | 43 |
44 private static String sProfilePath; | 44 private static String sProfilePath; |
45 | 45 |
46 // Object to notify when "clear browsing data" completes. | 46 // Object to notify when "clear browsing data" completes. |
47 private OnClearBrowsingDataListener mClearBrowsingDataListener; | 47 private OnClearBrowsingDataListener mClearBrowsingDataListener; |
48 private static final String LOG_TAG = "PrefServiceBridge"; | 48 private static final String LOG_TAG = "PrefServiceBridge"; |
49 | 49 |
50 // Constants related to the Contextual Search preference. | 50 // Constants related to the Contextual Search preference. |
51 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; | 51 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; |
52 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; | 52 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 if (currentVersion == MIGRATION_CURRENT_VERSION) return; | 134 if (currentVersion == MIGRATION_CURRENT_VERSION) return; |
135 if (currentVersion > MIGRATION_CURRENT_VERSION) { | 135 if (currentVersion > MIGRATION_CURRENT_VERSION) { |
136 Log.e(LOG_TAG, "Saved preferences version is newer than supported.
Attempting to " | 136 Log.e(LOG_TAG, "Saved preferences version is newer than supported.
Attempting to " |
137 + "run an older version of Chrome without clearing data is u
nsupported and " | 137 + "run an older version of Chrome without clearing data is u
nsupported and " |
138 + "the results may be unpredictable."); | 138 + "the results may be unpredictable."); |
139 } | 139 } |
140 | 140 |
141 if (currentVersion <= 0) { | 141 if (currentVersion <= 0) { |
142 nativeMigrateJavascriptPreference(); | 142 nativeMigrateJavascriptPreference(); |
143 } | 143 } |
| 144 if (currentVersion <= 1) { |
| 145 nativeMigrateLocationPreference(); |
| 146 nativeMigrateProtectedMediaPreference(); |
| 147 } |
144 preferences.edit().putInt(MIGRATION_PREF_KEY, MIGRATION_CURRENT_VERSION)
.commit(); | 148 preferences.edit().putInt(MIGRATION_PREF_KEY, MIGRATION_CURRENT_VERSION)
.commit(); |
145 } | 149 } |
146 | 150 |
147 /** | 151 /** |
148 * Returns the path to the user's profile directory via a callback. The call
back may be | 152 * Returns the path to the user's profile directory via a callback. The call
back may be |
149 * called synchronously or asynchronously. | 153 * called synchronously or asynchronously. |
150 */ | 154 */ |
151 public void getProfilePath(ProfilePathCallback callback) { | 155 public void getProfilePath(ProfilePathCallback callback) { |
152 if (!TextUtils.isEmpty(sProfilePath)) { | 156 if (!TextUtils.isEmpty(sProfilePath)) { |
153 callback.onGotProfilePath(sProfilePath); | 157 callback.onGotProfilePath(sProfilePath); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 private native boolean nativeGetIncognitoModeEnabled(); | 834 private native boolean nativeGetIncognitoModeEnabled(); |
831 private native boolean nativeGetIncognitoModeManaged(); | 835 private native boolean nativeGetIncognitoModeManaged(); |
832 private native boolean nativeGetPrintingEnabled(); | 836 private native boolean nativeGetPrintingEnabled(); |
833 private native boolean nativeGetPrintingManaged(); | 837 private native boolean nativeGetPrintingManaged(); |
834 private native boolean nativeGetForceSafeSearch(); | 838 private native boolean nativeGetForceSafeSearch(); |
835 private native void nativeSetTranslateEnabled(boolean enabled); | 839 private native void nativeSetTranslateEnabled(boolean enabled); |
836 private native void nativeResetTranslateDefaults(); | 840 private native void nativeResetTranslateDefaults(); |
837 private native boolean nativeGetJavaScriptEnabled(); | 841 private native boolean nativeGetJavaScriptEnabled(); |
838 private native void nativeSetJavaScriptEnabled(boolean enabled); | 842 private native void nativeSetJavaScriptEnabled(boolean enabled); |
839 private native void nativeMigrateJavascriptPreference(); | 843 private native void nativeMigrateJavascriptPreference(); |
| 844 private native void nativeMigrateLocationPreference(); |
| 845 private native void nativeMigrateProtectedMediaPreference(); |
840 private native void nativeSetJavaScriptAllowed(String pattern, int setting); | 846 private native void nativeSetJavaScriptAllowed(String pattern, int setting); |
841 private native void nativeGetJavaScriptExceptions(List<JavaScriptExceptionIn
fo> list); | 847 private native void nativeGetJavaScriptExceptions(List<JavaScriptExceptionIn
fo> list); |
842 private native void nativeClearBrowsingData(boolean history, boolean cache, | 848 private native void nativeClearBrowsingData(boolean history, boolean cache, |
843 boolean cookiesAndSiteData, boolean passwords, boolean formData); | 849 boolean cookiesAndSiteData, boolean passwords, boolean formData); |
844 private native boolean nativeCanDeleteBrowsingHistory(); | 850 private native boolean nativeCanDeleteBrowsingHistory(); |
845 private native void nativeSetAllowCookiesEnabled(boolean allow); | 851 private native void nativeSetAllowCookiesEnabled(boolean allow); |
846 private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled); | 852 private native void nativeSetBlockThirdPartyCookiesEnabled(boolean enabled); |
847 private native void nativeSetDoNotTrackEnabled(boolean enabled); | 853 private native void nativeSetDoNotTrackEnabled(boolean enabled); |
848 private native void nativeSetFullscreenAllowed(boolean allowed); | 854 private native void nativeSetFullscreenAllowed(boolean allowed); |
849 private native void nativeSetRememberPasswordsEnabled(boolean allow); | 855 private native void nativeSetRememberPasswordsEnabled(boolean allow); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 private native void nativeResetAcceptLanguages(String defaultLocale); | 890 private native void nativeResetAcceptLanguages(String defaultLocale); |
885 private native String nativeGetSyncLastAccountName(); | 891 private native String nativeGetSyncLastAccountName(); |
886 private native String nativeGetSupervisedUserCustodianName(); | 892 private native String nativeGetSupervisedUserCustodianName(); |
887 private native String nativeGetSupervisedUserCustodianEmail(); | 893 private native String nativeGetSupervisedUserCustodianEmail(); |
888 private native String nativeGetSupervisedUserCustodianProfileImageURL(); | 894 private native String nativeGetSupervisedUserCustodianProfileImageURL(); |
889 private native int nativeGetDefaultSupervisedUserFilteringBehavior(); | 895 private native int nativeGetDefaultSupervisedUserFilteringBehavior(); |
890 private native String nativeGetSupervisedUserSecondCustodianName(); | 896 private native String nativeGetSupervisedUserSecondCustodianName(); |
891 private native String nativeGetSupervisedUserSecondCustodianEmail(); | 897 private native String nativeGetSupervisedUserSecondCustodianEmail(); |
892 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(
); | 898 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(
); |
893 } | 899 } |
OLD | NEW |