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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 92 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
93 if (!devtools_manager) | 93 if (!devtools_manager) |
94 return false; | 94 return false; |
95 RenderViewHostDelegate* delegate = | 95 RenderViewHostDelegate* delegate = |
96 static_cast<WebContentsImpl*>(web_contents); | 96 static_cast<WebContentsImpl*>(web_contents); |
97 for (Instances::iterator it = g_instances.Get().begin(); | 97 for (Instances::iterator it = g_instances.Get().begin(); |
98 it != g_instances.Get().end(); ++it) { | 98 it != g_instances.Get().end(); ++it) { |
99 RenderViewHost* rvh = (*it)->render_view_host_; | 99 RenderViewHost* rvh = (*it)->render_view_host_; |
100 if (rvh && rvh->GetDelegate() != delegate) | 100 if (rvh && rvh->GetDelegate() != delegate) |
101 continue; | 101 continue; |
102 if (devtools_manager->GetDevToolsClientHostFor(*it)) | 102 if ((*it)->IsAttached()) |
103 return true; | 103 return true; |
104 } | 104 } |
105 return false; | 105 return false; |
106 } | 106 } |
107 | 107 |
108 // static | 108 // static |
109 std::string DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) { | 109 std::string DevToolsAgentHost::DisconnectRenderViewHost(RenderViewHost* rvh) { |
110 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(rvh); | 110 RenderViewDevToolsAgentHost* agent_host = FindAgentHost(rvh); |
111 if (!agent_host) | 111 if (!agent_host) |
112 return std::string(); | 112 return std::string(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 Source<BrowserContext>( | 225 Source<BrowserContext>( |
226 render_view_host_->GetSiteInstance()->GetProcess()-> | 226 render_view_host_->GetSiteInstance()->GetProcess()-> |
227 GetBrowserContext()), | 227 GetBrowserContext()), |
228 Details<RenderViewHost>(render_view_host_)); | 228 Details<RenderViewHost>(render_view_host_)); |
229 } | 229 } |
230 | 230 |
231 void RenderViewDevToolsAgentHost::NotifyClientDetaching() { | 231 void RenderViewDevToolsAgentHost::NotifyClientDetaching() { |
232 if (!render_view_host_) | 232 if (!render_view_host_) |
233 return; | 233 return; |
234 | 234 |
235 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | |
236 bool process_has_agents = false; | 235 bool process_has_agents = false; |
237 RenderProcessHost* render_process_host = render_view_host_->GetProcess(); | 236 RenderProcessHost* render_process_host = render_view_host_->GetProcess(); |
238 for (Instances::iterator it = g_instances.Get().begin(); | 237 for (Instances::iterator it = g_instances.Get().begin(); |
239 it != g_instances.Get().end(); ++it) { | 238 it != g_instances.Get().end(); ++it) { |
240 if (*it == this || !devtools_manager->GetDevToolsClientHostFor(*it)) | 239 if (*it == this || !(*it)->IsAttached()) |
241 continue; | 240 continue; |
242 RenderViewHost* rvh = (*it)->render_view_host(); | 241 RenderViewHost* rvh = (*it)->render_view_host(); |
243 if (rvh && rvh->GetProcess() == render_process_host) | 242 if (rvh && rvh->GetProcess() == render_process_host) |
244 process_has_agents = true; | 243 process_has_agents = true; |
245 } | 244 } |
246 | 245 |
247 // We are the last to disconnect from the renderer -> revoke permissions. | 246 // We are the last to disconnect from the renderer -> revoke permissions. |
248 if (!process_has_agents) { | 247 if (!process_has_agents) { |
249 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeReadRawCookies( | 248 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeReadRawCookies( |
250 render_process_host->GetID()); | 249 render_process_host->GetID()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 snapshot_bounds)) | 404 snapshot_bounds)) |
406 return false; | 405 return false; |
407 | 406 |
408 return base::Base64Encode(base::StringPiece( | 407 return base::Base64Encode(base::StringPiece( |
409 reinterpret_cast<char*>(&*png.begin()), | 408 reinterpret_cast<char*>(&*png.begin()), |
410 png.size()), | 409 png.size()), |
411 base_64_data); | 410 base_64_data); |
412 } | 411 } |
413 | 412 |
414 } // namespace content | 413 } // namespace content |
OLD | NEW |