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 "android_webview/native/aw_dev_tools_server.h" | 5 #include "android_webview/native/aw_dev_tools_server.h" |
6 | 6 |
7 #include "android_webview/native/aw_contents.h" | 7 #include "android_webview/native/aw_contents.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; | 32 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; |
33 | 33 |
34 // Delegate implementation for the devtools http handler for WebView. A new | 34 // Delegate implementation for the devtools http handler for WebView. A new |
35 // instance of this gets created each time web debugging is enabled. | 35 // instance of this gets created each time web debugging is enabled. |
36 class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { | 36 class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { |
37 public: | 37 public: |
38 AwDevToolsServerDelegate() {} | 38 AwDevToolsServerDelegate() {} |
39 virtual ~AwDevToolsServerDelegate() {} | 39 virtual ~AwDevToolsServerDelegate() {} |
40 | 40 |
41 // DevToolsHttpProtocolHandler::Delegate overrides. | 41 // DevToolsHttpProtocolHandler::Delegate overrides. |
42 virtual std::string GetDiscoveryPageHTML() OVERRIDE; | 42 virtual std::string GetDiscoveryPageHTML() override; |
43 | 43 |
44 virtual bool BundlesFrontendResources() OVERRIDE { | 44 virtual bool BundlesFrontendResources() override { |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 virtual base::FilePath GetDebugFrontendDir() OVERRIDE { | 48 virtual base::FilePath GetDebugFrontendDir() override { |
49 return base::FilePath(); | 49 return base::FilePath(); |
50 } | 50 } |
51 | 51 |
52 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( | 52 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( |
53 net::StreamListenSocket::Delegate* delegate, | 53 net::StreamListenSocket::Delegate* delegate, |
54 std::string* name) OVERRIDE { | 54 std::string* name) override { |
55 return scoped_ptr<net::StreamListenSocket>(); | 55 return scoped_ptr<net::StreamListenSocket>(); |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 DISALLOW_COPY_AND_ASSIGN(AwDevToolsServerDelegate); | 59 DISALLOW_COPY_AND_ASSIGN(AwDevToolsServerDelegate); |
60 }; | 60 }; |
61 | 61 |
62 | 62 |
63 std::string AwDevToolsServerDelegate::GetDiscoveryPageHTML() { | 63 std::string AwDevToolsServerDelegate::GetDiscoveryPageHTML() { |
64 const char html[] = | 64 const char html[] = |
65 "<html>" | 65 "<html>" |
66 "<head><title>WebView remote debugging</title></head>" | 66 "<head><title>WebView remote debugging</title></head>" |
67 "<body>Please use <a href=\'chrome://inspect\'>chrome://inspect</a>" | 67 "<body>Please use <a href=\'chrome://inspect\'>chrome://inspect</a>" |
68 "</body>" | 68 "</body>" |
69 "</html>"; | 69 "</html>"; |
70 return html; | 70 return html; |
71 } | 71 } |
72 | 72 |
73 // Factory for UnixDomainServerSocket. | 73 // Factory for UnixDomainServerSocket. |
74 class UnixDomainServerSocketFactory | 74 class UnixDomainServerSocketFactory |
75 : public content::DevToolsHttpHandler::ServerSocketFactory { | 75 : public content::DevToolsHttpHandler::ServerSocketFactory { |
76 public: | 76 public: |
77 explicit UnixDomainServerSocketFactory(const std::string& socket_name) | 77 explicit UnixDomainServerSocketFactory(const std::string& socket_name) |
78 : content::DevToolsHttpHandler::ServerSocketFactory(socket_name, 0, 1) {} | 78 : content::DevToolsHttpHandler::ServerSocketFactory(socket_name, 0, 1) {} |
79 | 79 |
80 private: | 80 private: |
81 // content::DevToolsHttpHandler::ServerSocketFactory. | 81 // content::DevToolsHttpHandler::ServerSocketFactory. |
82 virtual scoped_ptr<net::ServerSocket> Create() const OVERRIDE { | 82 virtual scoped_ptr<net::ServerSocket> Create() const override { |
83 return scoped_ptr<net::ServerSocket>( | 83 return scoped_ptr<net::ServerSocket>( |
84 new net::UnixDomainServerSocket( | 84 new net::UnixDomainServerSocket( |
85 base::Bind(&content::CanUserConnectToDevTools), | 85 base::Bind(&content::CanUserConnectToDevTools), |
86 true /* use_abstract_namespace */)); | 86 true /* use_abstract_namespace */)); |
87 } | 87 } |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); | 89 DISALLOW_COPY_AND_ASSIGN(UnixDomainServerSocketFactory); |
90 }; | 90 }; |
91 | 91 |
92 } // namespace | 92 } // namespace |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 AwDevToolsServer* devtools_server = | 149 AwDevToolsServer* devtools_server = |
150 reinterpret_cast<AwDevToolsServer*>(server); | 150 reinterpret_cast<AwDevToolsServer*>(server); |
151 if (enabled) { | 151 if (enabled) { |
152 devtools_server->Start(); | 152 devtools_server->Start(); |
153 } else { | 153 } else { |
154 devtools_server->Stop(); | 154 devtools_server->Stop(); |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 } // namespace android_webview | 158 } // namespace android_webview |
OLD | NEW |