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

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

Issue 920583002: [Android] Migrate javascript settings to a content setting from a pref. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Second round of cleanup Created 5 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/android/preferences/pref_service_bridge.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c3005e17b81555db9ea8ccf8dd3c2f87c4c983e8..d2332b48a8c42ea4b7df49b9763cbf8e0f4729a5 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
@@ -4,7 +4,11 @@
package org.chromium.chrome.browser.preferences;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
import android.text.TextUtils;
+import android.util.Log;
import org.chromium.base.CalledByNative;
import org.chromium.base.ThreadUtils;
@@ -31,6 +35,9 @@ public final class PrefServiceBridge {
public static final int SUPERVISED_USER_FILTERING_WARN = 1;
public static final int SUPERVISED_USER_FILTERING_BLOCK = 2;
+ private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion";
+ private static final int MIGRATION_CURRENT_VERSION = 1;
+
private static String sProfilePath;
// Object to notify when "clear browsing data" completes.
@@ -143,6 +150,25 @@ public final class PrefServiceBridge {
}
/**
+ * Migrates (synchronously) the preferences to the most recent version.
+ */
+ public void migratePreferences(Context context) {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ int currentVersion = preferences.getInt(MIGRATION_PREF_KEY, 0);
+ if (currentVersion == MIGRATION_CURRENT_VERSION) return;
+ if (currentVersion > MIGRATION_CURRENT_VERSION) {
+ Log.e(LOG_TAG, "Saved preferences version is newer than supported. Attempting to "
+ + "run an older version of Chrome without clearing data is unsupported and "
+ + "the results may be unpredictable.");
+ }
+
+ if (currentVersion <= 0) {
+ nativeMigrateJavascriptPreference();
+ }
+ preferences.edit().putInt(MIGRATION_PREF_KEY, MIGRATION_CURRENT_VERSION).commit();
+ }
+
+ /**
* Returns the path to the user's profile directory via a callback. The callback may be
* called synchronously or asynchronously.
*/
@@ -746,6 +772,7 @@ public final class PrefServiceBridge {
private native void nativeResetTranslateDefaults();
private native boolean nativeGetJavaScriptEnabled();
private native void nativeSetJavaScriptEnabled(boolean enabled);
+ private native void nativeMigrateJavascriptPreference();
private native void nativeClearBrowsingData(boolean history, boolean cache,
boolean cookiesAndSiteData, boolean passwords, boolean formData);
private native void nativeSetAllowCookiesEnabled(boolean allow);
« no previous file with comments | « no previous file | chrome/browser/android/preferences/pref_service_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698