OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell_devtools_delegate.h" | 5 #include "content/shell/shell_devtools_delegate.h" |
6 | 6 |
7 #include "content/public/browser/devtools_http_handler.h" | 7 #include "content/public/browser/devtools_http_handler.h" |
8 #include "grit/shell_resources.h" | 8 #include "grit/shell_resources.h" |
9 #include "net/base/tcp_listen_socket.h" | 9 #include "net/base/tcp_listen_socket.h" |
10 #include "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
11 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 ShellDevToolsDelegate::ShellDevToolsDelegate( | 16 ShellDevToolsDelegate::ShellDevToolsDelegate( |
| 17 int port, |
17 net::URLRequestContextGetter* context_getter) | 18 net::URLRequestContextGetter* context_getter) |
18 : context_getter_(context_getter) { | 19 : context_getter_(context_getter) { |
19 devtools_http_handler_ = DevToolsHttpHandler::Start( | 20 devtools_http_handler_ = DevToolsHttpHandler::Start( |
20 new net::TCPListenSocketFactory("127.0.0.1", 0), | 21 new net::TCPListenSocketFactory("127.0.0.1", port), |
21 "", | 22 "", |
22 context_getter_, | 23 context_getter_, |
23 this); | 24 this); |
24 } | 25 } |
25 | 26 |
26 ShellDevToolsDelegate::~ShellDevToolsDelegate() { | 27 ShellDevToolsDelegate::~ShellDevToolsDelegate() { |
27 } | 28 } |
28 | 29 |
29 void ShellDevToolsDelegate::Stop() { | 30 void ShellDevToolsDelegate::Stop() { |
30 // The call below destroys this. | 31 // The call below destroys this. |
31 devtools_http_handler_->Stop(); | 32 devtools_http_handler_->Stop(); |
32 } | 33 } |
33 | 34 |
34 std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { | 35 std::string ShellDevToolsDelegate::GetDiscoveryPageHTML() { |
35 return ResourceBundle::GetSharedInstance().GetRawDataResource( | 36 return ResourceBundle::GetSharedInstance().GetRawDataResource( |
36 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE, | 37 IDR_CONTENT_SHELL_DEVTOOLS_DISCOVERY_PAGE, |
37 ui::SCALE_FACTOR_NONE).as_string(); | 38 ui::SCALE_FACTOR_NONE).as_string(); |
38 } | 39 } |
39 | 40 |
40 bool ShellDevToolsDelegate::BundlesFrontendResources() { | 41 bool ShellDevToolsDelegate::BundlesFrontendResources() { |
41 return true; | 42 return true; |
42 } | 43 } |
43 | 44 |
44 std::string ShellDevToolsDelegate::GetFrontendResourcesBaseURL() { | 45 std::string ShellDevToolsDelegate::GetFrontendResourcesBaseURL() { |
45 return ""; | 46 return ""; |
46 } | 47 } |
47 | 48 |
48 } // namespace content | 49 } // namespace content |
OLD | NEW |