diff options
author | dgozman <dgozman@chromium.org> | 2015-04-22 10:48:21 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-22 17:50:20 +0000 |
commit | f72001505b06d68f7716b474e35865f33fffd4fe (patch) | |
tree | 9f1b9df53a2e40048e6e81afec51fb8c6a3db6e7 /chromecast | |
parent | 17c796f5d0df5855f9788d6b12d83ddcff309f10 (diff) | |
download | chromium_src-f72001505b06d68f7716b474e35865f33fffd4fe.zip chromium_src-f72001505b06d68f7716b474e35865f33fffd4fe.tar.gz chromium_src-f72001505b06d68f7716b474e35865f33fffd4fe.tar.bz2 |
Created devtools_discovery component.
New discovery is used in content shell, extensions and chromecast. Once all embedders migrate to devtools_discovery, DevToolsTarget will be removed from content.
BUG=476496
Review URL: https://codereview.chromium.org/1056343004
Cr-Commit-Position: refs/heads/master@{#326337}
Diffstat (limited to 'chromecast')
-rw-r--r-- | chromecast/browser/DEPS | 1 | ||||
-rw-r--r-- | chromecast/browser/devtools/cast_dev_tools_delegate.cc | 72 | ||||
-rw-r--r-- | chromecast/chromecast.gyp | 1 |
3 files changed, 7 insertions, 67 deletions
diff --git a/chromecast/browser/DEPS b/chromecast/browser/DEPS index e91498e..5306642 100644 --- a/chromecast/browser/DEPS +++ b/chromecast/browser/DEPS @@ -4,6 +4,7 @@ include_rules = [ "+cc/base/switches.h", "+chromecast", "+components/crash", + "+components/devtools_discovery", "+components/devtools_http_handler", "+components/network_hints/browser", "+content/public/browser", diff --git a/chromecast/browser/devtools/cast_dev_tools_delegate.cc b/chromecast/browser/devtools/cast_dev_tools_delegate.cc index d5bbf17..4144727 100644 --- a/chromecast/browser/devtools/cast_dev_tools_delegate.cc +++ b/chromecast/browser/devtools/cast_dev_tools_delegate.cc @@ -7,6 +7,7 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "base/strings/utf_string_conversions.h" +#include "components/devtools_discovery/devtools_discovery_manager.h" #include "content/public/browser/devtools_agent_host.h" #include "content/public/browser/devtools_target.h" #include "content/public/browser/favicon_status.h" @@ -20,67 +21,6 @@ namespace chromecast { namespace shell { -namespace { - -const char kTargetTypePage[] = "page"; -const char kTargetTypeServiceWorker[] = "service_worker"; -const char kTargetTypeSharedWorker[] = "worker"; -const char kTargetTypeOther[] = "other"; - -class Target : public content::DevToolsTarget { - public: - explicit Target(scoped_refptr<content::DevToolsAgentHost> agent_host); - - std::string GetId() const override { return agent_host_->GetId(); } - std::string GetParentId() const override { return std::string(); } - std::string GetType() const override { - switch (agent_host_->GetType()) { - case content::DevToolsAgentHost::TYPE_WEB_CONTENTS: - return kTargetTypePage; - case content::DevToolsAgentHost::TYPE_SERVICE_WORKER: - return kTargetTypeServiceWorker; - case content::DevToolsAgentHost::TYPE_SHARED_WORKER: - return kTargetTypeSharedWorker; - default: - break; - } - return kTargetTypeOther; - } - std::string GetTitle() const override { return agent_host_->GetTitle(); } - std::string GetDescription() const override { return std::string(); } - GURL GetURL() const override { return agent_host_->GetURL(); } - GURL GetFaviconURL() const override { return favicon_url_; } - base::TimeTicks GetLastActivityTime() const override { - return last_activity_time_; - } - bool IsAttached() const override { return agent_host_->IsAttached(); } - scoped_refptr<content::DevToolsAgentHost> GetAgentHost() const override { - return agent_host_; - } - bool Activate() const override { return agent_host_->Activate(); } - bool Close() const override { return agent_host_->Close(); } - - private: - scoped_refptr<content::DevToolsAgentHost> agent_host_; - GURL favicon_url_; - base::TimeTicks last_activity_time_; - - DISALLOW_COPY_AND_ASSIGN(Target); -}; - -Target::Target(scoped_refptr<content::DevToolsAgentHost> agent_host) - : agent_host_(agent_host) { - if (content::WebContents* web_contents = agent_host_->GetWebContents()) { - content::NavigationController& controller = web_contents->GetController(); - content::NavigationEntry* entry = controller.GetActiveEntry(); - if (entry != NULL && entry->GetURL().is_valid()) - favicon_url_ = entry->GetFavicon().url; - last_activity_time_ = web_contents->GetLastActiveTime(); - } -} - -} // namespace - // CastDevToolsDelegate ----------------------------------------------------- CastDevToolsDelegate::CastDevToolsDelegate() { @@ -129,12 +69,10 @@ CastDevToolsManagerDelegate::CreateNewTarget(const GURL& url) { void CastDevToolsManagerDelegate::EnumerateTargets(TargetCallback callback) { TargetList targets; - content::DevToolsAgentHost::List agents = - content::DevToolsAgentHost::GetOrCreateAll(); - for (content::DevToolsAgentHost::List::iterator it = agents.begin(); - it != agents.end(); ++it) { - targets.push_back(new Target(*it)); - } + devtools_discovery::DevToolsDiscoveryManager* discovery_manager = + devtools_discovery::DevToolsDiscoveryManager::GetInstance(); + for (const auto& descriptor : discovery_manager->GetDescriptors()) + targets.push_back(descriptor); callback.Run(targets); } diff --git a/chromecast/chromecast.gyp b/chromecast/chromecast.gyp index b9198ac..f6056b0 100644 --- a/chromecast/chromecast.gyp +++ b/chromecast/chromecast.gyp @@ -188,6 +188,7 @@ '../components/components.gyp:cdm_renderer', '../components/components.gyp:component_metrics_proto', '../components/components.gyp:crash_component', + '../components/components.gyp:devtools_discovery', '../components/components.gyp:devtools_http_handler', '../components/components.gyp:network_hints_browser', '../components/components.gyp:network_hints_renderer', |