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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "content/common/frame_replication_state.h" | 59 #include "content/common/frame_replication_state.h" |
60 #include "content/common/gpu/client/context_provider_command_buffer.h" | 60 #include "content/common/gpu/client/context_provider_command_buffer.h" |
61 #include "content/common/input_messages.h" | 61 #include "content/common/input_messages.h" |
62 #include "content/common/navigation_params.h" | 62 #include "content/common/navigation_params.h" |
63 #include "content/common/page_messages.h" | 63 #include "content/common/page_messages.h" |
64 #include "content/common/savable_subframe.h" | 64 #include "content/common/savable_subframe.h" |
65 #include "content/common/service_worker/service_worker_types.h" | 65 #include "content/common/service_worker/service_worker_types.h" |
66 #include "content/common/site_isolation_policy.h" | 66 #include "content/common/site_isolation_policy.h" |
67 #include "content/common/swapped_out_messages.h" | 67 #include "content/common/swapped_out_messages.h" |
68 #include "content/common/view_messages.h" | 68 #include "content/common/view_messages.h" |
| 69 #include "content/public/common/associated_interface_provider.h" |
69 #include "content/public/common/bindings_policy.h" | 70 #include "content/public/common/bindings_policy.h" |
70 #include "content/public/common/browser_side_navigation_policy.h" | 71 #include "content/public/common/browser_side_navigation_policy.h" |
71 #include "content/public/common/content_constants.h" | 72 #include "content/public/common/content_constants.h" |
72 #include "content/public/common/content_features.h" | 73 #include "content/public/common/content_features.h" |
73 #include "content/public/common/content_switches.h" | 74 #include "content/public/common/content_switches.h" |
74 #include "content/public/common/context_menu_params.h" | 75 #include "content/public/common/context_menu_params.h" |
75 #include "content/public/common/file_chooser_file_info.h" | 76 #include "content/public/common/file_chooser_file_info.h" |
76 #include "content/public/common/file_chooser_params.h" | 77 #include "content/public/common/file_chooser_params.h" |
77 #include "content/public/common/isolated_world_ids.h" | 78 #include "content/public/common/isolated_world_ids.h" |
78 #include "content/public/common/page_state.h" | 79 #include "content/public/common/page_state.h" |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 effective_connection_type_( | 1110 effective_connection_type_( |
1110 blink::WebEffectiveConnectionType::TypeUnknown), | 1111 blink::WebEffectiveConnectionType::TypeUnknown), |
1111 is_pasting_(false), | 1112 is_pasting_(false), |
1112 suppress_further_dialogs_(false), | 1113 suppress_further_dialogs_(false), |
1113 blame_context_(nullptr), | 1114 blame_context_(nullptr), |
1114 #if defined(ENABLE_PLUGINS) | 1115 #if defined(ENABLE_PLUGINS) |
1115 focused_pepper_plugin_(nullptr), | 1116 focused_pepper_plugin_(nullptr), |
1116 pepper_last_mouse_event_target_(nullptr), | 1117 pepper_last_mouse_event_target_(nullptr), |
1117 #endif | 1118 #endif |
1118 frame_binding_(this), | 1119 frame_binding_(this), |
| 1120 host_zoom_binding_(this), |
1119 has_accessed_initial_document_(false), | 1121 has_accessed_initial_document_(false), |
1120 weak_factory_(this) { | 1122 weak_factory_(this) { |
1121 // We don't have a service_manager::Connection at this point, so use nullptr. | 1123 // We don't have a service_manager::Connection at this point, so use nullptr. |
1122 // TODO(beng): We should fix this, so we can apply policy about which | 1124 // TODO(beng): We should fix this, so we can apply policy about which |
1123 // interfaces get exposed. | 1125 // interfaces get exposed. |
1124 interface_registry_.reset(new service_manager::InterfaceRegistry); | 1126 interface_registry_.reset(new service_manager::InterfaceRegistry); |
1125 service_manager::mojom::InterfaceProviderPtr remote_interfaces; | 1127 service_manager::mojom::InterfaceProviderPtr remote_interfaces; |
1126 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); | 1128 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); |
1127 remote_interfaces_.reset(new service_manager::InterfaceProvider); | 1129 remote_interfaces_.reset(new service_manager::InterfaceProvider); |
1128 remote_interfaces_->Bind(std::move(remote_interfaces)); | 1130 remote_interfaces_->Bind(std::move(remote_interfaces)); |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2626 return is_pasting_; | 2628 return is_pasting_; |
2627 } | 2629 } |
2628 | 2630 |
2629 // mojom::Frame implementation ------------------------------------------------- | 2631 // mojom::Frame implementation ------------------------------------------------- |
2630 | 2632 |
2631 void RenderFrameImpl::GetInterfaceProvider( | 2633 void RenderFrameImpl::GetInterfaceProvider( |
2632 service_manager::mojom::InterfaceProviderRequest request) { | 2634 service_manager::mojom::InterfaceProviderRequest request) { |
2633 interface_registry_->Bind(std::move(request)); | 2635 interface_registry_->Bind(std::move(request)); |
2634 } | 2636 } |
2635 | 2637 |
| 2638 // mojom::HostZoom implementation ---------------------------------------------- |
| 2639 |
| 2640 void RenderFrameImpl::SetHostZoomLevel(const GURL& url, double zoom_level) { |
| 2641 // TODO(wjmaclean): We should see if this restriction is really necessary, |
| 2642 // since it isn't enforced in other parts of the page zoom system (e.g. |
| 2643 // when a users changes the zoom of a currently displayed page). Android |
| 2644 // has no UI for this, so in theory the following code would normally just use |
| 2645 // the default zoom anyways. |
| 2646 #if !defined(OS_ANDROID) |
| 2647 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
| 2648 // for legacy WebView text scaling emulation. Thus, the code that resets |
| 2649 // the zoom level from this map will be effectively resetting text zoom level. |
| 2650 host_zoom_levels_[url] = zoom_level; |
| 2651 #endif |
| 2652 } |
| 2653 |
2636 // blink::WebFrameClient implementation ---------------------------------------- | 2654 // blink::WebFrameClient implementation ---------------------------------------- |
2637 | 2655 |
2638 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2656 blink::WebPlugin* RenderFrameImpl::createPlugin( |
2639 blink::WebLocalFrame* frame, | 2657 blink::WebLocalFrame* frame, |
2640 const blink::WebPluginParams& params) { | 2658 const blink::WebPluginParams& params) { |
2641 DCHECK_EQ(frame_, frame); | 2659 DCHECK_EQ(frame_, frame); |
2642 blink::WebPlugin* plugin = NULL; | 2660 blink::WebPlugin* plugin = NULL; |
2643 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2661 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
2644 this, frame, params, &plugin)) { | 2662 this, frame, params, &plugin)) { |
2645 return plugin; | 2663 return plugin; |
(...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4826 // Reset the zoom limits in case a plugin had changed them previously. This | 4844 // Reset the zoom limits in case a plugin had changed them previously. This |
4827 // will also call us back which will cause us to send a message to | 4845 // will also call us back which will cause us to send a message to |
4828 // update WebContentsImpl. | 4846 // update WebContentsImpl. |
4829 render_view_->webview()->zoomLimitsChanged( | 4847 render_view_->webview()->zoomLimitsChanged( |
4830 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 4848 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
4831 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 4849 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
4832 | 4850 |
4833 // Set zoom level, but don't do it for full-page plugin since they don't use | 4851 // Set zoom level, but don't do it for full-page plugin since they don't use |
4834 // the same zoom settings. | 4852 // the same zoom settings. |
4835 HostZoomLevels::iterator host_zoom = | 4853 HostZoomLevels::iterator host_zoom = |
4836 render_view_->host_zoom_levels_.find(GURL(request.url())); | 4854 host_zoom_levels_.find(GURL(request.url())); |
4837 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && | 4855 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && |
4838 render_view_->webview()->mainFrame()->document().isPluginDocument()) { | 4856 render_view_->webview()->mainFrame()->document().isPluginDocument()) { |
4839 // Reset the zoom levels for plugins. | 4857 // Reset the zoom levels for plugins. |
4840 render_view_->SetZoomLevel(0); | 4858 render_view_->SetZoomLevel(0); |
4841 } else { | 4859 } else { |
4842 // If the zoom level is not found, then do nothing. In-page navigation | 4860 // If the zoom level is not found, then do nothing. In-page navigation |
4843 // relies on not changing the zoom level in this case. | 4861 // relies on not changing the zoom level in this case. |
4844 if (host_zoom != render_view_->host_zoom_levels_.end()) | 4862 if (host_zoom != host_zoom_levels_.end()) |
4845 render_view_->SetZoomLevel(host_zoom->second); | 4863 render_view_->SetZoomLevel(host_zoom->second); |
4846 } | 4864 } |
4847 | 4865 |
4848 if (host_zoom != render_view_->host_zoom_levels_.end()) { | 4866 if (host_zoom != host_zoom_levels_.end()) { |
4849 // This zoom level was merely recorded transiently for this load. We can | 4867 // This zoom level was merely recorded transiently for this load. We can |
4850 // erase it now. If at some point we reload this page, the browser will | 4868 // erase it now. If at some point we reload this page, the browser will |
4851 // send us a new, up-to-date zoom level. | 4869 // send us a new, up-to-date zoom level. |
4852 render_view_->host_zoom_levels_.erase(host_zoom); | 4870 host_zoom_levels_.erase(host_zoom); |
4853 } | 4871 } |
4854 | 4872 |
4855 // Update contents MIME type for main frame. | 4873 // Update contents MIME type for main frame. |
4856 params.contents_mime_type = ds->response().mimeType().utf8(); | 4874 params.contents_mime_type = ds->response().mimeType().utf8(); |
4857 | 4875 |
4858 params.transition = navigation_state->GetTransitionType(); | 4876 params.transition = navigation_state->GetTransitionType(); |
4859 if (!ui::PageTransitionIsMainFrame(params.transition)) { | 4877 if (!ui::PageTransitionIsMainFrame(params.transition)) { |
4860 // If the main frame does a load, it should not be reported as a subframe | 4878 // If the main frame does a load, it should not be reported as a subframe |
4861 // navigation. This can occur in the following case: | 4879 // navigation. This can occur in the following case: |
4862 // 1. You're on a site with frames. | 4880 // 1. You're on a site with frames. |
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6398 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) | 6416 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) |
6399 if (!decoder_factory_) { | 6417 if (!decoder_factory_) { |
6400 decoder_factory_.reset( | 6418 decoder_factory_.reset( |
6401 new media::MojoDecoderFactory(GetMediaInterfaceProvider())); | 6419 new media::MojoDecoderFactory(GetMediaInterfaceProvider())); |
6402 } | 6420 } |
6403 #endif | 6421 #endif |
6404 return decoder_factory_.get(); | 6422 return decoder_factory_.get(); |
6405 } | 6423 } |
6406 | 6424 |
6407 void RenderFrameImpl::RegisterMojoInterfaces() { | 6425 void RenderFrameImpl::RegisterMojoInterfaces() { |
6408 // Only main frame have ImageDownloader service. | |
6409 if (!frame_->parent()) { | 6426 if (!frame_->parent()) { |
| 6427 // Only main frame have ImageDownloader service. |
6410 GetInterfaceRegistry()->AddInterface(base::Bind( | 6428 GetInterfaceRegistry()->AddInterface(base::Bind( |
6411 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6429 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
| 6430 |
| 6431 // Host zoom is per-page, so only added on the main frame. |
| 6432 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( |
| 6433 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); |
6412 } | 6434 } |
6413 } | 6435 } |
6414 | 6436 |
6415 template <typename Interface> | 6437 template <typename Interface> |
6416 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { | 6438 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { |
6417 GetRemoteInterfaces()->GetInterface(std::move(request)); | 6439 GetRemoteInterfaces()->GetInterface(std::move(request)); |
6418 } | 6440 } |
6419 | 6441 |
| 6442 void RenderFrameImpl::OnHostZoomClientRequest( |
| 6443 mojom::HostZoomAssociatedRequest request) { |
| 6444 DCHECK(!host_zoom_binding_.is_bound()); |
| 6445 host_zoom_binding_.Bind(std::move(request)); |
| 6446 } |
| 6447 |
6420 media::RendererWebMediaPlayerDelegate* | 6448 media::RendererWebMediaPlayerDelegate* |
6421 RenderFrameImpl::GetWebMediaPlayerDelegate() { | 6449 RenderFrameImpl::GetWebMediaPlayerDelegate() { |
6422 if (!media_player_delegate_) | 6450 if (!media_player_delegate_) |
6423 media_player_delegate_ = new media::RendererWebMediaPlayerDelegate(this); | 6451 media_player_delegate_ = new media::RendererWebMediaPlayerDelegate(this); |
6424 return media_player_delegate_; | 6452 return media_player_delegate_; |
6425 } | 6453 } |
6426 | 6454 |
6427 void RenderFrameImpl::checkIfAudioSinkExistsAndIsAuthorized( | 6455 void RenderFrameImpl::checkIfAudioSinkExistsAndIsAuthorized( |
6428 const blink::WebString& sink_id, | 6456 const blink::WebString& sink_id, |
6429 const blink::WebSecurityOrigin& security_origin, | 6457 const blink::WebSecurityOrigin& security_origin, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6574 // event target. Potentially a Pepper plugin will receive the event. | 6602 // event target. Potentially a Pepper plugin will receive the event. |
6575 // In order to tell whether a plugin gets the last mouse event and which it | 6603 // In order to tell whether a plugin gets the last mouse event and which it |
6576 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6604 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6577 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6605 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6578 // |pepper_last_mouse_event_target_|. | 6606 // |pepper_last_mouse_event_target_|. |
6579 pepper_last_mouse_event_target_ = nullptr; | 6607 pepper_last_mouse_event_target_ = nullptr; |
6580 #endif | 6608 #endif |
6581 } | 6609 } |
6582 | 6610 |
6583 } // namespace content | 6611 } // namespace content |
OLD | NEW |