Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: android_webview/native/aw_dev_tools_server.cc

Issue 2295623002: DevTools: simplify http handler delegate as it is moving into content. (Closed)
Patch Set: lcean Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/android/dev_tools_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 7 #include <utility>
8 8
9 #include "android_webview/common/aw_content_client.h" 9 #include "android_webview/common/aw_content_client.h"
10 #include "android_webview/native/aw_contents.h" 10 #include "android_webview/native/aw_contents.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "components/devtools_http_handler/devtools_http_handler.h" 17 #include "components/devtools_http_handler/devtools_http_handler.h"
18 #include "components/devtools_http_handler/devtools_http_handler_delegate.h" 18 #include "components/devtools_http_handler/devtools_http_handler_delegate.h"
19 #include "content/public/browser/android/devtools_auth.h" 19 #include "content/public/browser/android/devtools_auth.h"
20 #include "content/public/browser/devtools_agent_host.h" 20 #include "content/public/browser/devtools_agent_host.h"
21 #include "content/public/browser/devtools_socket_factory.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/user_agent.h" 23 #include "content/public/common/user_agent.h"
23 #include "jni/AwDevToolsServer_jni.h" 24 #include "jni/AwDevToolsServer_jni.h"
24 #include "net/base/net_errors.h" 25 #include "net/base/net_errors.h"
25 #include "net/socket/unix_domain_server_socket_posix.h" 26 #include "net/socket/unix_domain_server_socket_posix.h"
26 27
27 using base::android::JavaParamRef; 28 using base::android::JavaParamRef;
28 using content::DevToolsAgentHost; 29 using content::DevToolsAgentHost;
29 using content::RenderViewHost; 30 using content::RenderViewHost;
30 using content::WebContents; 31 using content::WebContents;
(...skipping 14 matching lines...) Expand all
45 public devtools_http_handler::DevToolsHttpHandlerDelegate { 46 public devtools_http_handler::DevToolsHttpHandlerDelegate {
46 public: 47 public:
47 AwDevToolsServerDelegate() { 48 AwDevToolsServerDelegate() {
48 } 49 }
49 50
50 ~AwDevToolsServerDelegate() override {} 51 ~AwDevToolsServerDelegate() override {}
51 52
52 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation. 53 // devtools_http_handler::DevToolsHttpHandlerDelegate implementation.
53 std::string GetDiscoveryPageHTML() override; 54 std::string GetDiscoveryPageHTML() override;
54 std::string GetFrontendResource(const std::string& path) override; 55 std::string GetFrontendResource(const std::string& path) override;
55 std::string GetPageThumbnailData(const GURL&) override;
56 content::DevToolsExternalAgentProxyDelegate*
57 HandleWebSocketConnection(const std::string& path) override;
58 56
59 private: 57 private:
60 58
61 DISALLOW_COPY_AND_ASSIGN(AwDevToolsServerDelegate); 59 DISALLOW_COPY_AND_ASSIGN(AwDevToolsServerDelegate);
62 }; 60 };
63 61
64 62
65 std::string AwDevToolsServerDelegate::GetDiscoveryPageHTML() { 63 std::string AwDevToolsServerDelegate::GetDiscoveryPageHTML() {
66 const char html[] = 64 const char html[] =
67 "<html>" 65 "<html>"
68 "<head><title>WebView remote debugging</title></head>" 66 "<head><title>WebView remote debugging</title></head>"
69 "<body>Please use <a href=\'chrome://inspect\'>chrome://inspect</a>" 67 "<body>Please use <a href=\'chrome://inspect\'>chrome://inspect</a>"
70 "</body>" 68 "</body>"
71 "</html>"; 69 "</html>";
72 return html; 70 return html;
73 } 71 }
74 72
75 std::string AwDevToolsServerDelegate::GetFrontendResource( 73 std::string AwDevToolsServerDelegate::GetFrontendResource(
76 const std::string& path) { 74 const std::string& path) {
77 return std::string(); 75 return std::string();
78 } 76 }
79 77
80 std::string AwDevToolsServerDelegate::GetPageThumbnailData(const GURL&) {
81 return std::string();
82 }
83
84 content::DevToolsExternalAgentProxyDelegate*
85 AwDevToolsServerDelegate::HandleWebSocketConnection(const std::string& path) {
86 return nullptr;
87 }
88
89 // Factory for UnixDomainServerSocket. 78 // Factory for UnixDomainServerSocket.
90 class UnixDomainServerSocketFactory 79 class UnixDomainServerSocketFactory : public content::DevToolsSocketFactory {
91 : public DevToolsHttpHandler::ServerSocketFactory {
92 public: 80 public:
93 explicit UnixDomainServerSocketFactory(const std::string& socket_name) 81 explicit UnixDomainServerSocketFactory(const std::string& socket_name)
94 : socket_name_(socket_name), 82 : socket_name_(socket_name),
95 last_tethering_socket_(0) { 83 last_tethering_socket_(0) {
96 } 84 }
97 85
98 private: 86 private:
99 // devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory. 87 // devtools_http_handler::DevToolsHttpHandler::ServerSocketFactory.
100 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override { 88 std::unique_ptr<net::ServerSocket> CreateForHttpServer() override {
101 std::unique_ptr<net::UnixDomainServerSocket> socket( 89 std::unique_ptr<net::UnixDomainServerSocket> socket(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 124 }
137 125
138 AwDevToolsServer::~AwDevToolsServer() { 126 AwDevToolsServer::~AwDevToolsServer() {
139 Stop(); 127 Stop();
140 } 128 }
141 129
142 void AwDevToolsServer::Start() { 130 void AwDevToolsServer::Start() {
143 if (devtools_http_handler_) 131 if (devtools_http_handler_)
144 return; 132 return;
145 133
146 std::unique_ptr<DevToolsHttpHandler::ServerSocketFactory> factory( 134 std::unique_ptr<content::DevToolsSocketFactory> factory(
147 new UnixDomainServerSocketFactory( 135 new UnixDomainServerSocketFactory(
148 base::StringPrintf(kSocketNameFormat, getpid()))); 136 base::StringPrintf(kSocketNameFormat, getpid())));
149 devtools_http_handler_.reset(new DevToolsHttpHandler( 137 devtools_http_handler_.reset(new DevToolsHttpHandler(
150 std::move(factory), 138 std::move(factory),
151 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()), 139 base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str()),
152 new AwDevToolsServerDelegate(), base::FilePath(), base::FilePath(), 140 new AwDevToolsServerDelegate(), base::FilePath(), base::FilePath(),
153 GetProduct(), GetUserAgent())); 141 GetProduct(), GetUserAgent()));
154 } 142 }
155 143
156 void AwDevToolsServer::Stop() { 144 void AwDevToolsServer::Stop() {
(...skipping 27 matching lines...) Expand all
184 AwDevToolsServer* devtools_server = 172 AwDevToolsServer* devtools_server =
185 reinterpret_cast<AwDevToolsServer*>(server); 173 reinterpret_cast<AwDevToolsServer*>(server);
186 if (enabled) { 174 if (enabled) {
187 devtools_server->Start(); 175 devtools_server->Start();
188 } else { 176 } else {
189 devtools_server->Stop(); 177 devtools_server->Stop();
190 } 178 }
191 } 179 }
192 180
193 } // namespace android_webview 181 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/dev_tools_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698