Commit 05a779da authored by dgozman's avatar dgozman Committed by Commit bot

Chromecast devtools delegate fixes.

This patch makes chromecast always bundle the frontend,
and exposes all content targets via remote debugging.

BUG=none

Review URL: https://codereview.chromium.org/517493003

Cr-Commit-Position: refs/heads/master@{#292865}
parent b3f4f911
...@@ -24,6 +24,7 @@ namespace { ...@@ -24,6 +24,7 @@ namespace {
const char kTargetTypePage[] = "page"; const char kTargetTypePage[] = "page";
const char kTargetTypeServiceWorker[] = "service_worker"; const char kTargetTypeServiceWorker[] = "service_worker";
const char kTargetTypeSharedWorker[] = "worker";
const char kTargetTypeOther[] = "other"; const char kTargetTypeOther[] = "other";
class Target : public content::DevToolsTarget { class Target : public content::DevToolsTarget {
...@@ -38,6 +39,8 @@ class Target : public content::DevToolsTarget { ...@@ -38,6 +39,8 @@ class Target : public content::DevToolsTarget {
return kTargetTypePage; return kTargetTypePage;
case content::DevToolsAgentHost::TYPE_SERVICE_WORKER: case content::DevToolsAgentHost::TYPE_SERVICE_WORKER:
return kTargetTypeServiceWorker; return kTargetTypeServiceWorker;
case content::DevToolsAgentHost::TYPE_SHARED_WORKER:
return kTargetTypeSharedWorker;
default: default:
break; break;
} }
...@@ -47,7 +50,9 @@ class Target : public content::DevToolsTarget { ...@@ -47,7 +50,9 @@ class Target : public content::DevToolsTarget {
return agent_host_->GetTitle(); return agent_host_->GetTitle();
} }
virtual std::string GetDescription() const OVERRIDE { return std::string(); } virtual std::string GetDescription() const OVERRIDE { return std::string(); }
virtual GURL GetURL() const OVERRIDE { return url_; } virtual GURL GetURL() const OVERRIDE {
return agent_host_->GetURL();
}
virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; } virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; }
virtual base::TimeTicks GetLastActivityTime() const OVERRIDE { virtual base::TimeTicks GetLastActivityTime() const OVERRIDE {
return last_activity_time_; return last_activity_time_;
...@@ -59,14 +64,15 @@ class Target : public content::DevToolsTarget { ...@@ -59,14 +64,15 @@ class Target : public content::DevToolsTarget {
const OVERRIDE { const OVERRIDE {
return agent_host_; return agent_host_;
} }
virtual bool Activate() const OVERRIDE; virtual bool Activate() const OVERRIDE {
virtual bool Close() const OVERRIDE; return agent_host_->Activate();
}
virtual bool Close() const OVERRIDE {
return agent_host_->Close();
}
private: private:
scoped_refptr<content::DevToolsAgentHost> agent_host_; scoped_refptr<content::DevToolsAgentHost> agent_host_;
std::string id_;
std::string title_;
GURL url_;
GURL favicon_url_; GURL favicon_url_;
base::TimeTicks last_activity_time_; base::TimeTicks last_activity_time_;
...@@ -84,22 +90,6 @@ Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host) ...@@ -84,22 +90,6 @@ Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host)
} }
} }
bool Target::Activate() const {
content::WebContents* web_contents = agent_host_->GetWebContents();
if (!web_contents)
return false;
web_contents->GetDelegate()->ActivateContents(web_contents);
return true;
}
bool Target::Close() const {
content::WebContents* web_contents = agent_host_->GetWebContents();
if (!web_contents)
return false;
web_contents->GetRenderViewHost()->ClosePage();
return true;
}
} // namespace } // namespace
CastDevToolsDelegate::CastDevToolsDelegate() { CastDevToolsDelegate::CastDevToolsDelegate() {
...@@ -109,22 +99,12 @@ CastDevToolsDelegate::~CastDevToolsDelegate() { ...@@ -109,22 +99,12 @@ CastDevToolsDelegate::~CastDevToolsDelegate() {
} }
std::string CastDevToolsDelegate::GetDiscoveryPageHTML() { std::string CastDevToolsDelegate::GetDiscoveryPageHTML() {
#if defined(OS_ANDROID)
return std::string();
#else
return ResourceBundle::GetSharedInstance().GetRawDataResource( return ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_CAST_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string(); IDR_CAST_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
#endif // defined(OS_ANDROID)
} }
bool CastDevToolsDelegate::BundlesFrontendResources() { bool CastDevToolsDelegate::BundlesFrontendResources() {
#if defined(OS_ANDROID)
// Since Android remote debugging connects over a Unix domain socket, Chrome
// will not load the same homepage.
return false;
#else
return true; return true;
#endif // defined(OS_ANDROID)
} }
base::FilePath CastDevToolsDelegate::GetDebugFrontendDir() { base::FilePath CastDevToolsDelegate::GetDebugFrontendDir() {
......
...@@ -29,10 +29,6 @@ namespace shell { ...@@ -29,10 +29,6 @@ namespace shell {
namespace { namespace {
#if defined(OS_ANDROID)
const char kFrontEndURL[] =
"http://chrome-devtools-frontend.appspot.com/serve_rev/%s/devtools.html";
#endif // defined(OS_ANDROID)
const int kDefaultRemoteDebuggingPort = 9222; const int kDefaultRemoteDebuggingPort = 9222;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -89,14 +85,6 @@ CreateSocketFactory(int port) { ...@@ -89,14 +85,6 @@ CreateSocketFactory(int port) {
#endif #endif
} }
std::string GetFrontendUrl() {
#if defined(OS_ANDROID)
return base::StringPrintf(kFrontEndURL, content::GetWebKitRevision().c_str());
#else
return std::string();
#endif // defined(OS_ANDROID)
}
} // namespace } // namespace
RemoteDebuggingServer::RemoteDebuggingServer() RemoteDebuggingServer::RemoteDebuggingServer()
...@@ -144,7 +132,7 @@ void RemoteDebuggingServer::OnPortChanged() { ...@@ -144,7 +132,7 @@ void RemoteDebuggingServer::OnPortChanged() {
if (port_ > 0) { if (port_ > 0) {
devtools_http_handler_ = content::DevToolsHttpHandler::Start( devtools_http_handler_ = content::DevToolsHttpHandler::Start(
CreateSocketFactory(port_), CreateSocketFactory(port_),
GetFrontendUrl(), std::string(),
new CastDevToolsDelegate(), new CastDevToolsDelegate(),
base::FilePath()); base::FilePath());
LOG(INFO) << "Devtools started: port=" << port_; LOG(INFO) << "Devtools started: port=" << port_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment