summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 15:34:29 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 15:34:29 +0000
commitf92f6646727bd3de87cc409398edcccf5ab8ad79 (patch)
tree5dda37fc6d785d26560857d75f4f2ece47ff9cbc /chrome/browser/extensions
parent23310a3556a228654ca17d2d6512f5cbc73635dc (diff)
downloadchromium_src-f92f6646727bd3de87cc409398edcccf5ab8ad79.zip
chromium_src-f92f6646727bd3de87cc409398edcccf5ab8ad79.tar.gz
chromium_src-f92f6646727bd3de87cc409398edcccf5ab8ad79.tar.bz2
DevTools: migrate APU from dedicated commands to the inspector protocol.
TBR=yurys git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-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
3 files changed, 65 insertions, 6 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));