| OLD | NEW |
| 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/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 void ShellDevToolsFrontend::Close() { | 100 void ShellDevToolsFrontend::Close() { |
| 101 frontend_shell_->Close(); | 101 frontend_shell_->Close(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 ShellDevToolsFrontend::ShellDevToolsFrontend(Shell* frontend_shell, | 104 ShellDevToolsFrontend::ShellDevToolsFrontend(Shell* frontend_shell, |
| 105 DevToolsAgentHost* agent_host) | 105 DevToolsAgentHost* agent_host) |
| 106 : WebContentsObserver(frontend_shell->web_contents()), | 106 : WebContentsObserver(frontend_shell->web_contents()), |
| 107 frontend_shell_(frontend_shell), | 107 frontend_shell_(frontend_shell), |
| 108 agent_host_(agent_host) { | 108 agent_host_(agent_host) { |
| 109 frontend_host_.reset( | 109 frontend_host_.reset(DevToolsFrontendHost::Create(web_contents(), this)); |
| 110 DevToolsClientHost::CreateDevToolsFrontendHost(web_contents(), this)); | 110 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
| 111 agent_host_.get(), this); |
| 111 } | 112 } |
| 112 | 113 |
| 113 ShellDevToolsFrontend::~ShellDevToolsFrontend() { | 114 ShellDevToolsFrontend::~ShellDevToolsFrontend() { |
| 114 } | 115 } |
| 115 | 116 |
| 116 void ShellDevToolsFrontend::RenderViewCreated( | |
| 117 RenderViewHost* render_view_host) { | |
| 118 DevToolsClientHost::SetupDevToolsFrontendClient( | |
| 119 web_contents()->GetRenderViewHost()); | |
| 120 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
| 121 manager->RegisterDevToolsClientHostFor(agent_host_.get(), | |
| 122 frontend_host_.get()); | |
| 123 } | |
| 124 | |
| 125 void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() { | 117 void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() { |
| 126 web_contents()->GetMainFrame()->ExecuteJavaScript( | 118 web_contents()->GetMainFrame()->ExecuteJavaScript( |
| 127 base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);")); | 119 base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);")); |
| 128 } | 120 } |
| 129 | 121 |
| 130 void ShellDevToolsFrontend::WebContentsDestroyed() { | 122 void ShellDevToolsFrontend::WebContentsDestroyed() { |
| 131 DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get()); | 123 DevToolsManager::GetInstance()->ClientHostClosing(this); |
| 132 delete this; | 124 delete this; |
| 133 } | 125 } |
| 134 | 126 |
| 135 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) { | 127 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) { |
| 136 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 128 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 137 WebKitTestController::Get()->DevToolsProcessCrashed(); | 129 WebKitTestController::Get()->DevToolsProcessCrashed(); |
| 138 } | 130 } |
| 139 | 131 |
| 132 bool ShellDevToolsFrontend::ShouldSetupDevToolsFrontendForUrl(const GURL& url) { |
| 133 return true; |
| 134 } |
| 135 |
| 136 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( |
| 137 const std::string& message) { |
| 138 DevToolsManager::GetInstance()->DispatchOnInspectorBackend( |
| 139 this, message); |
| 140 } |
| 141 |
| 142 void ShellDevToolsFrontend::DispatchOnInspectorFrontend( |
| 143 const std::string& message) { |
| 144 frontend_host_->DispatchOnDevToolsFrontend(message); |
| 145 } |
| 146 |
| 140 void ShellDevToolsFrontend::InspectedContentsClosing() { | 147 void ShellDevToolsFrontend::InspectedContentsClosing() { |
| 141 frontend_shell_->Close(); | 148 frontend_shell_->Close(); |
| 142 } | 149 } |
| 143 | 150 |
| 144 } // namespace content | 151 } // namespace content |
| OLD | NEW |