Home | History | Annotate | Download | only in front-end
      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 }
     54 
     55 WebInspector.Settings = function()
     56 {
     57     this.installApplicationSetting("colorFormat", "hex");
     58     this.installApplicationSetting("consoleHistory", []);
     59     this.installApplicationSetting("debuggerEnabled", false);
     60     this.installApplicationSetting("domWordWrap", true);
     61     this.installApplicationSetting("profilerEnabled", false);
     62     this.installApplicationSetting("eventListenersFilter", "all");
     63     this.installApplicationSetting("lastActivePanel", "elements");
     64     this.installApplicationSetting("lastViewedScriptFile", "application");
     65     this.installApplicationSetting("monitoringXHREnabled", false);
     66     this.installApplicationSetting("pauseOnExceptionStateString", WebInspector.ScriptsPanel.PauseOnExceptionsState.DontPauseOnExceptions);
     67     this.installApplicationSetting("resourcesLargeRows", true);
     68     this.installApplicationSetting("resourcesSortOptions", {timeOption: "responseTime", sizeOption: "transferSize"});
     69     this.installApplicationSetting("resourceViewTab", "content");
     70     this.installApplicationSetting("showInheritedComputedStyleProperties", false);
     71     this.installApplicationSetting("showUserAgentStyles", true);
     72     this.installApplicationSetting("watchExpressions", []);
     73     this.installApplicationSetting("breakpoints", []);
     74     this.installApplicationSetting("eventListenerBreakpoints", []);
     75     this.installApplicationSetting("domBreakpoints", []);
     76     this.installApplicationSetting("xhrBreakpoints", []);
     77 }
     78 
     79 WebInspector.Settings.prototype = {
     80     installApplicationSetting: function(key, defaultValue)
     81     {
     82         if (key in this)
     83             return;
     84 
     85         this.__defineGetter__(key, this._get.bind(this, key, defaultValue));
     86         this.__defineSetter__(key, this._set.bind(this, key));
     87     },
     88 
     89     _get: function(key, defaultValue)
     90     {
     91         if (window.localStorage != null && key in window.localStorage) {
     92             try {
     93                 return JSON.parse(window.localStorage[key]);
     94             } catch(e) {
     95                 window.localStorage.removeItem(key);
     96             }
     97         }
     98         return defaultValue;
     99     },
    100 
    101     _set: function(key, value)
    102     {
    103         if (window.localStorage != null)
    104             window.localStorage[key] = JSON.stringify(value);
    105     }
    106 }
    107 
    108 WebInspector.Settings.prototype.__proto__ = WebInspector.Object.prototype;
    109