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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/browser/shell_devtools_frontend.h" 5 #include "content/shell/browser/shell_devtools_frontend.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h"
8 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
11 #include "content/public/browser/devtools_http_handler.h" 13 #include "content/public/browser/devtools_http_handler.h"
12 #include "content/public/browser/devtools_manager.h" 14 #include "content/public/browser/devtools_manager.h"
13 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/render_view_host.h" 16 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
17 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
18 #include "content/shell/browser/shell_browser_context.h" 20 #include "content/shell/browser/shell_browser_context.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void ShellDevToolsFrontend::WebContentsDestroyed() { 130 void ShellDevToolsFrontend::WebContentsDestroyed() {
129 DevToolsManager::GetInstance()->ClientHostClosing(this); 131 DevToolsManager::GetInstance()->ClientHostClosing(this);
130 delete this; 132 delete this;
131 } 133 }
132 134
133 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) { 135 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) {
134 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) 136 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
135 WebKitTestController::Get()->DevToolsProcessCrashed(); 137 WebKitTestController::Get()->DevToolsProcessCrashed();
136 } 138 }
137 139
140 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend(
141 const std::string& message) {
142 std::string method;
143 std::string browser_message;
144 int id = 0;
145
146 base::ListValue* params = NULL;
147 base::DictionaryValue* dict = NULL;
148 scoped_ptr<base::Value> parsed_message(base::JSONReader::Read(message));
149 if (!parsed_message ||
150 !parsed_message->GetAsDictionary(&dict) ||
151 !dict->GetString("method", &method) ||
152 !dict->GetList("params", &params)) {
153 return;
154 }
155
156 if (method != "sendMessageToBrowser" ||
157 params->GetSize() != 1 ||
158 !params->GetString(0, &browser_message)) {
159 return;
160 }
161 dict->GetInteger("id", &id);
162
163 DevToolsManager::GetInstance()->DispatchOnInspectorBackend(
164 this, browser_message);
165
166 if (id) {
167 std::string code = "InspectorFrontendAPI.embedderMessageAck(" +
168 base::IntToString(id) + ",\"\");";
169 base::string16 javascript = base::UTF8ToUTF16(code);
170 web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
171 }
172 }
173
138 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( 174 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend(
139 const std::string& message) { 175 const std::string& message) {
140 DevToolsManager::GetInstance()->DispatchOnInspectorBackend( 176 DevToolsManager::GetInstance()->DispatchOnInspectorBackend(
141 this, message); 177 this, message);
142 } 178 }
143 179
144 void ShellDevToolsFrontend::DispatchOnInspectorFrontend( 180 void ShellDevToolsFrontend::DispatchOnInspectorFrontend(
145 const std::string& message) { 181 const std::string& message) {
146 if (frontend_host_) 182 if (frontend_host_)
147 frontend_host_->DispatchOnDevToolsFrontend(message); 183 frontend_host_->DispatchOnDevToolsFrontend(message);
148 } 184 }
149 185
150 void ShellDevToolsFrontend::InspectedContentsClosing() { 186 void ShellDevToolsFrontend::InspectedContentsClosing() {
151 frontend_shell_->Close(); 187 frontend_shell_->Close();
152 } 188 }
153 189
154 } // namespace content 190 } // namespace content
OLDNEW
« 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