[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

loislo at chromium.org loislo at chromium.org
Wed Dec 22 14:40:03 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 47c617dabd41d8f7c7ae430a14bf4fa300196946
Author: loislo at chromium.org <loislo at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Oct 15 08:31:03 2010 +0000

    2010-10-14  Ilya Tikhonovsky  <loislo at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: inspector settings/properties/states management
            should be extracted into separate class.
    
            We have a lot of flags/values in InspectorController.
            Some flags are persisting into profile.
            Others are part of inspector state for frontend.
            All these flags should keep their values after navigation.
            It'd be better to extract these flags/values into separate
            class which will care about theirs lifetime.
    
            https://bugs.webkit.org/show_bug.cgi?id=47275
    
            WebCore:
    
            * CMakeLists.txt:
            * GNUmakefile.am:
            * WebCore.exp.in:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * inspector/InspectorController.cpp:
            (WebCore::InspectorController::InspectorController):
            (WebCore::InspectorController::inspectorStartsAttached):
            (WebCore::InspectorController::setInspectorStartsAttached):
            (WebCore::InspectorController::setInspectorAttachedHeight):
            (WebCore::InspectorController::inspectorAttachedHeight):
            (WebCore::InspectorController::searchingForNodeInPage):
            (WebCore::InspectorController::resourceTrackingEnabled):
            (WebCore::InspectorController::saveApplicationSettings):
            (WebCore::InspectorController::getInspectorState):
            (WebCore::InspectorController::restoreInspectorStateFromCookie):
            (WebCore::InspectorController::getSettings):
            (WebCore::InspectorController::storeLastActivePanel):
            (WebCore::InspectorController::mouseDidMoveOverElement):
            (WebCore::InspectorController::handleMousePress):
            (WebCore::InspectorController::setSearchingForNode):
            (WebCore::InspectorController::setMonitoringXHREnabled):
            (WebCore::InspectorController::showPanel):
            (WebCore::InspectorController::disconnectFrontend):
            (WebCore::InspectorController::populateScriptObjects):
            (WebCore::InspectorController::restoreDebugger):
            (WebCore::InspectorController::restoreProfiler):
            (WebCore::InspectorController::getTrackedResource):
            (WebCore::InspectorController::didLoadResourceFromMemoryCache):
            (WebCore::InspectorController::identifierForInitialRequest):
            (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
            (WebCore::InspectorController::scriptImported):
            (WebCore::InspectorController::setResourceTrackingEnabled):
            (WebCore::InspectorController::ensureSettingsLoaded):
            (WebCore::InspectorController::startTimelineProfiler):
            (WebCore::InspectorController::stopTimelineProfiler):
            (WebCore::InspectorController::enableProfiler):
            (WebCore::InspectorController::disableProfiler):
            (WebCore::InspectorController::enableDebuggerFromFrontend):
            (WebCore::InspectorController::disableDebugger):
            (WebCore::InspectorController::loadBreakpoints):
            (WebCore::InspectorController::saveBreakpoints):
            * inspector/InspectorController.h:
            * inspector/InspectorFrontendClientLocal.cpp:
            (WebCore::InspectorFrontendClientLocal::changeAttachedWindowHeight):
            (WebCore::InspectorFrontendClientLocal::restoreAttachedWindowHeight):
            * inspector/InspectorState.cpp: Added.
            (WebCore::InspectorState::InspectorState):
            (WebCore::InspectorState::restoreFromInspectorCookie):
            (WebCore::InspectorState::generateStateObjectForFrontend):
            (WebCore::InspectorState::loadFromSettings):
            (WebCore::InspectorState::updateCookie):
            (WebCore::InspectorState::setValue):
            (WebCore::InspectorState::getBoolean):
            (WebCore::InspectorState::getString):
            (WebCore::InspectorState::getLong):
            (WebCore::InspectorState::registerBoolean):
            (WebCore::InspectorState::registerString):
            (WebCore::InspectorState::registerLong):
            (WebCore::InspectorState::Property::create):
            * inspector/InspectorState.h: Added.
            (WebCore::InspectorState::setBoolean):
            (WebCore::InspectorState::setString):
            (WebCore::InspectorState::setLong):
    
            WebKit/mac:
    
            * WebCoreSupport/WebInspectorClient.mm:
            (-[WebInspectorWindowController showWindow:]):
            (-[WebInspectorWindowController attach]):
            (-[WebInspectorWindowController detach]):
    
            WebKit/win:
    
            * WebCoreSupport/WebInspectorClient.cpp:
            (WebInspectorFrontendClient::attachWindow):
            (WebInspectorFrontendClient::detachWindow):
            (WebInspectorFrontendClient::showWindowWithoutNotifications):
    
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69844 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 58d43d0..96a634d 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -1114,6 +1114,7 @@ SET(WebCore_SOURCES
     inspector/InspectorResourceAgent.cpp
     inspector/InspectorStyleSheet.cpp
     inspector/InspectorValues.cpp
+    inspector/InspectorState.cpp
     inspector/InspectorStorageAgent.cpp
     inspector/InspectorTimelineAgent.cpp
     inspector/ScriptBreakpoint.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index c6abd8f..16d165f 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,86 @@
+2010-10-14  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: inspector settings/properties/states management
+        should be extracted into separate class.
+
+        We have a lot of flags/values in InspectorController.
+        Some flags are persisting into profile.
+        Others are part of inspector state for frontend.
+        All these flags should keep their values after navigation.
+        It'd be better to extract these flags/values into separate
+        class which will care about theirs lifetime.
+
+        https://bugs.webkit.org/show_bug.cgi?id=47275
+
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.exp.in:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::inspectorStartsAttached):
+        (WebCore::InspectorController::setInspectorStartsAttached):
+        (WebCore::InspectorController::setInspectorAttachedHeight):
+        (WebCore::InspectorController::inspectorAttachedHeight):
+        (WebCore::InspectorController::searchingForNodeInPage):
+        (WebCore::InspectorController::resourceTrackingEnabled):
+        (WebCore::InspectorController::saveApplicationSettings):
+        (WebCore::InspectorController::getInspectorState):
+        (WebCore::InspectorController::restoreInspectorStateFromCookie):
+        (WebCore::InspectorController::getSettings):
+        (WebCore::InspectorController::storeLastActivePanel):
+        (WebCore::InspectorController::mouseDidMoveOverElement):
+        (WebCore::InspectorController::handleMousePress):
+        (WebCore::InspectorController::setSearchingForNode):
+        (WebCore::InspectorController::setMonitoringXHREnabled):
+        (WebCore::InspectorController::showPanel):
+        (WebCore::InspectorController::disconnectFrontend):
+        (WebCore::InspectorController::populateScriptObjects):
+        (WebCore::InspectorController::restoreDebugger):
+        (WebCore::InspectorController::restoreProfiler):
+        (WebCore::InspectorController::getTrackedResource):
+        (WebCore::InspectorController::didLoadResourceFromMemoryCache):
+        (WebCore::InspectorController::identifierForInitialRequest):
+        (WebCore::InspectorController::resourceRetrievedByXMLHttpRequest):
+        (WebCore::InspectorController::scriptImported):
+        (WebCore::InspectorController::setResourceTrackingEnabled):
+        (WebCore::InspectorController::ensureSettingsLoaded):
+        (WebCore::InspectorController::startTimelineProfiler):
+        (WebCore::InspectorController::stopTimelineProfiler):
+        (WebCore::InspectorController::enableProfiler):
+        (WebCore::InspectorController::disableProfiler):
+        (WebCore::InspectorController::enableDebuggerFromFrontend):
+        (WebCore::InspectorController::disableDebugger):
+        (WebCore::InspectorController::loadBreakpoints):
+        (WebCore::InspectorController::saveBreakpoints):
+        * inspector/InspectorController.h:
+        * inspector/InspectorFrontendClientLocal.cpp:
+        (WebCore::InspectorFrontendClientLocal::changeAttachedWindowHeight):
+        (WebCore::InspectorFrontendClientLocal::restoreAttachedWindowHeight):
+        * inspector/InspectorState.cpp: Added.
+        (WebCore::InspectorState::InspectorState):
+        (WebCore::InspectorState::restoreFromInspectorCookie):
+        (WebCore::InspectorState::generateStateObjectForFrontend):
+        (WebCore::InspectorState::loadFromSettings):
+        (WebCore::InspectorState::updateCookie):
+        (WebCore::InspectorState::setValue):
+        (WebCore::InspectorState::getBoolean):
+        (WebCore::InspectorState::getString):
+        (WebCore::InspectorState::getLong):
+        (WebCore::InspectorState::registerBoolean):
+        (WebCore::InspectorState::registerString):
+        (WebCore::InspectorState::registerLong):
+        (WebCore::InspectorState::Property::create):
+        * inspector/InspectorState.h: Added.
+        (WebCore::InspectorState::setBoolean):
+        (WebCore::InspectorState::setString):
+        (WebCore::InspectorState::setLong):
+
 2010-10-14  Jia Pu  <jpu at apple.com>
 
         Reviewed by Adele Peterson.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 94084ca..c4eb1c2 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -1834,6 +1834,8 @@ webcore_sources += \
 	WebCore/inspector/InspectorResource.h \
 	WebCore/inspector/InspectorResourceAgent.cpp \
 	WebCore/inspector/InspectorResourceAgent.h \
+	WebCore/inspector/InspectorState.cpp \
+	WebCore/inspector/InspectorState.h \
 	WebCore/inspector/InspectorStorageAgent.cpp \
 	WebCore/inspector/InspectorStorageAgent.h \
 	WebCore/inspector/InspectorStyleSheet.cpp \
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index f99599f..e2811f6 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -1217,7 +1217,6 @@ __ZN7WebCore22GeolocationServiceMock8setErrorEN3WTF10PassRefPtrINS_13PositionErr
 #endif
 
 #if ENABLE(INSPECTOR)
-__ZN7WebCore19InspectorController10setSettingERKN3WTF6StringES4_
 __ZN7WebCore19InspectorController12ConsolePanelE
 __ZN7WebCore19InspectorController12ScriptsPanelE
 __ZN7WebCore19InspectorController13ProfilesPanelE
@@ -1228,12 +1227,12 @@ __ZN7WebCore19InspectorController15disableProfilerEb
 __ZN7WebCore19InspectorController18disconnectFrontendEv
 __ZN7WebCore19InspectorController20stopTimelineProfilerEv
 __ZN7WebCore19InspectorController21startTimelineProfilerEv
+__ZN7WebCore19InspectorController23inspectorStartsAttachedEv
 __ZN7WebCore19InspectorController25evaluateForTestInFrontendElRKN3WTF6StringE
 __ZN7WebCore19InspectorController26setInspectorFrontendClientEN3WTF10PassOwnPtrINS_23InspectorFrontendClientEEE
+__ZN7WebCore19InspectorController26setInspectorStartsAttachedEb
 __ZN7WebCore19InspectorController27startUserInitiatedProfilingEv
 __ZN7WebCore19InspectorController26stopUserInitiatedProfilingEv
-__ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv
-__ZN7WebCore19InspectorController34inspectorStartsAttachedSettingNameEv
 __ZNK7WebCore19InspectorController31isRecordingUserInitiatedProfileEv
 __ZNK7WebCore19InspectorController15profilerEnabledEv
 __ZN7WebCore19InspectorController4showEv
@@ -1253,7 +1252,6 @@ __ZN7WebCore28InspectorFrontendClientLocalC2EPNS_19InspectorControllerEPNS_4Page
 __ZN7WebCore28InspectorFrontendClientLocalD2Ev
 __ZNK7WebCore19InspectorController17drawNodeHighlightERNS_15GraphicsContextE
 __ZNK7WebCore19InspectorController7enabledEv
-__ZNK7WebCore19InspectorController7settingERKN3WTF6StringE
 #endif
 
 #if ENABLE(JAVA_BRIDGE)
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index b6fb076..7d3cb27 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1935,6 +1935,8 @@
             'inspector/InspectorResource.h',
             'inspector/InspectorResourceAgent.cpp',
             'inspector/InspectorResourceAgent.h',
+            'inspector/InspectorState.cpp',
+            'inspector/InspectorState.h',
             'inspector/InspectorStorageAgent.cpp',
             'inspector/InspectorStorageAgent.h',
             'inspector/InspectorStyleSheet.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index a0065ec..d479180 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -1002,6 +1002,7 @@ SOURCES += \
     inspector/InspectorProfilerAgent.cpp \
     inspector/InspectorResource.cpp \
     inspector/InspectorResourceAgent.cpp \
+    inspector/InspectorState.cpp \
     inspector/InspectorStorageAgent.cpp \
     inspector/InspectorStyleSheet.cpp \
     inspector/InspectorTimelineAgent.cpp \
@@ -1879,6 +1880,7 @@ HEADERS += \
     inspector/InspectorProfilerAgent.h \
     inspector/InspectorResource.h \
     inspector/InspectorResourceAgent.h \
+    inspector/InspectorState.h \
     inspector/InspectorStorageAgent.h \
     inspector/InspectorStyleSheet.h \
     inspector/InspectorTimelineAgent.h \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index 7237809..0771072 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -63247,6 +63247,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\inspector\InspectorState.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\inspector\InspectorState.h"
+				>
+			</File>
+			<File
 				RelativePath="..\inspector\InspectorStorageAgent.cpp"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 98b4e2a..086874e 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -1131,6 +1131,8 @@
 		4F4F5FFB11CBD2E100A186BF /* InspectorFrontend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F4F5FFA11CBD2D200A186BF /* InspectorFrontend.cpp */; };
 		4F707A9911EF679400ACDA69 /* InspectorBackendDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F707A9711EF679400ACDA69 /* InspectorBackendDispatcher.cpp */; };
 		4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F707A9811EF679400ACDA69 /* InspectorBackendDispatcher.h */; };
+		4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FA3B908125CD12100300BAD /* InspectorState.cpp */; };
+		4FA3B90B125CD12200300BAD /* InspectorState.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FA3B909125CD12200300BAD /* InspectorState.h */; };
 		4FD8D0F2119C718B002FA825 /* ScriptGCEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FD8D0F0119C718B002FA825 /* ScriptGCEvent.cpp */; };
 		4FD8D0F3119C718B002FA825 /* ScriptGCEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FD8D0F1119C718B002FA825 /* ScriptGCEvent.h */; };
 		510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7197,6 +7199,8 @@
 		4F4F5FFC11CBD30100A186BF /* InspectorFrontend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontend.h; sourceTree = "<group>"; };
 		4F707A9711EF679400ACDA69 /* InspectorBackendDispatcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorBackendDispatcher.cpp; sourceTree = "<group>"; };
 		4F707A9811EF679400ACDA69 /* InspectorBackendDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBackendDispatcher.h; sourceTree = "<group>"; };
+		4FA3B908125CD12100300BAD /* InspectorState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorState.cpp; sourceTree = "<group>"; };
+		4FA3B909125CD12200300BAD /* InspectorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorState.h; sourceTree = "<group>"; };
 		4FD8D0F0119C718B002FA825 /* ScriptGCEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptGCEvent.cpp; sourceTree = "<group>"; };
 		4FD8D0F1119C718B002FA825 /* ScriptGCEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptGCEvent.h; sourceTree = "<group>"; };
 		510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; };
@@ -12194,6 +12198,8 @@
 				41F061FF0F5F0B6600A07EAC /* InspectorResource.h */,
 				82AB1771125C826700C5069D /* InspectorResourceAgent.cpp */,
 				82AB1772125C826700C5069D /* InspectorResourceAgent.h */,
+				4FA3B908125CD12100300BAD /* InspectorState.cpp */,
+				4FA3B909125CD12200300BAD /* InspectorState.h */,
 				7AB0B1BE1211A62200A76940 /* InspectorStorageAgent.cpp */,
 				7AB0B1BF1211A62200A76940 /* InspectorStorageAgent.h */,
 				82AB176F125C826700C5069D /* InspectorStyleSheet.cpp */,
@@ -21069,6 +21075,7 @@
 				93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
+				4FA3B90B125CD12200300BAD /* InspectorState.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -23616,6 +23623,7 @@
 				93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
+				4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/inspector/InspectorController.cpp b/WebCore/inspector/InspectorController.cpp
index f637f4d..b4358d4 100644
--- a/WebCore/inspector/InspectorController.cpp
+++ b/WebCore/inspector/InspectorController.cpp
@@ -69,6 +69,7 @@
 #include "InspectorInstrumentation.h"
 #include "InspectorProfilerAgent.h"
 #include "InspectorResource.h"
+#include "InspectorState.h"
 #include "InspectorStorageAgent.h"
 #include "InspectorTimelineAgent.h"
 #include "InspectorValues.h"
@@ -116,41 +117,19 @@ using namespace std;
 
 namespace WebCore {
 
-static const char* const frontendSettingsSettingName = "frontendSettings";
-
-static const char* const debuggerAlwaysEnabledSettingName = "debuggerEnabled";
-static const char* const lastActivePanel = "lastActivePanel";
-static const char* const monitoringXHRSettingName = "xhrMonitor";
-static const char* const resourceTrackingAlwaysEnabledSettingName = "resourceTrackingEnabled";
-static const char* const profilerAlwaysEnabledSettingName = "profilerEnabled";
-
-static const char* const monitoringXHRStateName = "monitoringXHREnabled";
-static const char* const resourceTrackingEnabledStateName = "resourceTrackingEnabled";
-static const char* const searchingForNodeEnabledStateName = "searchingForNodeEnabled";
-static const char* const timelineProfilerEnabledStateName = "timelineProfilerEnabled";
-static const char* const pauseOnExceptionsStateStateName = "pauseOnExceptionsState";
-
-static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight";
-
 static const char* const domNativeBreakpointType = "DOM";
 static const char* const eventListenerNativeBreakpointType = "EventListener";
 static const char* const xhrNativeBreakpointType = "XHR";
 
+// FIXME: move last panel setting to the front-end
+const char* const InspectorController::LastActivePanel = "lastActivePanel";
 const char* const InspectorController::ElementsPanel = "elements";
 const char* const InspectorController::ConsolePanel = "console";
 const char* const InspectorController::ScriptsPanel = "scripts";
 const char* const InspectorController::ProfilesPanel = "profiles";
 
+const unsigned InspectorController::defaultAttachedHeight = 300;
 
-const String& InspectorController::inspectorStartsAttachedSettingName()
-{
-    DEFINE_STATIC_LOCAL(String, settingName, ("inspectorStartsAttached"));
-    return settingName;
-}
-
-static const unsigned defaultAttachedHeight = 300;
-static const float minimumAttachedHeight = 250.0f;
-static const float maximumAttachedHeightRatio = 0.75f;
 static const unsigned maximumConsoleMessages = 1000;
 static const unsigned expireConsoleMessagesStep = 100;
 
@@ -162,13 +141,10 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
     , m_loadEventTime(-1.0)
     , m_domContentEventTime(-1.0)
     , m_expiredConsoleMessageCount(0)
-    , m_showAfterVisible(lastActivePanel)
+    , m_showAfterVisible(LastActivePanel)
     , m_sessionSettings(InspectorObject::create())
     , m_groupLevel(0)
-    , m_searchingForNode(false)
-    , m_monitoringXHR(false)
     , m_previousMessage(0)
-    , m_resourceTrackingEnabled(false)
     , m_settingsLoaded(false)
     , m_inspectorBackend(InspectorBackend::create(this))
     , m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this))
@@ -179,6 +155,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
     , m_profilerAgent(InspectorProfilerAgent::create(this))
 #endif
 {
+    m_state = new InspectorState(client);
     ASSERT_ARG(page, page);
     ASSERT_ARG(client, client);
 }
@@ -222,27 +199,39 @@ bool InspectorController::enabled() const
     return m_inspectedPage->settings()->developerExtrasEnabled();
 }
 
-String InspectorController::setting(const String& key) const
+bool InspectorController::inspectorStartsAttached()
+{
+    return m_state->getBoolean(InspectorState::inspectorStartsAttached);
+}
+
+void InspectorController::setInspectorStartsAttached(bool attached)
 {
-    Settings::iterator it = m_settings.find(key);
-    if (it != m_settings.end())
-        return it->second;
+    m_state->setBoolean(InspectorState::inspectorStartsAttached, attached);
+}
 
-    String value;
-    m_client->populateSetting(key, &value);
-    m_settings.set(key, value);
-    return value;
+void InspectorController::setInspectorAttachedHeight(long height)
+{
+    m_state->setLong(InspectorState::inspectorAttachedHeight, height);
+}
+
+int InspectorController::inspectorAttachedHeight() const
+{
+    return m_state->getBoolean(InspectorState::inspectorAttachedHeight);
 }
 
-void InspectorController::setSetting(const String& key, const String& value)
+bool InspectorController::searchingForNodeInPage() const
 {
-    m_settings.set(key, value);
-    m_client->storeSetting(key, value);
+    return m_state->getBoolean(InspectorState::searchingForNode);
+}
+
+bool InspectorController::resourceTrackingEnabled() const
+{
+    return m_state->getBoolean(InspectorState::resourceTrackingEnabled);
 }
 
 void InspectorController::saveApplicationSettings(const String& settings)
 {
-    setSetting(frontendSettingsSettingName, settings);
+    m_state->setString(InspectorState::frontendSettings, settings);
 }
 
 void InspectorController::saveSessionSettings(const String& settingsJSON)
@@ -252,50 +241,24 @@ void InspectorController::saveSessionSettings(const String& settingsJSON)
 
 void InspectorController::getInspectorState(RefPtr<InspectorObject>* state)
 {
-    (*state)->setBoolean(monitoringXHRStateName, m_monitoringXHR);
-    (*state)->setBoolean(resourceTrackingEnabledStateName, m_resourceTrackingEnabled);
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     if (m_debuggerAgent)
-        (*state)->setNumber(pauseOnExceptionsStateStateName, m_debuggerAgent->pauseOnExceptionsState());
+        m_state->setLong(InspectorState::pauseOnExceptionsState, m_debuggerAgent->pauseOnExceptionsState());
 #endif
+    *state = m_state->generateStateObjectForFrontend();
 }
 
-void InspectorController::updateInspectorStateCookie()
-{
-    RefPtr<InspectorObject> state = InspectorObject::create();
-    state->setBoolean(monitoringXHRStateName, m_monitoringXHR);
-    state->setBoolean(resourceTrackingEnabledStateName, m_resourceTrackingEnabled);
-    state->setBoolean(timelineProfilerEnabledStateName, m_timelineAgent);
-    state->setBoolean(searchingForNodeEnabledStateName, m_searchingForNode);
-    m_client->updateInspectorStateCookie(state->toJSONString());
-}
-
-void InspectorController::restoreInspectorStateFromCookie(const String& inspectorStateString)
+void InspectorController::restoreInspectorStateFromCookie(const String& inspectorStateCookie)
 {
-    RefPtr<InspectorValue> inspectorStateValue = InspectorValue::parseJSON(inspectorStateString);
-    if (!inspectorStateValue)
-        return;
-
-    RefPtr<InspectorObject> inspectorState = inspectorStateValue->asObject();
-    if (!inspectorState)
-        return;
-
-    inspectorState->getBoolean(monitoringXHRStateName, &m_monitoringXHR);
-    inspectorState->getBoolean(resourceTrackingEnabledStateName, &m_resourceTrackingEnabled);
-    inspectorState->getBoolean(searchingForNodeEnabledStateName, &m_searchingForNode);
-
-    bool timelineProfilerEnabled = false;
-    inspectorState->getBoolean(timelineProfilerEnabledStateName, &timelineProfilerEnabled);
-    if (timelineProfilerEnabled)
+    m_state->restoreFromInspectorCookie(inspectorStateCookie);
+    if (m_state->getBoolean(InspectorState::timelineProfilerEnabled))
         startTimelineProfiler();
-    else
-        stopTimelineProfiler();
 }
 
 void InspectorController::getSettings(RefPtr<InspectorObject>* settings)
 {
     *settings = InspectorObject::create();
-    (*settings)->setString("application", setting(frontendSettingsSettingName));
+    (*settings)->setString("application", m_state->getString(InspectorState::frontendSettings));
     (*settings)->setString("session", m_sessionSettings->toJSONString());
 }
 
@@ -432,12 +395,12 @@ void InspectorController::markTimeline(const String& message)
 
 void InspectorController::storeLastActivePanel(const String& panelName)
 {
-    setSetting(lastActivePanel, panelName);
+    m_state->setString(InspectorState::lastActivePanel, panelName);
 }
 
 void InspectorController::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
 {
-    if (!enabled() || !m_searchingForNode)
+    if (!enabled() || !searchingForNodeInPage())
         return;
 
     Node* node = result.innerNode();
@@ -452,7 +415,7 @@ void InspectorController::handleMousePress()
     if (!enabled())
         return;
 
-    ASSERT(m_searchingForNode);
+    ASSERT(searchingForNodeInPage());
     if (!m_highlightedNode)
         return;
 
@@ -491,12 +454,11 @@ void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame)
 
 void InspectorController::setSearchingForNode(bool enabled)
 {
-    if (m_searchingForNode == enabled)
+    if (searchingForNodeInPage() == enabled)
         return;
-    m_searchingForNode = enabled;
-    if (!m_searchingForNode)
+    m_state->setBoolean(InspectorState::searchingForNode, enabled);
+    if (!enabled)
         hideHighlight();
-    updateInspectorStateCookie();
 }
 
 void InspectorController::setSearchingForNode(bool enabled, bool* newState)
@@ -508,11 +470,7 @@ void InspectorController::setSearchingForNode(bool enabled, bool* newState)
 void InspectorController::setMonitoringXHREnabled(bool enabled, bool* newState)
 {
     *newState = enabled;
-    if (m_monitoringXHR == enabled)
-        return;
-    m_monitoringXHR = enabled;
-    setSetting(monitoringXHRSettingName, enabled ? "true" : "false");
-    updateInspectorStateCookie();
+    m_state->setBoolean(InspectorState::monitoringXHR, enabled);
 }
 
 void InspectorController::connectFrontend()
@@ -576,7 +534,7 @@ void InspectorController::showPanel(const String& panel)
         return;
     }
 
-    if (panel == lastActivePanel)
+    if (panel == LastActivePanel)
         return;
 
     m_frontend->showPanel(panel);
@@ -612,7 +570,7 @@ void InspectorController::disconnectFrontend()
     unbindAllResources();
     stopTimelineProfiler();
 
-    m_showAfterVisible = lastActivePanel;
+    m_showAfterVisible = LastActivePanel;
 
     hideHighlight();
 
@@ -650,8 +608,8 @@ void InspectorController::populateScriptObjects()
     if (!m_frontend)
         return;
 
-    if (m_showAfterVisible == lastActivePanel)
-        m_showAfterVisible = setting(lastActivePanel);
+    if (m_showAfterVisible == LastActivePanel)
+        m_showAfterVisible = m_state->getString(InspectorState::lastActivePanel);
 
     showPanel(m_showAfterVisible);
 
@@ -713,8 +671,7 @@ void InspectorController::restoreDebugger()
     if (InspectorDebuggerAgent::isDebuggerAlwaysEnabled())
         enableDebuggerFromFrontend(false);
     else {
-        String debuggerEnabled = setting(debuggerAlwaysEnabledSettingName);
-        if (debuggerEnabled == "true" || m_attachDebuggerWhenShown)
+        if (m_state->getBoolean(InspectorState::debuggerAlwaysEnabled) || m_attachDebuggerWhenShown)
             enableDebugger();
     }
 #endif
@@ -725,11 +682,8 @@ void InspectorController::restoreProfiler()
     ASSERT(m_frontend);
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     m_profilerAgent->setFrontend(m_frontend.get());
-    if (!ScriptProfiler::isProfilerAlwaysEnabled()) {
-        String profilerEnabledSetting = setting(profilerAlwaysEnabledSettingName);
-        if (profilerEnabledSetting == "true")
-            enableProfiler();
-    }
+    if (!ScriptProfiler::isProfilerAlwaysEnabled() && m_state->getBoolean(InspectorState::profilerAlwaysEnabled))
+        enableProfiler();
 #endif
 }
 
@@ -901,7 +855,7 @@ InspectorResource* InspectorController::getTrackedResource(unsigned long identif
     if (!enabled())
         return 0;
 
-    if (m_resourceTrackingEnabled)
+    if (resourceTrackingEnabled())
         return m_resources.get(identifier).get();
 
     bool isMainResource = m_mainResource && m_mainResource->identifier() == identifier;
@@ -932,7 +886,7 @@ void InspectorController::didLoadResourceFromMemoryCache(DocumentLoader* loader,
     ASSERT(m_inspectedPage);
     bool isMainResource = isMainResourceLoader(loader, KURL(ParsedURLString, cachedResource->url()));
     ensureSettingsLoaded();
-    if (!isMainResource && !m_resourceTrackingEnabled)
+    if (!isMainResource && !resourceTrackingEnabled())
         return;
 
     RefPtr<InspectorResource> resource = InspectorResource::createCached(m_inspectedPage->progress()->createUniqueIdentifier(), loader, cachedResource);
@@ -956,7 +910,7 @@ void InspectorController::identifierForInitialRequest(unsigned long identifier,
 
     bool isMainResource = isMainResourceLoader(loader, request.url());
     ensureSettingsLoaded();
-    if (!isMainResource && !m_resourceTrackingEnabled)
+    if (!isMainResource && !resourceTrackingEnabled())
         return;
 
     RefPtr<InspectorResource> resource = InspectorResource::create(identifier, loader, request.url());
@@ -1137,10 +1091,10 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identi
     if (!enabled())
         return;
 
-    if (m_monitoringXHR)
+    if (m_state->getBoolean(InspectorState::monitoringXHR))
         addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL);
 
-    if (!m_resourceTrackingEnabled)
+    if (!resourceTrackingEnabled())
         return;
 
     InspectorResource* resource = m_resources.get(identifier).get();
@@ -1155,7 +1109,7 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identi
 
 void InspectorController::scriptImported(unsigned long identifier, const String& sourceString)
 {
-    if (!enabled() || !m_resourceTrackingEnabled)
+    if (!enabled() || !resourceTrackingEnabled())
         return;
 
     InspectorResource* resource = m_resources.get(identifier).get();
@@ -1174,8 +1128,7 @@ void InspectorController::setResourceTrackingEnabled(bool enable)
         return;
 
     ASSERT(m_inspectedPage);
-    m_resourceTrackingEnabled = enable;
-    updateInspectorStateCookie();
+    m_state->setBoolean(InspectorState::resourceTrackingEnabled, enable);
 }
 
 void InspectorController::setResourceTrackingEnabled(bool enable, bool always, bool* newState)
@@ -1183,18 +1136,16 @@ void InspectorController::setResourceTrackingEnabled(bool enable, bool always, b
     *newState = enable;
 
     if (always)
-        setSetting(resourceTrackingAlwaysEnabledSettingName, enable ? "true" : "false");
+        m_state->setBoolean(InspectorState::resourceTrackingAlwaysEnabled, enable);
 
-    if (m_resourceTrackingEnabled == enable)
+    if (resourceTrackingEnabled() == enable)
         return;
 
     ASSERT(m_inspectedPage);
-    m_resourceTrackingEnabled = enable;
+    m_state->setBoolean(InspectorState::resourceTrackingEnabled, enable);
 
     if (enable)
         m_inspectedPage->mainFrame()->navigationScheduler()->scheduleRefresh(true);
-
-    updateInspectorStateCookie();
 }
 
 void InspectorController::ensureSettingsLoaded()
@@ -1203,15 +1154,10 @@ void InspectorController::ensureSettingsLoaded()
         return;
     m_settingsLoaded = true;
 
-    String resourceTrackingAlwaysEnabled = setting(resourceTrackingAlwaysEnabledSettingName);
-    if (resourceTrackingAlwaysEnabled == "true")
-        m_resourceTrackingEnabled = true;
-
-    String monitoringXHRAlwaysEnabled = setting(monitoringXHRSettingName);
-    if (monitoringXHRAlwaysEnabled == "true")
-        m_monitoringXHR = true;
+    m_state->loadFromSettings();
 
-    updateInspectorStateCookie();
+    if (m_state->getBoolean(InspectorState::resourceTrackingAlwaysEnabled))
+        m_state->setBoolean(InspectorState::resourceTrackingEnabled, true);
 }
 
 void InspectorController::startTimelineProfiler()
@@ -1226,7 +1172,7 @@ void InspectorController::startTimelineProfiler()
     if (m_frontend)
         m_frontend->timelineProfilerWasStarted();
 
-    updateInspectorStateCookie();
+    m_state->setBoolean(InspectorState::timelineProfilerEnabled, true);
 }
 
 void InspectorController::stopTimelineProfiler()
@@ -1241,7 +1187,7 @@ void InspectorController::stopTimelineProfiler()
     if (m_frontend)
         m_frontend->timelineProfilerWasStopped();
 
-    updateInspectorStateCookie();
+    m_state->setBoolean(InspectorState::timelineProfilerEnabled, false);
 }
 
 #if ENABLE(WORKERS)
@@ -1613,14 +1559,14 @@ bool InspectorController::profilerEnabled() const
 void InspectorController::enableProfiler(bool always, bool skipRecompile)
 {
     if (always)
-        setSetting(profilerAlwaysEnabledSettingName, "true");
+        m_state->setBoolean(InspectorState::profilerAlwaysEnabled, true);
     m_profilerAgent->enable(skipRecompile);
 }
 
 void InspectorController::disableProfiler(bool always)
 {
     if (always)
-        setSetting(profilerAlwaysEnabledSettingName, "false");
+        m_state->setBoolean(InspectorState::profilerAlwaysEnabled, false);
     m_profilerAgent->disable();
 }
 #endif
@@ -1630,7 +1576,7 @@ void InspectorController::enableDebuggerFromFrontend(bool always)
 {
     ASSERT(!debuggerEnabled());
     if (always)
-        setSetting(debuggerAlwaysEnabledSettingName, "true");
+        m_state->setBoolean(InspectorState::debuggerAlwaysEnabled, true);
 
     ASSERT(m_inspectedPage);
 
@@ -1661,7 +1607,7 @@ void InspectorController::disableDebugger(bool always)
         return;
 
     if (always)
-        setSetting(debuggerAlwaysEnabledSettingName, "false");
+        m_state->setBoolean(InspectorState::debuggerAlwaysEnabled, false);
 
     ASSERT(m_inspectedPage);
 
@@ -1779,12 +1725,14 @@ String InspectorController::breakpointsSettingKey()
 
 PassRefPtr<InspectorValue> InspectorController::loadBreakpoints()
 {
-    return InspectorValue::parseJSON(setting(breakpointsSettingKey()));
+    String jsonString;
+    m_client->populateSetting(breakpointsSettingKey(), &jsonString);
+    return InspectorValue::parseJSON(jsonString);
 }
 
 void InspectorController::saveBreakpoints(PassRefPtr<InspectorObject> breakpoints)
 {
-    setSetting(breakpointsSettingKey(), breakpoints->toJSONString());
+    m_client->storeSetting(breakpointsSettingKey(), breakpoints->toJSONString());
 }
 #endif
 
diff --git a/WebCore/inspector/InspectorController.h b/WebCore/inspector/InspectorController.h
index af6b5cf..86d823e 100644
--- a/WebCore/inspector/InspectorController.h
+++ b/WebCore/inspector/InspectorController.h
@@ -68,6 +68,7 @@ class InspectorFrontendClient;
 class InspectorObject;
 class InspectorProfilerAgent;
 class InspectorResource;
+class InspectorState;
 class InspectorStorageAgent;
 class InspectorTimelineAgent;
 class InspectorValue;
@@ -101,6 +102,7 @@ public:
     typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
     typedef HashMap<int, RefPtr<InspectorDOMStorageResource> > DOMStorageResourcesMap;
 
+    static const char* const LastActivePanel;
     static const char* const ConsolePanel;
     static const char* const ElementsPanel;
     static const char* const ProfilesPanel;
@@ -121,13 +123,11 @@ public:
     Page* inspectedPage() const { return m_inspectedPage; }
     void reloadPage();
 
-    String setting(const String& key) const;
-    void setSetting(const String& key, const String& value);
     void saveApplicationSettings(const String& settings);
     void saveSessionSettings(const String&);
     void getSettings(RefPtr<InspectorObject>*);
 
-    void restoreInspectorStateFromCookie(const String& inspectorState);
+    void restoreInspectorStateFromCookie(const String& inspectorCookie);
 
     void inspect(Node*);
     void highlight(Node*);
@@ -151,7 +151,7 @@ public:
     void clearConsoleMessages();
     const Vector<OwnPtr<ConsoleMessage> >& consoleMessages() const { return m_consoleMessages; }
 
-    bool searchingForNodeInPage() const { return m_searchingForNode; }
+    bool searchingForNodeInPage() const;
     void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
     void handleMousePress();
 
@@ -176,7 +176,7 @@ public:
 
     void setResourceTrackingEnabled(bool enabled);
     void setResourceTrackingEnabled(bool enabled, bool always, bool* newState);
-    bool resourceTrackingEnabled() const { return m_resourceTrackingEnabled; }
+    bool resourceTrackingEnabled() const;
 
     void ensureSettingsLoaded();
 
@@ -269,10 +269,14 @@ public:
     void removeAllScriptsToEvaluateOnLoad();
     void setInspectorExtensionAPI(const String& source);
 
-    static const String& inspectorStartsAttachedSettingName();
+    bool inspectorStartsAttached();
+    void setInspectorStartsAttached(bool);
+    void setInspectorAttachedHeight(long height);
+    int inspectorAttachedHeight() const;
+
+    static const unsigned defaultAttachedHeight;
 
 private:
-    void updateInspectorStateCookie();
     void getInspectorState(RefPtr<InspectorObject>* state);
 
     friend class InspectorBackend;
@@ -344,6 +348,7 @@ private:
     RefPtr<InspectorStorageAgent> m_storageAgent;
     OwnPtr<InspectorCSSStore> m_cssStore;
     OwnPtr<InspectorTimelineAgent> m_timelineAgent;
+    OwnPtr<InspectorState> m_state;
 
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     OwnPtr<InspectorApplicationCacheAgent> m_applicationCacheAgent;
@@ -372,10 +377,7 @@ private:
     RefPtr<InspectorValue> m_sessionSettings;
 #endif
     unsigned m_groupLevel;
-    bool m_searchingForNode;
-    bool m_monitoringXHR;
     ConsoleMessage* m_previousMessage;
-    bool m_resourceTrackingEnabled;
     bool m_settingsLoaded;
     RefPtr<InspectorBackend> m_inspectorBackend;
     OwnPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
diff --git a/WebCore/inspector/InspectorFrontendClientLocal.cpp b/WebCore/inspector/InspectorFrontendClientLocal.cpp
index 77616da..4812b2a 100644
--- a/WebCore/inspector/InspectorFrontendClientLocal.cpp
+++ b/WebCore/inspector/InspectorFrontendClientLocal.cpp
@@ -47,7 +47,6 @@
 
 namespace WebCore {
 
-static const char* const inspectorAttachedHeightName = "inspectorAttachedHeight";
 static const unsigned defaultAttachedHeight = 300;
 static const float minimumAttachedHeight = 250.0f;
 static const float maximumAttachedHeightRatio = 0.75f;
@@ -108,7 +107,7 @@ void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
 {
     unsigned totalHeight = m_frontendPage->mainFrame()->view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();
     unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight);
-    m_inspectorController->setSetting(inspectorAttachedHeightName, String::number(attachedHeight));
+    m_inspectorController->setInspectorAttachedHeight(attachedHeight);
     setAttachedWindowHeight(attachedHeight);
 }
 
@@ -134,10 +133,9 @@ void InspectorFrontendClientLocal::setAttachedWindow(bool attached)
 void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
 {
     unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();
-    String attachedHeight = m_inspectorController->setting(inspectorAttachedHeightName);
+    int attachedHeight = m_inspectorController->inspectorAttachedHeight();
     bool success = true;
-    int height = attachedHeight.toInt(&success);
-    unsigned preferredHeight = success ? static_cast<unsigned>(height) : defaultAttachedHeight;
+    unsigned preferredHeight = success ? static_cast<unsigned>(attachedHeight) : defaultAttachedHeight;
     
     // This call might not go through (if the window starts out detached), but if the window is initially created attached,
     // InspectorController::attachWindow is never called, so we need to make sure to set the attachedWindowHeight.
diff --git a/WebCore/inspector/InspectorState.cpp b/WebCore/inspector/InspectorState.cpp
new file mode 100644
index 0000000..b731b76
--- /dev/null
+++ b/WebCore/inspector/InspectorState.cpp
@@ -0,0 +1,181 @@
+/*
+ * Copyright (C) 2010 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 GOOGLE AND ITS 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 APPLE OR ITS 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 "InspectorState.h"
+
+#include "InspectorClient.h"
+#include "InspectorController.h"
+
+#if ENABLE(INSPECTOR)
+
+namespace WebCore {
+
+InspectorState::InspectorState(InspectorClient* client)
+    : m_client(client)
+{
+    registerBoolean(monitoringXHR, false, "monitoringXHR", "xhrMonitor");
+    registerBoolean(resourceTrackingEnabled, false, "resourceTrackingEnabled", (const char*)0);
+    registerBoolean(resourceTrackingAlwaysEnabled, false, (const char*)0, "resourceTrackingEnabled");
+    registerBoolean(timelineProfilerEnabled, false, "timelineProfilerEnabled", (const char*)0);
+    registerBoolean(searchingForNode, false, "searchingForNodeEnabled", (const char*)0);
+    registerBoolean(profilerAlwaysEnabled, false, (const char*)0, "profilerEnabled");
+    registerString(frontendSettings, "", (const char*)0, "frontendSettings");
+    registerBoolean(debuggerAlwaysEnabled, false, (const char*)0, "debuggerEnabled");
+    registerString(lastActivePanel, InspectorController::LastActivePanel, (const char*)0, "lastActivePanel");
+    registerBoolean(inspectorStartsAttached, true, (const char*)0, "InspectorStartsAttached");
+    registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, (const char*)0, "inspectorAttachedHeight");
+    registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", (const char*)0);
+}
+
+void InspectorState::restoreFromInspectorCookie(const String& json)
+{
+    RefPtr<InspectorValue> jsonValue = InspectorValue::parseJSON(json);
+    if (!jsonValue)
+        return;
+
+    RefPtr<InspectorObject> jsonObject = jsonValue->asObject();
+    if (!jsonObject)
+        return;
+
+    for (InspectorObject::iterator i = jsonObject->begin(); i != jsonObject->end(); ++i) {
+        InspectorPropertyId id = (InspectorPropertyId)i->first.toInt();
+        ASSERT(id > 0 && id < lastPropertyId);
+        PropertyMap::iterator j = m_properties.find(id);
+        ASSERT(j != m_properties.end());
+        ASSERT(j->second.m_value->type() == i->second->type());
+        j->second.m_value = i->second;
+    }
+}
+
+PassRefPtr<InspectorObject> InspectorState::generateStateObjectForFrontend()
+{
+    RefPtr<InspectorObject> stateObject = InspectorObject::create();
+    for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i) {
+        if (i->second.m_frontendAlias.length())
+            stateObject->setValue(i->second.m_frontendAlias, i->second.m_value);
+    }
+    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:
+                i->second.m_value = InspectorBasicValue::create(value == "true");
+                break;
+            case InspectorValue::TypeString:
+                i->second.m_value = InspectorString::create(value);
+                break;
+            case InspectorValue::TypeNumber:
+                i->second.m_value = InspectorBasicValue::create((double)value.toInt());
+                break;
+            default:
+                ASSERT(false);
+                break;
+            }
+        }
+    }
+}
+
+void InspectorState::updateCookie()
+{
+    RefPtr<InspectorObject> cookieObject = InspectorObject::create();
+    for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i)
+        cookieObject->setValue(String::number(i->first), i->second.m_value);
+    m_client->updateInspectorStateCookie(cookieObject->toJSONString());
+}
+
+void InspectorState::setValue(InspectorPropertyId id, PassRefPtr<InspectorValue> value, const String& stringValue)
+{
+    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();
+}
+
+bool InspectorState::getBoolean(InspectorPropertyId id)
+{
+    PropertyMap::iterator i = m_properties.find(id);
+    ASSERT(i != m_properties.end());
+    bool value = false;
+    i->second.m_value->asBoolean(&value);
+    return value;
+}
+
+String InspectorState::getString(InspectorPropertyId id)
+{
+    PropertyMap::iterator i = m_properties.find(id);
+    ASSERT(i != m_properties.end());
+    String value;
+    i->second.m_value->asString(&value);
+    return value;
+}
+
+long InspectorState::getLong(InspectorPropertyId id)
+{
+    PropertyMap::iterator i = m_properties.find(id);
+    ASSERT(i != m_properties.end());
+    long value = 0;
+    i->second.m_value->asNumber(&value);
+    return value;
+}
+
+void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias, const String& preferenceName)
+{
+    m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias, preferenceName));
+}
+
+void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias, const String& preferenceName)
+{
+    m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias, preferenceName));
+}
+
+void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias, const String& preferenceName)
+{
+    m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias, preferenceName));
+}
+
+InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias, const String& preferenceName)
+{
+    Property property;
+    property.m_value = value;
+    property.m_frontendAlias = frontendAlias;
+    property.m_preferenceName = preferenceName;
+    return property;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
diff --git a/WebCore/inspector/InspectorState.h b/WebCore/inspector/InspectorState.h
new file mode 100644
index 0000000..e6e6da8
--- /dev/null
+++ b/WebCore/inspector/InspectorState.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010 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:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  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.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 GOOGLE AND ITS 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 APPLE OR ITS 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 InspectorState_h
+#define InspectorState_h
+
+#include "InspectorValues.h"
+#include "PlatformString.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class InspectorClient;
+
+class InspectorState {
+public:
+    enum InspectorPropertyId {
+        monitoringXHR = 1,
+        resourceTrackingEnabled,
+        resourceTrackingAlwaysEnabled,
+        timelineProfilerEnabled,
+        searchingForNode,
+        profilerAlwaysEnabled,
+        frontendSettings,
+        debuggerAlwaysEnabled,
+        lastActivePanel,
+        inspectorStartsAttached,
+        inspectorAttachedHeight,
+        pauseOnExceptionsState,
+        lastPropertyId
+    };
+
+    InspectorState(InspectorClient* client);
+
+    PassRefPtr<InspectorObject> generateStateObjectForFrontend();
+    void restoreFromInspectorCookie(const String& jsonString);
+    void loadFromSettings();
+
+    bool getBoolean(InspectorPropertyId propertyId);
+    String getString(InspectorPropertyId propertyId);
+    long getLong(InspectorPropertyId propertyId);
+
+    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)); }
+
+private:
+    void updateCookie();
+    void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value, const String& stringValue);
+
+    struct Property {
+        static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias, const String& preferenceName);
+        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);
+
+    InspectorClient* m_client;
+};
+
+} // namespace WebCore
+
+#endif // !defined(InspectorState_h)
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index 5d8d762..e9b2e7a 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,24 @@
+2010-10-14  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: inspector settings/properties/states management
+        should be extracted into separate class.
+
+        We have a lot of flags/values in InspectorController.
+        Some flags are persisting into profile.
+        Others are part of inspector state for frontend.
+        All these flags should keep their values after navigation.
+        It'd be better to extract these flags/values into separate
+        class which will care about theirs lifetime.
+
+        https://bugs.webkit.org/show_bug.cgi?id=47275
+
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController showWindow:]):
+        (-[WebInspectorWindowController attach]):
+        (-[WebInspectorWindowController detach]):
+
 2010-10-13  Gavin Barraclough  <barraclough at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
index d4d0213..d0c6c78 100644
--- a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
+++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
@@ -358,8 +358,8 @@ void WebInspectorFrontendClient::updateWindowTitle() const
     _visible = YES;
     
     // If no preference is set - default to an attached window. This is important for inspector LayoutTests.
-    String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(InspectorController::inspectorStartsAttachedSettingName());
-    _shouldAttach = shouldAttach != "false";
+    // FIXME: This flag can be fetched directly from the flags storage.
+    _shouldAttach = [_inspectedWebView page]->inspectorController()->inspectorStartsAttached();
     
     if (_shouldAttach && !_frontendClient->canAttachWindow())
         _shouldAttach = NO;
@@ -394,7 +394,8 @@ void WebInspectorFrontendClient::updateWindowTitle() const
     if (_attachedToInspectedWebView)
         return;
 
-    [_inspectedWebView page]->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "true");
+    // FIXME: This flag can be saved directly to the flags storage.
+    [_inspectedWebView page]->inspectorController()->setInspectorStartsAttached(true);
 
     [self close];
     [self showWindow:nil];
@@ -405,7 +406,8 @@ void WebInspectorFrontendClient::updateWindowTitle() const
     if (!_attachedToInspectedWebView)
         return;
 
-    [_inspectedWebView page]->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "false");
+    // FIXME: This flag can be saved to the flags storage directly.
+    [_inspectedWebView page]->inspectorController()->setInspectorStartsAttached(false);
 
     [self close];
     [self showWindow:nil];
diff --git a/WebKit/win/ChangeLog b/WebKit/win/ChangeLog
index a846b75..4c5f8b7 100644
--- a/WebKit/win/ChangeLog
+++ b/WebKit/win/ChangeLog
@@ -1,3 +1,24 @@
+2010-10-14  Ilya Tikhonovsky  <loislo at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: inspector settings/properties/states management
+        should be extracted into separate class.
+
+        We have a lot of flags/values in InspectorController.
+        Some flags are persisting into profile.
+        Others are part of inspector state for frontend.
+        All these flags should keep their values after navigation.
+        It'd be better to extract these flags/values into separate
+        class which will care about theirs lifetime.
+
+        https://bugs.webkit.org/show_bug.cgi?id=47275
+
+        * WebCoreSupport/WebInspectorClient.cpp:
+        (WebInspectorFrontendClient::attachWindow):
+        (WebInspectorFrontendClient::detachWindow):
+        (WebInspectorFrontendClient::showWindowWithoutNotifications):
+
 2010-10-13  Gavin Barraclough  <barraclough at apple.com>
 
         Reviewed by Oliver Hunt.
diff --git a/WebKit/win/WebCoreSupport/WebInspectorClient.cpp b/WebKit/win/WebCoreSupport/WebInspectorClient.cpp
index 1b79dde..0672537 100644
--- a/WebKit/win/WebCoreSupport/WebInspectorClient.cpp
+++ b/WebKit/win/WebCoreSupport/WebInspectorClient.cpp
@@ -273,7 +273,8 @@ void WebInspectorFrontendClient::attachWindow()
     if (m_attached)
         return;
 
-    m_inspectedWebView->page()->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "true");
+    // FIXME: This flag can be saved to the flags storage directly.
+    m_inspectedWebView->page()->inspectorController()->setInspectorStartsAttached(true);
 
     closeWindowWithoutNotifications();
     showWindowWithoutNotifications();
@@ -284,7 +285,8 @@ void WebInspectorFrontendClient::detachWindow()
     if (!m_attached)
         return;
 
-    m_inspectedWebView->page()->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "false");
+    // FIXME: This flag can be saved to the flags storage directly.
+    m_inspectedWebView->page()->inspectorController()->setInspectorStartsAttached(false);
 
     closeWindowWithoutNotifications();
     showWindowWithoutNotifications();
@@ -364,8 +366,8 @@ void WebInspectorFrontendClient::showWindowWithoutNotifications()
         shouldAttach = true;
     else {
         // If no preference is set - default to an attached window. This is important for inspector LayoutTests.
-        String shouldAttachPref = m_inspectedWebView->page()->inspectorController()->setting(InspectorController::inspectorStartsAttachedSettingName());
-        shouldAttach = shouldAttachPref != "false";
+        // FIXME: This flag can be fetched directly from the flags storage.
+        shouldAttach = m_inspectedWebView->page()->inspectorController()->inspectorStartsAttached();
 
         if (shouldAttach && !canAttachWindow())
             shouldAttach = false;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list