Chromium Code Reviews| Index: content/renderer/render_frame_impl.cc |
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
| index 5007f28f5c19f40d05bae2cdb26a00a3940ca5de..0b20f4d0c261943d8cbc8083301f531a04b66353 100644 |
| --- a/content/renderer/render_frame_impl.cc |
| +++ b/content/renderer/render_frame_impl.cc |
| @@ -141,6 +141,7 @@ |
| #include "content/renderer/stats_collection_controller.h" |
| #include "content/renderer/web_frame_utils.h" |
| #include "content/renderer/web_ui_extension.h" |
| +#include "content/renderer/web_ui_extension_data.h" |
| #include "content/renderer/websharedworker_proxy.h" |
| #include "crypto/sha2.h" |
| #include "gin/modules/module_registry.h" |
| @@ -1246,8 +1247,6 @@ void RenderFrameImpl::Initialize() { |
| "parent", parent_id); |
| } |
| - MaybeEnableMojoBindings(); |
| - |
| #if BUILDFLAG(ENABLE_PLUGINS) |
| new PepperBrowserConnection(this); |
| #endif |
| @@ -1277,6 +1276,13 @@ void RenderFrameImpl::Initialize() { |
| DCHECK(render_view_->HasAddedInputHandler()); |
| input_handler_manager->RegisterRoutingID(GetRoutingID()); |
| } |
| + |
| + const base::CommandLine& command_line = |
| + *base::CommandLine::ForCurrentProcess(); |
| + if (command_line.HasSwitch(switches::kDomAutomationController)) |
| + enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
| + if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| + enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
| } |
| void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { |
| @@ -2671,6 +2677,21 @@ void RenderFrameImpl::GetInterfaceProvider( |
| browser_info.identity, browser_spec); |
| } |
| +void RenderFrameImpl::AllowBindings(int32_t enabled_bindings_flags) { |
| + if (IsMainFrame() && (enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) && |
|
Charlie Reis
2016/12/16 01:01:52
Should we have a TODO to move WebUIExtensionData t
Sam McNally
2017/01/12 09:27:09
Done.
|
| + !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) { |
| + // WebUIExtensionData deletes itself when |render_view_| is destroyed. |
| + new WebUIExtensionData(render_view_); |
| + } |
| + |
| + enabled_bindings_ |= enabled_bindings_flags; |
| + |
| + // Keep track of the total bindings accumulated in this process. |
| + RenderProcess::current()->AddBindings(enabled_bindings_flags); |
| + |
| + MaybeEnableMojoBindings(); |
| +} |
| + |
| // mojom::HostZoom implementation ---------------------------------------------- |
| void RenderFrameImpl::SetHostZoomLevel(const GURL& url, double zoom_level) { |
| @@ -3689,15 +3710,13 @@ void RenderFrameImpl::didCreateNewDocument(blink::WebLocalFrame* frame) { |
| void RenderFrameImpl::didClearWindowObject(blink::WebLocalFrame* frame) { |
| DCHECK_EQ(frame_, frame); |
| - int enabled_bindings = render_view_->GetEnabledBindings(); |
| - |
| - if (enabled_bindings & BINDINGS_POLICY_WEB_UI) |
| + if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) |
| WebUIExtension::Install(frame); |
| - if (enabled_bindings & BINDINGS_POLICY_DOM_AUTOMATION) |
| + if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) |
| DomAutomationController::Install(this, frame); |
| - if (enabled_bindings & BINDINGS_POLICY_STATS_COLLECTION) |
| + if (enabled_bindings_ & BINDINGS_POLICY_STATS_COLLECTION) |
| StatsCollectionController::Install(frame); |
| const base::CommandLine& command_line = |
| @@ -6201,7 +6220,6 @@ void RenderFrameImpl::SendUpdateState() { |
| } |
| void RenderFrameImpl::MaybeEnableMojoBindings() { |
| - int enabled_bindings = RenderProcess::current()->GetEnabledBindings(); |
|
Charlie Reis
2016/12/16 01:01:52
This might be wrong. Before, it was checking agai
Sam McNally
2017/01/12 09:27:08
This was the papering-over that made layout test m
|
| // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS |
| // are mutually exclusive. They provide access to Mojo bindings, but do so in |
| // incompatible ways. |
| @@ -6211,8 +6229,8 @@ void RenderFrameImpl::MaybeEnableMojoBindings() { |
| // Make sure that at most one of BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO |
| // and BINDINGS_POLICY_HEADLESS have been set. |
| // NOTE x & (x - 1) == 0 is true iff x is zero or a power of two. |
| - DCHECK_EQ((enabled_bindings & kAllBindingsTypes) & |
| - ((enabled_bindings & kAllBindingsTypes) - 1), |
| + DCHECK_EQ((enabled_bindings_ & kAllBindingsTypes) & |
| + ((enabled_bindings_ & kAllBindingsTypes) - 1), |
| 0); |
| // If an MojoBindingsController already exists for this RenderFrameImpl, avoid |
| @@ -6221,12 +6239,11 @@ void RenderFrameImpl::MaybeEnableMojoBindings() { |
| if (RenderFrameObserverTracker<MojoBindingsController>::Get(this)) |
| return; |
| - if (IsMainFrame() && |
| - enabled_bindings & BINDINGS_POLICY_WEB_UI) { |
| + if (IsMainFrame() && enabled_bindings_ & BINDINGS_POLICY_WEB_UI) { |
| new MojoBindingsController(this, MojoBindingsType::FOR_WEB_UI); |
| - } else if (enabled_bindings & BINDINGS_POLICY_MOJO) { |
| + } else if (enabled_bindings_ & BINDINGS_POLICY_MOJO) { |
| new MojoBindingsController(this, MojoBindingsType::FOR_LAYOUT_TESTS); |
| - } else if (enabled_bindings & BINDINGS_POLICY_HEADLESS) { |
| + } else if (enabled_bindings_ & BINDINGS_POLICY_HEADLESS) { |
| new MojoBindingsController(this, MojoBindingsType::FOR_HEADLESS); |
| } |
| } |
| @@ -6568,6 +6585,10 @@ bool RenderFrameImpl::IsBrowserSideNavigationPending() { |
| return browser_side_navigation_pending_; |
| } |
| +int RenderFrameImpl::GetEnabledBindings() const { |
| + return enabled_bindings_; |
| +} |
| + |
| blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
| if (frame_->document().isPluginDocument()) |
| return frame_->document().to<WebPluginDocument>().plugin(); |