OLD | NEW |
---|---|
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 this.workerInspectorWidth = this.createSetting("workerInspectorWidth", 600); | 99 this.workerInspectorWidth = this.createSetting("workerInspectorWidth", 600); |
100 this.workerInspectorHeight = this.createSetting("workerInspectorHeight", 600 ); | 100 this.workerInspectorHeight = this.createSetting("workerInspectorHeight", 600 ); |
101 this.messageURLFilters = this.createSetting("messageURLFilters", {}); | 101 this.messageURLFilters = this.createSetting("messageURLFilters", {}); |
102 this.networkHideDataURL = this.createSetting("networkHideDataURL", false); | 102 this.networkHideDataURL = this.createSetting("networkHideDataURL", false); |
103 this.messageLevelFilters = this.createSetting("messageLevelFilters", {}); | 103 this.messageLevelFilters = this.createSetting("messageLevelFilters", {}); |
104 this.splitVerticallyWhenDockedToRight = this.createSetting("splitVerticallyW henDockedToRight", true); | 104 this.splitVerticallyWhenDockedToRight = this.createSetting("splitVerticallyW henDockedToRight", true); |
105 this.visiblePanels = this.createSetting("visiblePanels", {}); | 105 this.visiblePanels = this.createSetting("visiblePanels", {}); |
106 this.shortcutPanelSwitch = this.createSetting("shortcutPanelSwitch", false); | 106 this.shortcutPanelSwitch = this.createSetting("shortcutPanelSwitch", false); |
107 this.showWhitespacesInEditor = this.createSetting("showWhitespacesInEditor", false); | 107 this.showWhitespacesInEditor = this.createSetting("showWhitespacesInEditor", false); |
108 this.skipStackFramesSwitch = this.createSetting("skipStackFramesSwitch", fal se); | 108 this.skipStackFramesSwitch = this.createSetting("skipStackFramesSwitch", fal se); |
109 this.skipStackFramesPattern = this.createSetting("skipStackFramesPattern", " "); | 109 this.skipStackFramesPattern = this.createRegExpSetting("skipStackFramesPatte rn", ""); |
vsevik
2014/03/26 08:53:18
I assume this change fine for users of this settin
aandrey
2014/03/26 09:13:46
Yes.
| |
110 this.pauseOnExceptionEnabled = this.createSetting("pauseOnExceptionEnabled", false); | 110 this.pauseOnExceptionEnabled = this.createSetting("pauseOnExceptionEnabled", false); |
111 this.pauseOnCaughtException = this.createSetting("pauseOnCaughtException", f alse); | 111 this.pauseOnCaughtException = this.createSetting("pauseOnCaughtException", f alse); |
112 this.enableAsyncStackTraces = this.createSetting("enableAsyncStackTraces", f alse); | 112 this.enableAsyncStackTraces = this.createSetting("enableAsyncStackTraces", f alse); |
113 } | 113 } |
114 | 114 |
115 WebInspector.Settings.prototype = { | 115 WebInspector.Settings.prototype = { |
116 /** | 116 /** |
117 * @param {string} key | 117 * @param {string} key |
118 * @param {*} defaultValue | 118 * @param {*} defaultValue |
119 * @return {!WebInspector.Setting} | 119 * @return {!WebInspector.Setting} |
120 */ | 120 */ |
121 createSetting: function(key, defaultValue) | 121 createSetting: function(key, defaultValue) |
122 { | 122 { |
123 if (!this._registry[key]) | 123 if (!this._registry[key]) |
124 this._registry[key] = new WebInspector.Setting(key, defaultValue, th is._eventSupport, window.localStorage); | 124 this._registry[key] = new WebInspector.Setting(key, defaultValue, th is._eventSupport, window.localStorage); |
125 return this._registry[key]; | 125 return this._registry[key]; |
126 }, | 126 }, |
127 | 127 |
128 /** | 128 /** |
129 * @param {string} key | 129 * @param {string} key |
130 * @param {string} defaultValue | |
131 * @param {string=} regexFlags | |
132 * @return {!WebInspector.RegExpSetting} | |
133 */ | |
134 createRegExpSetting: function(key, defaultValue, regexFlags) | |
135 { | |
136 if (!this._registry[key]) | |
137 this._registry[key] = new WebInspector.RegExpSetting(key, defaultVal ue, this._eventSupport, window.localStorage, regexFlags); | |
138 return this._registry[key]; | |
139 }, | |
140 | |
141 /** | |
142 * @param {string} key | |
130 * @param {*} defaultValue | 143 * @param {*} defaultValue |
131 * @param {function(*, function(string, ...))} setterCallback | 144 * @param {function(*, function(string, ...))} setterCallback |
132 * @return {!WebInspector.Setting} | 145 * @return {!WebInspector.Setting} |
133 */ | 146 */ |
134 createBackendSetting: function(key, defaultValue, setterCallback) | 147 createBackendSetting: function(key, defaultValue, setterCallback) |
135 { | 148 { |
136 if (!this._registry[key]) | 149 if (!this._registry[key]) |
137 this._registry[key] = new WebInspector.BackendSetting(key, defaultVa lue, this._eventSupport, window.localStorage, setterCallback); | 150 this._registry[key] = new WebInspector.BackendSetting(key, defaultVa lue, this._eventSupport, window.localStorage, setterCallback); |
138 return this._registry[key]; | 151 return this._registry[key]; |
139 }, | 152 }, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 } | 231 } |
219 } | 232 } |
220 this._eventSupport.dispatchEventToListeners(this._name, value); | 233 this._eventSupport.dispatchEventToListeners(this._name, value); |
221 } | 234 } |
222 } | 235 } |
223 | 236 |
224 /** | 237 /** |
225 * @constructor | 238 * @constructor |
226 * @extends {WebInspector.Setting} | 239 * @extends {WebInspector.Setting} |
227 * @param {string} name | 240 * @param {string} name |
241 * @param {string} defaultValue | |
242 * @param {!WebInspector.Object} eventSupport | |
243 * @param {?Storage} storage | |
244 * @param {string=} regexFlags | |
245 */ | |
246 WebInspector.RegExpSetting = function(name, defaultValue, eventSupport, storage, regexFlags) | |
247 { | |
248 WebInspector.Setting.call(this, name, defaultValue, eventSupport, storage); | |
249 this._regexFlags = regexFlags; | |
250 this.addChangeListener(this._valueChanged, this); | |
vsevik
2014/03/26 08:51:46
I've heard it's a bad practice for a class to list
aandrey
2014/03/26 09:13:46
Good point! Done.
| |
251 } | |
252 | |
253 WebInspector.RegExpSetting.prototype = { | |
254 /** | |
255 * @return {?RegExp} | |
256 */ | |
257 asRegExp: function() | |
258 { | |
259 if (typeof this._regex !== "undefined") | |
260 return this._regex; | |
261 this._regex = null; | |
262 try { | |
263 this._regex = new RegExp(this.get(), this._regexFlags || ""); | |
264 } catch (e) { | |
265 } | |
266 return this._regex; | |
267 }, | |
268 | |
269 _valueChanged: function() | |
270 { | |
271 delete this._regex; | |
272 }, | |
273 | |
274 __proto__: WebInspector.Setting.prototype | |
275 } | |
276 | |
277 /** | |
278 * @constructor | |
279 * @extends {WebInspector.Setting} | |
280 * @param {string} name | |
228 * @param {*} defaultValue | 281 * @param {*} defaultValue |
229 * @param {!WebInspector.Object} eventSupport | 282 * @param {!WebInspector.Object} eventSupport |
230 * @param {?Storage} storage | 283 * @param {?Storage} storage |
231 * @param {function(*,function(string, ...))} setterCallback | 284 * @param {function(*,function(string, ...))} setterCallback |
232 */ | 285 */ |
233 WebInspector.BackendSetting = function(name, defaultValue, eventSupport, storage , setterCallback) | 286 WebInspector.BackendSetting = function(name, defaultValue, eventSupport, storage , setterCallback) |
234 { | 287 { |
235 WebInspector.Setting.call(this, name, defaultValue, eventSupport, storage); | 288 WebInspector.Setting.call(this, name, defaultValue, eventSupport, storage); |
236 this._setterCallback = setterCallback; | 289 this._setterCallback = setterCallback; |
237 var currentValue = this.get(); | 290 var currentValue = this.get(); |
(...skipping 14 matching lines...) Expand all Loading... | |
252 WebInspector.console.log("Error applying setting " + this._name + ": " + error); | 305 WebInspector.console.log("Error applying setting " + this._name + ": " + error); |
253 this._eventSupport.dispatchEventToListeners(this._name, this._va lue); | 306 this._eventSupport.dispatchEventToListeners(this._name, this._va lue); |
254 return; | 307 return; |
255 } | 308 } |
256 WebInspector.Setting.prototype.set.call(this, value); | 309 WebInspector.Setting.prototype.set.call(this, value); |
257 } | 310 } |
258 this._setterCallback(value, callback.bind(this)); | 311 this._setterCallback(value, callback.bind(this)); |
259 }, | 312 }, |
260 | 313 |
261 __proto__: WebInspector.Setting.prototype | 314 __proto__: WebInspector.Setting.prototype |
262 }; | 315 } |
263 | 316 |
264 /** | 317 /** |
265 * @constructor | 318 * @constructor |
266 * @param {boolean} experimentsEnabled | 319 * @param {boolean} experimentsEnabled |
267 */ | 320 */ |
268 WebInspector.ExperimentsSettings = function(experimentsEnabled) | 321 WebInspector.ExperimentsSettings = function(experimentsEnabled) |
269 { | 322 { |
270 this._experimentsEnabled = experimentsEnabled; | 323 this._experimentsEnabled = experimentsEnabled; |
271 this._setting = WebInspector.settings.createSetting("experiments", {}); | 324 this._setting = WebInspector.settings.createSetting("experiments", {}); |
272 this._experiments = []; | 325 this._experiments = []; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
599 { | 652 { |
600 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused | 653 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused |
601 // periodical breakpoints duplication leading to inspector slowness. | 654 // periodical breakpoints duplication leading to inspector slowness. |
602 if (breakpointsSetting.get().length > maxBreakpointsCount) | 655 if (breakpointsSetting.get().length > maxBreakpointsCount) |
603 breakpointsSetting.set([]); | 656 breakpointsSetting.set([]); |
604 } | 657 } |
605 } | 658 } |
606 | 659 |
607 WebInspector.settings = new WebInspector.Settings(); | 660 WebInspector.settings = new WebInspector.Settings(); |
608 WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings(WebInspe ctor.queryParam("experiments") !== null); | 661 WebInspector.experimentsSettings = new WebInspector.ExperimentsSettings(WebInspe ctor.queryParam("experiments") !== null); |
OLD | NEW |