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

Unified Diff: Source/devtools/front_end/main/Main.js

Issue 1085253003: Revert of Revert of DevTools: allow storing devtools preferences on the browser side. [blink] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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: Source/devtools/front_end/main/Main.js
diff --git a/Source/devtools/front_end/main/Main.js b/Source/devtools/front_end/main/Main.js
index 15a90efe4d70583ce9f6ec2b0d70362009bdcb78..c388bba8ce1e1eff38b7103dbcb1f0bff75f713f 100644
--- a/Source/devtools/front_end/main/Main.js
+++ b/Source/devtools/front_end/main/Main.js
@@ -117,21 +117,63 @@
if (InspectorFrontendHost.isUnderTest())
self.runtime.useTestBase();
- this._createSettings();
+ InspectorFrontendHost.getPreferences(this._createSettings.bind(this));
+ },
+
+ /**
+ * @param {!Object<string, string>} prefs
+ */
+ _createSettings: function(prefs)
+ {
+ // Patch settings from the URL param (for tests).
+ var settingsParam = Runtime.queryParam("settings");
+ if (settingsParam) {
+ try {
+ var settings = JSON.parse(window.decodeURI(settingsParam));
+ for (var key in settings)
+ prefs[key] = settings[key];
+ } catch(e) {
+ // Ignore malformed settings.
+ }
+ }
+
+ this._initializeExperiments(prefs);
+
+ /**
+ * @param {!Array<{name: string}>} changes
+ */
+ function trackPrefsObject(changes)
+ {
+ if (!Object.keys(prefs).length) {
+ InspectorFrontendHost.clearPreferences();
+ return;
+ }
+
+ for (var change of changes) {
+ var name = change.name;
+ if (name in prefs)
+ InspectorFrontendHost.setPreference(name, prefs[name]);
+ else
+ InspectorFrontendHost.removePreference(name);
+ }
+ }
+
+ Object.observe(prefs, trackPrefsObject);
+ WebInspector.settings = new WebInspector.Settings(prefs);
+
+ if (!InspectorFrontendHost.isUnderTest()) {
+ // This setting is needed for backwards compatibility with Devtools CodeSchool extension. DO NOT REMOVE
+ WebInspector.settings.pauseOnExceptionStateString = new WebInspector.PauseOnExceptionStateSetting();
+ new WebInspector.VersionController().updateVersion();
+ }
+
this._createAppUI();
},
- _createSettings: function()
- {
- this._initializeExperiments();
- WebInspector.settings = new WebInspector.Settings();
-
- // This setting is needed for backwards compatibility with Devtools CodeSchool extension. DO NOT REMOVE
- WebInspector.settings.pauseOnExceptionStateString = new WebInspector.PauseOnExceptionStateSetting();
- new WebInspector.VersionController().updateVersion();
- },
-
- _initializeExperiments: function()
+ /**
+ * @param {!Object<string, string>} prefs
+ */
+ _initializeExperiments: function(prefs)
{
Runtime.experiments.register("accessibilityInspection", "Accessibility Inspection", true);
Runtime.experiments.register("animationInspection", "Animation Inspection");
@@ -161,8 +203,8 @@
Runtime.experiments.cleanUpStaleExperiments();
if (InspectorFrontendHost.isUnderTest()) {
+ var testPath = JSON.parse(prefs["testPath"] || "\"\"");
// Enable experiments for testing.
- var testPath = self.localStorage ? self.localStorage["testPath"] || "" : "";
if (testPath.indexOf("debugger/promise") !== -1)
Runtime.experiments.enableForTest("promiseTracker");
if (testPath.indexOf("elements/") !== -1)
« no previous file with comments | « Source/devtools/front_end/host/InspectorFrontendHost.js ('k') | Source/devtools/front_end/settings/SettingsScreen.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698