2011-01-14 Pavel Feldman <pfeldman@chromium.org>
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jan 2011 09:28:52 +0000 (09:28 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jan 2011 09:28:52 +0000 (09:28 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: extract InspectorSettings from InspectorState,
        simplify it.
        https://bugs.webkit.org/show_bug.cgi?id=52429

        * CMakeLists.txt:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.xcodeproj/project.pbxproj:
        * inspector/InspectorClient.h:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::InspectorController):
        (WebCore::InspectorController::inspectorStartsAttached):
        (WebCore::InspectorController::setInspectorStartsAttached):
        (WebCore::InspectorController::setInspectorAttachedHeight):
        (WebCore::InspectorController::inspectorAttachedHeight):
        (WebCore::InspectorController::setMonitoringXHREnabled):
        (WebCore::InspectorController::restoreDebugger):
        (WebCore::InspectorController::restoreProfiler):
        (WebCore::InspectorController::ensureSettingsLoaded):
        (WebCore::InspectorController::enableProfiler):
        (WebCore::InspectorController::disableProfiler):
        (WebCore::InspectorController::enableDebuggerFromFrontend):
        (WebCore::InspectorController::disableDebugger):
        * inspector/InspectorController.h:
        * inspector/InspectorSettings.cpp: Added.
        (WebCore::InspectorSettings::InspectorSettings):
        (WebCore::InspectorSettings::getBoolean):
        (WebCore::InspectorSettings::setBoolean):
        (WebCore::InspectorSettings::getLong):
        (WebCore::InspectorSettings::setLong):
        (WebCore::InspectorSettings::registerBoolean):
        (WebCore::InspectorSettings::registerLong):
        * inspector/InspectorSettings.h: Added.
        * inspector/InspectorState.cpp:
        (WebCore::InspectorState::InspectorState):
        (WebCore::InspectorState::setValue):
        (WebCore::InspectorState::setObject):
        (WebCore::InspectorState::registerBoolean):
        (WebCore::InspectorState::registerString):
        (WebCore::InspectorState::registerLong):
        (WebCore::InspectorState::registerObject):
        (WebCore::InspectorState::Property::create):
        * inspector/InspectorState.h:
        (WebCore::InspectorState::setBoolean):
        (WebCore::InspectorState::setString):
        (WebCore::InspectorState::setLong):

2011-01-14  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: extract InspectorSettings from InspectorState,
        simplify it.
        https://bugs.webkit.org/show_bug.cgi?id=52429

        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@75777 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorSettings.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorSettings.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorState.cpp
Source/WebCore/inspector/InspectorState.h
WebKit2/ChangeLog
WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp

index c04e8a3..4a6c2c1 100644 (file)
@@ -1167,10 +1167,11 @@ SET(WebCore_SOURCES
     inspector/InspectorInstrumentation.cpp
     inspector/InspectorProfilerAgent.cpp
     inspector/InspectorResourceAgent.cpp
-    inspector/InspectorStyleSheet.cpp
-    inspector/InspectorValues.cpp
+    inspector/InspectorSettings.cpp
     inspector/InspectorState.cpp
+    inspector/InspectorStyleSheet.cpp
     inspector/InspectorTimelineAgent.cpp
+    inspector/InspectorValues.cpp
     inspector/ScriptArguments.cpp
     inspector/ScriptBreakpoint.cpp
     inspector/ScriptCallFrame.cpp
index e8123b0..6122404 100644 (file)
@@ -1,3 +1,55 @@
+2011-01-14  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: extract InspectorSettings from InspectorState,
+        simplify it.
+        https://bugs.webkit.org/show_bug.cgi?id=52429
+
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/InspectorClient.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::inspectorStartsAttached):
+        (WebCore::InspectorController::setInspectorStartsAttached):
+        (WebCore::InspectorController::setInspectorAttachedHeight):
+        (WebCore::InspectorController::inspectorAttachedHeight):
+        (WebCore::InspectorController::setMonitoringXHREnabled):
+        (WebCore::InspectorController::restoreDebugger):
+        (WebCore::InspectorController::restoreProfiler):
+        (WebCore::InspectorController::ensureSettingsLoaded):
+        (WebCore::InspectorController::enableProfiler):
+        (WebCore::InspectorController::disableProfiler):
+        (WebCore::InspectorController::enableDebuggerFromFrontend):
+        (WebCore::InspectorController::disableDebugger):
+        * inspector/InspectorController.h:
+        * inspector/InspectorSettings.cpp: Added.
+        (WebCore::InspectorSettings::InspectorSettings):
+        (WebCore::InspectorSettings::getBoolean):
+        (WebCore::InspectorSettings::setBoolean):
+        (WebCore::InspectorSettings::getLong):
+        (WebCore::InspectorSettings::setLong):
+        (WebCore::InspectorSettings::registerBoolean):
+        (WebCore::InspectorSettings::registerLong):
+        * inspector/InspectorSettings.h: Added.
+        * inspector/InspectorState.cpp:
+        (WebCore::InspectorState::InspectorState):
+        (WebCore::InspectorState::setValue):
+        (WebCore::InspectorState::setObject):
+        (WebCore::InspectorState::registerBoolean):
+        (WebCore::InspectorState::registerString):
+        (WebCore::InspectorState::registerLong):
+        (WebCore::InspectorState::registerObject):
+        (WebCore::InspectorState::Property::create):
+        * inspector/InspectorState.h:
+        (WebCore::InspectorState::setBoolean):
+        (WebCore::InspectorState::setString):
+        (WebCore::InspectorState::setLong):
+
 2011-01-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r75774.
index 1ab5cfe..87bf435 100644 (file)
@@ -1977,6 +1977,8 @@ webcore_sources += \
        Source/WebCore/inspector/InspectorProfilerAgent.h \
        Source/WebCore/inspector/InspectorResourceAgent.cpp \
        Source/WebCore/inspector/InspectorResourceAgent.h \
+       Source/WebCore/inspector/InspectorSettings.cpp \
+       Source/WebCore/inspector/InspectorSettings.h \
        Source/WebCore/inspector/InspectorState.cpp \
        Source/WebCore/inspector/InspectorState.h \
        Source/WebCore/inspector/InspectorStyleSheet.cpp \
index 5547863..c1cb6de 100644 (file)
             'inspector/InspectorResourceAgent.cpp',
             'inspector/InspectorResourceAgent.h',
             'inspector/InspectorState.cpp',
+            'inspector/InspectorSettings.h',
+            'inspector/InspectorSettings.cpp',
             'inspector/InspectorState.h',
             'inspector/InspectorStyleSheet.cpp',
             'inspector/InspectorStyleSheet.h',
index 819d569..b0409f1 100644 (file)
@@ -1058,6 +1058,7 @@ SOURCES += \
     inspector/InspectorInstrumentation.cpp \
     inspector/InspectorProfilerAgent.cpp \
     inspector/InspectorResourceAgent.cpp \
+    inspector/InspectorSettings.cpp \
     inspector/InspectorState.cpp \
     inspector/InspectorStyleSheet.cpp \
     inspector/InspectorTimelineAgent.cpp \
@@ -1949,6 +1950,7 @@ HEADERS += \
     inspector/InspectorInstrumentation.h \
     inspector/InspectorProfilerAgent.h \
     inspector/InspectorResourceAgent.h \
+    inspector/InspectorSettings.h \
     inspector/InspectorState.h \
     inspector/InspectorStyleSheet.h \
     inspector/InspectorTimelineAgent.h \
index bc3d04d..a431b5c 100644 (file)
                7A1F2B52126C61B20006A7E6 /* InspectorClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */; };
                7A24587B1021EAF4000A00AA /* InspectorDOMAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A2458791021EAF4000A00AA /* InspectorDOMAgent.cpp */; };
                7A24587C1021EAF4000A00AA /* InspectorDOMAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A24587A1021EAF4000A00AA /* InspectorDOMAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7A5640BF12DF9E5E00F4536D /* InspectorSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A5640BD12DF9E5E00F4536D /* InspectorSettings.cpp */; };
+               7A5640C012DF9E5E00F4536D /* InspectorSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A5640BE12DF9E5E00F4536D /* InspectorSettings.h */; };
                7A674BDB0F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A674BD90F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp */; };
                7A674BDC0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */; };
                7A74ECBA101839A600BF939E /* InspectorDOMStorageAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECB8101839A500BF939E /* InspectorDOMStorageAgent.cpp */; };
                7A24587A1021EAF4000A00AA /* InspectorDOMAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDOMAgent.h; sourceTree = "<group>"; };
                7A563E5412DE32B000F4536D /* InjectedScriptSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScriptSource.h; sourceTree = "<group>"; };
                7A563F9512DF5C9100F4536D /* InjectedScriptSource.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = InjectedScriptSource.js; sourceTree = "<group>"; };
+               7A5640BD12DF9E5E00F4536D /* InspectorSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorSettings.cpp; sourceTree = "<group>"; };
+               7A5640BE12DF9E5E00F4536D /* InspectorSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorSettings.h; sourceTree = "<group>"; };
                7A674BD90F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageGroupLoadDeferrer.cpp; sourceTree = "<group>"; };
                7A674BDA0F9EBF4E006CF099 /* PageGroupLoadDeferrer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageGroupLoadDeferrer.h; sourceTree = "<group>"; };
                7A74ECB8101839A500BF939E /* InspectorDOMStorageAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDOMStorageAgent.cpp; sourceTree = "<group>"; };
                                7A0E76F710BF08ED00A0276E /* InjectedScriptHost.h */,
                                7A0E76F810BF08ED00A0276E /* InjectedScriptHost.idl */,
                                7A563F9512DF5C9100F4536D /* InjectedScriptSource.js */,
+                               7A5640BD12DF9E5E00F4536D /* InspectorSettings.cpp */,
+                               7A5640BE12DF9E5E00F4536D /* InspectorSettings.h */,
                                B885E8D211E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp */,
                                B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */,
                                7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */,
                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
                                2E37DFDB12DBAFB800A6B233 /* DOMURL.h in Headers */,
                                2E37E00612DBC5A400A6B233 /* JSDOMURL.h in Headers */,
+                               4FC2842412DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.h in Headers */,
+                               7A5640C012DF9E5E00F4536D /* InspectorSettings.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
                                2E37DFDA12DBAFB800A6B233 /* DOMURL.cpp in Sources */,
                                2E37E00512DBC5A400A6B233 /* JSDOMURL.cpp in Sources */,
+                               4FC2842512DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.cpp in Sources */,
+                               7A5640BF12DF9E5E00F4536D /* InspectorSettings.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 0c78246..3b8007e 100644 (file)
@@ -26,7 +26,6 @@
 #ifndef InspectorClient_h
 #define InspectorClient_h
 
-#include "InspectorController.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
index 20da731..6547fb7 100644 (file)
@@ -69,6 +69,7 @@
 #include "InspectorInstrumentation.h"
 #include "InspectorProfilerAgent.h"
 #include "InspectorResourceAgent.h"
+#include "InspectorSettings.h"
 #include "InspectorState.h"
 #include "InspectorTimelineAgent.h"
 #include "InspectorValues.h"
@@ -130,8 +131,6 @@ const char* const InspectorController::ConsolePanel = "console";
 const char* const InspectorController::ScriptsPanel = "scripts";
 const char* const InspectorController::ProfilesPanel = "profiles";
 
-const unsigned InspectorController::defaultAttachedHeight = 300;
-
 static const unsigned maximumConsoleMessages = 1000;
 static const unsigned expireConsoleMessagesStep = 100;
 
@@ -142,7 +141,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
     , m_cssAgent(new InspectorCSSAgent())
     , m_expiredConsoleMessageCount(0)
     , m_previousMessage(0)
-    , m_settingsLoaded(false)
     , m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this))
     , m_injectedScriptHost(InjectedScriptHost::create(this))
 #if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -194,22 +192,22 @@ bool InspectorController::enabled() const
 
 bool InspectorController::inspectorStartsAttached()
 {
-    return m_state->getBoolean(InspectorState::inspectorStartsAttached);
+    return m_settings->getBoolean(InspectorSettings::InspectorStartsAttached);
 }
 
 void InspectorController::setInspectorStartsAttached(bool attached)
 {
-    m_state->setBoolean(InspectorState::inspectorStartsAttached, attached);
+    m_settings->setBoolean(InspectorSettings::InspectorStartsAttached, attached);
 }
 
 void InspectorController::setInspectorAttachedHeight(long height)
 {
-    m_state->setLong(InspectorState::inspectorAttachedHeight, height);
+    m_settings->setLong(InspectorSettings::InspectorAttachedHeight, height);
 }
 
-int InspectorController::inspectorAttachedHeight() const
+long InspectorController::inspectorAttachedHeight() const
 {
-    return m_state->getBoolean(InspectorState::inspectorAttachedHeight);
+    return m_settings->getLong(InspectorSettings::InspectorAttachedHeight);
 }
 
 bool InspectorController::searchingForNodeInPage() const
@@ -467,6 +465,7 @@ void InspectorController::setMonitoringXHREnabled(bool enabled, bool* newState)
 {
     *newState = enabled;
     m_state->setBoolean(InspectorState::monitoringXHR, enabled);
+    m_settings->setBoolean(InspectorSettings::MonitoringXHREnabled, enabled);
 }
 
 void InspectorController::connectFrontend()
@@ -668,7 +667,7 @@ void InspectorController::restoreDebugger()
     if (InspectorDebuggerAgent::isDebuggerAlwaysEnabled())
         enableDebuggerFromFrontend(false);
     else {
-        if (m_state->getBoolean(InspectorState::debuggerAlwaysEnabled) || m_attachDebuggerWhenShown)
+        if (m_settings->getBoolean(InspectorSettings::DebuggerAlwaysEnabled) || m_attachDebuggerWhenShown)
             enableDebugger();
     }
 #endif
@@ -679,7 +678,7 @@ void InspectorController::restoreProfiler(ProfilerRestoreAction action)
     ASSERT(m_frontend);
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     m_profilerAgent->setFrontend(m_frontend.get());
-    if (!ScriptProfiler::isProfilerAlwaysEnabled() && m_state->getBoolean(InspectorState::profilerAlwaysEnabled))
+    if (!ScriptProfiler::isProfilerAlwaysEnabled() && m_settings->getBoolean(InspectorSettings::ProfilerAlwaysEnabled))
         enableProfiler();
     if (action == ProfilerRestoreResetAgent)
         m_profilerAgent->resetState();
@@ -847,11 +846,10 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(const String& url, c
 
 void InspectorController::ensureSettingsLoaded()
 {
-    if (m_settingsLoaded)
+    if (m_settings)
         return;
-    m_settingsLoaded = true;
-
-    m_state->loadFromSettings();
+    m_settings = new InspectorSettings(m_client);
+    m_state->setBoolean(InspectorState::monitoringXHR, m_settings->getBoolean(InspectorSettings::MonitoringXHREnabled));
 }
 
 void InspectorController::startTimelineProfiler()
@@ -1157,14 +1155,14 @@ bool InspectorController::profilerEnabled() const
 void InspectorController::enableProfiler(bool always, bool skipRecompile)
 {
     if (always)
-        m_state->setBoolean(InspectorState::profilerAlwaysEnabled, true);
+        m_settings->setBoolean(InspectorSettings::ProfilerAlwaysEnabled, true);
     m_profilerAgent->enable(skipRecompile);
 }
 
 void InspectorController::disableProfiler(bool always)
 {
     if (always)
-        m_state->setBoolean(InspectorState::profilerAlwaysEnabled, false);
+        m_settings->setBoolean(InspectorSettings::ProfilerAlwaysEnabled, false);
     m_profilerAgent->disable();
 }
 #endif
@@ -1174,7 +1172,7 @@ void InspectorController::enableDebuggerFromFrontend(bool always)
 {
     ASSERT(!debuggerEnabled());
     if (always)
-        m_state->setBoolean(InspectorState::debuggerAlwaysEnabled, true);
+        m_settings->setBoolean(InspectorSettings::DebuggerAlwaysEnabled, true);
 
     ASSERT(m_inspectedPage);
 
@@ -1206,7 +1204,7 @@ void InspectorController::disableDebugger(bool always)
         return;
 
     if (always)
-        m_state->setBoolean(InspectorState::debuggerAlwaysEnabled, false);
+        m_settings->setBoolean(InspectorSettings::DebuggerAlwaysEnabled, false);
 
     ASSERT(m_inspectedPage);
 
index fef2a6d..ccf344e 100644 (file)
@@ -70,6 +70,7 @@ class InspectorFrontendClient;
 class InspectorObject;
 class InspectorProfilerAgent;
 class InspectorResourceAgent;
+class InspectorSettings;
 class InspectorState;
 class InspectorStorageAgent;
 class InspectorTimelineAgent;
@@ -259,9 +260,7 @@ public:
     bool inspectorStartsAttached();
     void setInspectorStartsAttached(bool);
     void setInspectorAttachedHeight(long height);
-    int inspectorAttachedHeight() const;
-
-    static const unsigned defaultAttachedHeight;
+    long inspectorAttachedHeight() const;
 
 private:
     friend class InspectorBackend;
@@ -331,6 +330,7 @@ private:
 
     OwnPtr<InspectorTimelineAgent> m_timelineAgent;
     OwnPtr<InspectorState> m_state;
+    OwnPtr<InspectorSettings> m_settings;
 
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     OwnPtr<InspectorApplicationCacheAgent> m_applicationCacheAgent;
@@ -359,13 +359,9 @@ private:
     String m_showAfterVisible;
     RefPtr<Node> m_highlightedNode;
     ConsoleMessage* m_previousMessage;
-    bool m_settingsLoaded;
     OwnPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
     RefPtr<InjectedScriptHost> m_injectedScriptHost;
 
-    typedef HashMap<String, String> Settings;
-    mutable Settings m_settings;
-
     Vector<pair<long, String> > m_pendingEvaluateTestCommands;
     Vector<String> m_scriptsToEvaluateOnLoad;
     String m_inspectorExtensionAPI;
diff --git a/Source/WebCore/inspector/InspectorSettings.cpp b/Source/WebCore/inspector/InspectorSettings.cpp
new file mode 100644 (file)
index 0000000..3ebc3ab
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include "InspectorSettings.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "InspectorClient.h"
+
+namespace WebCore {
+
+const char* InspectorSettings::MonitoringXHREnabled = "xhrMonitor";
+const char* InspectorSettings::ProfilerAlwaysEnabled = "profilerEnabled";
+const char* InspectorSettings::DebuggerAlwaysEnabled = "debuggerEnabled";
+const char* InspectorSettings::InspectorStartsAttached = "inspectorStartsAttached";
+const char* InspectorSettings::InspectorAttachedHeight = "inspectorAttachedHeight";
+
+InspectorSettings::InspectorSettings(InspectorClient* client)
+    : m_client(client)
+{
+    registerBoolean(MonitoringXHREnabled, false);
+    registerBoolean(ProfilerAlwaysEnabled, false);
+    registerBoolean(DebuggerAlwaysEnabled, false);
+    registerBoolean(InspectorStartsAttached, true);
+    registerLong(InspectorAttachedHeight, 300);
+}
+
+bool InspectorSettings::getBoolean(const String& name)
+{
+    String value;
+    m_client->populateSetting(name, &value);
+    if (value.isEmpty())
+        value = m_defaultValues.get(name);
+    return value == "true";
+}
+
+void InspectorSettings::setBoolean(const String& name, bool value)
+{
+    m_client->storeSetting(name, value ? "true" : "false");
+}
+
+long InspectorSettings::getLong(const String& name)
+{
+    String value;
+    m_client->populateSetting(name, &value);
+    if (value.isEmpty())
+        value = m_defaultValues.get(name);
+    return value.toInt();
+}
+
+void InspectorSettings::setLong(const String& name, long value)
+{
+    m_client->storeSetting(name, String::number(value));
+}
+
+void InspectorSettings::registerBoolean(const String& name, bool defaultValue)
+{
+    m_defaultValues.set(name, defaultValue ? "true" : "false");
+}
+
+void InspectorSettings::registerLong(const String& name, long defaultValue)
+{
+    m_defaultValues.set(name, String::number(defaultValue));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebCore/inspector/InspectorSettings.h b/Source/WebCore/inspector/InspectorSettings.h
new file mode 100644 (file)
index 0000000..717d11f
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorSettings_h
+#define InspectorSettings_h
+
+#if ENABLE(INSPECTOR)
+
+#include "PlatformString.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class InspectorClient;
+
+class InspectorSettings {
+public:
+    static const char* MonitoringXHREnabled;
+    static const char* ProfilerAlwaysEnabled;
+    static const char* DebuggerAlwaysEnabled;
+    static const char* InspectorStartsAttached;
+    static const char* InspectorAttachedHeight;
+
+    InspectorSettings(InspectorClient* client);
+
+    bool getBoolean(const String& name);
+    void setBoolean(const String& name, bool value);
+
+    long getLong(const String& name);
+    void setLong(const String& name, long value);
+
+private:
+    void registerBoolean(const String& name, bool defaultValue);
+    void registerLong(const String& name, long defaultValue);
+
+    typedef HashMap<String, String> Dictionary;
+    Dictionary m_defaultValues;
+    InspectorClient* m_client;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
+#endif // !defined(InspectorSettings_h)
index 0865648..7a9a4ad 100644 (file)
@@ -39,17 +39,16 @@ namespace WebCore {
 InspectorState::InspectorState(InspectorClient* client)
     : m_client(client)
 {
-    registerBoolean(monitoringXHR, false, "monitoringXHREnabled", "xhrMonitor");
-    registerBoolean(timelineProfilerEnabled, false, "timelineProfilerEnabled", String());
-    registerBoolean(searchingForNode, false, "searchingForNodeEnabled", String());
-    registerBoolean(profilerAlwaysEnabled, false, String(), "profilerEnabled");
-    registerBoolean(debuggerAlwaysEnabled, false, String(), "debuggerEnabled");
-    registerBoolean(inspectorStartsAttached, true, String(), "InspectorStartsAttached");
-    registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, String(), "inspectorAttachedHeight");
-    registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", String());
-    registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled", String());
-    registerBoolean(userInitiatedProfiling, false, "userInitiatedProfiling", String());
-    registerObject(stickyBreakpoints, String(), String());
+    // Pure reload state
+    registerBoolean(userInitiatedProfiling, false, String());
+    registerBoolean(timelineProfilerEnabled, false, String());
+    registerBoolean(searchingForNode, false, String());
+    registerObject(stickyBreakpoints, String());
+
+    // Should go away
+    registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled");
+    registerBoolean(monitoringXHR, false, "monitoringXHREnabled");
+    registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState");
 }
 
 void InspectorState::restoreFromInspectorCookie(const String& json)
@@ -82,32 +81,6 @@ PassRefPtr<InspectorObject> InspectorState::generateStateObjectForFrontend()
     return stateObject.release();
 }
 
-void InspectorState::loadFromSettings()
-{
-    for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i) {
-        if (i->second.m_preferenceName.length()) {
-            String value;
-            m_client->populateSetting(i->second.m_preferenceName, &value);
-            switch (i->second.m_value->type()) {
-            case InspectorValue::TypeBoolean:
-                if (value.length())
-                    i->second.m_value = InspectorBasicValue::create(value == "true");
-                break;
-            case InspectorValue::TypeString:
-                i->second.m_value = InspectorString::create(value);
-                break;
-            case InspectorValue::TypeNumber:
-                if (value.length())
-                    i->second.m_value = InspectorBasicValue::create((double)value.toInt());
-                break;
-            default:
-                ASSERT(false);
-                break;
-            }
-        }
-    }
-}
-
 void InspectorState::updateCookie()
 {
     RefPtr<InspectorObject> cookieObject = InspectorObject::create();
@@ -116,13 +89,11 @@ void InspectorState::updateCookie()
     m_client->updateInspectorStateCookie(cookieObject->toJSONString());
 }
 
-void InspectorState::setValue(InspectorPropertyId id, PassRefPtr<InspectorValue> value, const String& stringValue)
+void InspectorState::setValue(InspectorPropertyId id, PassRefPtr<InspectorValue> value)
 {
     PropertyMap::iterator i = m_properties.find(id);
     ASSERT(i != m_properties.end());
     i->second.m_value = value;
-    if (i->second.m_preferenceName.length())
-        m_client->storeSetting(i->second.m_preferenceName, stringValue);
     updateCookie();
 }
 
@@ -166,37 +137,34 @@ void InspectorState::setObject(InspectorPropertyId id, PassRefPtr<InspectorObjec
     ASSERT(i != m_properties.end());
     Property& property = i->second;
     property.m_value = value;
-    if (property.m_preferenceName.length())
-        m_client->storeSetting(property.m_preferenceName, value->toJSONString());
     updateCookie();
 }
 
-void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias, const String& preferenceName)
+void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias)
 {
-    m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias, preferenceName));
+    m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias));
 }
 
-void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias, const String& preferenceName)
+void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias)
 {
-    m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias, preferenceName));
+    m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias));
 }
 
-void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias, const String& preferenceName)
+void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias)
 {
-    m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias, preferenceName));
+    m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias));
 }
 
-void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias, const String& preferenceName)
+void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias)
 {
-    m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias, preferenceName));
+    m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias));
 }
 
-InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias, const String& preferenceName)
+InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias)
 {
     Property property;
     property.m_value = value;
     property.m_frontendAlias = frontendAlias;
-    property.m_preferenceName = preferenceName;
     return property;
 }
 
index 4f57da7..3142c92 100644 (file)
@@ -47,11 +47,6 @@ public:
         monitoringXHR = 1,
         timelineProfilerEnabled,
         searchingForNode,
-        profilerAlwaysEnabled,
-        debuggerAlwaysEnabled,
-        lastActivePanel,
-        inspectorStartsAttached,
-        inspectorAttachedHeight,
         pauseOnExceptionsState,
         consoleMessagesEnabled,
         userInitiatedProfiling,
@@ -63,7 +58,6 @@ public:
 
     PassRefPtr<InspectorObject> generateStateObjectForFrontend();
     void restoreFromInspectorCookie(const String& jsonString);
-    void loadFromSettings();
     String getFrontendAlias(InspectorPropertyId propertyId);
 
     bool getBoolean(InspectorPropertyId propertyId);
@@ -71,28 +65,27 @@ public:
     long getLong(InspectorPropertyId propertyId);
     PassRefPtr<InspectorObject> getObject(InspectorPropertyId id);
 
-    void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value), value ? "true" : "false"); }
-    void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value), value); }
-    void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value), String::number(value)); }
+    void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value)); }
+    void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value)); }
+    void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value)); }
     void setObject(InspectorPropertyId propertyId, PassRefPtr<InspectorObject> value);
 
 private:
     void updateCookie();
-    void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value, const String& stringValue);
+    void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value);
 
     struct Property {
-        static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias, const String& preferenceName);
+        static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias);
         String m_frontendAlias;
-        String m_preferenceName;
         RefPtr<InspectorValue> m_value;
     };
     typedef HashMap<long, Property> PropertyMap;
     PropertyMap m_properties;
 
-    void registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias, const String& preferenceName);
-    void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias, const String& preferenceName);
-    void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias, const String& preferenceName);
-    void registerObject(InspectorPropertyId propertyId, const String& frontendAlias, const String& preferenceName);
+    void registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias);
+    void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias);
+    void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias);
+    void registerObject(InspectorPropertyId propertyId, const String& frontendAlias);
 
     InspectorClient* m_client;
 };
index 06daccb..8d63ce1 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-14  Pavel Feldman  <pfeldman@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: extract InspectorSettings from InspectorState, 
+        simplify it.
+        https://bugs.webkit.org/show_bug.cgi?id=52429
+
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+
 2011-01-13  Enrica Casucci  <enrica@apple.com>
 
         Reviewed by Darin Adler.
index 1d8fa1c..ddd1fa8 100644 (file)
@@ -30,6 +30,7 @@
 #include "WebInspectorFrontendClient.h"
 #include "WebInspector.h"
 #include "WebPage.h"
+#include <WebCore/InspectorController.h>
 #include <WebCore/Page.h>
 
 #define DISABLE_NOT_IMPLEMENTED_WARNINGS 1