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/command_line.h" | |
10 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
12 #include "base/json/string_escape.h" | 11 #include "base/json/string_escape.h" |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
17 #include "base/values.h" | 16 #include "base/values.h" |
18 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
21 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
24 #include "content/public/common/content_switches.h" | |
25 #include "content/shell/browser/shell.h" | 23 #include "content/shell/browser/shell.h" |
26 #include "content/shell/browser/shell_browser_context.h" | 24 #include "content/shell/browser/shell_browser_context.h" |
27 #include "content/shell/browser/shell_browser_main_parts.h" | 25 #include "content/shell/browser/shell_browser_main_parts.h" |
28 #include "content/shell/browser/shell_content_browser_client.h" | 26 #include "content/shell/browser/shell_content_browser_client.h" |
29 #include "content/shell/browser/shell_devtools_manager_delegate.h" | 27 #include "content/shell/browser/shell_devtools_manager_delegate.h" |
30 #include "content/shell/common/shell_switches.h" | |
31 #include "net/base/io_buffer.h" | 28 #include "net/base/io_buffer.h" |
32 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
33 #include "net/http/http_response_headers.h" | 30 #include "net/http/http_response_headers.h" |
34 #include "net/url_request/url_fetcher.h" | 31 #include "net/url_request/url_fetcher.h" |
35 #include "net/url_request/url_fetcher_response_writer.h" | 32 #include "net/url_request/url_fetcher_response_writer.h" |
36 | 33 |
37 namespace content { | 34 namespace content { |
38 | 35 |
39 namespace { | 36 namespace { |
40 | 37 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 shell_devtools_, "DevToolsAPI.streamWrite", | 88 shell_devtools_, "DevToolsAPI.streamWrite", |
92 base::Owned(id), base::Owned(chunkValue), nullptr)); | 89 base::Owned(id), base::Owned(chunkValue), nullptr)); |
93 return num_bytes; | 90 return num_bytes; |
94 } | 91 } |
95 | 92 |
96 int ResponseWriter::Finish(const net::CompletionCallback& callback) { | 93 int ResponseWriter::Finish(const net::CompletionCallback& callback) { |
97 return net::OK; | 94 return net::OK; |
98 } | 95 } |
99 | 96 |
100 static GURL GetFrontendURL() { | 97 static GURL GetFrontendURL() { |
101 const base::CommandLine& command_line = | 98 int port = ShellDevToolsManagerDelegate::GetHttpHandlerPort(); |
102 *base::CommandLine::ForCurrentProcess(); | |
103 uint16_t port = 0; | |
104 if (command_line.HasSwitch(switches::kRemoteDebuggingPort)) { | |
105 int temp_port; | |
106 std::string port_str = | |
107 command_line.GetSwitchValueASCII(switches::kRemoteDebuggingPort); | |
108 if (base::StringToInt(port_str, &temp_port) && | |
109 temp_port >= 0 && temp_port < 65535) { | |
110 port = static_cast<uint16_t>(temp_port); | |
111 } else { | |
112 DLOG(WARNING) << "Invalid http debugger port number " << temp_port; | |
113 } | |
114 } | |
115 return GURL( | 99 return GURL( |
116 base::StringPrintf("http://127.0.0.1:%d/devtools/inspector.html", port)); | 100 base::StringPrintf("http://127.0.0.1:%d/devtools/inspector.html", port)); |
117 } | 101 } |
118 | 102 |
119 } // namespace | 103 } // namespace |
120 | 104 |
121 // This constant should be in sync with | 105 // This constant should be in sync with |
122 // the constant at devtools_ui_bindings.cc. | 106 // the constant at devtools_ui_bindings.cc. |
123 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; | 107 const size_t kMaxMessageChunkSize = IPC::Channel::kMaximumMessageSize / 4; |
124 | 108 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 CallClientFunction("DevToolsAPI.embedderMessageAck", | 369 CallClientFunction("DevToolsAPI.embedderMessageAck", |
386 &id_value, arg, nullptr); | 370 &id_value, arg, nullptr); |
387 } | 371 } |
388 | 372 |
389 void ShellDevToolsFrontend::AgentHostClosed( | 373 void ShellDevToolsFrontend::AgentHostClosed( |
390 DevToolsAgentHost* agent_host, bool replaced) { | 374 DevToolsAgentHost* agent_host, bool replaced) { |
391 frontend_shell_->Close(); | 375 frontend_shell_->Close(); |
392 } | 376 } |
393 | 377 |
394 } // namespace content | 378 } // namespace content |
OLD | NEW |