| Index: android_webview/native/aw_dev_tools_server.cc
|
| diff --git a/android_webview/native/aw_dev_tools_server.cc b/android_webview/native/aw_dev_tools_server.cc
|
| index 6783bae189ad5154a4c286036812efbe6c9e0491..a1373fd620f7520b5073c9565d99fa9244ce760e 100644
|
| --- a/android_webview/native/aw_dev_tools_server.cc
|
| +++ b/android_webview/native/aw_dev_tools_server.cc
|
| @@ -32,16 +32,17 @@ const char kFrontEndURL[] =
|
| const char kSocketNameFormat[] = "webview_devtools_remote_%d";
|
|
|
| const char kTargetTypePage[] = "page";
|
| +const char kTargetTypeOther[] = "other";
|
|
|
| std::string GetViewDescription(WebContents* web_contents);
|
|
|
| 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 GetParentId() const OVERRIDE { return std::string(); }
|
| - virtual std::string GetType() const OVERRIDE { return kTargetTypePage; }
|
| + virtual std::string GetType() const OVERRIDE { return type_; }
|
| virtual std::string GetTitle() const OVERRIDE { return title_; }
|
| virtual std::string GetDescription() const OVERRIDE { return description_; }
|
| virtual GURL GetURL() const OVERRIDE { return url_; }
|
| @@ -61,20 +62,26 @@ class Target : public content::DevToolsTarget {
|
| private:
|
| scoped_refptr<DevToolsAgentHost> agent_host_;
|
| std::string id_;
|
| + std::string type_;
|
| std::string title_;
|
| std::string description_;
|
| GURL url_;
|
| base::TimeTicks last_activity_time_;
|
| };
|
|
|
| -Target::Target(WebContents* web_contents) {
|
| - agent_host_ =
|
| - DevToolsAgentHost::GetOrCreateFor(web_contents->GetRenderViewHost());
|
| - id_ = agent_host_->GetId();
|
| - description_ = GetViewDescription(web_contents);
|
| - title_ = base::UTF16ToUTF8(web_contents->GetTitle());
|
| - url_ = web_contents->GetURL();
|
| - last_activity_time_ = web_contents->GetLastActiveTime();
|
| +Target::Target(scoped_refptr<DevToolsAgentHost> agent_host)
|
| + : agent_host_(agent_host),
|
| + id_(agent_host_->GetId()),
|
| + url_(agent_host_->GetURL()) {
|
| + type_ = kTargetTypeOther;
|
| + if (RenderViewHost* rvh = agent_host_->GetRenderViewHost()) {
|
| + if (WebContents* web_contents = WebContents::FromRenderViewHost(rvh)) {
|
| + description_ = GetViewDescription(web_contents);
|
| + title_ = base::UTF16ToUTF8(web_contents->GetTitle());
|
| + last_activity_time_ = web_contents->GetLastActiveTime();
|
| + type_ = kTargetTypePage;
|
| + }
|
| + }
|
| }
|
|
|
| // Delegate implementation for the devtools http handler for WebView. A new
|
| @@ -104,18 +111,7 @@ class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
|
| return scoped_ptr<content::DevToolsTarget>();
|
| }
|
|
|
| - virtual void EnumerateTargets(TargetCallback callback) OVERRIDE {
|
| - TargetList targets;
|
| - 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)
|
| - targets.push_back(new Target(web_contents));
|
| - }
|
| - callback.Run(targets);
|
| - }
|
| + virtual void EnumerateTargets(TargetCallback callback) OVERRIDE;
|
|
|
| virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(
|
| net::StreamListenSocket::Delegate* delegate,
|
| @@ -127,6 +123,20 @@ class AwDevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
|
| DISALLOW_COPY_AND_ASSIGN(AwDevToolsServerDelegate);
|
| };
|
|
|
| +static void CreateTargets(
|
| + const AwDevToolsServerDelegate::TargetCallback& callback,
|
| + const DevToolsAgentHost::List& agents) {
|
| + AwDevToolsServerDelegate::TargetList targets;
|
| + for (DevToolsAgentHost::List::const_iterator it = agents.begin();
|
| + it != agents.end(); ++it) {
|
| + targets.push_back(new Target(*it));
|
| + }
|
| + callback.Run(targets);
|
| +}
|
| +
|
| +void AwDevToolsServerDelegate::EnumerateTargets(TargetCallback callback) {
|
| + DevToolsAgentHost::GetOrCreateAllHosts(base::Bind(&CreateTargets, callback));
|
| +}
|
|
|
| std::string AwDevToolsServerDelegate::GetDiscoveryPageHTML() {
|
| const char html[] =
|
|
|