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

Unified Diff: components/devtools_discovery/basic_target_descriptor.cc

Issue 2277473007: Revert of DevTools: merge devtools target with devtools host, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/devtools_discovery/basic_target_descriptor.cc
diff --git a/components/devtools_discovery/basic_target_descriptor.cc b/components/devtools_discovery/basic_target_descriptor.cc
index 04e3ba58fc148515b7e578651cdd3507cfb7a5ac..29b52dd8cc97afddf7952e3bb129a58723b79b6e 100644
--- a/components/devtools_discovery/basic_target_descriptor.cc
+++ b/components/devtools_discovery/basic_target_descriptor.cc
@@ -13,16 +13,93 @@
namespace devtools_discovery {
+const char BasicTargetDescriptor::kTypePage[] = "page";
+const char BasicTargetDescriptor::kTypeServiceWorker[] = "service_worker";
+const char BasicTargetDescriptor::kTypeSharedWorker[] = "worker";
+const char BasicTargetDescriptor::kTypeOther[] = "other";
+
+namespace {
+
+std::string GetTypeFromAgentHost(DevToolsAgentHost* agent_host) {
+ switch (agent_host->GetType()) {
+ case DevToolsAgentHost::TYPE_WEB_CONTENTS:
+ return BasicTargetDescriptor::kTypePage;
+ case DevToolsAgentHost::TYPE_SERVICE_WORKER:
+ return BasicTargetDescriptor::kTypeServiceWorker;
+ case DevToolsAgentHost::TYPE_SHARED_WORKER:
+ return BasicTargetDescriptor::kTypeSharedWorker;
+ default:
+ break;
+ }
+ return BasicTargetDescriptor::kTypeOther;
+}
+
+} // namespace
+
BasicTargetDescriptor::BasicTargetDescriptor(
scoped_refptr<DevToolsAgentHost> agent_host)
- : agent_host_(agent_host) {
+ : agent_host_(agent_host),
+ type_(GetTypeFromAgentHost(agent_host.get())),
+ title_(agent_host->GetTitle()),
+ url_(agent_host->GetURL()) {
+ if (content::WebContents* web_contents = agent_host_->GetWebContents()) {
+ content::NavigationController& controller = web_contents->GetController();
+ content::NavigationEntry* entry = controller.GetLastCommittedEntry();
+ if (entry != NULL && entry->GetURL().is_valid())
+ favicon_url_ = entry->GetFavicon().url;
+ last_activity_time_ = web_contents->GetLastActiveTime();
+ }
}
BasicTargetDescriptor::~BasicTargetDescriptor() {
+}
+
+std::string BasicTargetDescriptor::GetId() const {
+ return agent_host_->GetId();
+}
+
+std::string BasicTargetDescriptor::GetParentId() const {
+ return parent_id_;
+}
+
+std::string BasicTargetDescriptor::GetType() const {
+ return type_;
+}
+
+std::string BasicTargetDescriptor::GetTitle() const {
+ return title_;
+}
+
+std::string BasicTargetDescriptor::GetDescription() const {
+ return description_;
+}
+
+GURL BasicTargetDescriptor::GetURL() const {
+ return url_;
+}
+
+GURL BasicTargetDescriptor::GetFaviconURL() const {
+ return favicon_url_;
+}
+
+base::TimeTicks BasicTargetDescriptor::GetLastActivityTime() const {
+ return last_activity_time_;
+}
+
+bool BasicTargetDescriptor::IsAttached() const {
+ return agent_host_->IsAttached();
}
scoped_refptr<DevToolsAgentHost> BasicTargetDescriptor::GetAgentHost() const {
return agent_host_;
}
+bool BasicTargetDescriptor::Activate() const {
+ return agent_host_->Activate();
+}
+
+bool BasicTargetDescriptor::Close() const {
+ return agent_host_->Close();
+}
+
} // namespace devtools_discovery
« no previous file with comments | « components/devtools_discovery/basic_target_descriptor.h ('k') | components/devtools_discovery/devtools_discovery_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698