tizen beta release
[profile/ivi/webkit-efl.git] / debian / libwebkit-engine / usr / share / ewebkit-0 / webinspector / Settings.js
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
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
13  * distribution.
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.
17  *
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.
29  */
30
31
32 var Preferences = {
33     maxInlineTextChildLength: 80,
34     minConsoleHeight: 75,
35     minSidebarWidth: 100,
36     minElementsSidebarWidth: 200,
37     minScriptsSidebarWidth: 200,
38     styleRulesExpandedState: {},
39     showMissingLocalizedStrings: false,
40     showColorNicknames: true,
41     saveAsAvailable: false,
42     useLowerCaseMenuTitlesOnWindows: false,
43     hasExtensions: false,
44     sharedWorkersDebugNote: undefined,
45     localizeUI: true,
46     applicationTitle: "Web Inspector - %s"
47 }
48
49 var Capabilities = {
50     samplingCPUProfiler: false,
51 /* #if TIZEN_REMOTE_WEB_INSPECTOR */
52     debuggerAlwaysEnabled: true,
53 /* #else  */
54 /*  debuggerAlwaysEnabled: false, */
55 /* #endif */
56     profilerAlwaysEnabled: false,
57     nativeInstrumentationEnabled: false,
58     showTimingTab: false,
59     showCookiesTab: false,
60     heapProfilerPresent: false,
61     detailedHeapProfiles: false,
62     canInspectWorkers: false,
63     canClearCacheAndCookies: false,
64     canDisableCache: false
65 }
66
67 /**
68  * @constructor
69  */
70 WebInspector.Settings = function()
71 {
72     this._eventSupport = new WebInspector.Object();
73
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);
98
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;
103 }
104
105 WebInspector.Settings.prototype = {
106     /**
107      * @return {WebInspector.Setting}
108      */
109     createSetting: function(key, defaultValue)
110     {
111         return new WebInspector.Setting(key, defaultValue, this._eventSupport);
112     }
113 }
114
115 /**
116  * @constructor
117  */
118 WebInspector.Setting = function(name, defaultValue, eventSupport)
119 {
120     this._name = name;
121     this._defaultValue = defaultValue;
122     this._eventSupport = eventSupport;
123 }
124
125 WebInspector.Setting.prototype = {
126     addChangeListener: function(listener, thisObject)
127     {
128         this._eventSupport.addEventListener(this._name, listener, thisObject);
129     },
130
131     removeChangeListener: function(listener, thisObject)
132     {
133         this._eventSupport.removeEventListener(this._name, listener, thisObject);
134     },
135
136     get name()
137     {
138         return this._name;
139     },
140
141     get: function()
142     {
143         var value = this._defaultValue;
144         if (window.localStorage != null && this._name in window.localStorage) {
145             try {
146                 value = JSON.parse(window.localStorage[this._name]);
147             } catch(e) {
148                 window.localStorage.removeItem(this._name);
149             }
150         }
151         return value;
152     },
153
154     set: function(value)
155     {
156         if (window.localStorage != null) {
157             try {
158                 window.localStorage[this._name] = JSON.stringify(value);
159             } catch(e) {
160                 console.error("Error saving setting with name:" + this._name);
161             }
162         }
163         this._eventSupport.dispatchEventToListeners(this._name, value);
164     }
165 }
166
167 WebInspector.settings = new WebInspector.Settings();