OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/devtools/render_view_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "content/browser/child_process_security_policy_impl.h" | 9 #include "content/browser/child_process_security_policy_impl.h" |
10 #include "content/browser/devtools/devtools_manager_impl.h" | 10 #include "content/browser/devtools/devtools_manager_impl.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 if (cookie == (*it)->GetId()) { | 113 if (cookie == (*it)->GetId()) { |
114 (*it)->ConnectRenderViewHost(rvh, true); | 114 (*it)->ConnectRenderViewHost(rvh, true); |
115 break; | 115 break; |
116 } | 116 } |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 //static | 120 //static |
121 std::vector<RenderViewHost*> DevToolsAgentHost::GetValidRenderViewHosts() { | 121 std::vector<RenderViewHost*> DevToolsAgentHost::GetValidRenderViewHosts() { |
122 std::vector<RenderViewHost*> result; | 122 std::vector<RenderViewHost*> result; |
123 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); | 123 RenderWidgetHost::List widgets = RenderWidgetHost::GetRenderWidgetHosts(); |
124 !it.IsAtEnd(); it.Advance()) { | 124 for (size_t i = 0; i < widgets.size(); ++i) { |
125 RenderProcessHost* render_process_host = it.GetCurrentValue(); | |
126 DCHECK(render_process_host); | |
127 | |
128 // Ignore processes that don't have a connection, such as crashed contents. | 125 // Ignore processes that don't have a connection, such as crashed contents. |
129 if (!render_process_host->HasConnection()) | 126 if (!widgets[i]->GetProcess()->HasConnection()) |
| 127 continue; |
| 128 if (!widgets[i]->IsRenderView()) |
130 continue; | 129 continue; |
131 | 130 |
132 RenderProcessHost::RenderWidgetHostsIterator rwit( | 131 RenderViewHost* rvh = RenderViewHost::From(widgets[i]); |
133 render_process_host->GetRenderWidgetHostsIterator()); | 132 // Don't report swapped out views. |
134 for (; !rwit.IsAtEnd(); rwit.Advance()) { | 133 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()) |
135 const RenderWidgetHost* widget = rwit.GetCurrentValue(); | 134 continue; |
136 DCHECK(widget); | |
137 if (!widget || !widget->IsRenderView()) | |
138 continue; | |
139 | 135 |
140 RenderViewHost* rvh = | 136 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); |
141 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); | 137 // Don't report a RenderViewHost if it is not the current RenderViewHost |
142 // Don't report swapped out views. | 138 // for some WebContents. |
143 if (static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()) | 139 if (!web_contents || rvh != web_contents->GetRenderViewHost()) |
144 continue; | 140 continue; |
145 | 141 |
146 WebContents* web_contents = WebContents::FromRenderViewHost(rvh); | 142 result.push_back(rvh); |
147 // Don't report a RenderViewHost if it is not the current RenderViewHost | |
148 // for some WebContents. | |
149 if (!web_contents || rvh != web_contents->GetRenderViewHost()) | |
150 continue; | |
151 | |
152 result.push_back(rvh); | |
153 } | |
154 } | 143 } |
155 return result; | 144 return result; |
156 } | 145 } |
157 | 146 |
158 // static | 147 // static |
159 void RenderViewDevToolsAgentHost::OnCancelPendingNavigation( | 148 void RenderViewDevToolsAgentHost::OnCancelPendingNavigation( |
160 RenderViewHost* pending, | 149 RenderViewHost* pending, |
161 RenderViewHost* current) { | 150 RenderViewHost* current) { |
162 std::string cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending); | 151 std::string cookie = DevToolsAgentHost::DisconnectRenderViewHost(pending); |
163 if (cookie != std::string()) | 152 if (cookie != std::string()) |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 if (render_view_host_) | 322 if (render_view_host_) |
334 GetContentClient()->browser()->ClearCache(render_view_host_); | 323 GetContentClient()->browser()->ClearCache(render_view_host_); |
335 } | 324 } |
336 | 325 |
337 void RenderViewDevToolsAgentHost::OnClearBrowserCookies() { | 326 void RenderViewDevToolsAgentHost::OnClearBrowserCookies() { |
338 if (render_view_host_) | 327 if (render_view_host_) |
339 GetContentClient()->browser()->ClearCookies(render_view_host_); | 328 GetContentClient()->browser()->ClearCookies(render_view_host_); |
340 } | 329 } |
341 | 330 |
342 } // namespace content | 331 } // namespace content |
OLD | NEW |