Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1711)

Unified Diff: content/shell/browser/shell_devtools_frontend.cc

Issue 423673003: [DevTools] Make sendMessageToBackend one of embedder messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed compile Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/shell_devtools_frontend.cc
diff --git a/content/shell/browser/shell_devtools_frontend.cc b/content/shell/browser/shell_devtools_frontend.cc
index fe30eddef0c8e94ebb52eb416e94017c8683a661..76e29365762156cb0697442c4a8cfa8a12583a30 100644
--- a/content/shell/browser/shell_devtools_frontend.cc
+++ b/content/shell/browser/shell_devtools_frontend.cc
@@ -5,7 +5,9 @@
#include "content/shell/browser/shell_devtools_frontend.h"
#include "base/command_line.h"
+#include "base/json/json_reader.h"
#include "base/path_service.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/browser/devtools_http_handler.h"
@@ -135,6 +137,40 @@ void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) {
WebKitTestController::Get()->DevToolsProcessCrashed();
}
+void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend(
+ const std::string& message) {
+ std::string method;
+ std::string browser_message;
+ int id = 0;
+
+ base::ListValue* params = NULL;
+ base::DictionaryValue* dict = NULL;
+ scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
+ if (!parsed_message ||
+ !parsed_message->GetAsDictionary(&dict) ||
+ !dict->GetString("method", &method) ||
+ !dict->GetList("params", &params)) {
+ return;
+ }
+
+ if (method != "sendMessageToBrowser" ||
+ params->GetSize() != 1 ||
+ !params->GetString(0, &browser_message)) {
+ return;
+ }
+ dict->GetInteger("id", &id);
+
+ DevToolsManager::GetInstance()->DispatchOnInspectorBackend(
+ this, browser_message);
+
+ if (id) {
+ std::string code = "InspectorFrontendAPI.embedderMessageAck(" +
+ base::IntToString(id) + ",\"\");";
+ base::string16 javascript = base::UTF8ToUTF16(code);
+ web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
+ }
+}
+
void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend(
const std::string& message) {
DevToolsManager::GetInstance()->DispatchOnInspectorBackend(
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698