Index: chrome/browser/android/dev_tools_server.cc |
diff --git a/chrome/browser/android/dev_tools_server.cc b/chrome/browser/android/dev_tools_server.cc |
index ff1acd3bf99cb6ee9a5d5047c44144b50c49610a..7e360c94800c59ac92dcc614fa7da799ceef0652 100644 |
--- a/chrome/browser/android/dev_tools_server.cc |
+++ b/chrome/browser/android/dev_tools_server.cc |
@@ -102,8 +102,8 @@ class TargetBase : public content::DevToolsTarget { |
last_activity_time_(web_contents->GetLastActiveTime()) { |
} |
- TargetBase(const base::string16& title, const GURL& url) |
- : title_(base::UTF16ToUTF8(title)), |
+ TargetBase(const std::string& title, const GURL& url) |
+ : title_(title), |
url_(url) |
{} |
@@ -188,7 +188,7 @@ class TabTarget : public TargetBase { |
} |
TabTarget(int tab_id, const base::string16& title, const GURL& url) |
- : TargetBase(title, url), |
+ : TargetBase(base::UTF16ToUTF8(title), url), |
tab_id_(tab_id) { |
} |
@@ -213,10 +213,9 @@ class TabTarget : public TargetBase { |
class NonTabTarget : public TargetBase { |
public: |
- explicit NonTabTarget(WebContents* web_contents) |
- : TargetBase(web_contents), |
- agent_host_(DevToolsAgentHost::GetOrCreateFor( |
- web_contents->GetRenderViewHost())) { |
+ explicit NonTabTarget(scoped_refptr<DevToolsAgentHost> agent_host) |
+ : TargetBase("", agent_host->GetURL()), |
+ agent_host_(agent_host) { |
} |
// content::DevToolsTarget implementation: |
@@ -323,6 +322,12 @@ class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { |
} |
virtual void EnumerateTargets(TargetCallback callback) OVERRIDE { |
+ DevToolsAgentHost::GetOrCreateAllHosts( |
+ base::Bind(&DevToolsServerDelegate::CreateAllTargets, callback)); |
+ } |
+ |
+ static void CreateAllTargets(const TargetCallback& callback, |
+ const DevToolsAgentHost::List& agent_hosts) { |
TargetList targets; |
// Enumerate existing tabs, including the ones with no WebContents. |
@@ -346,16 +351,15 @@ class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate { |
} |
// Add targets for WebContents not associated with any tabs. |
- std::vector<RenderViewHost*> rvh_list = |
- DevToolsAgentHost::GetValidRenderViewHosts(); |
- for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin(); |
- it != rvh_list.end(); ++it) { |
- WebContents* web_contents = WebContents::FromRenderViewHost(*it); |
- if (!web_contents) |
- continue; |
- if (tab_web_contents.find(web_contents) != tab_web_contents.end()) |
- continue; |
- targets.push_back(new NonTabTarget(web_contents)); |
+ for (DevToolsAgentHost::List::const_iterator it = agent_hosts.begin(); |
+ it != agent_hosts.end(); ++it) { |
+ if (RenderViewHost* rvh = (*it)->GetRenderViewHost()) { |
+ if (WebContents* web_contents = WebContents::FromRenderViewHost(rvh)) { |
+ if (tab_web_contents.find(web_contents) != tab_web_contents.end()) |
+ continue; |
+ } |
+ } |
+ targets.push_back(new NonTabTarget(*it)); |
} |
callback.Run(targets); |