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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "content/common/frame_replication_state.h" | 57 #include "content/common/frame_replication_state.h" |
58 #include "content/common/gpu/client/context_provider_command_buffer.h" | 58 #include "content/common/gpu/client/context_provider_command_buffer.h" |
59 #include "content/common/input_messages.h" | 59 #include "content/common/input_messages.h" |
60 #include "content/common/navigation_params.h" | 60 #include "content/common/navigation_params.h" |
61 #include "content/common/page_messages.h" | 61 #include "content/common/page_messages.h" |
62 #include "content/common/savable_subframe.h" | 62 #include "content/common/savable_subframe.h" |
63 #include "content/common/service_worker/service_worker_types.h" | 63 #include "content/common/service_worker/service_worker_types.h" |
64 #include "content/common/site_isolation_policy.h" | 64 #include "content/common/site_isolation_policy.h" |
65 #include "content/common/swapped_out_messages.h" | 65 #include "content/common/swapped_out_messages.h" |
66 #include "content/common/view_messages.h" | 66 #include "content/common/view_messages.h" |
| 67 #include "content/public/common/associated_interface_provider.h" |
67 #include "content/public/common/bindings_policy.h" | 68 #include "content/public/common/bindings_policy.h" |
68 #include "content/public/common/browser_side_navigation_policy.h" | 69 #include "content/public/common/browser_side_navigation_policy.h" |
69 #include "content/public/common/content_constants.h" | 70 #include "content/public/common/content_constants.h" |
70 #include "content/public/common/content_features.h" | 71 #include "content/public/common/content_features.h" |
71 #include "content/public/common/content_switches.h" | 72 #include "content/public/common/content_switches.h" |
72 #include "content/public/common/context_menu_params.h" | 73 #include "content/public/common/context_menu_params.h" |
73 #include "content/public/common/file_chooser_file_info.h" | 74 #include "content/public/common/file_chooser_file_info.h" |
74 #include "content/public/common/file_chooser_params.h" | 75 #include "content/public/common/file_chooser_params.h" |
75 #include "content/public/common/isolated_world_ids.h" | 76 #include "content/public/common/isolated_world_ids.h" |
76 #include "content/public/common/mojo_shell_connection.h" | 77 #include "content/public/common/mojo_shell_connection.h" |
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 effective_connection_type_( | 1074 effective_connection_type_( |
1074 blink::WebEffectiveConnectionType::TypeUnknown), | 1075 blink::WebEffectiveConnectionType::TypeUnknown), |
1075 is_pasting_(false), | 1076 is_pasting_(false), |
1076 suppress_further_dialogs_(false), | 1077 suppress_further_dialogs_(false), |
1077 blame_context_(nullptr), | 1078 blame_context_(nullptr), |
1078 #if defined(ENABLE_PLUGINS) | 1079 #if defined(ENABLE_PLUGINS) |
1079 focused_pepper_plugin_(nullptr), | 1080 focused_pepper_plugin_(nullptr), |
1080 pepper_last_mouse_event_target_(nullptr), | 1081 pepper_last_mouse_event_target_(nullptr), |
1081 #endif | 1082 #endif |
1082 frame_binding_(this), | 1083 frame_binding_(this), |
| 1084 host_zoom_binding_(this), |
1083 has_accessed_initial_document_(false), | 1085 has_accessed_initial_document_(false), |
1084 weak_factory_(this) { | 1086 weak_factory_(this) { |
1085 // We don't have a shell::Connection at this point, so use nullptr. | 1087 // We don't have a shell::Connection at this point, so use nullptr. |
1086 // TODO(beng): We should fix this, so we can apply policy about which | 1088 // TODO(beng): We should fix this, so we can apply policy about which |
1087 // interfaces get exposed. | 1089 // interfaces get exposed. |
1088 interface_registry_.reset(new shell::InterfaceRegistry); | 1090 interface_registry_.reset(new shell::InterfaceRegistry); |
1089 shell::mojom::InterfaceProviderPtr remote_interfaces; | 1091 shell::mojom::InterfaceProviderPtr remote_interfaces; |
1090 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); | 1092 pending_remote_interface_provider_request_ = GetProxy(&remote_interfaces); |
1091 remote_interfaces_.reset(new shell::InterfaceProvider); | 1093 remote_interfaces_.reset(new shell::InterfaceProvider); |
1092 remote_interfaces_->Bind(std::move(remote_interfaces)); | 1094 remote_interfaces_->Bind(std::move(remote_interfaces)); |
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 return is_pasting_; | 2579 return is_pasting_; |
2578 } | 2580 } |
2579 | 2581 |
2580 // mojom::Frame implementation ------------------------------------------------- | 2582 // mojom::Frame implementation ------------------------------------------------- |
2581 | 2583 |
2582 void RenderFrameImpl::GetInterfaceProvider( | 2584 void RenderFrameImpl::GetInterfaceProvider( |
2583 shell::mojom::InterfaceProviderRequest request) { | 2585 shell::mojom::InterfaceProviderRequest request) { |
2584 interface_registry_->Bind(std::move(request)); | 2586 interface_registry_->Bind(std::move(request)); |
2585 } | 2587 } |
2586 | 2588 |
| 2589 // mojom::HostZoom implementation ---------------------------------------------- |
| 2590 |
| 2591 void RenderFrameImpl::SetHostZoomLevel(const GURL& url, double zoom_level) { |
| 2592 // TODO(wjmaclean): We should see if this restriction is really necessary, |
| 2593 // since it isn't enforced in other parts of the page zoom system (e.g. |
| 2594 // when a users changes the zoom of a currently displayed page). Android |
| 2595 // has no UI for this, so in theory the following code would normally just use |
| 2596 // the default zoom anyways. |
| 2597 #if !defined(OS_ANDROID) |
| 2598 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
| 2599 // for legacy WebView text scaling emulation. Thus, the code that resets |
| 2600 // the zoom level from this map will be effectively resetting text zoom level. |
| 2601 host_zoom_levels_[url] = zoom_level; |
| 2602 #endif |
| 2603 } |
| 2604 |
| 2605 void RenderFrameImpl::OnHostZoomClientRequest( |
| 2606 mojom::HostZoomAssociatedRequest request) { |
| 2607 DCHECK(!host_zoom_binding_.is_bound()); |
| 2608 host_zoom_binding_.Bind(std::move(request)); |
| 2609 } |
| 2610 |
2587 // blink::WebFrameClient implementation ---------------------------------------- | 2611 // blink::WebFrameClient implementation ---------------------------------------- |
2588 | 2612 |
2589 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2613 blink::WebPlugin* RenderFrameImpl::createPlugin( |
2590 blink::WebLocalFrame* frame, | 2614 blink::WebLocalFrame* frame, |
2591 const blink::WebPluginParams& params) { | 2615 const blink::WebPluginParams& params) { |
2592 DCHECK_EQ(frame_, frame); | 2616 DCHECK_EQ(frame_, frame); |
2593 blink::WebPlugin* plugin = NULL; | 2617 blink::WebPlugin* plugin = NULL; |
2594 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2618 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
2595 this, frame, params, &plugin)) { | 2619 this, frame, params, &plugin)) { |
2596 return plugin; | 2620 return plugin; |
(...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4694 // Reset the zoom limits in case a plugin had changed them previously. This | 4718 // Reset the zoom limits in case a plugin had changed them previously. This |
4695 // will also call us back which will cause us to send a message to | 4719 // will also call us back which will cause us to send a message to |
4696 // update WebContentsImpl. | 4720 // update WebContentsImpl. |
4697 render_view_->webview()->zoomLimitsChanged( | 4721 render_view_->webview()->zoomLimitsChanged( |
4698 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 4722 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
4699 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 4723 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
4700 | 4724 |
4701 // Set zoom level, but don't do it for full-page plugin since they don't use | 4725 // Set zoom level, but don't do it for full-page plugin since they don't use |
4702 // the same zoom settings. | 4726 // the same zoom settings. |
4703 HostZoomLevels::iterator host_zoom = | 4727 HostZoomLevels::iterator host_zoom = |
4704 render_view_->host_zoom_levels_.find(GURL(request.url())); | 4728 host_zoom_levels_.find(GURL(request.url())); |
4705 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && | 4729 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && |
4706 render_view_->webview()->mainFrame()->document().isPluginDocument()) { | 4730 render_view_->webview()->mainFrame()->document().isPluginDocument()) { |
4707 // Reset the zoom levels for plugins. | 4731 // Reset the zoom levels for plugins. |
4708 render_view_->SetZoomLevel(0); | 4732 render_view_->SetZoomLevel(0); |
4709 } else { | 4733 } else { |
4710 // If the zoom level is not found, then do nothing. In-page navigation | 4734 // If the zoom level is not found, then do nothing. In-page navigation |
4711 // relies on not changing the zoom level in this case. | 4735 // relies on not changing the zoom level in this case. |
4712 if (host_zoom != render_view_->host_zoom_levels_.end()) | 4736 if (host_zoom != host_zoom_levels_.end()) |
4713 render_view_->SetZoomLevel(host_zoom->second); | 4737 render_view_->SetZoomLevel(host_zoom->second); |
4714 } | 4738 } |
4715 | 4739 |
4716 if (host_zoom != render_view_->host_zoom_levels_.end()) { | 4740 if (host_zoom != host_zoom_levels_.end()) { |
4717 // This zoom level was merely recorded transiently for this load. We can | 4741 // This zoom level was merely recorded transiently for this load. We can |
4718 // erase it now. If at some point we reload this page, the browser will | 4742 // erase it now. If at some point we reload this page, the browser will |
4719 // send us a new, up-to-date zoom level. | 4743 // send us a new, up-to-date zoom level. |
4720 render_view_->host_zoom_levels_.erase(host_zoom); | 4744 host_zoom_levels_.erase(host_zoom); |
4721 } | 4745 } |
4722 | 4746 |
4723 // Update contents MIME type for main frame. | 4747 // Update contents MIME type for main frame. |
4724 params.contents_mime_type = ds->response().mimeType().utf8(); | 4748 params.contents_mime_type = ds->response().mimeType().utf8(); |
4725 | 4749 |
4726 params.transition = navigation_state->GetTransitionType(); | 4750 params.transition = navigation_state->GetTransitionType(); |
4727 if (!ui::PageTransitionIsMainFrame(params.transition)) { | 4751 if (!ui::PageTransitionIsMainFrame(params.transition)) { |
4728 // If the main frame does a load, it should not be reported as a subframe | 4752 // If the main frame does a load, it should not be reported as a subframe |
4729 // navigation. This can occur in the following case: | 4753 // navigation. This can occur in the following case: |
4730 // 1. You're on a site with frames. | 4754 // 1. You're on a site with frames. |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6259 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) | 6283 #if defined(ENABLE_MOJO_AUDIO_DECODER) || defined(ENABLE_MOJO_VIDEO_DECODER) |
6260 if (!decoder_factory_) { | 6284 if (!decoder_factory_) { |
6261 decoder_factory_.reset( | 6285 decoder_factory_.reset( |
6262 new media::MojoDecoderFactory(GetMediaInterfaceProvider())); | 6286 new media::MojoDecoderFactory(GetMediaInterfaceProvider())); |
6263 } | 6287 } |
6264 #endif | 6288 #endif |
6265 return decoder_factory_.get(); | 6289 return decoder_factory_.get(); |
6266 } | 6290 } |
6267 | 6291 |
6268 void RenderFrameImpl::RegisterMojoInterfaces() { | 6292 void RenderFrameImpl::RegisterMojoInterfaces() { |
6269 // Only main frame have ImageDownloader service. | |
6270 if (!frame_->parent()) { | 6293 if (!frame_->parent()) { |
| 6294 // Only main frame have ImageDownloader service. |
6271 GetInterfaceRegistry()->AddInterface(base::Bind( | 6295 GetInterfaceRegistry()->AddInterface(base::Bind( |
6272 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6296 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
| 6297 |
| 6298 GetAssociatedInterfaceRegistry()->AddInterface(base::Bind( |
| 6299 &RenderFrameImpl::OnHostZoomClientRequest, weak_factory_.GetWeakPtr())); |
6273 } | 6300 } |
6274 } | 6301 } |
6275 | 6302 |
6276 template <typename Interface> | 6303 template <typename Interface> |
6277 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { | 6304 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { |
6278 GetRemoteInterfaces()->GetInterface(std::move(request)); | 6305 GetRemoteInterfaces()->GetInterface(std::move(request)); |
6279 } | 6306 } |
6280 | 6307 |
6281 media::RendererWebMediaPlayerDelegate* | 6308 media::RendererWebMediaPlayerDelegate* |
6282 RenderFrameImpl::GetWebMediaPlayerDelegate() { | 6309 RenderFrameImpl::GetWebMediaPlayerDelegate() { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6431 // event target. Potentially a Pepper plugin will receive the event. | 6458 // event target. Potentially a Pepper plugin will receive the event. |
6432 // In order to tell whether a plugin gets the last mouse event and which it | 6459 // In order to tell whether a plugin gets the last mouse event and which it |
6433 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6460 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6434 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6461 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6435 // |pepper_last_mouse_event_target_|. | 6462 // |pepper_last_mouse_event_target_|. |
6436 pepper_last_mouse_event_target_ = nullptr; | 6463 pepper_last_mouse_event_target_ = nullptr; |
6437 #endif | 6464 #endif |
6438 } | 6465 } |
6439 | 6466 |
6440 } // namespace content | 6467 } // namespace content |
OLD | NEW |