| 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_frame_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 
| 6 | 6 | 
| 7 #include <tuple> | 7 #include <tuple> | 
| 8 #include <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/guid.h" | 10 #include "base/guid.h" | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49 #include "content/public/common/browser_side_navigation_policy.h" | 49 #include "content/public/common/browser_side_navigation_policy.h" | 
| 50 #include "content/public/common/content_features.h" | 50 #include "content/public/common/content_features.h" | 
| 51 | 51 | 
| 52 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) | 
| 53 #include "content/public/browser/render_widget_host_view.h" | 53 #include "content/public/browser/render_widget_host_view.h" | 
| 54 #include "services/device/public/interfaces/wake_lock_context.mojom.h" | 54 #include "services/device/public/interfaces/wake_lock_context.mojom.h" | 
| 55 #endif | 55 #endif | 
| 56 | 56 | 
| 57 namespace content { | 57 namespace content { | 
| 58 | 58 | 
| 59 typedef std::vector<RenderFrameDevToolsAgentHost*> Instances; | 59 typedef std::vector<RenderFrameDevToolsAgentHost*> AgentHostArray; | 
| 60 | 60 | 
| 61 namespace { | 61 namespace { | 
| 62 base::LazyInstance<Instances>::Leaky g_instances = LAZY_INSTANCE_INITIALIZER; | 62 base::LazyInstance<AgentHostArray>::Leaky g_agent_host_instances = LAZY_INSTANCE
      _INITIALIZER; | 
| 63 | 63 | 
| 64 RenderFrameDevToolsAgentHost* FindAgentHost(FrameTreeNode* frame_tree_node) { | 64 RenderFrameDevToolsAgentHost* FindAgentHost(FrameTreeNode* frame_tree_node) { | 
| 65   if (g_instances == NULL) | 65   if (g_agent_host_instances == NULL) | 
| 66     return NULL; | 66     return NULL; | 
| 67   for (Instances::iterator it = g_instances.Get().begin(); | 67   for (AgentHostArray::iterator it = g_agent_host_instances.Get().begin(); | 
| 68        it != g_instances.Get().end(); ++it) { | 68        it != g_agent_host_instances.Get().end(); ++it) { | 
| 69     if ((*it)->frame_tree_node() == frame_tree_node) | 69     if ((*it)->frame_tree_node() == frame_tree_node) | 
| 70       return *it; | 70       return *it; | 
| 71   } | 71   } | 
| 72   return NULL; | 72   return NULL; | 
| 73 } | 73 } | 
| 74 | 74 | 
| 75 bool ShouldCreateDevToolsForHost(RenderFrameHost* rfh) { | 75 bool ShouldCreateDevToolsForHost(RenderFrameHost* rfh) { | 
| 76   return rfh->IsCrossProcessSubframe() || !rfh->GetParent(); | 76   return rfh->IsCrossProcessSubframe() || !rfh->GetParent(); | 
| 77 } | 77 } | 
| 78 | 78 | 
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 455     } | 455     } | 
| 456   } | 456   } | 
| 457   WebContentsObserver::Observe( | 457   WebContentsObserver::Observe( | 
| 458       WebContentsImpl::FromFrameTreeNode(frame_tree_node)); | 458       WebContentsImpl::FromFrameTreeNode(frame_tree_node)); | 
| 459 | 459 | 
| 460   if (web_contents() && web_contents()->GetCrashedStatus() != | 460   if (web_contents() && web_contents()->GetCrashedStatus() != | 
| 461       base::TERMINATION_STATUS_STILL_RUNNING) { | 461       base::TERMINATION_STATUS_STILL_RUNNING) { | 
| 462     current_frame_crashed_ = true; | 462     current_frame_crashed_ = true; | 
| 463   } | 463   } | 
| 464 | 464 | 
| 465   g_instances.Get().push_back(this); | 465   g_agent_host_instances.Get().push_back(this); | 
| 466   AddRef();  // Balanced in RenderFrameHostDestroyed. | 466   AddRef();  // Balanced in RenderFrameHostDestroyed. | 
| 467 | 467 | 
| 468   NotifyCreated(); | 468   NotifyCreated(); | 
| 469 } | 469 } | 
| 470 | 470 | 
| 471 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { | 471 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { | 
| 472   DCHECK(!IsBrowserSideNavigationEnabled()); | 472   DCHECK(!IsBrowserSideNavigationEnabled()); | 
| 473   DCHECK(!pending_); | 473   DCHECK(!pending_); | 
| 474   current_frame_crashed_ = false; | 474   current_frame_crashed_ = false; | 
| 475   pending_.reset(new FrameHostHolder(this, host)); | 475   pending_.reset(new FrameHostHolder(this, host)); | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 640 void RenderFrameDevToolsAgentHost::OnClientsDetached() { | 640 void RenderFrameDevToolsAgentHost::OnClientsDetached() { | 
| 641 #if defined(OS_ANDROID) | 641 #if defined(OS_ANDROID) | 
| 642   GetWakeLock()->CancelWakeLock(); | 642   GetWakeLock()->CancelWakeLock(); | 
| 643 #endif | 643 #endif | 
| 644   frame_trace_recorder_.reset(); | 644   frame_trace_recorder_.reset(); | 
| 645   if (IsBrowserSideNavigationEnabled()) | 645   if (IsBrowserSideNavigationEnabled()) | 
| 646     RevokePolicy(frame_host_); | 646     RevokePolicy(frame_host_); | 
| 647 } | 647 } | 
| 648 | 648 | 
| 649 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 649 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 
| 650   Instances::iterator it = std::find(g_instances.Get().begin(), | 650   AgentHostArray::iterator it = std::find(g_agent_host_instances.Get().begin(), | 
| 651                                      g_instances.Get().end(), | 651                                      g_agent_host_instances.Get().end(), | 
| 652                                      this); | 652                                      this); | 
| 653   if (it != g_instances.Get().end()) | 653   if (it != g_agent_host_instances.Get().end()) | 
| 654     g_instances.Get().erase(it); | 654     g_agent_host_instances.Get().erase(it); | 
| 655 } | 655 } | 
| 656 | 656 | 
| 657 void RenderFrameDevToolsAgentHost::ReadyToCommitNavigation( | 657 void RenderFrameDevToolsAgentHost::ReadyToCommitNavigation( | 
| 658     NavigationHandle* navigation_handle) { | 658     NavigationHandle* navigation_handle) { | 
| 659   if (!IsBrowserSideNavigationEnabled()) | 659   if (!IsBrowserSideNavigationEnabled()) | 
| 660     return; | 660     return; | 
| 661   NavigationHandleImpl* handle = | 661   NavigationHandleImpl* handle = | 
| 662       static_cast<NavigationHandleImpl*>(navigation_handle); | 662       static_cast<NavigationHandleImpl*>(navigation_handle); | 
| 663   if (handle->frame_tree_node() != frame_tree_node_) | 663   if (handle->frame_tree_node() != frame_tree_node_) | 
| 664     return; | 664     return; | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 779   ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadRawCookies( | 779   ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadRawCookies( | 
| 780       process_id); | 780       process_id); | 
| 781 } | 781 } | 
| 782 | 782 | 
| 783 void RenderFrameDevToolsAgentHost::RevokePolicy(RenderFrameHostImpl* host) { | 783 void RenderFrameDevToolsAgentHost::RevokePolicy(RenderFrameHostImpl* host) { | 
| 784   if (!host) | 784   if (!host) | 
| 785     return; | 785     return; | 
| 786 | 786 | 
| 787   bool process_has_agents = false; | 787   bool process_has_agents = false; | 
| 788   RenderProcessHost* process_host = host->GetProcess(); | 788   RenderProcessHost* process_host = host->GetProcess(); | 
| 789   for (RenderFrameDevToolsAgentHost* agent : g_instances.Get()) { | 789   for (RenderFrameDevToolsAgentHost* agent : g_agent_host_instances.Get()) { | 
| 790     if (!agent->IsAttached()) | 790     if (!agent->IsAttached()) | 
| 791       continue; | 791       continue; | 
| 792     if (IsBrowserSideNavigationEnabled()) { | 792     if (IsBrowserSideNavigationEnabled()) { | 
| 793       if (agent->frame_host_ && agent->frame_host_ != host && | 793       if (agent->frame_host_ && agent->frame_host_ != host && | 
| 794           agent->frame_host_->GetProcess() == process_host) { | 794           agent->frame_host_->GetProcess() == process_host) { | 
| 795         process_has_agents = true; | 795         process_has_agents = true; | 
| 796       } | 796       } | 
| 797       continue; | 797       continue; | 
| 798     } | 798     } | 
| 799     if (agent->current_ && agent->current_->host() != host && | 799     if (agent->current_ && agent->current_->host() != host && | 
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1349 | 1349 | 
| 1350   sender->Send(new DevToolsAgentMsg_RequestNewWindow_ACK( | 1350   sender->Send(new DevToolsAgentMsg_RequestNewWindow_ACK( | 
| 1351       sender->GetRoutingID(), success)); | 1351       sender->GetRoutingID(), success)); | 
| 1352 } | 1352 } | 
| 1353 | 1353 | 
| 1354 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1354 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 
| 1355   return frame_tree_node_ && frame_tree_node_->parent(); | 1355   return frame_tree_node_ && frame_tree_node_->parent(); | 
| 1356 } | 1356 } | 
| 1357 | 1357 | 
| 1358 }  // namespace content | 1358 }  // namespace content | 
| OLD | NEW | 
|---|