2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 canEditScriptSource: false,
34 maxInlineTextChildLength: 80,
37 minElementsSidebarWidth: 200,
38 minScriptsSidebarWidth: 200,
39 styleRulesExpandedState: {},
40 showMissingLocalizedStrings: false,
41 samplingCPUProfiler: false,
42 showColorNicknames: true,
43 debuggerAlwaysEnabled: false,
44 profilerAlwaysEnabled: false,
45 onlineDetectionEnabled: true,
46 nativeInstrumentationEnabled: false,
47 useDataURLForResourceImageIcons: true,
49 showCookiesTab: false,
51 heapProfilerPresent: false,
52 detailedHeapProfiles: false,
53 saveAsAvailable: false,
54 useLowerCaseMenuTitlesOnWindows: false,
55 canInspectWorkers: false,
56 canClearCacheAndCookies: false,
57 canDisableCache: false,
58 showNetworkPanelInitiatorColumn: false
64 WebInspector.Settings = function()
66 this._eventSupport = new WebInspector.Object();
68 this.colorFormat = this.createSetting("colorFormat", "hex");
69 this.consoleHistory = this.createSetting("consoleHistory", []);
70 this.debuggerEnabled = this.createSetting("debuggerEnabled", false);
71 this.domWordWrap = this.createSetting("domWordWrap", true);
72 this.profilerEnabled = this.createSetting("profilerEnabled", false);
73 this.eventListenersFilter = this.createSetting("eventListenersFilter", "all");
74 this.lastActivePanel = this.createSetting("lastActivePanel", "elements");
75 this.lastViewedScriptFile = this.createSetting("lastViewedScriptFile", "application");
76 this.monitoringXHREnabled = this.createSetting("monitoringXHREnabled", false);
77 this.preserveConsoleLog = this.createSetting("preserveConsoleLog", false);
78 this.resourcesLargeRows = this.createSetting("resourcesLargeRows", true);
79 this.resourcesSortOptions = this.createSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"});
80 this.resourceViewTab = this.createSetting("resourceViewTab", "preview");
81 this.showInheritedComputedStyleProperties = this.createSetting("showInheritedComputedStyleProperties", false);
82 this.showUserAgentStyles = this.createSetting("showUserAgentStyles", true);
83 this.watchExpressions = this.createSetting("watchExpressions", []);
84 this.breakpoints = this.createSetting("breakpoints", []);
85 this.eventListenerBreakpoints = this.createSetting("eventListenerBreakpoints", []);
86 this.domBreakpoints = this.createSetting("domBreakpoints", []);
87 this.xhrBreakpoints = this.createSetting("xhrBreakpoints", []);
88 this.workerInspectionEnabled = this.createSetting("workerInspectionEnabled", []);
89 this.cacheDisabled = this.createSetting("cacheDisabled", false);
90 this.showScriptFolders = this.createSetting("showScriptFolders", true);
92 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
93 // periodical breakpoints duplication leading to inspector slowness.
94 if (window.localStorage.breakpoints && window.localStorage.breakpoints.length > 500000)
95 delete window.localStorage.breakpoints;
98 WebInspector.Settings.prototype = {
100 * @return {WebInspector.Setting}
102 createSetting: function(key, defaultValue)
104 return new WebInspector.Setting(key, defaultValue, this._eventSupport);
111 WebInspector.Setting = function(name, defaultValue, eventSupport)
114 this._defaultValue = defaultValue;
115 this._eventSupport = eventSupport;
118 WebInspector.Setting.prototype = {
119 addChangeListener: function(listener, thisObject)
121 this._eventSupport.addEventListener(this._name, listener, thisObject);
124 removeChangeListener: function(listener, thisObject)
126 this._eventSupport.removeEventListener(this._name, listener, thisObject);
136 var value = this._defaultValue;
137 if (window.localStorage != null && this._name in window.localStorage) {
139 value = JSON.parse(window.localStorage[this._name]);
141 window.localStorage.removeItem(this._name);
149 if (window.localStorage != null) {
151 window.localStorage[this._name] = JSON.stringify(value);
153 console.error("Error saving setting with name:" + this._name);
156 this._eventSupport.dispatchEventToListeners(this._name, value);
160 WebInspector.settings = new WebInspector.Settings();