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

Side by Side Diff: content/shell/browser/shell_devtools_frontend.cc

Issue 449043002: [DevTools] Make DevTools clients talk directly to DevToolsAgentHost instead of using DevToolsManage… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed DetachAllClients 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
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/json/json_reader.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "content/public/browser/devtools_http_handler.h" 13 #include "content/public/browser/devtools_http_handler.h"
14 #include "content/public/browser/devtools_manager.h"
15 #include "content/public/browser/render_frame_host.h" 14 #include "content/public/browser/render_frame_host.h"
16 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
19 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
20 #include "content/shell/browser/shell_browser_context.h" 19 #include "content/shell/browser/shell_browser_context.h"
21 #include "content/shell/browser/shell_browser_main_parts.h" 20 #include "content/shell/browser/shell_browser_main_parts.h"
22 #include "content/shell/browser/shell_content_browser_client.h" 21 #include "content/shell/browser/shell_content_browser_client.h"
23 #include "content/shell/browser/shell_devtools_delegate.h" 22 #include "content/shell/browser/shell_devtools_delegate.h"
24 #include "content/shell/browser/webkit_test_controller.h" 23 #include "content/shell/browser/webkit_test_controller.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 agent_host_(agent_host) { 108 agent_host_(agent_host) {
110 } 109 }
111 110
112 ShellDevToolsFrontend::~ShellDevToolsFrontend() { 111 ShellDevToolsFrontend::~ShellDevToolsFrontend() {
113 } 112 }
114 113
115 void ShellDevToolsFrontend::RenderViewCreated( 114 void ShellDevToolsFrontend::RenderViewCreated(
116 RenderViewHost* render_view_host) { 115 RenderViewHost* render_view_host) {
117 if (!frontend_host_) { 116 if (!frontend_host_) {
118 frontend_host_.reset(DevToolsFrontendHost::Create(render_view_host, this)); 117 frontend_host_.reset(DevToolsFrontendHost::Create(render_view_host, this));
119 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( 118 agent_host_->AttachClient(this);
120 agent_host_.get(), this);
121 } 119 }
122 } 120 }
123 121
124 void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() { 122 void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() {
125 web_contents()->GetMainFrame()->ExecuteJavaScript( 123 web_contents()->GetMainFrame()->ExecuteJavaScript(
126 base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);")); 124 base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);"));
127 } 125 }
128 126
129 void ShellDevToolsFrontend::WebContentsDestroyed() { 127 void ShellDevToolsFrontend::WebContentsDestroyed() {
130 DevToolsManager::GetInstance()->ClientHostClosing(this); 128 agent_host_->DetachClient();
131 delete this; 129 delete this;
132 } 130 }
133 131
134 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) { 132 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) {
135 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) 133 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
136 WebKitTestController::Get()->DevToolsProcessCrashed(); 134 WebKitTestController::Get()->DevToolsProcessCrashed();
137 } 135 }
138 136
139 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend( 137 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend(
140 const std::string& message) { 138 const std::string& message) {
(...skipping 11 matching lines...) Expand all
152 return; 150 return;
153 } 151 }
154 152
155 if (method != "sendMessageToBrowser" || 153 if (method != "sendMessageToBrowser" ||
156 params->GetSize() != 1 || 154 params->GetSize() != 1 ||
157 !params->GetString(0, &browser_message)) { 155 !params->GetString(0, &browser_message)) {
158 return; 156 return;
159 } 157 }
160 dict->GetInteger("id", &id); 158 dict->GetInteger("id", &id);
161 159
162 DevToolsManager::GetInstance()->DispatchOnInspectorBackend( 160 agent_host_->DispatchProtocolMessage(browser_message);
163 this, browser_message);
164 161
165 if (id) { 162 if (id) {
166 std::string code = "InspectorFrontendAPI.embedderMessageAck(" + 163 std::string code = "InspectorFrontendAPI.embedderMessageAck(" +
167 base::IntToString(id) + ",\"\");"; 164 base::IntToString(id) + ",\"\");";
168 base::string16 javascript = base::UTF8ToUTF16(code); 165 base::string16 javascript = base::UTF8ToUTF16(code);
169 web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); 166 web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
170 } 167 }
171 } 168 }
172 169
173 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( 170 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend(
174 const std::string& message) { 171 const std::string& message) {
175 DevToolsManager::GetInstance()->DispatchOnInspectorBackend( 172 agent_host_->DispatchProtocolMessage(message);
176 this, message);
177 } 173 }
178 174
179 void ShellDevToolsFrontend::DispatchOnInspectorFrontend( 175 void ShellDevToolsFrontend::DispatchProtocolMessage(
180 const std::string& message) { 176 DevToolsAgentHost* agent_host, const std::string& message) {
181 std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");"; 177 std::string code = "InspectorFrontendAPI.dispatchMessage(" + message + ");";
182 base::string16 javascript = base::UTF8ToUTF16(code); 178 base::string16 javascript = base::UTF8ToUTF16(code);
183 web_contents()->GetMainFrame()->ExecuteJavaScript(javascript); 179 web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
184 } 180 }
185 181
186 void ShellDevToolsFrontend::InspectedContentsClosing() { 182 void ShellDevToolsFrontend::AgentHostClosed(
183 DevToolsAgentHost* agent_host, bool replaced) {
187 frontend_shell_->Close(); 184 frontend_shell_->Close();
188 } 185 }
189 186
190 } // namespace content 187 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | content/shell/browser/webkit_test_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698