| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/browser/shell_devtools_delegate.h" | 5 #include "content/shell/browser/shell_devtools_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 private: | 100 private: |
| 101 scoped_refptr<DevToolsAgentHost> agent_host_; | 101 scoped_refptr<DevToolsAgentHost> agent_host_; |
| 102 std::string id_; | 102 std::string id_; |
| 103 std::string title_; | 103 std::string title_; |
| 104 GURL url_; | 104 GURL url_; |
| 105 GURL favicon_url_; | 105 GURL favicon_url_; |
| 106 base::TimeTicks last_activity_time_; | 106 base::TimeTicks last_activity_time_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 Target::Target(WebContents* web_contents) { | 109 Target::Target(WebContents* web_contents) { |
| 110 agent_host_ = | 110 agent_host_ = DevToolsAgentHost::GetOrCreateFor(web_contents); |
| 111 DevToolsAgentHost::GetOrCreateFor(web_contents->GetRenderViewHost()); | |
| 112 id_ = agent_host_->GetId(); | 111 id_ = agent_host_->GetId(); |
| 113 title_ = base::UTF16ToUTF8(web_contents->GetTitle()); | 112 title_ = base::UTF16ToUTF8(web_contents->GetTitle()); |
| 114 url_ = web_contents->GetURL(); | 113 url_ = web_contents->GetURL(); |
| 115 content::NavigationController& controller = web_contents->GetController(); | 114 content::NavigationController& controller = web_contents->GetController(); |
| 116 content::NavigationEntry* entry = controller.GetActiveEntry(); | 115 content::NavigationEntry* entry = controller.GetActiveEntry(); |
| 117 if (entry != NULL && entry->GetURL().is_valid()) | 116 if (entry != NULL && entry->GetURL().is_valid()) |
| 118 favicon_url_ = entry->GetFavicon().url; | 117 favicon_url_ = entry->GetFavicon().url; |
| 119 last_activity_time_ = web_contents->GetLastActiveTime(); | 118 last_activity_time_ = web_contents->GetLastActiveTime(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 bool Target::Activate() const { | 121 bool Target::Activate() const { |
| 123 RenderViewHost* rvh = agent_host_->GetRenderViewHost(); | 122 WebContents* web_contents = agent_host_->GetWebContents(); |
| 124 if (!rvh) | |
| 125 return false; | |
| 126 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); | |
| 127 if (!web_contents) | 123 if (!web_contents) |
| 128 return false; | 124 return false; |
| 129 web_contents->GetDelegate()->ActivateContents(web_contents); | 125 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 130 return true; | 126 return true; |
| 131 } | 127 } |
| 132 | 128 |
| 133 bool Target::Close() const { | 129 bool Target::Close() const { |
| 134 RenderViewHost* rvh = agent_host_->GetRenderViewHost(); | 130 WebContents* web_contents = agent_host_->GetWebContents(); |
| 135 if (!rvh) | 131 if (!web_contents) |
| 136 return false; | 132 return false; |
| 137 rvh->ClosePage(); | 133 web_contents->GetRenderViewHost()->ClosePage(); |
| 138 return true; | 134 return true; |
| 139 } | 135 } |
| 140 | 136 |
| 141 } // namespace | 137 } // namespace |
| 142 | 138 |
| 143 namespace content { | 139 namespace content { |
| 144 | 140 |
| 145 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) | 141 ShellDevToolsDelegate::ShellDevToolsDelegate(BrowserContext* browser_context) |
| 146 : browser_context_(browser_context) { | 142 : browser_context_(browser_context) { |
| 147 std::string frontend_url; | 143 std::string frontend_url; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 Shell* shell = Shell::CreateNewWindow(browser_context_, | 187 Shell* shell = Shell::CreateNewWindow(browser_context_, |
| 192 url, | 188 url, |
| 193 NULL, | 189 NULL, |
| 194 MSG_ROUTING_NONE, | 190 MSG_ROUTING_NONE, |
| 195 gfx::Size()); | 191 gfx::Size()); |
| 196 return scoped_ptr<DevToolsTarget>(new Target(shell->web_contents())); | 192 return scoped_ptr<DevToolsTarget>(new Target(shell->web_contents())); |
| 197 } | 193 } |
| 198 | 194 |
| 199 void ShellDevToolsDelegate::EnumerateTargets(TargetCallback callback) { | 195 void ShellDevToolsDelegate::EnumerateTargets(TargetCallback callback) { |
| 200 TargetList targets; | 196 TargetList targets; |
| 201 std::vector<RenderViewHost*> rvh_list = | 197 std::vector<WebContents*> wc_list = |
| 202 content::DevToolsAgentHost::GetValidRenderViewHosts(); | 198 content::DevToolsAgentHost::GetInspectableWebContents(); |
| 203 for (std::vector<RenderViewHost*>::iterator it = rvh_list.begin(); | 199 for (std::vector<WebContents*>::iterator it = wc_list.begin(); |
| 204 it != rvh_list.end(); ++it) { | 200 it != wc_list.end(); |
| 205 WebContents* web_contents = WebContents::FromRenderViewHost(*it); | 201 ++it) { |
| 206 if (web_contents) | 202 targets.push_back(new Target(*it)); |
| 207 targets.push_back(new Target(web_contents)); | |
| 208 } | 203 } |
| 209 callback.Run(targets); | 204 callback.Run(targets); |
| 210 } | 205 } |
| 211 | 206 |
| 212 scoped_ptr<net::StreamListenSocket> | 207 scoped_ptr<net::StreamListenSocket> |
| 213 ShellDevToolsDelegate::CreateSocketForTethering( | 208 ShellDevToolsDelegate::CreateSocketForTethering( |
| 214 net::StreamListenSocket::Delegate* delegate, | 209 net::StreamListenSocket::Delegate* delegate, |
| 215 std::string* name) { | 210 std::string* name) { |
| 216 return scoped_ptr<net::StreamListenSocket>(); | 211 return scoped_ptr<net::StreamListenSocket>(); |
| 217 } | 212 } |
| 218 | 213 |
| 219 } // namespace content | 214 } // namespace content |
| OLD | NEW |