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(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;
+ case content::DevToolsAgentHost::TYPE_SHARED_WORKER:
+ return kTargetTypeSharedWorker;
+ 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 GetURL() const OVERRIDE {
+ return agent_host_->GetURL();
+ }
virtual GURL GetFaviconURL() const OVERRIDE { return favicon_url_; }
virtual base::TimeTicks GetLastActivityTime() const OVERRIDE {
return last_activity_time_;
const OVERRIDE {
return agent_host_;
}
- virtual bool Activate() const OVERRIDE;
- virtual bool Close() const OVERRIDE;
+ virtual bool Activate() const OVERRIDE {
+ return agent_host_->Activate();
+ }
+ virtual bool Close() const OVERRIDE {
+ return agent_host_->Close();
+ }
private:
scoped_refptr<content::DevToolsAgentHost> agent_host_;
- std::string id_;
- std::string title_;
- GURL url_;
GURL favicon_url_;
base::TimeTicks last_activity_time_;
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();
-}
-
-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;
+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() {
}
}
std::string CastDevToolsDelegate::GetDiscoveryPageHTML() {
-#if defined(OS_ANDROID)
- return std::string();
-#else
return ResourceBundle::GetSharedInstance().GetRawDataResource(
IDR_CAST_SHELL_DEVTOOLS_DISCOVERY_PAGE).as_string();
-#endif // defined(OS_ANDROID)
}
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;
-#endif // defined(OS_ANDROID)
}
base::FilePath CastDevToolsDelegate::GetDebugFrontendDir() {
return base::FilePath();
}
-std::string CastDevToolsDelegate::GetPageThumbnailData(const GURL& url) {
- return "";
+scoped_ptr<net::StreamListenSocket>
+CastDevToolsDelegate::CreateSocketForTethering(
+ net::StreamListenSocket::Delegate* delegate,
+ std::string* name) {
+ return scoped_ptr<net::StreamListenSocket>();
}
-scoped_ptr<content::DevToolsTarget> CastDevToolsDelegate::CreateNewTarget(
+// CastDevToolsManagerDelegate -----------------------------------------------
+
+CastDevToolsManagerDelegate::CastDevToolsManagerDelegate() {
+}
+
+CastDevToolsManagerDelegate::~CastDevToolsManagerDelegate() {
+}
+
+base::DictionaryValue* CastDevToolsManagerDelegate::HandleCommand(
+ content::DevToolsAgentHost* agent_host,
+ base::DictionaryValue* command) {
+ return NULL;
+}
+
+std::string CastDevToolsManagerDelegate::GetPageThumbnailData(
const GURL& url) {
+ return "";
+}
+
+scoped_ptr<content::DevToolsTarget>
+CastDevToolsManagerDelegate::CreateNewTarget(const GURL& url) {
return scoped_ptr<content::DevToolsTarget>();
}
-void CastDevToolsDelegate::EnumerateTargets(TargetCallback callback) {
+void CastDevToolsManagerDelegate::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);
}
-scoped_ptr<net::StreamListenSocket>
-CastDevToolsDelegate::CreateSocketForTethering(
- net::StreamListenSocket::Delegate* delegate,
- std::string* name) {
- return scoped_ptr<net::StreamListenSocket>();
-}
-
} // namespace shell
} // namespace chromecast