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

Side by Side Diff: Source/devtools/front_end/common/Settings.js

Issue 385173007: DevTools: move UI components to target observers in preparation to early UI initialization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 this.splitVerticallyWhenDockedToRight = this.createSetting("splitVerticallyW henDockedToRight", true); 85 this.splitVerticallyWhenDockedToRight = this.createSetting("splitVerticallyW henDockedToRight", true);
86 this.visiblePanels = this.createSetting("visiblePanels", {}); 86 this.visiblePanels = this.createSetting("visiblePanels", {});
87 this.shortcutPanelSwitch = this.createSetting("shortcutPanelSwitch", false); 87 this.shortcutPanelSwitch = this.createSetting("shortcutPanelSwitch", false);
88 this.showWhitespacesInEditor = this.createSetting("showWhitespacesInEditor", false); 88 this.showWhitespacesInEditor = this.createSetting("showWhitespacesInEditor", false);
89 this.skipStackFramesPattern = this.createRegExpSetting("skipStackFramesPatte rn", ""); 89 this.skipStackFramesPattern = this.createRegExpSetting("skipStackFramesPatte rn", "");
90 this.pauseOnExceptionEnabled = this.createSetting("pauseOnExceptionEnabled", false); 90 this.pauseOnExceptionEnabled = this.createSetting("pauseOnExceptionEnabled", false);
91 this.pauseOnCaughtException = this.createSetting("pauseOnCaughtException", f alse); 91 this.pauseOnCaughtException = this.createSetting("pauseOnCaughtException", f alse);
92 this.enableAsyncStackTraces = this.createSetting("enableAsyncStackTraces", f alse); 92 this.enableAsyncStackTraces = this.createSetting("enableAsyncStackTraces", f alse);
93 this.showMediaQueryInspector = this.createSetting("showMediaQueryInspector", false); 93 this.showMediaQueryInspector = this.createSetting("showMediaQueryInspector", false);
94 this.disableOverridesWarning = this.createSetting("disableOverridesWarning", false); 94 this.disableOverridesWarning = this.createSetting("disableOverridesWarning", false);
95
96 // Rendering options
97 this.showPaintRects = this.createSetting("showPaintRects", false);
98 this.showDebugBorders = this.createSetting("showDebugBorders", false);
99 this.showFPSCounter = this.createSetting("showFPSCounter", false);
100 this.continuousPainting = this.createSetting("continuousPainting", false);
101 this.showScrollBottleneckRects = this.createSetting("showScrollBottleneckRec ts", false);
95 } 102 }
96 103
97 WebInspector.Settings.prototype = { 104 WebInspector.Settings.prototype = {
98 /** 105 /**
99 * @param {string} key 106 * @param {string} key
100 * @param {*} defaultValue 107 * @param {*} defaultValue
101 * @return {!WebInspector.Setting} 108 * @return {!WebInspector.Setting}
102 */ 109 */
103 createSetting: function(key, defaultValue) 110 createSetting: function(key, defaultValue)
104 { 111 {
105 if (!this._registry[key]) 112 if (!this._registry[key])
106 this._registry[key] = new WebInspector.Setting(key, defaultValue, th is._eventSupport, window.localStorage); 113 this._registry[key] = new WebInspector.Setting(key, defaultValue, th is._eventSupport, window.localStorage);
107 return this._registry[key]; 114 return this._registry[key];
108 }, 115 },
109 116
110 /** 117 /**
111 * @param {string} key 118 * @param {string} key
112 * @param {string} defaultValue 119 * @param {string} defaultValue
113 * @param {string=} regexFlags 120 * @param {string=} regexFlags
114 * @return {!WebInspector.Setting} 121 * @return {!WebInspector.Setting}
115 */ 122 */
116 createRegExpSetting: function(key, defaultValue, regexFlags) 123 createRegExpSetting: function(key, defaultValue, regexFlags)
117 { 124 {
118 if (!this._registry[key]) 125 if (!this._registry[key])
119 this._registry[key] = new WebInspector.RegExpSetting(key, defaultVal ue, this._eventSupport, window.localStorage, regexFlags); 126 this._registry[key] = new WebInspector.RegExpSetting(key, defaultVal ue, this._eventSupport, window.localStorage, regexFlags);
120 return this._registry[key]; 127 return this._registry[key];
121 },
122
123 /**
124 * @param {string} key
125 * @param {*} defaultValue
126 * @param {function(*, function(string, ...))} setterCallback
127 * @return {!WebInspector.Setting}
128 */
129 createBackendSetting: function(key, defaultValue, setterCallback)
130 {
131 if (!this._registry[key])
132 this._registry[key] = new WebInspector.BackendSetting(key, defaultVa lue, this._eventSupport, window.localStorage, setterCallback);
133 return this._registry[key];
134 },
135
136 initializeBackendSettings: function()
137 {
138 this.showPaintRects = WebInspector.settings.createBackendSetting("showPa intRects", false, PageAgent.setShowPaintRects.bind(PageAgent));
139 this.showDebugBorders = WebInspector.settings.createBackendSetting("show DebugBorders", false, PageAgent.setShowDebugBorders.bind(PageAgent));
140 this.continuousPainting = WebInspector.settings.createBackendSetting("co ntinuousPainting", false, PageAgent.setContinuousPaintingEnabled.bind(PageAgent) );
141 this.showFPSCounter = WebInspector.settings.createBackendSetting("showFP SCounter", false, PageAgent.setShowFPSCounter.bind(PageAgent));
142 this.showScrollBottleneckRects = WebInspector.settings.createBackendSett ing("showScrollBottleneckRects", false, PageAgent.setShowScrollBottleneckRects.b ind(PageAgent));
143 } 128 }
144 } 129 }
145 130
146 /** 131 /**
147 * @constructor 132 * @constructor
148 * @param {string} name 133 * @param {string} name
149 * @param {V} defaultValue 134 * @param {V} defaultValue
150 * @param {!WebInspector.Object} eventSupport 135 * @param {!WebInspector.Object} eventSupport
151 * @param {?Storage} storage 136 * @param {?Storage} storage
152 * @template V 137 * @template V
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } catch (e) { 275 } catch (e) {
291 } 276 }
292 return this._regex; 277 return this._regex;
293 }, 278 },
294 279
295 __proto__: WebInspector.Setting.prototype 280 __proto__: WebInspector.Setting.prototype
296 } 281 }
297 282
298 /** 283 /**
299 * @constructor 284 * @constructor
300 * @extends {WebInspector.Setting}
301 * @param {string} name
302 * @param {*} defaultValue
303 * @param {!WebInspector.Object} eventSupport
304 * @param {?Storage} storage
305 * @param {function(*,function(string, ...))} setterCallback
306 */
307 WebInspector.BackendSetting = function(name, defaultValue, eventSupport, storage , setterCallback)
308 {
309 WebInspector.Setting.call(this, name, defaultValue, eventSupport, storage);
310 this._setterCallback = setterCallback;
311 var currentValue = this.get();
312 if (currentValue !== defaultValue)
313 this.set(currentValue);
314 }
315
316 WebInspector.BackendSetting.prototype = {
317 /**
318 * @override
319 * @param {*} value
320 */
321 set: function(value)
322 {
323 /**
324 * @param {?Protocol.Error} error
325 * @this {WebInspector.BackendSetting}
326 */
327 function callback(error)
328 {
329 if (error) {
330 WebInspector.console.addErrorMessage("Error applying setting " + this._name + ": " + error);
331 this._eventSupport.dispatchEventToListeners(this._name, this._va lue);
332 return;
333 }
334 WebInspector.Setting.prototype.set.call(this, value);
335 }
336 this._setterCallback(value, callback.bind(this));
337 },
338
339 __proto__: WebInspector.Setting.prototype
340 }
341
342 /**
343 * @constructor
344 * @param {boolean} experimentsEnabled 285 * @param {boolean} experimentsEnabled
345 */ 286 */
346 WebInspector.ExperimentsSettings = function(experimentsEnabled) 287 WebInspector.ExperimentsSettings = function(experimentsEnabled)
347 { 288 {
348 this._experimentsEnabled = experimentsEnabled; 289 this._experimentsEnabled = experimentsEnabled;
349 this._setting = WebInspector.settings.createSetting("experiments", {}); 290 this._setting = WebInspector.settings.createSetting("experiments", {});
350 this._experiments = []; 291 this._experiments = [];
351 this._enabledForTest = {}; 292 this._enabledForTest = {};
352 293
353 // Add currently running experiments here. 294 // Add currently running experiments here.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 738
798 _fireChangedIfNeeded: function() 739 _fireChangedIfNeeded: function()
799 { 740 {
800 var newValue = this._calculateValue(); 741 var newValue = this._calculateValue();
801 if (newValue === this._value) 742 if (newValue === this._value)
802 return; 743 return;
803 this._value = newValue; 744 this._value = newValue;
804 this._eventSupport.dispatchEventToListeners(this._name, this._value); 745 this._eventSupport.dispatchEventToListeners(this._name, this._value);
805 } 746 }
806 } 747 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/common/ModuleManager.js ('k') | Source/devtools/front_end/elements/ElementsPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698