| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/shell/browser/shell_browser_context.h" | 24 #include "content/shell/browser/shell_browser_context.h" |
| 25 #include "content/shell/browser/shell_browser_main_parts.h" | 25 #include "content/shell/browser/shell_browser_main_parts.h" |
| 26 #include "content/shell/browser/shell_content_browser_client.h" | 26 #include "content/shell/browser/shell_content_browser_client.h" |
| 27 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 27 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
| 28 #include "net/base/io_buffer.h" | 28 #include "net/base/io_buffer.h" |
| 29 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 30 #include "net/http/http_response_headers.h" | 30 #include "net/http/http_response_headers.h" |
| 31 #include "net/url_request/url_fetcher.h" | 31 #include "net/url_request/url_fetcher.h" |
| 32 #include "net/url_request/url_fetcher_response_writer.h" | 32 #include "net/url_request/url_fetcher_response_writer.h" |
| 33 | 33 |
| 34 #if !defined(OS_ANDROID) | |
| 35 #include "content/public/browser/devtools_frontend_host.h" | |
| 36 #endif | |
| 37 | |
| 38 namespace content { | 34 namespace content { |
| 39 | 35 |
| 40 namespace { | 36 namespace { |
| 41 | 37 |
| 42 | 38 |
| 43 // ResponseWriter ------------------------------------------------------------- | 39 // ResponseWriter ------------------------------------------------------------- |
| 44 | 40 |
| 45 class ResponseWriter : public net::URLFetcherResponseWriter { | 41 class ResponseWriter : public net::URLFetcherResponseWriter { |
| 46 public: | 42 public: |
| 47 ResponseWriter(base::WeakPtr<ShellDevToolsFrontend> shell_devtools_, | 43 ResponseWriter(base::WeakPtr<ShellDevToolsFrontend> shell_devtools_, |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 inspect_element_at_x_(-1), | 157 inspect_element_at_x_(-1), |
| 162 inspect_element_at_y_(-1), | 158 inspect_element_at_y_(-1), |
| 163 weak_factory_(this) { | 159 weak_factory_(this) { |
| 164 } | 160 } |
| 165 | 161 |
| 166 ShellDevToolsFrontend::~ShellDevToolsFrontend() { | 162 ShellDevToolsFrontend::~ShellDevToolsFrontend() { |
| 167 for (const auto& pair : pending_requests_) | 163 for (const auto& pair : pending_requests_) |
| 168 delete pair.first; | 164 delete pair.first; |
| 169 } | 165 } |
| 170 | 166 |
| 171 #if !defined(OS_ANDROID) | |
| 172 void ShellDevToolsFrontend::RenderViewCreated( | 167 void ShellDevToolsFrontend::RenderViewCreated( |
| 173 RenderViewHost* render_view_host) { | 168 RenderViewHost* render_view_host) { |
| 174 if (!frontend_host_) { | 169 if (!frontend_host_) { |
| 175 frontend_host_.reset(DevToolsFrontendHost::Create( | 170 frontend_host_.reset(DevToolsFrontendHost::Create( |
| 176 web_contents()->GetMainFrame(), | 171 web_contents()->GetMainFrame(), |
| 177 base::Bind(&ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend, | 172 base::Bind(&ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend, |
| 178 base::Unretained(this)))); | 173 base::Unretained(this)))); |
| 179 } | 174 } |
| 180 } | 175 } |
| 181 #endif | |
| 182 | |
| 183 #if defined(OS_ANDROID) | |
| 184 void ShellDevToolsFrontend::RenderViewCreated( | |
| 185 RenderViewHost* render_view_host) { | |
| 186 // No devtools frontend for android | |
| 187 } | |
| 188 #endif | |
| 189 | 176 |
| 190 void ShellDevToolsFrontend::DocumentAvailableInMainFrame() { | 177 void ShellDevToolsFrontend::DocumentAvailableInMainFrame() { |
| 191 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_); | 178 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_); |
| 192 agent_host_->AttachClient(this); | 179 agent_host_->AttachClient(this); |
| 193 if (inspect_element_at_x_ != -1) { | 180 if (inspect_element_at_x_ != -1) { |
| 194 agent_host_->InspectElement( | 181 agent_host_->InspectElement( |
| 195 this, inspect_element_at_x_, inspect_element_at_y_); | 182 this, inspect_element_at_x_, inspect_element_at_y_); |
| 196 inspect_element_at_x_ = -1; | 183 inspect_element_at_x_ = -1; |
| 197 inspect_element_at_y_ = -1; | 184 inspect_element_at_y_ = -1; |
| 198 } | 185 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 &id_value, arg, nullptr); | 374 &id_value, arg, nullptr); |
| 388 } | 375 } |
| 389 | 376 |
| 390 void ShellDevToolsFrontend::AgentHostClosed( | 377 void ShellDevToolsFrontend::AgentHostClosed( |
| 391 DevToolsAgentHost* agent_host, bool replaced) { | 378 DevToolsAgentHost* agent_host, bool replaced) { |
| 392 agent_host_ = nullptr; | 379 agent_host_ = nullptr; |
| 393 frontend_shell_->Close(); | 380 frontend_shell_->Close(); |
| 394 } | 381 } |
| 395 | 382 |
| 396 } // namespace content | 383 } // namespace content |
| OLD | NEW |