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

Unified Diff: components/devtools_discovery/basic_target_descriptor.cc

Issue 1109483003: [DevTools] Migrate chrome to devtools_discovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@devtools-discovery-android
Patch Set: rebased Created 5 years, 8 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
« no previous file with comments | « components/devtools_discovery/basic_target_descriptor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bbb62d0f3c676d05527900b4fc414debb16e9e4d..d8d2f8386ef0b79e60154dde82e3ccbce19f7f78 100644
--- a/components/devtools_discovery/basic_target_descriptor.cc
+++ b/components/devtools_discovery/basic_target_descriptor.cc
@@ -18,9 +18,30 @@ 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.GetActiveEntry();
@@ -38,33 +59,23 @@ std::string BasicTargetDescriptor::GetId() const {
}
std::string BasicTargetDescriptor::GetParentId() const {
- return std::string();
+ return parent_id_;
}
std::string BasicTargetDescriptor::GetType() const {
- switch (agent_host_->GetType()) {
- case DevToolsAgentHost::TYPE_WEB_CONTENTS:
- return kTypePage;
- case DevToolsAgentHost::TYPE_SERVICE_WORKER:
- return kTypeServiceWorker;
- case DevToolsAgentHost::TYPE_SHARED_WORKER:
- return kTypeSharedWorker;
- default:
- break;
- }
- return kTypeOther;
+ return type_;
}
std::string BasicTargetDescriptor::GetTitle() const {
- return agent_host_->GetTitle();
+ return title_;
}
std::string BasicTargetDescriptor::GetDescription() const {
- return std::string();
+ return description_;
}
GURL BasicTargetDescriptor::GetURL() const {
- return agent_host_->GetURL();
+ return url_;
}
GURL BasicTargetDescriptor::GetFaviconURL() const {
« no previous file with comments | « components/devtools_discovery/basic_target_descriptor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698