| 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( | |
| 110 DevToolsClientHost::CreateDevToolsFrontendHost(web_contents(), this)); | |
| 111 } | 109 } |
| 112 | 110 |
| 113 ShellDevToolsFrontend::~ShellDevToolsFrontend() { | 111 ShellDevToolsFrontend::~ShellDevToolsFrontend() { |
| 114 } | 112 } |
| 115 | 113 |
| 116 void ShellDevToolsFrontend::RenderViewCreated( | 114 void ShellDevToolsFrontend::RenderViewCreated( |
| 117 RenderViewHost* render_view_host) { | 115 RenderViewHost* render_view_host) { |
| 118 DevToolsClientHost::SetupDevToolsFrontendClient( | 116 if (!frontend_host_) { |
| 119 web_contents()->GetRenderViewHost()); | 117 frontend_host_.reset(DevToolsFrontendHost::Create(render_view_host, this)); |
| 120 DevToolsManager* manager = DevToolsManager::GetInstance(); | 118 DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
| 121 manager->RegisterDevToolsClientHostFor(agent_host_.get(), | 119 agent_host_.get(), this); |
| 122 frontend_host_.get()); | 120 } |
| 123 } | 121 } |
| 124 | 122 |
| 125 void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() { | 123 void ShellDevToolsFrontend::DocumentOnLoadCompletedInMainFrame() { |
| 126 web_contents()->GetMainFrame()->ExecuteJavaScript( | 124 web_contents()->GetMainFrame()->ExecuteJavaScript( |
| 127 base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);")); | 125 base::ASCIIToUTF16("InspectorFrontendAPI.setUseSoftMenu(true);")); |
| 128 } | 126 } |
| 129 | 127 |
| 130 void ShellDevToolsFrontend::WebContentsDestroyed() { | 128 void ShellDevToolsFrontend::WebContentsDestroyed() { |
| 131 DevToolsManager::GetInstance()->ClientHostClosing(frontend_host_.get()); | 129 DevToolsManager::GetInstance()->ClientHostClosing(this); |
| 132 delete this; | 130 delete this; |
| 133 } | 131 } |
| 134 | 132 |
| 135 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) { | 133 void ShellDevToolsFrontend::RenderProcessGone(base::TerminationStatus status) { |
| 136 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 134 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 137 WebKitTestController::Get()->DevToolsProcessCrashed(); | 135 WebKitTestController::Get()->DevToolsProcessCrashed(); |
| 138 } | 136 } |
| 139 | 137 |
| 138 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( |
| 139 const std::string& message) { |
| 140 DevToolsManager::GetInstance()->DispatchOnInspectorBackend( |
| 141 this, message); |
| 142 } |
| 143 |
| 144 void ShellDevToolsFrontend::DispatchOnInspectorFrontend( |
| 145 const std::string& message) { |
| 146 if (frontend_host_) |
| 147 frontend_host_->DispatchOnDevToolsFrontend(message); |
| 148 } |
| 149 |
| 140 void ShellDevToolsFrontend::InspectedContentsClosing() { | 150 void ShellDevToolsFrontend::InspectedContentsClosing() { |
| 141 frontend_shell_->Close(); | 151 frontend_shell_->Close(); |
| 142 } | 152 } |
| 143 | 153 |
| 144 } // namespace content | 154 } // namespace content |
| OLD | NEW |