| Index: chromecast/shell/browser/devtools/cast_dev_tools_delegate.cc
|
| diff --git a/chromecast/shell/browser/devtools/cast_dev_tools_delegate.cc b/chromecast/shell/browser/devtools/cast_dev_tools_delegate.cc
|
| index 77cfba1f3d1a4e612562d857fb0af736fce6b6d0..fa61a30d92a4eedd1eae6a56643d62b3a547af52 100644
|
| --- a/chromecast/shell/browser/devtools/cast_dev_tools_delegate.cc
|
| +++ b/chromecast/shell/browser/devtools/cast_dev_tools_delegate.cc
|
| @@ -23,15 +23,29 @@ namespace shell {
|
| namespace {
|
|
|
| const char kTargetTypePage[] = "page";
|
| +const char kTargetTypeServiceWorker[] = "service_worker";
|
| +const char kTargetTypeOther[] = "other";
|
|
|
| class Target : public content::DevToolsTarget {
|
| public:
|
| - explicit Target(content::WebContents* web_contents);
|
| + explicit Target(scoped_refptr<content::DevToolsAgentHost> agent_host);
|
|
|
| - virtual std::string GetId() const OVERRIDE { return id_; }
|
| + virtual std::string GetId() const OVERRIDE { return agent_host_->GetId(); }
|
| virtual std::string GetParentId() const OVERRIDE { return std::string(); }
|
| - virtual std::string GetType() const OVERRIDE { return kTargetTypePage; }
|
| - virtual std::string GetTitle() const OVERRIDE { return title_; }
|
| + virtual 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;
|
| + default:
|
| + break;
|
| + }
|
| + return kTargetTypeOther;
|
| + }
|
| + virtual std::string GetTitle() const OVERRIDE {
|
| + return agent_host_->GetTitle();
|
| + }
|
| virtual std::string GetDescription() const OVERRIDE { return std::string(); }
|
| virtual GURL GetURL() const OVERRIDE { return url_; }
|
| virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; }
|
| @@ -59,16 +73,15 @@ class Target : public content::DevToolsTarget {
|
| DISALLOW_COPY_AND_ASSIGN(Target);
|
| };
|
|
|
| -Target::Target(content::WebContents* web_contents) {
|
| - agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents);
|
| - id_ = agent_host_->GetId();
|
| - title_ = base::UTF16ToUTF8(web_contents->GetTitle());
|
| - url_ = web_contents->GetURL();
|
| - 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();
|
| +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();
|
| + }
|
| }
|
|
|
| bool Target::Activate() const {
|
| @@ -129,11 +142,10 @@ scoped_ptr<content::DevToolsTarget> CastDevToolsDelegate::CreateNewTarget(
|
|
|
| void CastDevToolsDelegate::EnumerateTargets(TargetCallback callback) {
|
| TargetList targets;
|
| - std::vector<content::WebContents*> wc_list =
|
| - content::DevToolsAgentHost::GetInspectableWebContents();
|
| - for (std::vector<content::WebContents*>::iterator it = wc_list.begin();
|
| - it != wc_list.end();
|
| - ++it) {
|
| + 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));
|
| }
|
| callback.Run(targets);
|
|
|