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 (devtools_manager->IsAttached(*it)) |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(); | 235 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
236 bool process_has_agents = false; | 236 bool process_has_agents = false; |
237 RenderProcessHost* render_process_host = render_view_host_->GetProcess(); | 237 RenderProcessHost* render_process_host = render_view_host_->GetProcess(); |
238 for (Instances::iterator it = g_instances.Get().begin(); | 238 for (Instances::iterator it = g_instances.Get().begin(); |
239 it != g_instances.Get().end(); ++it) { | 239 it != g_instances.Get().end(); ++it) { |
240 if (*it == this || !devtools_manager->GetDevToolsClientHostFor(*it)) | 240 if (*it == this || !devtools_manager->IsAttached(*it)) |
241 continue; | 241 continue; |
242 RenderViewHost* rvh = (*it)->render_view_host(); | 242 RenderViewHost* rvh = (*it)->render_view_host(); |
243 if (rvh && rvh->GetProcess() == render_process_host) | 243 if (rvh && rvh->GetProcess() == render_process_host) |
244 process_has_agents = true; | 244 process_has_agents = true; |
245 } | 245 } |
246 | 246 |
247 // We are the last to disconnect from the renderer -> revoke permissions. | 247 // We are the last to disconnect from the renderer -> revoke permissions. |
248 if (!process_has_agents) { | 248 if (!process_has_agents) { |
249 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeReadRawCookies( | 249 ChildProcessSecurityPolicyImpl::GetInstance()->RevokeReadRawCookies( |
250 render_process_host->GetID()); | 250 render_process_host->GetID()); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 snapshot_bounds)) | 405 snapshot_bounds)) |
406 return false; | 406 return false; |
407 | 407 |
408 return base::Base64Encode(base::StringPiece( | 408 return base::Base64Encode(base::StringPiece( |
409 reinterpret_cast<char*>(&*png.begin()), | 409 reinterpret_cast<char*>(&*png.begin()), |
410 png.size()), | 410 png.size()), |
411 base_64_data); | 411 base_64_data); |
412 } | 412 } |
413 | 413 |
414 } // namespace content | 414 } // namespace content |
OLD | NEW |