diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-11 12:28:35 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-11 12:28:35 +0000 |
commit | 7153d83d9dd74251ee98d6d4d0794b84a374f990 (patch) | |
tree | 8708297f9240b7aeef6977055016387e0b7e1de7 /chrome | |
parent | adb98d94912f8a499821734ce190936a557bc2b5 (diff) | |
download | chromium_src-7153d83d9dd74251ee98d6d4d0794b84a374f990.zip chromium_src-7153d83d9dd74251ee98d6d4d0794b84a374f990.tar.gz chromium_src-7153d83d9dd74251ee98d6d4d0794b84a374f990.tar.bz2 |
DevTools: migrate APU from dedicated commands to the inspector protocol.
BUG=
TEST=
Review URL: http://codereview.chromium.org/6119005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_devtools_bridge.cc | 67 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_devtools_bridge.h | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_devtools_browsertests.cc | 2 | ||||
-rw-r--r-- | chrome/common/devtools_messages_internal.h | 8 | ||||
-rw-r--r-- | chrome/renderer/devtools_agent.cc | 16 | ||||
-rw-r--r-- | chrome/renderer/devtools_agent.h | 2 |
6 files changed, 65 insertions, 32 deletions
diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc index 8394ad0..71422ca 100644 --- a/chrome/browser/extensions/extension_devtools_bridge.cc +++ b/chrome/browser/extensions/extension_devtools_bridge.cc @@ -4,9 +4,11 @@ #include "chrome/browser/extensions/extension_devtools_bridge.h" +#include "base/json/json_writer.h" #include "base/message_loop.h" #include "base/string_util.h" #include "base/stringprintf.h" +#include "base/values.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/extensions/extension_devtools_events.h" #include "chrome/browser/extensions/extension_devtools_manager.h" @@ -32,6 +34,22 @@ ExtensionDevToolsBridge::ExtensionDevToolsBridge(int tab_id, ExtensionDevToolsBridge::~ExtensionDevToolsBridge() { } +static std::string FormatDevToolsMessage(int seq, + const std::string& domain, + const std::string& command, + DictionaryValue* arguments) { + + DictionaryValue message; + message.SetInteger("seq", seq); + message.SetString("domain", domain); + message.SetString("command", command); + message.Set("arguments", arguments); + + std::string json; + base::JSONWriter::Write(&message, false, &json); + return json; +} + bool ExtensionDevToolsBridge::RegisterAsDevToolsClientHost() { DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); @@ -43,11 +61,51 @@ bool ExtensionDevToolsBridge::RegisterAsDevToolsClientHost() { &browser, &tab_strip, &contents, &tab_index)) { DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); + if (devtools_manager->GetDevToolsClientHostFor(contents-> + render_view_host()) != NULL) + return false; + devtools_manager->RegisterDevToolsClientHostFor( contents->render_view_host(), this); + + // Following messages depend on inspector protocol that is not yet + // finalized. + + // 1. Set injected script content. + DictionaryValue* arguments = new DictionaryValue(); + arguments->SetString("scriptSource", "'{}'"); devtools_manager->ForwardToDevToolsAgent( this, - DevToolsAgentMsg_SetApuAgentEnabled(true)); + DevToolsAgentMsg_DispatchOnInspectorBackend( + FormatDevToolsMessage(0, + "Inspector", + "setInjectedScriptSource", + arguments))); + + // 2. Report front-end is loaded. + devtools_manager->ForwardToDevToolsAgent( + this, + DevToolsAgentMsg_FrontendLoaded()); + + // 3. Do not break on exceptions. + arguments = new DictionaryValue(); + arguments->SetInteger("pauseOnExceptionsState", 0); + devtools_manager->ForwardToDevToolsAgent( + this, + DevToolsAgentMsg_DispatchOnInspectorBackend( + FormatDevToolsMessage(1, + "Debugger", + "setPauseOnExceptionsState", + arguments))); + + // 4. Start timeline profiler. + devtools_manager->ForwardToDevToolsAgent( + this, + DevToolsAgentMsg_DispatchOnInspectorBackend( + FormatDevToolsMessage(2, + "Inspector", + "startTimelineProfiler", + new DictionaryValue()))); return true; } return false; @@ -76,16 +134,17 @@ void ExtensionDevToolsBridge::InspectedTabClosing() { void ExtensionDevToolsBridge::SendMessageToClient(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(ExtensionDevToolsBridge, msg) - IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchToAPU, OnDispatchToAPU); + IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend, + OnDispatchOnInspectorFrontend); IPC_MESSAGE_UNHANDLED_ERROR() IPC_END_MESSAGE_MAP() } -void ExtensionDevToolsBridge::OnDispatchToAPU(const std::string& data) { +void ExtensionDevToolsBridge::OnDispatchOnInspectorFrontend( + const std::string& data) { DCHECK_EQ(MessageLoop::current()->type(), MessageLoop::TYPE_UI); std::string json = base::StringPrintf("[%s]", data.c_str()); profile_->GetExtensionEventRouter()->DispatchEventToRenderers( on_page_event_name_, json, profile_, GURL()); } - diff --git a/chrome/browser/extensions/extension_devtools_bridge.h b/chrome/browser/extensions/extension_devtools_bridge.h index ad103a2..4a0a9da 100644 --- a/chrome/browser/extensions/extension_devtools_bridge.h +++ b/chrome/browser/extensions/extension_devtools_bridge.h @@ -32,7 +32,7 @@ class ExtensionDevToolsBridge : public DevToolsClientHost { virtual void SendMessageToClient(const IPC::Message& msg); private: - void OnDispatchToAPU(const std::string& data); + void OnDispatchOnInspectorFrontend(const std::string& data); // ID of the tab we are monitoring. int tab_id_; diff --git a/chrome/browser/extensions/extension_devtools_browsertests.cc b/chrome/browser/extensions/extension_devtools_browsertests.cc index c29a4ca..d9984be 100644 --- a/chrome/browser/extensions/extension_devtools_browsertests.cc +++ b/chrome/browser/extensions/extension_devtools_browsertests.cc @@ -82,7 +82,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionDevToolsBrowserTest, FLAKY_TimelineApi) { // Test onPageEvent event. result = false; - DevToolsClientMsg_DispatchToAPU pageEventMessage(""); + DevToolsClientMsg_DispatchOnInspectorFrontend pageEventMessage(""); devtools_client_host->SendMessageToClient(pageEventMessage); ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( host->render_view_host(), L"", L"testReceivePageEvent()", &result)); diff --git a/chrome/common/devtools_messages_internal.h b/chrome/common/devtools_messages_internal.h index 6019d60..a3ae7eb 100644 --- a/chrome/common/devtools_messages_internal.h +++ b/chrome/common/devtools_messages_internal.h @@ -52,11 +52,6 @@ IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DispatchOnInspectorFrontend, IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DebuggerOutput, std::string /* message */) -// Legacy APU dispatch message. -IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DispatchToAPU, - std::string /* message */) - - //----------------------------------------------------------------------------- // These are messages sent from DevToolsClient to DevToolsAgent through the // browser. @@ -85,6 +80,3 @@ IPC_MESSAGE_CONTROL1(DevToolsAgentMsg_DebuggerCommand, IPC_MESSAGE_CONTROL2(DevToolsAgentMsg_InspectElement, int /* x */, int /* y */) - -// Enables/disables the apu agent. -IPC_MESSAGE_CONTROL1(DevToolsAgentMsg_SetApuAgentEnabled, bool /* enabled */) diff --git a/chrome/renderer/devtools_agent.cc b/chrome/renderer/devtools_agent.cc index e1dbba6..ca1ef3a 100644 --- a/chrome/renderer/devtools_agent.cc +++ b/chrome/renderer/devtools_agent.cc @@ -83,8 +83,6 @@ bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend, OnDispatchOnInspectorBackend) IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) - IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled, - OnSetApuAgentEnabled) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -105,13 +103,6 @@ void DevToolsAgent::sendDebuggerOutput(const WebKit::WebString& data) { render_view_->Send(m); } -void DevToolsAgent::sendDispatchToAPU(const WebKit::WebString& data) { - IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( - routing_id_, - DevToolsClientMsg_DispatchToAPU(data.utf8())); - render_view_->Send(m); -} - int DevToolsAgent::hostIdentifier() { return routing_id_; } @@ -200,13 +191,6 @@ void DevToolsAgent::OnInspectElement(int x, int y) { } } -void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { - WebDevToolsAgent* web_agent = GetWebAgent(); - if (web_agent) - web_agent->setRuntimeProperty("apu-agent", enabled ? - WebString::fromUTF8("true") : WebString::fromUTF8("false")); -} - WebDevToolsAgent* DevToolsAgent::GetWebAgent() { WebView* web_view = render_view_->webview(); if (!web_view) diff --git a/chrome/renderer/devtools_agent.h b/chrome/renderer/devtools_agent.h index 14a7247..4b1b465 100644 --- a/chrome/renderer/devtools_agent.h +++ b/chrome/renderer/devtools_agent.h @@ -39,7 +39,6 @@ class DevToolsAgent : public WebKit::WebDevToolsAgentClient, // WebDevToolsAgentClient implementation virtual void sendMessageToInspectorFrontend(const WebKit::WebString& data); virtual void sendDebuggerOutput(const WebKit::WebString& data); - virtual void sendDispatchToAPU(const WebKit::WebString& data); virtual int hostIdentifier(); virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature, @@ -66,7 +65,6 @@ class DevToolsAgent : public WebKit::WebDevToolsAgentClient, void OnFrontendLoaded(); void OnDispatchOnInspectorBackend(const std::string& message); void OnInspectElement(int x, int y); - void OnSetApuAgentEnabled(bool enabled); static std::map<int, DevToolsAgent*> agent_for_routing_id_; |