Web Inspector: query backend for capabilities explicitly.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2011 11:33:10 +0000 (11:33 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2011 11:33:10 +0000 (11:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73442

Reviewed by Yury Semikhatsky.

Source/WebCore:

This change removes the hardcoded Capabilities values in favor of
explicit query commands issued against the backend. I'll remove the
Meta agent in a subsequent change.

* bindings/js/ScriptDebugServer.h:
(WebCore::ScriptDebugServer::causesRecompilation):
(WebCore::ScriptDebugServer::supportsNativeBreakpoints):
* bindings/js/ScriptProfiler.h:
(WebCore::ScriptProfiler::causesRecompilation):
(WebCore::ScriptProfiler::isSampling):
(WebCore::ScriptProfiler::hasHeapProfiler):
* bindings/v8/ScriptDebugServer.h:
(WebCore::ScriptDebugServer::causesRecompilation):
(WebCore::ScriptDebugServer::supportsNativeBreakpoints):
* bindings/v8/ScriptProfiler.h:
(WebCore::ScriptProfiler::causesRecompilation):
(WebCore::ScriptProfiler::isSampling):
(WebCore::ScriptProfiler::hasHeapProfiler):
* inspector/Inspector.json:
* inspector/InspectorClient.h:
(WebCore::InspectorClient::canClearBrowserCache):
(WebCore::InspectorClient::canClearBrowserCookies):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::show):
* inspector/InspectorController.h:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::causesRecompilation):
(WebCore::InspectorDebuggerAgent::canSetScriptSource):
(WebCore::InspectorDebuggerAgent::supportsNativeBreakpoints):
* inspector/InspectorDebuggerAgent.h:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::frontendLoaded):
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::causesRecompilation):
(WebCore::InspectorProfilerAgent::isSampling):
(WebCore::InspectorProfilerAgent::hasHeapProfiler):
(WebCore::InspectorProfilerAgent::disable):
(WebCore::InspectorProfilerAgent::enable):
(WebCore::InspectorProfilerAgent::setFrontend):
* inspector/InspectorProfilerAgent.h:
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::canClearBrowserCache):
(WebCore::InspectorResourceAgent::canClearBrowserCookies):
* inspector/InspectorResourceAgent.h:
* inspector/front-end/DebuggerModel.js:
(WebInspector.DebuggerModel):
(WebInspector.DebuggerModel.prototype.enableDebugger):
(WebInspector.DebuggerModel.prototype.canSetScriptSource):
* inspector/front-end/NetworkItemView.js:
(WebInspector.NetworkItemView):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView.onCanClearBrowserCache):
(WebInspector.NetworkLogView.onCanClearBrowserCookies):
(WebInspector.NetworkLogView):
(WebInspector.NetworkLogView.prototype._contextMenu):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
* inspector/front-end/ScriptsPanel.js:
* inspector/front-end/Settings.js:
* inspector/front-end/SettingsScreen.js:
(WebInspector.SettingsScreen):
* inspector/front-end/inspector.js:
(WebInspector.get inspectedPageDomain):
(WebInspector._initializeCapability):
(WebInspector.doLoadedDone):

Source/WebKit/chromium:

* src/InspectorClientImpl.cpp:
(WebKit::InspectorClientImpl::canClearBrowserCache):
(WebKit::InspectorClientImpl::canClearBrowserCookies):
* src/InspectorClientImpl.h:
* src/js/DevTools.js:

LayoutTests:

* inspector/profiler/detailed-heapshots-test.js:

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

31 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/profiler/detailed-heapshots-test.js
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptDebugServer.h
Source/WebCore/bindings/js/ScriptProfiler.h
Source/WebCore/bindings/v8/ScriptDebugServer.h
Source/WebCore/bindings/v8/ScriptProfiler.h
Source/WebCore/inspector/Inspector.json
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorProfilerAgent.cpp
Source/WebCore/inspector/InspectorProfilerAgent.h
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/inspector/InspectorResourceAgent.h
Source/WebCore/inspector/front-end/DebuggerModel.js
Source/WebCore/inspector/front-end/NetworkItemView.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/Settings.js
Source/WebCore/inspector/front-end/SettingsScreen.js
Source/WebCore/inspector/front-end/inspector.js
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/InspectorClientImpl.cpp
Source/WebKit/chromium/src/InspectorClientImpl.h
Source/WebKit/chromium/src/js/DevTools.js

index 829a389..3920025 100644 (file)
@@ -1,3 +1,12 @@
+2011-12-01  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: query backend for capabilities explicitly.
+        https://bugs.webkit.org/show_bug.cgi?id=73442
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/profiler/detailed-heapshots-test.js:
+
 2011-12-01  Hayato Ito  <hayato@chromium.org>
 
         Unreviewed. Update chromium test expectations, marking flaky.
index e9ca805..be63e87 100644 (file)
@@ -13,12 +13,7 @@ InspectorTest.startProfilerTest = function(callback)
         InspectorTest._panelReset = InspectorTest.override(WebInspector.panels.profiles, "_reset", function(){}, true);
         InspectorTest.addSniffer(WebInspector.DetailedHeapshotView.prototype, "_updatePercentButton", InspectorTest._snapshotViewShown, true);
 
-        if (Capabilities.detailedHeapProfiles)
-            detailedHeapProfilesEnabled();
-        else {
-            InspectorTest.addSniffer(WebInspector.panels.profiles, "_populateProfiles", detailedHeapProfilesEnabled);
-            WebInspector.panels.profiles._enableDetailedHeapProfiles(true);
-        }
+        detailedHeapProfilesEnabled();
     }
 
     function detailedHeapProfilesEnabled()
index 3f8adf0..3005bba 100644 (file)
@@ -1,3 +1,78 @@
+2011-12-01  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: query backend for capabilities explicitly.
+        https://bugs.webkit.org/show_bug.cgi?id=73442
+
+        Reviewed by Yury Semikhatsky.
+
+        This change removes the hardcoded Capabilities values in favor of
+        explicit query commands issued against the backend. I'll remove the
+        Meta agent in a subsequent change.
+
+        * bindings/js/ScriptDebugServer.h:
+        (WebCore::ScriptDebugServer::causesRecompilation):
+        (WebCore::ScriptDebugServer::supportsNativeBreakpoints):
+        * bindings/js/ScriptProfiler.h:
+        (WebCore::ScriptProfiler::causesRecompilation):
+        (WebCore::ScriptProfiler::isSampling):
+        (WebCore::ScriptProfiler::hasHeapProfiler):
+        * bindings/v8/ScriptDebugServer.h:
+        (WebCore::ScriptDebugServer::causesRecompilation):
+        (WebCore::ScriptDebugServer::supportsNativeBreakpoints):
+        * bindings/v8/ScriptProfiler.h:
+        (WebCore::ScriptProfiler::causesRecompilation):
+        (WebCore::ScriptProfiler::isSampling):
+        (WebCore::ScriptProfiler::hasHeapProfiler):
+        * inspector/Inspector.json:
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::canClearBrowserCache):
+        (WebCore::InspectorClient::canClearBrowserCookies):
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::connectFrontend):
+        (WebCore::InspectorController::show):
+        * inspector/InspectorController.h:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::causesRecompilation):
+        (WebCore::InspectorDebuggerAgent::canSetScriptSource):
+        (WebCore::InspectorDebuggerAgent::supportsNativeBreakpoints):
+        * inspector/InspectorDebuggerAgent.h:
+        * inspector/InspectorFrontendClientLocal.cpp:
+        (WebCore::InspectorFrontendClientLocal::frontendLoaded):
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::causesRecompilation):
+        (WebCore::InspectorProfilerAgent::isSampling):
+        (WebCore::InspectorProfilerAgent::hasHeapProfiler):
+        (WebCore::InspectorProfilerAgent::disable):
+        (WebCore::InspectorProfilerAgent::enable):
+        (WebCore::InspectorProfilerAgent::setFrontend):
+        * inspector/InspectorProfilerAgent.h:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::canClearBrowserCache):
+        (WebCore::InspectorResourceAgent::canClearBrowserCookies):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/front-end/DebuggerModel.js:
+        (WebInspector.DebuggerModel):
+        (WebInspector.DebuggerModel.prototype.enableDebugger):
+        (WebInspector.DebuggerModel.prototype.canSetScriptSource):
+        * inspector/front-end/NetworkItemView.js:
+        (WebInspector.NetworkItemView):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView.onCanClearBrowserCache):
+        (WebInspector.NetworkLogView.onCanClearBrowserCookies):
+        (WebInspector.NetworkLogView):
+        (WebInspector.NetworkLogView.prototype._contextMenu):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype._reportHeapSnapshotProgress):
+        * inspector/front-end/ScriptsPanel.js:
+        * inspector/front-end/Settings.js:
+        * inspector/front-end/SettingsScreen.js:
+        (WebInspector.SettingsScreen):
+        * inspector/front-end/inspector.js:
+        (WebInspector.get inspectedPageDomain):
+        (WebInspector._initializeCapability):
+        (WebInspector.doLoadedDone):
+
 2011-11-28  Hans Wennborg  <hans@chromium.org>
 
         IndexedDB: Fix reverse cursor with non-existent upper bound
index 7f8cb05..2494c20 100644 (file)
@@ -84,6 +84,9 @@ public:
     bool canSetScriptSource();
     bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, ScriptValue* newCallFrames, ScriptObject* result);
 
+    bool causesRecompilation() { return true; }
+    bool supportsNativeBreakpoints() { return false; }
+
     void recompileAllJSFunctionsSoon();
     virtual void recompileAllJSFunctions(Timer<ScriptDebugServer>* = 0) = 0;
 
index ef68aaf..8bb05c4 100644 (file)
@@ -55,6 +55,9 @@ public:
     static void start(ScriptState* state, const String& title);
     static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
     static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String&, HeapSnapshotProgress*) { return 0; }
+    static bool causesRecompilation() { return true; }
+    static bool isSampling() { return false; }
+    static bool hasHeapProfiler() { return false; }
 };
 
 } // namespace WebCore
index c3920ec..cac050d 100644 (file)
@@ -78,6 +78,9 @@ public:
     bool canSetScriptSource();
     bool setScriptSource(const String& sourceID, const String& newContent, bool preview, String* error, ScriptValue* newCallFrames, ScriptObject* result);
 
+    bool causesRecompilation() { return false; }
+    bool supportsNativeBreakpoints() { return true; }
+
     void recompileAllJSFunctionsSoon() { }
     void recompileAllJSFunctions(Timer<ScriptDebugServer>* = 0) { }
 
index 114aae0..7106d7c 100644 (file)
@@ -59,6 +59,9 @@ public:
     static void start(ScriptState* state, const String& title);
     static PassRefPtr<ScriptProfile> stop(ScriptState* state, const String& title);
     static PassRefPtr<ScriptHeapSnapshot> takeHeapSnapshot(const String& title, HeapSnapshotProgress*);
+    static bool causesRecompilation() { return false; }
+    static bool isSampling() { return true; }
+    static bool hasHeapProfiler() { return true; }
     static void initialize();
 };
 
index 5ab9108..318a5a0 100644 (file)
                 ]
             },
             {
+                "name": "canClearBrowserCache",
+                "description": "Tells whether clearing browser cache is supported.",
+                "returns": [
+                    { "name": "result", "type": "boolean", "description": "True if browser cache can be cleared." }
+                ]
+            },
+            {
                 "name": "clearBrowserCache",
                 "description": "Clears browser cache."
             },
             {
+                "name": "canClearBrowserCookies",
+                "description": "Tells whether clearing browser cookies is supported.",
+                "returns": [
+                    { "name": "result", "type": "boolean", "description": "True if browser cookies can be cleared." }
+                ]
+            },
+            {
                 "name": "clearBrowserCookies",
                 "description": "Clears browser cookies."
             },
         ],
         "commands": [
             {
+                "name": "causesRecompilation",
+                "returns": [
+                    { "name": "result", "type": "boolean", "description": "True if enabling debugger causes scripts recompilation." }
+                ],
+                "hidden": true,
+                "description": "Tells whether enabling debugger causes scripts recompilation."
+            },
+            {
+                "name": "supportsNativeBreakpoints",
+                "returns": [
+                    { "name": "result", "type": "boolean", "description": "True if debugger supports native breakpoints." }
+                ],
+                "hidden": true,
+                "description": "Tells whether debugger supports native breakpoints."
+            },
+            {
                 "name": "enable",
                 "description": "Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received."
             },
                 "description": "Searches for given string in script content."
             },
             {
+                "name": "canSetScriptSource",
+                "returns": [
+                    { "name": "result", "type": "boolean", "description": "True if <code>setScriptSource</code> is supported." }
+                ],
+                "description": "Tells whether <code>setScriptSource</code> is supported."
+            },
+            {
                 "name": "setScriptSource",
                 "parameters": [
                     { "name": "scriptId", "$ref": "ScriptId", "description": "Id of the script to edit." },
         ],
         "commands": [
             {
-                "name": "enable"
+                "name": "causesRecompilation",
+                "returns": [
+                    { "name": "result", "type": "boolean" }
+                ]
             },
             {
-                "name": "disable"
+                "name": "isSampling",
+                "returns": [
+                    { "name": "result", "type": "boolean" }
+                ]
             },
             {
-                "name": "isEnabled",
+                "name": "hasHeapProfiler",
                 "returns": [
-                    { "name": "state", "type": "boolean" }
+                    { "name": "result", "type": "boolean" }
                 ]
             },
             {
+                "name": "enable"
+            },
+            {
+                "name": "disable"
+            },
+            {
                 "name": "start"
             },
             {
         ],
         "events": [
             {
-                "name": "profilerWasEnabled"
-            },
-            {
-                "name": "profilerWasDisabled"
-            },
-            {
                 "name": "addProfileHeader",
                 "parameters": [
                     { "name": "header", "$ref": "ProfileHeader" }
index 83ab232..53b55c5 100644 (file)
@@ -50,7 +50,9 @@ public:
     virtual void highlight() = 0;
     virtual void hideHighlight() = 0;
 
+    virtual bool canClearBrowserCache() { return false; }
     virtual void clearBrowserCache() { }
+    virtual bool canClearBrowserCookies() { return false; }
     virtual void clearBrowserCookies() { }
 
     bool doDispatchMessageOnFrontendPage(Page* frontendPage, const String& message);
index f3a0d87..d6913fe 100644 (file)
@@ -77,7 +77,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     , m_state(adoptPtr(new InspectorState(inspectorClient)))
     , m_page(page)
     , m_inspectorClient(inspectorClient)
-    , m_openingFrontend(false)
 {
     OwnPtr<InspectorAgent> inspectorAgentPtr(InspectorAgent::create(page, m_injectedScriptManager.get(), m_instrumentingAgents.get(), m_state.get()));
     m_inspectorAgent = inspectorAgentPtr.get();
@@ -190,7 +189,6 @@ void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWo
 
 void InspectorController::connectFrontend()
 {
-    m_openingFrontend = false;
     m_inspectorFrontend = adoptPtr(new InspectorFrontend(m_inspectorClient));
     // We can reconnect to existing front-end -> unmute state.
     m_state->unmute();
@@ -237,14 +235,11 @@ void InspectorController::show()
     if (!enabled())
         return;
 
-    if (m_openingFrontend)
-        return;
-
     if (m_inspectorFrontend)
         m_inspectorClient->bringFrontendToFront();
     else {
-        m_openingFrontend = true;
         m_inspectorClient->openInspectorFrontend(this);
+        connectFrontend();
     }
 }
 
index cd61486..049e260 100644 (file)
@@ -124,7 +124,6 @@ private:
     OwnPtr<InspectorFrontend> m_inspectorFrontend;
     Page* m_page;
     InspectorClient* m_inspectorClient;
-    bool m_openingFrontend;
     typedef Vector<OwnPtr<InspectorBaseAgentInterface> > Agents;
     Agents m_agents;
 };
index ff6ac82..2221ec2 100644 (file)
@@ -99,10 +99,19 @@ bool InspectorDebuggerAgent::enabled()
     return m_state->getBoolean(DebuggerAgentState::debuggerEnabled);
 }
 
-void InspectorDebuggerAgent::getAgentCapabilities(InspectorArray* capabilities)
+void InspectorDebuggerAgent::causesRecompilation(ErrorString*, bool* result)
 {
-    if (scriptDebugServer().canSetScriptSource())
-        capabilities->pushString(InspectorFrontend::Debugger::capabilitySetScriptSource);
+    *result = scriptDebugServer().causesRecompilation();
+}
+
+void InspectorDebuggerAgent::canSetScriptSource(ErrorString*, bool* result)
+{
+    *result = scriptDebugServer().canSetScriptSource();
+}
+
+void InspectorDebuggerAgent::supportsNativeBreakpoints(ErrorString*, bool* result)
+{
+    *result = scriptDebugServer().supportsNativeBreakpoints();
 }
 
 void InspectorDebuggerAgent::enable(ErrorString*)
index 43da21a..ba242dc 100644 (file)
@@ -65,13 +65,16 @@ public:
 
     virtual ~InspectorDebuggerAgent();
 
+    void causesRecompilation(ErrorString*, bool*);
+    void canSetScriptSource(ErrorString*, bool*);
+    void supportsNativeBreakpoints(ErrorString*, bool*);
+
     void enable(ErrorString*);
     void disable(ErrorString*);
 
     virtual void setFrontend(InspectorFrontend*);
     virtual void clearFrontend();
     virtual void restore();
-    virtual void getAgentCapabilities(InspectorArray*);
 
     void didClearMainFrameWindowObject();
 
index e7ce55f..b7661f1 100644 (file)
@@ -115,13 +115,15 @@ InspectorFrontendClientLocal::~InspectorFrontendClientLocal()
 {
     if (m_frontendHost)
         m_frontendHost->disconnectClient();
-    m_frontendScriptState = 0;
     m_frontendPage = 0;
+    m_frontendScriptState = 0;
     m_inspectorController = 0;
 }
 
 void InspectorFrontendClientLocal::windowObjectCleared()
 {
+    if (m_frontendHost)
+        m_frontendHost->disconnectClient();
     // FIXME: don't keep reference to the script state
     m_frontendScriptState = scriptStateFromPage(debuggerWorld(), m_frontendPage);
     m_frontendHost = InspectorFrontendHost::create(this, m_frontendPage);
@@ -131,7 +133,6 @@ void InspectorFrontendClientLocal::windowObjectCleared()
 void InspectorFrontendClientLocal::frontendLoaded()
 {
     bringToFront();
-    m_inspectorController->connectFrontend();
     m_frontendLoaded = true;
     if (!m_evaluateOnLoad.isEmpty())
         evaluateOnLoad(m_evaluateOnLoad);
index 0ce2db5..950f18c 100644 (file)
@@ -201,12 +201,12 @@ void InspectorFrontendHost::setExtensionAPI(const String& script)
 
 String InspectorFrontendHost::localizedStringsURL()
 {
-    return m_client->localizedStringsURL();
+    return m_client ? m_client->localizedStringsURL() : "";
 }
 
 String InspectorFrontendHost::hiddenPanels()
 {
-    return m_client->hiddenPanels();
+    return m_client ? m_client->hiddenPanels() : "";
 }
 
 void InspectorFrontendHost::copyText(const String& text)
index ed34172..2228223 100644 (file)
@@ -137,6 +137,22 @@ PassRefPtr<InspectorObject> InspectorProfilerAgent::createSnapshotHeader(const S
     return header;
 }
 
+
+void InspectorProfilerAgent::causesRecompilation(ErrorString*, bool* result)
+{
+    *result = ScriptProfiler::causesRecompilation();
+}
+
+void InspectorProfilerAgent::isSampling(ErrorString*, bool* result)
+{
+    *result = ScriptProfiler::isSampling();
+}
+
+void InspectorProfilerAgent::hasHeapProfiler(ErrorString*, bool* result)
+{
+    *result = ScriptProfiler::hasHeapProfiler();
+}
+
 void InspectorProfilerAgent::enable(ErrorString*)
 {
     if (enabled())
@@ -157,8 +173,6 @@ void InspectorProfilerAgent::disable()
         return;
     m_enabled = false;
     PageScriptDebugServer::shared().recompileAllJSFunctionsSoon();
-    if (m_frontend)
-        m_frontend->profilerWasDisabled();
 }
 
 void InspectorProfilerAgent::enable(bool skipRecompile)
@@ -168,8 +182,6 @@ void InspectorProfilerAgent::enable(bool skipRecompile)
     m_enabled = true;
     if (!skipRecompile)
         PageScriptDebugServer::shared().recompileAllJSFunctionsSoon();
-    if (m_frontend)
-        m_frontend->profilerWasEnabled();
 }
 
 String InspectorProfilerAgent::getCurrentUserInitiatedProfileName(bool incrementProfileNumber)
@@ -261,7 +273,6 @@ void InspectorProfilerAgent::resetFrontendProfiles()
 void InspectorProfilerAgent::setFrontend(InspectorFrontend* frontend)
 {
     m_frontend = frontend->profiler();
-    restoreEnablement();
 }
 
 void InspectorProfilerAgent::clearFrontend()
index 14064c6..d473390 100644 (file)
@@ -68,9 +68,12 @@ public:
     void clearProfiles(ErrorString*) { resetState(); }
     void resetState();
 
+    void causesRecompilation(ErrorString*, bool*);
+    void isSampling(ErrorString*, bool*);
+    void hasHeapProfiler(ErrorString*, bool*);
+
     void enable(ErrorString*);
     void disable(ErrorString*);
-    void isEnabled(ErrorString*, bool* result) { *result = enabled(); }
     void start(ErrorString* = 0);
     void stop(ErrorString* = 0);
 
index df84519..03547f0 100644 (file)
@@ -506,11 +506,21 @@ void InspectorResourceAgent::getResponseBody(ErrorString* errorString, const Str
     *errorString = "No data found for resource with given identifier";
 }
 
+void InspectorResourceAgent::canClearBrowserCache(ErrorString*, bool* result)
+{
+    *result = m_client->canClearBrowserCache();
+}
+
 void InspectorResourceAgent::clearBrowserCache(ErrorString*)
 {
     m_client->clearBrowserCache();
 }
 
+void InspectorResourceAgent::canClearBrowserCookies(ErrorString*, bool* result)
+{
+    *result = m_client->canClearBrowserCookies();
+}
+
 void InspectorResourceAgent::clearBrowserCookies(ErrorString*)
 {
     m_client->clearBrowserCookies();
index 2828967..8f6f75b 100644 (file)
@@ -130,7 +130,9 @@ public:
     void getResponseBody(ErrorString*, const String& requestId, String* content, bool* base64Encoded);
     void clearCache(ErrorString*, const String* const optionalPreservedLoaderId);
 
+    void canClearBrowserCache(ErrorString*, bool*);
     void clearBrowserCache(ErrorString*);
+    void canClearBrowserCookies(ErrorString*, bool*);
     void clearBrowserCookies(ErrorString*);
     void setCacheDisabled(ErrorString*, bool cacheDisabled);
 
index 075968c..a0d00c4 100644 (file)
@@ -40,7 +40,7 @@ WebInspector.DebuggerModel = function()
      */
     this._scripts = {};
 
-    this._capabilitiesObject = {};
+    this._canSetScriptSource = false;
 
     InspectorBackend.registerDebuggerDispatcher(new WebInspector.DebuggerDispatcher(this));
 }
@@ -87,22 +87,11 @@ WebInspector.DebuggerModel.BreakReason = {
 WebInspector.DebuggerModel.prototype = {
     enableDebugger: function()
     {
-        /**
-         * @param {Protocol.Error} error
-         * @param {Array.<MetaAgent.DomainCapabilities>} capabilities
-         */
-        function callback(error, capabilities)
+        function callback(error, result)
         {
-            for (var i = 0; i < capabilities.length; ++i) {
-                if (capabilities[i].domainName !== "Debugger")
-                    continue;
-
-                var capabilitiesList = capabilities[i].capabilities;
-                for (var j = 0; j < capabilitiesList.length; ++j)
-                    this._capabilitiesObject[capabilitiesList[j]] = true;
-            }
+            this._canSetScriptSource = result;
         }
-        MetaAgent.getCapabilities(["Debugger"], callback.bind(this));
+        DebuggerAgent.canSetScriptSource(callback.bind(this));
         DebuggerAgent.enable(this._debuggerWasEnabled.bind(this));
     },
 
@@ -116,7 +105,7 @@ WebInspector.DebuggerModel.prototype = {
      */
     canSetScriptSource: function()
     {
-        return !!this._capabilitiesObject[DebuggerAgent.capabilitySetScriptSource];
+        return this._canSetScriptSource;
     },
 
     _debuggerWasEnabled: function()
index 20a78d9..14d193f 100644 (file)
@@ -47,12 +47,12 @@ WebInspector.NetworkItemView = function(resource)
     this.appendTab("preview", WebInspector.UIString("Preview"), previewView);
     this.appendTab("response", WebInspector.UIString("Response"), responseView);
 
-    if (Capabilities.showCookiesTab) {
+    if (resource.requestCookies || resource.responseCookies) {
         this._cookiesView = new WebInspector.ResourceCookiesView(resource);
         this.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView);
     }
 
-    if (Capabilities.showTimingTab) {
+    if (resource.timing) {
         var timingView = new WebInspector.ResourceTimingView(resource);
         this.appendTab("timing", WebInspector.UIString("Timing"), timingView);
     }
index 5aef6c2..4cda71a 100644 (file)
@@ -66,6 +66,17 @@ WebInspector.NetworkLogView = function()
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.DOMContentLoaded, this._domContentLoadedEventFired, this);
 
     this._initializeView();
+    function onCanClearBrowserCache(error, result)
+    {
+        this._canClearBrowserCache = result;
+    }
+    NetworkAgent.canClearBrowserCache(onCanClearBrowserCache.bind(this));
+
+    function onCanClearBrowserCookies(error, result)
+    {
+        this._canClearBrowserCookies = result;
+    }
+    NetworkAgent.canClearBrowserCache(onCanClearBrowserCookies.bind(this));
 }
 
 WebInspector.NetworkLogView.prototype = {
@@ -940,11 +951,12 @@ WebInspector.NetworkLogView.prototype = {
             contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Save all as HAR" : "Save All as HAR"), this._exportAll.bind(this));
         }
 
-        if (Capabilities.canClearCacheAndCookies) {
+        if (this._canClearBrowserCache || this._canClearBrowserCookies)
             contextMenu.appendSeparator();
+        if (this._canClearBrowserCache)
             contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear browser cache" : "Clear Browser Cache"), this._clearBrowserCache.bind(this));
+        if (this._canClearBrowserCookies)
             contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear browser cookies" : "Clear Browser Cookies"), this._clearBrowserCookies.bind(this));
-        }
 
         contextMenu.show(event);
     },
index 1bd2c10..8d8a97a 100644 (file)
@@ -119,7 +119,7 @@ WebInspector.ProfilesPanel = function()
 
     this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item");
     this.enableToggleButton.addEventListener("click", this._toggleProfiling.bind(this), false);
-    if (Capabilities.profilerAlwaysEnabled)
+    if (!Capabilities.profilerCausesRecompilation)
         this.enableToggleButton.element.addStyleClass("hidden");
 
     this.clearResultsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Clear all profiles."), "clear-status-bar-item");
@@ -131,7 +131,7 @@ WebInspector.ProfilesPanel = function()
     this.welcomeView = new WebInspector.WelcomeView("profiles", WebInspector.UIString("Welcome to the Profiles panel"));
 
     this._profiles = [];
-    this._profilerEnabled = Capabilities.profilerAlwaysEnabled;
+    this._profilerEnabled = !Capabilities.profilerCausesRecompilation;
     this._reset();
 
     this._registerProfileType(new WebInspector.CPUProfileType());
@@ -140,15 +140,8 @@ WebInspector.ProfilesPanel = function()
 
     InspectorBackend.registerProfilerDispatcher(new WebInspector.ProfilerDispatcher(this));
 
-    if (Capabilities.profilerAlwaysEnabled || WebInspector.settings.profilerEnabled.get())
-        ProfilerAgent.enable();
-    else {
-        function onProfilerEnebled(error, value) {
-            if (value)
-                this._profilerWasEnabled();
-        }
-        ProfilerAgent.isEnabled(onProfilerEnebled.bind(this));
-    }
+    if (!Capabilities.profilerCausesRecompilation || WebInspector.settings.profilerEnabled.get())
+        ProfilerAgent.enable(this._profilerWasEnabled.bind(this));
 }
 
 WebInspector.ProfilesPanel.prototype = {
@@ -797,10 +790,10 @@ WebInspector.ProfilesPanel.prototype = {
     {
         if (this._profilerEnabled) {
             WebInspector.settings.profilerEnabled.set(false);
-            ProfilerAgent.disable();
+            ProfilerAgent.disable(this._profilerWasDisabled.bind(this));
         } else {
             WebInspector.settings.profilerEnabled.set(!!optionalAlways);
-            ProfilerAgent.enable();
+            ProfilerAgent.enable(this._profilerWasEnabled.bind(this));
         }
     },
 
@@ -877,21 +870,6 @@ WebInspector.ProfilesPanel.prototype = {
             if (done >= total)
                 this._removeProfileHeader(this._temporaryTakingSnapshot);
         }
-    },
-
-    _enableDetailedHeapProfiles: function(resetAgent)
-    {
-        if (resetAgent)
-            this._clearProfiles();
-        else
-            this._reset();
-        var oldProfileType = this._profileTypesByIdMap[WebInspector.DetailedHeapshotProfileType.TypeId];
-        var profileType = new WebInspector.DetailedHeapshotProfileType();
-        profileType.treeElement = oldProfileType.treeElement;
-        this._profileTypesByIdMap[profileType.id] = profileType;
-        Capabilities.detailedHeapProfiles = true;
-        this.detach();
-        this.show();
     }
 }
 
@@ -904,16 +882,6 @@ WebInspector.ProfilerDispatcher = function(profiler)
 }
 
 WebInspector.ProfilerDispatcher.prototype = {
-    profilerWasEnabled: function()
-    {
-        this._profiler._profilerWasEnabled();
-    },
-
-    profilerWasDisabled: function()
-    {
-        this._profiler._profilerWasDisabled();
-    },
-
     resetProfiles: function()
     {
         this._profiler._reset();
index 2f13a61..66aca99 100644 (file)
@@ -74,7 +74,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
         this.sidebarPanes.eventListenerBreakpoints = new WebInspector.EventListenerBreakpointsSidebarPane();
     }
 
-    if (Capabilities.canInspectWorkers && !WebInspector.WorkerManager.isWorkerFrontend()) {
+    if (Preferences.exposeWorkersInspection && !WebInspector.WorkerManager.isWorkerFrontend()) {
         WorkerAgent.setWorkerInspectionEnabled(true);
         this.sidebarPanes.workerList = new WebInspector.WorkerListSidebarPane(WebInspector.workerManager);
     } else
@@ -103,7 +103,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
 
     this.enableToggleButton = new WebInspector.StatusBarButton("", "enable-toggle-status-bar-item");
     this.enableToggleButton.addEventListener("click", this.toggleDebugging, this);
-    if (Capabilities.debuggerAlwaysEnabled)
+    if (!Capabilities.debuggerCausesRecompilation)
         this.enableToggleButton.element.addStyleClass("hidden");
 
     this._pauseOnExceptionButton = new WebInspector.StatusBarButton("", "scripts-pause-on-exceptions-status-bar-item", 3);
@@ -116,7 +116,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
     this._scriptViewStatusBarItemsContainer = document.createElement("div");
     this._scriptViewStatusBarItemsContainer.style.display = "inline-block";
 
-    this._debuggerEnabled = Capabilities.debuggerAlwaysEnabled;
+    this._debuggerEnabled = !Capabilities.debuggerCausesRecompilation;
 
     this._reset(false);
 
@@ -137,7 +137,7 @@ WebInspector.ScriptsPanel = function(presentationModel)
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ExecutionLineChanged, this._executionLineChanged, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerReset, this._reset.bind(this, false));
     
-    var enableDebugger = Capabilities.debuggerAlwaysEnabled || WebInspector.settings.debuggerEnabled.get();
+    var enableDebugger = !Capabilities.debuggerCausesRecompilation || WebInspector.settings.debuggerEnabled.get();
     if (enableDebugger)
         WebInspector.debuggerModel.enableDebugger();
 
index 63c853f..9d3a9a4 100644 (file)
@@ -43,21 +43,17 @@ var Preferences = {
     hasExtensions: false,
     sharedWorkersDebugNote: undefined,
     localizeUI: true,
+    exposeDisableCache: false,
+    exposeWorkersInspection: false,
     applicationTitle: "Web Inspector - %s"
 }
 
 var Capabilities = {
     samplingCPUProfiler: false,
-    debuggerAlwaysEnabled: false,
-    profilerAlwaysEnabled: false,
+    debuggerCausesRecompilation: true,
+    profilerCausesRecompilation: true,
     nativeInstrumentationEnabled: false,
-    showTimingTab: false,
-    showCookiesTab: false,
-    heapProfilerPresent: false,
-    detailedHeapProfiles: false,
-    canInspectWorkers: false,
-    canClearCacheAndCookies: false,
-    canDisableCache: false
+    heapProfilerPresent: false
 }
 
 /**
index 9221f5f..500cbf5 100644 (file)
@@ -59,7 +59,7 @@ WebInspector.SettingsScreen = function()
         ], WebInspector.settings.textEditorIndent));
 
     p = this._appendSection(WebInspector.UIString("Network"), true);
-    if (Capabilities.canDisableCache)
+    if (Preferences.exposeDisableCache)
         p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Disable cache"), WebInspector.settings.cacheDisabled));
     p.appendChild(this._createUserActionControl());
 
index 9bc5a11..f8613f9 100644 (file)
@@ -278,6 +278,13 @@ var WebInspector = {
     {
         var parsedURL = WebInspector.inspectedPageURL && WebInspector.inspectedPageURL.asParsedURL();
         return parsedURL ? parsedURL.host : "";
+    },
+
+    _initializeCapability: function(name, callback, error, result)
+    {
+        Capabilities[name] = result;
+        if (callback)
+            callback();
     }
 }
 
@@ -317,18 +324,26 @@ WebInspector.loaded = function()
 
 WebInspector.doLoadedDone = function()
 {
-    InspectorFrontendHost.loaded();
-
-    WebInspector.WorkerManager.loaded();
-
+    // Install styles and themes
     WebInspector.installPortStyles();
-
     if (WebInspector.socket)
         document.body.addStyleClass("remote");
 
     if (WebInspector.queryParamsObject.toolbarColor && WebInspector.queryParamsObject.textColor)
         WebInspector.setToolbarColors(WebInspector.queryParamsObject.toolbarColor, WebInspector.queryParamsObject.textColor);
 
+    InspectorFrontendHost.loaded();
+    WebInspector.WorkerManager.loaded();
+
+    DebuggerAgent.causesRecompilation(WebInspector._initializeCapability.bind(WebInspector, "debuggerCausesRecompilation", null));
+    DebuggerAgent.supportsNativeBreakpoints(WebInspector._initializeCapability.bind(WebInspector, "nativeInstrumentationEnabled", null));
+    ProfilerAgent.causesRecompilation(WebInspector._initializeCapability.bind(WebInspector, "profilerCausesRecompilation", null));
+    ProfilerAgent.isSampling(WebInspector._initializeCapability.bind(WebInspector, "samplingCPUProfiler", null));
+    ProfilerAgent.hasHeapProfiler(WebInspector._initializeCapability.bind(WebInspector, "heapProfilerPresent", WebInspector._doLoadedDoneWithCapabilities.bind(WebInspector)));
+}
+
+WebInspector._doLoadedDoneWithCapabilities = function()
+{
     WebInspector.shortcutsScreen = new WebInspector.ShortcutsScreen();
     this._registerShortcuts();
 
index 1a3cc3d..9f41825 100644 (file)
@@ -1,3 +1,16 @@
+2011-12-01  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: query backend for capabilities explicitly.
+        https://bugs.webkit.org/show_bug.cgi?id=73442
+
+        Reviewed by Yury Semikhatsky.
+
+        * src/InspectorClientImpl.cpp:
+        (WebKit::InspectorClientImpl::canClearBrowserCache):
+        (WebKit::InspectorClientImpl::canClearBrowserCookies):
+        * src/InspectorClientImpl.h:
+        * src/js/DevTools.js:
+
 2011-11-29  Hans Wennborg  <hans@chromium.org>
 
         IndexedDB: Cursor pre-fetching
index 9f5aad1..cce33fe 100644 (file)
@@ -106,12 +106,22 @@ void InspectorClientImpl::updateInspectorStateCookie(const WTF::String& inspecto
         agent->updateInspectorStateCookie(inspectorState);
 }
 
+bool InspectorClientImpl::canClearBrowserCache()
+{
+    return true;
+}
+
 void InspectorClientImpl::clearBrowserCache()
 {
     if (WebDevToolsAgentImpl* agent = devToolsAgent())
         agent->clearBrowserCache();
 }
 
+bool InspectorClientImpl::canClearBrowserCookies()
+{
+    return true;
+}
+
 void InspectorClientImpl::clearBrowserCookies()
 {
     if (WebDevToolsAgentImpl* agent = devToolsAgent())
index 0e900b5..b16b6f4 100644 (file)
@@ -59,7 +59,9 @@ public:
 
     virtual void updateInspectorStateCookie(const WTF::String&);
 
+    virtual bool canClearBrowserCache();
     virtual void clearBrowserCache();
+    virtual bool canClearBrowserCookies();
     virtual void clearBrowserCookies();
 private:
     WebDevToolsAgentImpl* devToolsAgent();
index 455177b..f001c48 100644 (file)
     Preferences.sharedWorkersDebugNote = "Shared workers can be inspected in the Task Manager";
     Preferences.localizeUI = false;
     Preferences.applicationTitle = "Developer Tools - %s";
-
-    Capabilities.samplingCPUProfiler = true;
-    Capabilities.heapProfilerPresent = true;
-    Capabilities.detailedHeapProfiles = true;
-    Capabilities.debuggerAlwaysEnabled = true;
-    Capabilities.profilerAlwaysEnabled = true;
-    Capabilities.nativeInstrumentationEnabled = true;
-    Capabilities.showTimingTab = true;
-    Capabilities.showCookiesTab = true;
-    Capabilities.canInspectWorkers = true;
-    Capabilities.canClearCacheAndCookies = true;
-    Capabilities.canDisableCache = true;
+    Preferences.exposeDisableCache = true;
+    Preferences.exposeWorkersInspection = true;
 })();}
 
 /** Pending WebKit upstream by apavlov). Fixes iframe vs drag problem. */