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

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

Issue 459403002: DevTools: Added service workers to remote debugging targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made DevToolsAgentHost::GetType return enum Created 6 years, 4 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
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 "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 14 matching lines...) Expand all
25 using content::RenderViewHost; 25 using content::RenderViewHost;
26 using content::WebContents; 26 using content::WebContents;
27 27
28 namespace { 28 namespace {
29 29
30 const char kFrontEndURL[] = 30 const char kFrontEndURL[] =
31 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html"; 31 "http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html";
32 const char kSocketNameFormat[] = "webview_devtools_remote_%d"; 32 const char kSocketNameFormat[] = "webview_devtools_remote_%d";
33 33
34 const char kTargetTypePage[] = "page"; 34 const char kTargetTypePage[] = "page";
35 const char kTargetTypeServiceWorker[] = "service_worker";
36 const char kTargetTypeOther[] = "other";
35 37
36 std::string GetViewDescription(WebContents* web_contents); 38 std::string GetViewDescription(WebContents* web_contents);
37 39
38 class Target : public content::DevToolsTarget { 40 class Target : public content::DevToolsTarget {
39 public: 41 public:
40 explicit Target(WebContents* web_contents); 42 explicit Target(scoped_refptr<DevToolsAgentHost> agent_host);
41 43
42 virtual std::string GetId() const OVERRIDE { return id_; } 44 virtual std::string GetId() const OVERRIDE { return agent_host_->GetId(); }
43 virtual std::string GetParentId() const OVERRIDE { return std::string(); } 45 virtual std::string GetParentId() const OVERRIDE { return std::string(); }
44 virtual std::string GetType() const OVERRIDE { return kTargetTypePage; } 46 virtual std::string GetType() const OVERRIDE {
45 virtual std::string GetTitle() const OVERRIDE { return title_; } 47 switch (agent_host_->GetType()) {
48 case DevToolsAgentHost::AGENT_HOST_WEB_CONTENTS:
49 return kTargetTypePage;
50 case DevToolsAgentHost::AGENT_HOST_SERVICE_WORKER:
51 return kTargetTypeServiceWorker;
52 default:
53 {} // Do nothing.
dgozman 2014/08/22 08:38:28 break;
vkuzkokov 2014/08/22 11:01:47 Done.
54 }
55 return kTargetTypeOther;
56 }
57 virtual std::string GetTitle() const OVERRIDE {
58 return agent_host_->GetTitle();
59 }
46 virtual std::string GetDescription() const OVERRIDE { return description_; } 60 virtual std::string GetDescription() const OVERRIDE { return description_; }
47 virtual GURL GetURL() const OVERRIDE { return url_; } 61 virtual GURL GetURL() const OVERRIDE { return agent_host_->GetURL(); }
48 virtual GURL GetFaviconURL() const OVERRIDE { return GURL(); } 62 virtual GURL GetFaviconURL() const OVERRIDE { return GURL(); }
49 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE { 63 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE {
50 return last_activity_time_; 64 return last_activity_time_;
51 } 65 }
52 virtual bool IsAttached() const OVERRIDE { 66 virtual bool IsAttached() const OVERRIDE {
53 return agent_host_->IsAttached(); 67 return agent_host_->IsAttached();
54 } 68 }
55 virtual scoped_refptr<DevToolsAgentHost> GetAgentHost() const OVERRIDE { 69 virtual scoped_refptr<DevToolsAgentHost> GetAgentHost() const OVERRIDE {
56 return agent_host_; 70 return agent_host_;
57 } 71 }
58 virtual bool Activate() const OVERRIDE { return false; } 72 virtual bool Activate() const OVERRIDE { return agent_host_->Activate(); }
59 virtual bool Close() const OVERRIDE { return false; } 73 virtual bool Close() const OVERRIDE { return agent_host_->Close(); }
60 74
61 private: 75 private:
62 scoped_refptr<DevToolsAgentHost> agent_host_; 76 scoped_refptr<DevToolsAgentHost> agent_host_;
63 std::string id_;
64 std::string title_;
65 std::string description_; 77 std::string description_;
66 GURL url_;
67 base::TimeTicks last_activity_time_; 78 base::TimeTicks last_activity_time_;
68 }; 79 };
69 80
70 Target::Target(WebContents* web_contents) { 81 Target::Target(scoped_refptr<DevToolsAgentHost> agent_host)
71 agent_host_ = 82 : agent_host_(agent_host) {
72 DevToolsAgentHost::GetOrCreateFor(web_contents); 83 if (WebContents* web_contents = agent_host->GetWebContents()) {
73 id_ = agent_host_->GetId(); 84 description_ = GetViewDescription(web_contents);
74 description_ = GetViewDescription(web_contents); 85 last_activity_time_ = web_contents->GetLastActiveTime();
75 title_ = base::UTF16ToUTF8(web_contents->GetTitle()); 86 }
76 url_ = web_contents->GetURL();
77 last_activity_time_ = web_contents->GetLastActiveTime();
78 } 87 }
79 88
80 // Delegate implementation for the devtools http handler for WebView. A new 89 // Delegate implementation for the devtools http handler for WebView. A new
81 // instance of this gets created each time web debugging is enabled. 90 // instance of this gets created each time web debugging is enabled.
82 class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { 91 class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
83 public: 92 public:
84 AwDevToolsServerDelegate() {} 93 AwDevToolsServerDelegate() {}
85 virtual ~AwDevToolsServerDelegate() {} 94 virtual ~AwDevToolsServerDelegate() {}
86 95
87 // DevToolsHttpProtocolHandler::Delegate overrides. 96 // DevToolsHttpProtocolHandler::Delegate overrides.
(...skipping 11 matching lines...) Expand all
99 return ""; 108 return "";
100 } 109 }
101 110
102 virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget( 111 virtual scoped_ptr<content::DevToolsTarget> CreateNewTarget(
103 const GURL&) OVERRIDE { 112 const GURL&) OVERRIDE {
104 return scoped_ptr<content::DevToolsTarget>(); 113 return scoped_ptr<content::DevToolsTarget>();
105 } 114 }
106 115
107 virtual void EnumerateTargets(TargetCallback callback) OVERRIDE { 116 virtual void EnumerateTargets(TargetCallback callback) OVERRIDE {
108 TargetList targets; 117 TargetList targets;
109 std::vector<WebContents*> wc_list = 118 DevToolsAgentHost::List agents = DevToolsAgentHost::GetOrCreateAll();
110 DevToolsAgentHost::GetInspectableWebContents(); 119 for (DevToolsAgentHost::List::iterator it = agents.begin();
111 for (std::vector<WebContents*>::iterator it = wc_list.begin(); 120 it != agents.end(); ++it) {
112 it != wc_list.end(); ++it) {
113 targets.push_back(new Target(*it)); 121 targets.push_back(new Target(*it));
114 } 122 }
115 callback.Run(targets); 123 callback.Run(targets);
116 } 124 }
117 125
118 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering( 126 virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
119 net::StreamListenSocket::Delegate* delegate, 127 net::StreamListenSocket::Delegate* delegate,
120 std::string* name) OVERRIDE { 128 std::string* name) OVERRIDE {
121 return scoped_ptr<net::StreamListenSocket>(); 129 return scoped_ptr<net::StreamListenSocket>();
122 } 130 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 AwDevToolsServer* devtools_server = 225 AwDevToolsServer* devtools_server =
218 reinterpret_cast<AwDevToolsServer*>(server); 226 reinterpret_cast<AwDevToolsServer*>(server);
219 if (enabled) { 227 if (enabled) {
220 devtools_server->Start(); 228 devtools_server->Start();
221 } else { 229 } else {
222 devtools_server->Stop(); 230 devtools_server->Stop();
223 } 231 }
224 } 232 }
225 233
226 } // namespace android_webview 234 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/dev_tools_server.cc » ('j') | chrome/browser/android/dev_tools_server.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698