| Index: content/browser/devtools/render_frame_devtools_agent_host.cc
|
| diff --git a/content/browser/devtools/render_frame_devtools_agent_host.cc b/content/browser/devtools/render_frame_devtools_agent_host.cc
|
| index 6b5fc43bbbb29ec8f68b9277ac90999d641785b4..d572f3a01ce58545eedcd97df0338556273a8d8d 100644
|
| --- a/content/browser/devtools/render_frame_devtools_agent_host.cc
|
| +++ b/content/browser/devtools/render_frame_devtools_agent_host.cc
|
| @@ -405,33 +405,42 @@ RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(
|
| // Note Page.setControlNavigations is intended to control navigations in the
|
| // main frame and all child frames and |page_handler_| only exists for the
|
| // main frame.
|
| - if (!agent_host || !agent_host->session())
|
| - return nullptr;
|
| - protocol::PageHandler* page_handler =
|
| - protocol::PageHandler::FromSession(agent_host->session());
|
| - if (!page_handler)
|
| + if (!agent_host)
|
| return nullptr;
|
| - return page_handler->CreateThrottleForNavigation(navigation_handle);
|
| + for (auto* page_handler : protocol::PageHandler::ForAgentHost(agent_host)) {
|
| + std::unique_ptr<NavigationThrottle> throttle =
|
| + page_handler->CreateThrottleForNavigation(navigation_handle);
|
| + if (throttle)
|
| + return throttle;
|
| + }
|
| + return nullptr;
|
| }
|
|
|
| // static
|
| bool RenderFrameDevToolsAgentHost::IsNetworkHandlerEnabled(
|
| FrameTreeNode* frame_tree_node) {
|
| RenderFrameDevToolsAgentHost* agent_host = GetAgentHostFor(frame_tree_node);
|
| - if (!agent_host || !agent_host->session())
|
| + if (!agent_host)
|
| return false;
|
| - return protocol::NetworkHandler::FromSession(agent_host->session())
|
| - ->enabled();
|
| + for (auto* network : protocol::NetworkHandler::ForAgentHost(agent_host)) {
|
| + if (network->enabled())
|
| + return true;
|
| + }
|
| + return false;
|
| }
|
|
|
| // static
|
| std::string RenderFrameDevToolsAgentHost::UserAgentOverride(
|
| FrameTreeNode* frame_tree_node) {
|
| RenderFrameDevToolsAgentHost* agent_host = GetAgentHostFor(frame_tree_node);
|
| - if (!agent_host || !agent_host->session())
|
| + if (!agent_host)
|
| return std::string();
|
| - return protocol::NetworkHandler::FromSession(agent_host->session())
|
| - ->UserAgentOverride();
|
| + for (auto* network : protocol::NetworkHandler::ForAgentHost(agent_host)) {
|
| + std::string override = network->UserAgentOverride();
|
| + if (!override.empty())
|
| + return override;
|
| + }
|
| + return std::string();
|
| }
|
|
|
| // static
|
| @@ -662,8 +671,8 @@ void RenderFrameDevToolsAgentHost::DidFinishNavigation(
|
| pending_->host() == navigation_handle->GetRenderFrameHost()) {
|
| CommitPending();
|
| }
|
| - if (session())
|
| - protocol::TargetHandler::FromSession(session())->UpdateServiceWorkers();
|
| + for (auto* target : protocol::TargetHandler::ForAgentHost(this))
|
| + target->UpdateServiceWorkers();
|
| } else if (pending_ && pending_->host()->GetFrameTreeNodeId() ==
|
| navigation_handle->GetFrameTreeNodeId()) {
|
| DiscardPending();
|
| @@ -696,8 +705,10 @@ void RenderFrameDevToolsAgentHost::DidFinishNavigation(
|
| DispatchBufferedProtocolMessagesIfNecessary();
|
|
|
| DCHECK(CheckConsistency());
|
| - if (session() && navigation_handle->HasCommitted())
|
| - protocol::TargetHandler::FromSession(session())->UpdateServiceWorkers();
|
| + if (navigation_handle->HasCommitted()) {
|
| + for (auto* target : protocol::TargetHandler::ForAgentHost(this))
|
| + target->UpdateServiceWorkers();
|
| + }
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::AboutToNavigateRenderFrame(
|
| @@ -742,15 +753,8 @@ void RenderFrameDevToolsAgentHost::OnFailedNavigation(
|
| const BeginNavigationParams& begin_params,
|
| net::Error error_code) {
|
| DCHECK(IsBrowserSideNavigationEnabled());
|
| - if (!session())
|
| - return;
|
| -
|
| - protocol::NetworkHandler* handler =
|
| - protocol::NetworkHandler::FromSession(session());
|
| - if (!handler)
|
| - return;
|
| -
|
| - handler->NavigationFailed(common_params, begin_params, error_code);
|
| + for (auto* network : protocol::NetworkHandler::ForAgentHost(this))
|
| + network->NavigationFailed(common_params, begin_params, error_code);
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::RenderFrameHostChanged(
|
| @@ -759,8 +763,8 @@ void RenderFrameDevToolsAgentHost::RenderFrameHostChanged(
|
| // CommitPending may destruct |this|.
|
| scoped_refptr<RenderFrameDevToolsAgentHost> protect(this);
|
|
|
| - if (session())
|
| - protocol::TargetHandler::FromSession(session())->UpdateFrames();
|
| + for (auto* target : protocol::TargetHandler::ForAgentHost(this))
|
| + target->UpdateFrames();
|
|
|
| if (IsBrowserSideNavigationEnabled() && !current_frame_crashed_)
|
| return;
|
| @@ -852,15 +856,13 @@ void RenderFrameDevToolsAgentHost::RenderProcessGone(
|
| case base::TERMINATION_STATUS_OOM_PROTECTED:
|
| #endif
|
| case base::TERMINATION_STATUS_LAUNCH_FAILED:
|
| - if (session())
|
| - protocol::InspectorHandler::FromSession(session())->TargetCrashed();
|
| + for (auto* inspector : protocol::InspectorHandler::ForAgentHost(this))
|
| + inspector->TargetCrashed();
|
| current_frame_crashed_ = true;
|
| break;
|
| default:
|
| - if (session()) {
|
| - protocol::InspectorHandler::FromSession(session())
|
| - ->TargetDetached("Render process gone.");
|
| - }
|
| + for (auto* inspector : protocol::InspectorHandler::ForAgentHost(this))
|
| + inspector->TargetDetached("Render process gone.");
|
| break;
|
| }
|
| DCHECK(CheckConsistency());
|
| @@ -888,10 +890,8 @@ bool RenderFrameDevToolsAgentHost::OnMessageReceived(
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::DidAttachInterstitialPage() {
|
| - protocol::PageHandler* page_handler =
|
| - session() ? protocol::PageHandler::FromSession(session()) : nullptr;
|
| - if (page_handler)
|
| - page_handler->DidAttachInterstitialPage();
|
| + for (auto* page : protocol::PageHandler::ForAgentHost(this))
|
| + page->DidAttachInterstitialPage();
|
|
|
| // TODO(dgozman): this may break for cross-process subframes.
|
| if (!pending_) {
|
| @@ -906,10 +906,8 @@ void RenderFrameDevToolsAgentHost::DidAttachInterstitialPage() {
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::DidDetachInterstitialPage() {
|
| - protocol::PageHandler* page_handler =
|
| - session() ? protocol::PageHandler::FromSession(session()) : nullptr;
|
| - if (page_handler)
|
| - page_handler->DidDetachInterstitialPage();
|
| + for (auto* page : protocol::PageHandler::ForAgentHost(this))
|
| + page->DidDetachInterstitialPage();
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::WasShown() {
|
| @@ -923,21 +921,21 @@ void RenderFrameDevToolsAgentHost::WasHidden() {
|
| }
|
|
|
| void RenderFrameDevToolsAgentHost::DidReceiveCompositorFrame() {
|
| - if (!session())
|
| - return;
|
| const cc::CompositorFrameMetadata& metadata =
|
| RenderWidgetHostImpl::From(
|
| web_contents()->GetRenderViewHost()->GetWidget())
|
| ->last_frame_metadata();
|
| - protocol::PageHandler* page_handler =
|
| - protocol::PageHandler::FromSession(session());
|
| - if (page_handler)
|
| - page_handler->OnSwapCompositorFrame(metadata.Clone());
|
| - protocol::InputHandler::FromSession(session())->OnSwapCompositorFrame(
|
| - metadata);
|
| - protocol::TracingHandler* tracing_handler =
|
| - protocol::TracingHandler::FromSession(session());
|
| - if (frame_trace_recorder_ && tracing_handler->did_initiate_recording()) {
|
| + for (auto* page : protocol::PageHandler::ForAgentHost(this))
|
| + page->OnSwapCompositorFrame(metadata.Clone());
|
| + for (auto* input : protocol::InputHandler::ForAgentHost(this))
|
| + input->OnSwapCompositorFrame(metadata);
|
| +
|
| + if (!frame_trace_recorder_)
|
| + return;
|
| + bool did_initiate_recording = false;
|
| + for (auto* tracing : protocol::TracingHandler::ForAgentHost(this))
|
| + did_initiate_recording |= tracing->did_initiate_recording();
|
| + if (did_initiate_recording) {
|
| frame_trace_recorder_->OnSwapCompositorFrame(
|
| current_ ? current_->host() : nullptr, metadata);
|
| }
|
| @@ -1115,20 +1113,19 @@ void RenderFrameDevToolsAgentHost::SignalSynchronousSwapCompositorFrame(
|
|
|
| void RenderFrameDevToolsAgentHost::SynchronousSwapCompositorFrame(
|
| cc::CompositorFrameMetadata frame_metadata) {
|
| - if (!session())
|
| + for (auto* page : protocol::PageHandler::ForAgentHost(this))
|
| + page->OnSynchronousSwapCompositorFrame(frame_metadata.Clone());
|
| + for (auto* input : protocol::InputHandler::ForAgentHost(this))
|
| + input->OnSwapCompositorFrame(frame_metadata);
|
| +
|
| + if (!frame_trace_recorder_)
|
| return;
|
| - protocol::PageHandler* page_handler =
|
| - protocol::PageHandler::FromSession(session());
|
| - if (page_handler)
|
| - page_handler->OnSynchronousSwapCompositorFrame(std::move(frame_metadata));
|
| - protocol::InputHandler::FromSession(session())
|
| - ->OnSwapCompositorFrame(frame_metadata);
|
| - protocol::TracingHandler* tracing_handler =
|
| - protocol::TracingHandler::FromSession(session());
|
| - if (frame_trace_recorder_ && tracing_handler->did_initiate_recording()) {
|
| + bool did_initiate_recording = false;
|
| + for (auto* tracing : protocol::TracingHandler::ForAgentHost(this))
|
| + did_initiate_recording |= tracing->did_initiate_recording();
|
| + if (did_initiate_recording) {
|
| frame_trace_recorder_->OnSynchronousSwapCompositorFrame(
|
| - current_ ? current_->host() : nullptr,
|
| - frame_metadata);
|
| + current_ ? current_->host() : nullptr, frame_metadata);
|
| }
|
| }
|
|
|
|
|