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 maxInlineTextChildLength: 80,
36 minElementsSidebarWidth: 200,
37 minScriptsSidebarWidth: 200,
38 styleRulesExpandedState: {},
39 showMissingLocalizedStrings: false,
40 showColorNicknames: true,
41 saveAsAvailable: false,
42 useLowerCaseMenuTitlesOnWindows: false,
44 sharedWorkersDebugNote: undefined,
46 applicationTitle: "Web Inspector - %s"
50 samplingCPUProfiler: false,
51 /* #if TIZEN_REMOTE_WEB_INSPECTOR */
52 debuggerAlwaysEnabled: true,
54 /* debuggerAlwaysEnabled: false, */
56 profilerAlwaysEnabled: false,
57 nativeInstrumentationEnabled: false,
59 showCookiesTab: false,
60 heapProfilerPresent: false,
61 detailedHeapProfiles: false,
62 canInspectWorkers: false,
63 canClearCacheAndCookies: false,
64 canDisableCache: false
70 WebInspector.Settings = function()
72 this._eventSupport = new WebInspector.Object();
74 this.colorFormat = this.createSetting("colorFormat", "hex");
75 this.consoleHistory = this.createSetting("consoleHistory", []);
76 this.debuggerEnabled = this.createSetting("debuggerEnabled", false);
77 this.domWordWrap = this.createSetting("domWordWrap", true);
78 this.profilerEnabled = this.createSetting("profilerEnabled", false);
79 this.eventListenersFilter = this.createSetting("eventListenersFilter", "all");
80 this.lastActivePanel = this.createSetting("lastActivePanel", "elements");
81 this.lastViewedScriptFile = this.createSetting("lastViewedScriptFile", "application");
82 this.monitoringXHREnabled = this.createSetting("monitoringXHREnabled", false);
83 this.preserveConsoleLog = this.createSetting("preserveConsoleLog", false);
84 this.resourcesLargeRows = this.createSetting("resourcesLargeRows", true);
85 this.resourcesSortOptions = this.createSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"});
86 this.resourceViewTab = this.createSetting("resourceViewTab", "preview");
87 this.showInheritedComputedStyleProperties = this.createSetting("showInheritedComputedStyleProperties", false);
88 this.showUserAgentStyles = this.createSetting("showUserAgentStyles", true);
89 this.watchExpressions = this.createSetting("watchExpressions", []);
90 this.breakpoints = this.createSetting("breakpoints", []);
91 this.eventListenerBreakpoints = this.createSetting("eventListenerBreakpoints", []);
92 this.domBreakpoints = this.createSetting("domBreakpoints", []);
93 this.xhrBreakpoints = this.createSetting("xhrBreakpoints", []);
94 this.cacheDisabled = this.createSetting("cacheDisabled", false);
95 this.overrideUserAgent = this.createSetting("overrideUserAgent", "");
96 this.userAgent = this.createSetting("userAgent", "");
97 this.showScriptFolders = this.createSetting("showScriptFolders", true);
99 // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
100 // periodical breakpoints duplication leading to inspector slowness.
101 if (window.localStorage.breakpoints && window.localStorage.breakpoints.length > 500000)
102 delete window.localStorage.breakpoints;
105 WebInspector.Settings.prototype = {
107 * @return {WebInspector.Setting}
109 createSetting: function(key, defaultValue)
111 return new WebInspector.Setting(key, defaultValue, this._eventSupport);
118 WebInspector.Setting = function(name, defaultValue, eventSupport)
121 this._defaultValue = defaultValue;
122 this._eventSupport = eventSupport;
125 WebInspector.Setting.prototype = {
126 addChangeListener: function(listener, thisObject)
128 this._eventSupport.addEventListener(this._name, listener, thisObject);
131 removeChangeListener: function(listener, thisObject)
133 this._eventSupport.removeEventListener(this._name, listener, thisObject);
143 var value = this._defaultValue;
144 if (window.localStorage != null && this._name in window.localStorage) {
146 value = JSON.parse(window.localStorage[this._name]);
148 window.localStorage.removeItem(this._name);
156 if (window.localStorage != null) {
158 window.localStorage[this._name] = JSON.stringify(value);
160 console.error("Error saving setting with name:" + this._name);
163 this._eventSupport.dispatchEventToListeners(this._name, value);
167 WebInspector.settings = new WebInspector.Settings();