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

Unified Diff: content/shell/browser/shell_devtools_delegate.cc

Issue 459403002: DevTools: Added service workers to remote debugging targets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remote debugger is now properly notified of service worker being closed Created 6 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: content/shell/browser/shell_devtools_delegate.cc
diff --git a/content/shell/browser/shell_devtools_delegate.cc b/content/shell/browser/shell_devtools_delegate.cc
index 0f4214f1d42367d51e1edefa89f2d1dd82234b57..70485e20ad16d094a6d171e25069bc4013b67a44 100644
--- a/content/shell/browser/shell_devtools_delegate.cc
+++ b/content/shell/browser/shell_devtools_delegate.cc
@@ -76,14 +76,21 @@ net::StreamListenSocketFactory* CreateSocketFactory() {
class Target : public content::DevToolsTarget {
public:
- explicit Target(WebContents* web_contents);
+ explicit Target(scoped_refptr<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 {
+ std::string result = agent_host_->GetType();
+ if (result == DevToolsAgentHost::kTypeWebContents)
+ result = kTargetTypePage;
+ return result;
+ }
+ 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_;
@@ -99,39 +106,27 @@ class Target : public content::DevToolsTarget {
private:
scoped_refptr<DevToolsAgentHost> agent_host_;
- std::string id_;
- std::string title_;
- GURL url_;
GURL favicon_url_;
base::TimeTicks last_activity_time_;
};
-Target::Target(WebContents* web_contents) {
- agent_host_ = 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<DevToolsAgentHost> agent_host)
+ : agent_host_(agent_host) {
+ if (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 {
- WebContents* web_contents = agent_host_->GetWebContents();
- if (!web_contents)
- return false;
- web_contents->GetDelegate()->ActivateContents(web_contents);
- return true;
+ return agent_host_->Activate();
}
bool Target::Close() const {
- WebContents* web_contents = agent_host_->GetWebContents();
- if (!web_contents)
- return false;
- web_contents->GetRenderViewHost()->ClosePage();
- return true;
+ return agent_host_->Close();
}
} // namespace
@@ -189,16 +184,16 @@ ShellDevToolsDelegate::CreateNewTarget(const GURL& url) {
NULL,
MSG_ROUTING_NONE,
gfx::Size());
- return scoped_ptr<DevToolsTarget>(new Target(shell->web_contents()));
+ return scoped_ptr<DevToolsTarget>(
+ new Target(DevToolsAgentHost::GetOrCreateFor(shell->web_contents())));
}
void ShellDevToolsDelegate::EnumerateTargets(TargetCallback callback) {
TargetList targets;
- std::vector<WebContents*> wc_list =
- content::DevToolsAgentHost::GetInspectableWebContents();
- for (std::vector<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);
« content/public/browser/devtools_agent_host.h ('K') | « content/public/browser/devtools_agent_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698