2011-04-28 Ilya Tikhonovsky <loislo@chromium.org>
[WebKit-https.git] / Source / WebCore / inspector / front-end / 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     canEditScriptSource: false,
34     maxInlineTextChildLength: 80,
35     minConsoleHeight: 75,
36     minSidebarWidth: 100,
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,
48     showTimingTab: false,
49     showCookiesTab: false,
50     debugMode: false,
51     heapProfilerPresent: false,
52     detailedHeapProfiles: false,
53     saveAsAvailable: false
54 }
55
56 WebInspector.Settings = function()
57 {
58     this.installApplicationSetting("colorFormat", "hex");
59     this.installApplicationSetting("consoleHistory", []);
60     this.installApplicationSetting("debuggerEnabled", false);
61     this.installApplicationSetting("domWordWrap", true);
62     this.installApplicationSetting("profilerEnabled", false);
63     this.installApplicationSetting("eventListenersFilter", "all");
64     this.installApplicationSetting("lastActivePanel", "elements");
65     this.installApplicationSetting("lastViewedScriptFile", "application");
66     this.installApplicationSetting("monitoringXHREnabled", false);
67     this.installApplicationSetting("pauseOnExceptionStateString", WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions);
68     this.installApplicationSetting("resourcesLargeRows", true);
69     this.installApplicationSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"});
70     this.installApplicationSetting("resourceViewTab", "content");
71     this.installApplicationSetting("showInheritedComputedStyleProperties", false);
72     this.installApplicationSetting("showUserAgentStyles", true);
73     this.installApplicationSetting("watchExpressions", []);
74     this.installApplicationSetting("breakpoints", []);
75     this.installApplicationSetting("eventListenerBreakpoints", []);
76     this.installApplicationSetting("domBreakpoints", []);
77     this.installApplicationSetting("xhrBreakpoints", []);
78 }
79
80 WebInspector.Settings.prototype = {
81     installApplicationSetting: function(key, defaultValue)
82     {
83         if (key in this)
84             return;
85
86         this.__defineGetter__(key, this._get.bind(this, key, defaultValue));
87         this.__defineSetter__(key, this._set.bind(this, key));
88     },
89
90     _get: function(key, defaultValue)
91     {
92         if (window.localStorage != null && key in window.localStorage) {
93             try {
94                 return JSON.parse(window.localStorage[key]);
95             } catch(e) {
96                 window.localStorage.removeItem(key);
97             }
98         }
99         return defaultValue;
100     },
101
102     _set: function(key, value)
103     {
104         if (window.localStorage != null)
105             window.localStorage[key] = JSON.stringify(value);
106     }
107 }
108
109 WebInspector.Settings.prototype.__proto__ = WebInspector.Object.prototype;