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

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

Issue 1066813003: 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..ce19dd92023174e96f52c216928f54749fa96fd9 100644
--- a/Source/devtools/front_end/main/Main.js
+++ b/Source/devtools/front_end/main/Main.js
@@ -117,21 +117,49 @@ WebInspector.Main.prototype = {
if (InspectorFrontendHost.isUnderTest())
self.runtime.useTestBase();
- this._createSettings();
- this._createAppUI();
+ InspectorFrontendHost.getPreferences(this._createSettings.bind(this));
},
- _createSettings: function()
+ /**
+ * @param {!Object<string, string>} prefs
+ */
+ _createSettings: function(prefs)
{
- this._initializeExperiments();
- WebInspector.settings = new WebInspector.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);
// 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();
},
- _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 +189,8 @@ WebInspector.Main.prototype = {
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)

Powered by Google App Engine
This is Rietveld 408576698