summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 16:47:45 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 16:47:45 +0000
commit804be3af5e9a45547178b46fe1c5ccf492c791fc (patch)
tree94d755e74cf8da191ce5222180df108ff523598b
parent8853bc93814dc661e2066b9f73a1ad9fa730ff87 (diff)
downloadchromium_src-804be3af5e9a45547178b46fe1c5ccf492c791fc.zip
chromium_src-804be3af5e9a45547178b46fe1c5ccf492c791fc.tar.gz
chromium_src-804be3af5e9a45547178b46fe1c5ccf492c791fc.tar.bz2
Revert r71044: "DevTools: migrate APU from dedicated commands to the inspector protocol."
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71048 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension_devtools_bridge.cc67
-rw-r--r--chrome/browser/extensions/extension_devtools_bridge.h2
-rw-r--r--chrome/browser/extensions/extension_devtools_browsertests.cc2
-rw-r--r--chrome/common/devtools_messages_internal.h13
-rw-r--r--chrome/renderer/devtools_agent.cc16
-rw-r--r--chrome/renderer/devtools_agent.h2
6 files changed, 31 insertions, 71 deletions
diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc
index 71422ca..8394ad0 100644
--- a/chrome/browser/extensions/extension_devtools_bridge.cc
+++ b/chrome/browser/extensions/extension_devtools_bridge.cc
@@ -4,11 +4,9 @@
#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"
@@ -34,22 +32,6 @@ 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);
@@ -61,51 +43,11 @@ 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_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())));
+ DevToolsAgentMsg_SetApuAgentEnabled(true));
return true;
}
return false;
@@ -134,17 +76,16 @@ void ExtensionDevToolsBridge::InspectedTabClosing() {
void ExtensionDevToolsBridge::SendMessageToClient(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(ExtensionDevToolsBridge, msg)
- IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchOnInspectorFrontend,
- OnDispatchOnInspectorFrontend);
+ IPC_MESSAGE_HANDLER(DevToolsClientMsg_DispatchToAPU, OnDispatchToAPU);
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
}
-void ExtensionDevToolsBridge::OnDispatchOnInspectorFrontend(
- const std::string& data) {
+void ExtensionDevToolsBridge::OnDispatchToAPU(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 4a0a9da..ad103a2 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 OnDispatchOnInspectorFrontend(const std::string& data);
+ void OnDispatchToAPU(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 d9984be..c29a4ca 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_DispatchOnInspectorFrontend pageEventMessage("");
+ DevToolsClientMsg_DispatchToAPU 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 15be740..6019d60 100644
--- a/chrome/common/devtools_messages_internal.h
+++ b/chrome/common/devtools_messages_internal.h
@@ -51,11 +51,12 @@ IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DispatchOnInspectorFrontend,
// Legacy debugger output message.
IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DebuggerOutput,
std::string /* message */)
-
-// Legacy APU dispatch message.
-IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DispatchToAPU,
+
+// Legacy APU dispatch message.
+IPC_MESSAGE_CONTROL1(DevToolsClientMsg_DispatchToAPU,
std::string /* message */)
+
//-----------------------------------------------------------------------------
// These are messages sent from DevToolsClient to DevToolsAgent through the
// browser.
@@ -84,6 +85,6 @@ 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 */)
+
+// 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 ca1ef3a..e1dbba6 100644
--- a/chrome/renderer/devtools_agent.cc
+++ b/chrome/renderer/devtools_agent.cc
@@ -83,6 +83,8 @@ 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;
@@ -103,6 +105,13 @@ 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_;
}
@@ -191,6 +200,13 @@ 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 4b1b465..14a7247 100644
--- a/chrome/renderer/devtools_agent.h
+++ b/chrome/renderer/devtools_agent.h
@@ -39,6 +39,7 @@ 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,
@@ -65,6 +66,7 @@ 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_;