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

Side by Side Diff: chromecast/shell/browser/devtools/cast_dev_tools_delegate.cc

Issue 517493003: Chromecast devtools delegate fixes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: always bundle Created 6 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 | chromecast/shell/browser/devtools/remote_debugging_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/shell/browser/devtools/cast_dev_tools_delegate.h" 5 #include "chromecast/shell/browser/devtools/cast_dev_tools_delegate.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/devtools_agent_host.h" 10 #include "content/public/browser/devtools_agent_host.h"
11 #include "content/public/browser/devtools_target.h" 11 #include "content/public/browser/devtools_target.h"
12 #include "content/public/browser/favicon_status.h" 12 #include "content/public/browser/favicon_status.h"
13 #include "content/public/browser/navigation_entry.h" 13 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_delegate.h" 16 #include "content/public/browser/web_contents_delegate.h"
17 #include "grit/shell_resources.h" 17 #include "grit/shell_resources.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 19
20 namespace chromecast { 20 namespace chromecast {
21 namespace shell { 21 namespace shell {
22 22
23 namespace { 23 namespace {
24 24
25 const char kTargetTypePage[] = "page"; 25 const char kTargetTypePage[] = "page";
26 const char kTargetTypeServiceWorker[] = "service_worker"; 26 const char kTargetTypeServiceWorker[] = "service_worker";
27 const char kTargetTypeSharedWorker[] = "worker";
27 const char kTargetTypeOther[] = "other"; 28 const char kTargetTypeOther[] = "other";
28 29
29 class Target : public content::DevToolsTarget { 30 class Target : public content::DevToolsTarget {
30 public: 31 public:
31 explicit Target(scoped_refptr<content::DevToolsAgentHost> agent_host); 32 explicit Target(scoped_refptr<content::DevToolsAgentHost> agent_host);
32 33
33 virtual std::string GetId() const OVERRIDE { return agent_host_->GetId(); } 34 virtual std::string GetId() const OVERRIDE { return agent_host_->GetId(); }
34 virtual std::string GetParentId() const OVERRIDE { return std::string(); } 35 virtual std::string GetParentId() const OVERRIDE { return std::string(); }
35 virtual std::string GetType() const OVERRIDE { 36 virtual std::string GetType() const OVERRIDE {
36 switch (agent_host_->GetType()) { 37 switch (agent_host_->GetType()) {
37 case content::DevToolsAgentHost::TYPE_WEB_CONTENTS: 38 case content::DevToolsAgentHost::TYPE_WEB_CONTENTS:
38 return kTargetTypePage; 39 return kTargetTypePage;
39 case content::DevToolsAgentHost::TYPE_SERVICE_WORKER: 40 case content::DevToolsAgentHost::TYPE_SERVICE_WORKER:
40 return kTargetTypeServiceWorker; 41 return kTargetTypeServiceWorker;
42 case content::DevToolsAgentHost::TYPE_SHARED_WORKER:
43 return kTargetTypeSharedWorker;
41 default: 44 default:
42 break; 45 break;
43 } 46 }
44 return kTargetTypeOther; 47 return kTargetTypeOther;
45 } 48 }
46 virtual std::string GetTitle() const OVERRIDE { 49 virtual std::string GetTitle() const OVERRIDE {
47 return agent_host_->GetTitle(); 50 return agent_host_->GetTitle();
48 } 51 }
49 virtual std::string GetDescription() const OVERRIDE { return std::string(); } 52 virtual std::string GetDescription() const OVERRIDE { return std::string(); }
50 virtual GURL GetURL() const OVERRIDE { return url_; } 53 virtual GURL GetURL() const OVERRIDE {
54 return agent_host_->GetURL();
55 }
51 virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; } 56 virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; }
52 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE { 57 virtual base::TimeTicks GetLastActivityTime() const OVERRIDE {
53 return last_activity_time_; 58 return last_activity_time_;
54 } 59 }
55 virtual bool IsAttached() const OVERRIDE { 60 virtual bool IsAttached() const OVERRIDE {
56 return agent_host_->IsAttached(); 61 return agent_host_->IsAttached();
57 } 62 }
58 virtual scoped_refptr<content::DevToolsAgentHost> GetAgentHost() 63 virtual scoped_refptr<content::DevToolsAgentHost> GetAgentHost()
59 const OVERRIDE { 64 const OVERRIDE {
60 return agent_host_; 65 return agent_host_;
61 } 66 }
62 virtual bool Activate() const OVERRIDE; 67 virtual bool Activate() const OVERRIDE {
63 virtual bool Close() const OVERRIDE; 68 return agent_host_->Activate();
69 }
70 virtual bool Close() const OVERRIDE {
71 return agent_host_->Close();
72 }
64 73
65 private: 74 private:
66 scoped_refptr<content::DevToolsAgentHost> agent_host_; 75 scoped_refptr<content::DevToolsAgentHost> agent_host_;
67 std::string id_;
68 std::string title_;
69 GURL url_;
70 GURL favicon_url_; 76 GURL favicon_url_;
71 base::TimeTicks last_activity_time_; 77 base::TimeTicks last_activity_time_;
72 78
73 DISALLOW_COPY_AND_ASSIGN(Target); 79 DISALLOW_COPY_AND_ASSIGN(Target);
74 }; 80 };
75 81
76 Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host) 82 Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host)
77 : agent_host_(agent_host) { 83 : agent_host_(agent_host) {
78 if (content::WebContents* web_contents = agent_host_->GetWebContents()) { 84 if (content::WebContents* web_contents = agent_host_->GetWebContents()) {
79 content::NavigationController& controller = web_contents->GetController(); 85 content::NavigationController& controller = web_contents->GetController();
80 content::NavigationEntry* entry = controller.GetActiveEntry(); 86 content::NavigationEntry* entry = controller.GetActiveEntry();
81 if (entry != NULL && entry->GetURL().is_valid()) 87 if (entry != NULL && entry->GetURL().is_valid())
82 favicon_url_ = entry->GetFavicon().url; 88 favicon_url_ = entry->GetFavicon().url;
83 last_activity_time_ = web_contents->GetLastActiveTime(); 89 last_activity_time_ = web_contents->GetLastActiveTime();
84 } 90 }
85 } 91 }
86 92
87 bool Target::Activate() const {
88 content::WebContents* web_contents = agent_host_->GetWebContents();
89 if (!web_contents)
90 return false;
91 web_contents->GetDelegate()->ActivateContents(web_contents);
92 return true;
93 }
94
95 bool Target::Close() const {
96 content::WebContents* web_contents = agent_host_->GetWebContents();
97 if (!web_contents)
98 return false;
99 web_contents->GetRenderViewHost()->ClosePage();
100 return true;
101 }
102
103 } // namespace 93 } // namespace
104 94
105 CastDevToolsDelegate::CastDevToolsDelegate() { 95 CastDevToolsDelegate::CastDevToolsDelegate() {
106 } 96 }
107 97
108 CastDevToolsDelegate::~CastDevToolsDelegate() { 98 CastDevToolsDelegate::~CastDevToolsDelegate() {
109 } 99 }
110 100
111 std::string CastDevToolsDelegate::GetDiscoveryPageHTML() { 101 std::string CastDevToolsDelegate::GetDiscoveryPageHTML() {
112 #if defined(OS_ANDROID)
113 return std::string();
114 #else
115 return ResourceBundle::GetSharedInstance().GetRawDataResource( 102 return ResourceBundle::GetSharedInstance().GetRawDataResource(
116 IDR_CAST_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); 103 IDR_CAST_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
117 #endif // defined(OS_ANDROID)
118 } 104 }
119 105
120 bool CastDevToolsDelegate::BundlesFrontendResources() { 106 bool CastDevToolsDelegate::BundlesFrontendResources() {
121 #if defined(OS_ANDROID)
122 // Since Android remote debugging connects over a Unix domain socket, Chrome
123 // will not load the same homepage.
124 return false;
125 #else
126 return true; 107 return true;
127 #endif // defined(OS_ANDROID)
128 } 108 }
129 109
130 base::FilePath CastDevToolsDelegate::GetDebugFrontendDir() { 110 base::FilePath CastDevToolsDelegate::GetDebugFrontendDir() {
131 return base::FilePath(); 111 return base::FilePath();
132 } 112 }
133 113
134 std::string CastDevToolsDelegate::GetPageThumbnailData(const GURL& url) { 114 std::string CastDevToolsDelegate::GetPageThumbnailData(const GURL& url) {
135 return ""; 115 return "";
136 } 116 }
137 117
(...skipping 15 matching lines...) Expand all
153 133
154 scoped_ptr<net::StreamListenSocket> 134 scoped_ptr<net::StreamListenSocket>
155 CastDevToolsDelegate::CreateSocketForTethering( 135 CastDevToolsDelegate::CreateSocketForTethering(
156 net::StreamListenSocket::Delegate* delegate, 136 net::StreamListenSocket::Delegate* delegate,
157 std::string* name) { 137 std::string* name) {
158 return scoped_ptr<net::StreamListenSocket>(); 138 return scoped_ptr<net::StreamListenSocket>();
159 } 139 }
160 140
161 } // namespace shell 141 } // namespace shell
162 } // namespace chromecast 142 } // namespace chromecast
OLDNEW
« no previous file with comments | « no previous file | chromecast/shell/browser/devtools/remote_debugging_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698