OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 #include "content/renderer/render_widget_fullscreen_pepper.h" | 134 #include "content/renderer/render_widget_fullscreen_pepper.h" |
135 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 135 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
136 #include "content/renderer/renderer_webcolorchooser_impl.h" | 136 #include "content/renderer/renderer_webcolorchooser_impl.h" |
137 #include "content/renderer/savable_resources.h" | 137 #include "content/renderer/savable_resources.h" |
138 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" | 138 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" |
139 #include "content/renderer/shared_worker_repository.h" | 139 #include "content/renderer/shared_worker_repository.h" |
140 #include "content/renderer/skia_benchmarking_extension.h" | 140 #include "content/renderer/skia_benchmarking_extension.h" |
141 #include "content/renderer/stats_collection_controller.h" | 141 #include "content/renderer/stats_collection_controller.h" |
142 #include "content/renderer/web_frame_utils.h" | 142 #include "content/renderer/web_frame_utils.h" |
143 #include "content/renderer/web_ui_extension.h" | 143 #include "content/renderer/web_ui_extension.h" |
144 #include "content/renderer/web_ui_extension_data.h" | |
144 #include "content/renderer/websharedworker_proxy.h" | 145 #include "content/renderer/websharedworker_proxy.h" |
145 #include "crypto/sha2.h" | 146 #include "crypto/sha2.h" |
146 #include "gin/modules/module_registry.h" | 147 #include "gin/modules/module_registry.h" |
147 #include "media/audio/audio_output_device.h" | 148 #include "media/audio/audio_output_device.h" |
148 #include "media/base/audio_renderer_mixer_input.h" | 149 #include "media/base/audio_renderer_mixer_input.h" |
149 #include "media/base/cdm_factory.h" | 150 #include "media/base/cdm_factory.h" |
150 #include "media/base/decoder_factory.h" | 151 #include "media/base/decoder_factory.h" |
151 #include "media/base/media.h" | 152 #include "media/base/media.h" |
152 #include "media/base/media_log.h" | 153 #include "media/base/media_log.h" |
153 #include "media/base/media_switches.h" | 154 #include "media/base/media_switches.h" |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1239 bool is_tracing_navigation = false; | 1240 bool is_tracing_navigation = false; |
1240 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); | 1241 TRACE_EVENT_CATEGORY_GROUP_ENABLED("navigation", &is_tracing_navigation); |
1241 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); | 1242 TRACE_EVENT_CATEGORY_GROUP_ENABLED("rail", &is_tracing_rail); |
1242 if (is_tracing_rail || is_tracing_navigation) { | 1243 if (is_tracing_rail || is_tracing_navigation) { |
1243 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); | 1244 int parent_id = GetRoutingIdForFrameOrProxy(frame_->parent()); |
1244 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", | 1245 TRACE_EVENT2("navigation,rail", "RenderFrameImpl::Initialize", |
1245 "id", routing_id_, | 1246 "id", routing_id_, |
1246 "parent", parent_id); | 1247 "parent", parent_id); |
1247 } | 1248 } |
1248 | 1249 |
1249 MaybeEnableMojoBindings(); | |
1250 | |
1251 #if BUILDFLAG(ENABLE_PLUGINS) | 1250 #if BUILDFLAG(ENABLE_PLUGINS) |
1252 new PepperBrowserConnection(this); | 1251 new PepperBrowserConnection(this); |
1253 #endif | 1252 #endif |
1254 new SharedWorkerRepository(this); | 1253 new SharedWorkerRepository(this); |
1255 | 1254 |
1256 if (IsLocalRoot()) { | 1255 if (IsLocalRoot()) { |
1257 // DevToolsAgent is a RenderFrameObserver, and will destruct itself | 1256 // DevToolsAgent is a RenderFrameObserver, and will destruct itself |
1258 // when |this| is deleted. | 1257 // when |this| is deleted. |
1259 devtools_agent_ = new DevToolsAgent(this); | 1258 devtools_agent_ = new DevToolsAgent(this); |
1260 } | 1259 } |
1261 | 1260 |
1262 RegisterMojoInterfaces(); | 1261 RegisterMojoInterfaces(); |
1263 | 1262 |
1264 // We delay calling this until we have the WebFrame so that any observer or | 1263 // We delay calling this until we have the WebFrame so that any observer or |
1265 // embedder can call GetWebFrame on any RenderFrame. | 1264 // embedder can call GetWebFrame on any RenderFrame. |
1266 GetContentClient()->renderer()->RenderFrameCreated(this); | 1265 GetContentClient()->renderer()->RenderFrameCreated(this); |
1267 | 1266 |
1268 #if defined(OS_ANDROID) | 1267 #if defined(OS_ANDROID) |
1269 new AppWebMessagePortClient(this); | 1268 new AppWebMessagePortClient(this); |
1270 #endif | 1269 #endif |
1271 | 1270 |
1272 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 1271 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
1273 // render_thread may be NULL in tests. | 1272 // render_thread may be NULL in tests. |
1274 InputHandlerManager* input_handler_manager = | 1273 InputHandlerManager* input_handler_manager = |
1275 render_thread ? render_thread->input_handler_manager() : nullptr; | 1274 render_thread ? render_thread->input_handler_manager() : nullptr; |
1276 if (input_handler_manager) { | 1275 if (input_handler_manager) { |
1277 DCHECK(render_view_->HasAddedInputHandler()); | 1276 DCHECK(render_view_->HasAddedInputHandler()); |
1278 input_handler_manager->RegisterRoutingID(GetRoutingID()); | 1277 input_handler_manager->RegisterRoutingID(GetRoutingID()); |
1279 } | 1278 } |
1279 | |
1280 const base::CommandLine& command_line = | |
1281 *base::CommandLine::ForCurrentProcess(); | |
1282 if (command_line.HasSwitch(switches::kDomAutomationController)) | |
1283 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | |
1284 if (command_line.HasSwitch(switches::kStatsCollectionController)) | |
1285 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | |
1280 } | 1286 } |
1281 | 1287 |
1282 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { | 1288 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { |
1283 DCHECK(!blame_context_); | 1289 DCHECK(!blame_context_); |
1284 blame_context_ = base::MakeUnique<FrameBlameContext>(this, parent_frame); | 1290 blame_context_ = base::MakeUnique<FrameBlameContext>(this, parent_frame); |
1285 blame_context_->Initialize(); | 1291 blame_context_->Initialize(); |
1286 } | 1292 } |
1287 | 1293 |
1288 RenderWidget* RenderFrameImpl::GetRenderWidget() { | 1294 RenderWidget* RenderFrameImpl::GetRenderWidget() { |
1289 return GetLocalRoot()->render_widget_.get(); | 1295 return GetLocalRoot()->render_widget_.get(); |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2664 service_manager::GetInterfaceProviderSpec( | 2670 service_manager::GetInterfaceProviderSpec( |
2665 mojom::kNavigation_FrameSpec, child_info.interface_provider_specs, | 2671 mojom::kNavigation_FrameSpec, child_info.interface_provider_specs, |
2666 &child_spec); | 2672 &child_spec); |
2667 service_manager::GetInterfaceProviderSpec( | 2673 service_manager::GetInterfaceProviderSpec( |
2668 mojom::kNavigation_FrameSpec, browser_info.interface_provider_specs, | 2674 mojom::kNavigation_FrameSpec, browser_info.interface_provider_specs, |
2669 &browser_spec); | 2675 &browser_spec); |
2670 interface_registry_->Bind(std::move(request), child_info.identity, child_spec, | 2676 interface_registry_->Bind(std::move(request), child_info.identity, child_spec, |
2671 browser_info.identity, browser_spec); | 2677 browser_info.identity, browser_spec); |
2672 } | 2678 } |
2673 | 2679 |
2680 void RenderFrameImpl::AllowBindings(int32_t enabled_bindings_flags) { | |
2681 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.
| |
2682 !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) { | |
2683 // WebUIExtensionData deletes itself when |render_view_| is destroyed. | |
2684 new WebUIExtensionData(render_view_); | |
2685 } | |
2686 | |
2687 enabled_bindings_ |= enabled_bindings_flags; | |
2688 | |
2689 // Keep track of the total bindings accumulated in this process. | |
2690 RenderProcess::current()->AddBindings(enabled_bindings_flags); | |
2691 | |
2692 MaybeEnableMojoBindings(); | |
2693 } | |
2694 | |
2674 // mojom::HostZoom implementation ---------------------------------------------- | 2695 // mojom::HostZoom implementation ---------------------------------------------- |
2675 | 2696 |
2676 void RenderFrameImpl::SetHostZoomLevel(const GURL& url, double zoom_level) { | 2697 void RenderFrameImpl::SetHostZoomLevel(const GURL& url, double zoom_level) { |
2677 // TODO(wjmaclean): We should see if this restriction is really necessary, | 2698 // TODO(wjmaclean): We should see if this restriction is really necessary, |
2678 // since it isn't enforced in other parts of the page zoom system (e.g. | 2699 // since it isn't enforced in other parts of the page zoom system (e.g. |
2679 // when a users changes the zoom of a currently displayed page). Android | 2700 // when a users changes the zoom of a currently displayed page). Android |
2680 // has no UI for this, so in theory the following code would normally just use | 2701 // has no UI for this, so in theory the following code would normally just use |
2681 // the default zoom anyways. | 2702 // the default zoom anyways. |
2682 #if !defined(OS_ANDROID) | 2703 #if !defined(OS_ANDROID) |
2683 // On Android, page zoom isn't used, and in case of WebView, text zoom is used | 2704 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3682 | 3703 |
3683 for (auto& observer : observers_) | 3704 for (auto& observer : observers_) |
3684 observer.DidCreateNewDocument(); | 3705 observer.DidCreateNewDocument(); |
3685 for (auto& observer : render_view_->observers()) | 3706 for (auto& observer : render_view_->observers()) |
3686 observer.DidCreateNewDocument(frame); | 3707 observer.DidCreateNewDocument(frame); |
3687 } | 3708 } |
3688 | 3709 |
3689 void RenderFrameImpl::didClearWindowObject(blink::WebLocalFrame* frame) { | 3710 void RenderFrameImpl::didClearWindowObject(blink::WebLocalFrame* frame) { |
3690 DCHECK_EQ(frame_, frame); | 3711 DCHECK_EQ(frame_, frame); |
3691 | 3712 |
3692 int enabled_bindings = render_view_->GetEnabledBindings(); | 3713 if (enabled_bindings_ & BINDINGS_POLICY_WEB_UI) |
3693 | |
3694 if (enabled_bindings & BINDINGS_POLICY_WEB_UI) | |
3695 WebUIExtension::Install(frame); | 3714 WebUIExtension::Install(frame); |
3696 | 3715 |
3697 if (enabled_bindings & BINDINGS_POLICY_DOM_AUTOMATION) | 3716 if (enabled_bindings_ & BINDINGS_POLICY_DOM_AUTOMATION) |
3698 DomAutomationController::Install(this, frame); | 3717 DomAutomationController::Install(this, frame); |
3699 | 3718 |
3700 if (enabled_bindings & BINDINGS_POLICY_STATS_COLLECTION) | 3719 if (enabled_bindings_ & BINDINGS_POLICY_STATS_COLLECTION) |
3701 StatsCollectionController::Install(frame); | 3720 StatsCollectionController::Install(frame); |
3702 | 3721 |
3703 const base::CommandLine& command_line = | 3722 const base::CommandLine& command_line = |
3704 *base::CommandLine::ForCurrentProcess(); | 3723 *base::CommandLine::ForCurrentProcess(); |
3705 | 3724 |
3706 if (command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) | 3725 if (command_line.HasSwitch(cc::switches::kEnableGpuBenchmarking)) |
3707 GpuBenchmarking::Install(frame); | 3726 GpuBenchmarking::Install(frame); |
3708 | 3727 |
3709 if (command_line.HasSwitch(switches::kEnableSkiaBenchmarking)) | 3728 if (command_line.HasSwitch(switches::kEnableSkiaBenchmarking)) |
3710 SkiaBenchmarking::Install(frame); | 3729 SkiaBenchmarking::Install(frame); |
(...skipping 2483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6194 void RenderFrameImpl::SendUpdateState() { | 6213 void RenderFrameImpl::SendUpdateState() { |
6195 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | 6214 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
6196 if (current_history_item_.isNull()) | 6215 if (current_history_item_.isNull()) |
6197 return; | 6216 return; |
6198 | 6217 |
6199 Send(new FrameHostMsg_UpdateState( | 6218 Send(new FrameHostMsg_UpdateState( |
6200 routing_id_, SingleHistoryItemToPageState(current_history_item_))); | 6219 routing_id_, SingleHistoryItemToPageState(current_history_item_))); |
6201 } | 6220 } |
6202 | 6221 |
6203 void RenderFrameImpl::MaybeEnableMojoBindings() { | 6222 void RenderFrameImpl::MaybeEnableMojoBindings() { |
6204 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
| |
6205 // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS | 6223 // BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO and BINDINGS_POLICY_HEADLESS |
6206 // are mutually exclusive. They provide access to Mojo bindings, but do so in | 6224 // are mutually exclusive. They provide access to Mojo bindings, but do so in |
6207 // incompatible ways. | 6225 // incompatible ways. |
6208 const int kAllBindingsTypes = | 6226 const int kAllBindingsTypes = |
6209 BINDINGS_POLICY_WEB_UI | BINDINGS_POLICY_MOJO | BINDINGS_POLICY_HEADLESS; | 6227 BINDINGS_POLICY_WEB_UI | BINDINGS_POLICY_MOJO | BINDINGS_POLICY_HEADLESS; |
6210 | 6228 |
6211 // Make sure that at most one of BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO | 6229 // Make sure that at most one of BINDINGS_POLICY_WEB_UI, BINDINGS_POLICY_MOJO |
6212 // and BINDINGS_POLICY_HEADLESS have been set. | 6230 // and BINDINGS_POLICY_HEADLESS have been set. |
6213 // NOTE x & (x - 1) == 0 is true iff x is zero or a power of two. | 6231 // NOTE x & (x - 1) == 0 is true iff x is zero or a power of two. |
6214 DCHECK_EQ((enabled_bindings & kAllBindingsTypes) & | 6232 DCHECK_EQ((enabled_bindings_ & kAllBindingsTypes) & |
6215 ((enabled_bindings & kAllBindingsTypes) - 1), | 6233 ((enabled_bindings_ & kAllBindingsTypes) - 1), |
6216 0); | 6234 0); |
6217 | 6235 |
6218 // If an MojoBindingsController already exists for this RenderFrameImpl, avoid | 6236 // If an MojoBindingsController already exists for this RenderFrameImpl, avoid |
6219 // creating another one. It is not kept as a member, as it deletes itself when | 6237 // creating another one. It is not kept as a member, as it deletes itself when |
6220 // the frame is destroyed. | 6238 // the frame is destroyed. |
6221 if (RenderFrameObserverTracker<MojoBindingsController>::Get(this)) | 6239 if (RenderFrameObserverTracker<MojoBindingsController>::Get(this)) |
6222 return; | 6240 return; |
6223 | 6241 |
6224 if (IsMainFrame() && | 6242 if (IsMainFrame() && enabled_bindings_ & BINDINGS_POLICY_WEB_UI) { |
6225 enabled_bindings & BINDINGS_POLICY_WEB_UI) { | |
6226 new MojoBindingsController(this, MojoBindingsType::FOR_WEB_UI); | 6243 new MojoBindingsController(this, MojoBindingsType::FOR_WEB_UI); |
6227 } else if (enabled_bindings & BINDINGS_POLICY_MOJO) { | 6244 } else if (enabled_bindings_ & BINDINGS_POLICY_MOJO) { |
6228 new MojoBindingsController(this, MojoBindingsType::FOR_LAYOUT_TESTS); | 6245 new MojoBindingsController(this, MojoBindingsType::FOR_LAYOUT_TESTS); |
6229 } else if (enabled_bindings & BINDINGS_POLICY_HEADLESS) { | 6246 } else if (enabled_bindings_ & BINDINGS_POLICY_HEADLESS) { |
6230 new MojoBindingsController(this, MojoBindingsType::FOR_HEADLESS); | 6247 new MojoBindingsController(this, MojoBindingsType::FOR_HEADLESS); |
6231 } | 6248 } |
6232 } | 6249 } |
6233 | 6250 |
6234 void RenderFrameImpl::SendFailedProvisionalLoad( | 6251 void RenderFrameImpl::SendFailedProvisionalLoad( |
6235 const blink::WebURLRequest& request, | 6252 const blink::WebURLRequest& request, |
6236 const blink::WebURLError& error, | 6253 const blink::WebURLError& error, |
6237 blink::WebLocalFrame* frame) { | 6254 blink::WebLocalFrame* frame) { |
6238 bool show_repost_interstitial = | 6255 bool show_repost_interstitial = |
6239 (error.reason == net::ERR_CACHE_MISS && | 6256 (error.reason == net::ERR_CACHE_MISS && |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6561 } | 6578 } |
6562 | 6579 |
6563 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { | 6580 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { |
6564 return visibilityState(); | 6581 return visibilityState(); |
6565 } | 6582 } |
6566 | 6583 |
6567 bool RenderFrameImpl::IsBrowserSideNavigationPending() { | 6584 bool RenderFrameImpl::IsBrowserSideNavigationPending() { |
6568 return browser_side_navigation_pending_; | 6585 return browser_side_navigation_pending_; |
6569 } | 6586 } |
6570 | 6587 |
6588 int RenderFrameImpl::GetEnabledBindings() const { | |
6589 return enabled_bindings_; | |
6590 } | |
6591 | |
6571 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | 6592 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
6572 if (frame_->document().isPluginDocument()) | 6593 if (frame_->document().isPluginDocument()) |
6573 return frame_->document().to<WebPluginDocument>().plugin(); | 6594 return frame_->document().to<WebPluginDocument>().plugin(); |
6574 | 6595 |
6575 #if BUILDFLAG(ENABLE_PLUGINS) | 6596 #if BUILDFLAG(ENABLE_PLUGINS) |
6576 if (plugin_find_handler_) | 6597 if (plugin_find_handler_) |
6577 return plugin_find_handler_->container()->plugin(); | 6598 return plugin_find_handler_->container()->plugin(); |
6578 #endif | 6599 #endif |
6579 | 6600 |
6580 return nullptr; | 6601 return nullptr; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6681 // event target. Potentially a Pepper plugin will receive the event. | 6702 // event target. Potentially a Pepper plugin will receive the event. |
6682 // In order to tell whether a plugin gets the last mouse event and which it | 6703 // In order to tell whether a plugin gets the last mouse event and which it |
6683 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6704 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6684 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6705 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6685 // |pepper_last_mouse_event_target_|. | 6706 // |pepper_last_mouse_event_target_|. |
6686 pepper_last_mouse_event_target_ = nullptr; | 6707 pepper_last_mouse_event_target_ = nullptr; |
6687 #endif | 6708 #endif |
6688 } | 6709 } |
6689 | 6710 |
6690 } // namespace content | 6711 } // namespace content |
OLD | NEW |