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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 // embedder can call GetWebFrame on any RenderFrame. | 1143 // embedder can call GetWebFrame on any RenderFrame. |
1144 GetContentClient()->renderer()->RenderFrameCreated(this); | 1144 GetContentClient()->renderer()->RenderFrameCreated(this); |
1145 } | 1145 } |
1146 | 1146 |
1147 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { | 1147 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { |
1148 DCHECK(!blame_context_); | 1148 DCHECK(!blame_context_); |
1149 blame_context_ = new FrameBlameContext(this, parent_frame); | 1149 blame_context_ = new FrameBlameContext(this, parent_frame); |
1150 blame_context_->Initialize(); | 1150 blame_context_->Initialize(); |
1151 } | 1151 } |
1152 | 1152 |
| 1153 void RenderFrameImpl::OnGotZoomLevel(const GURL& url, double zoom_level) { |
| 1154 host_zoom_levels_[url] = zoom_level; |
| 1155 } |
| 1156 |
1153 RenderWidget* RenderFrameImpl::GetRenderWidget() { | 1157 RenderWidget* RenderFrameImpl::GetRenderWidget() { |
1154 RenderFrameImpl* local_root = | 1158 RenderFrameImpl* local_root = |
1155 RenderFrameImpl::FromWebFrame(frame_->localRoot()); | 1159 RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
1156 return local_root->render_widget_.get(); | 1160 return local_root->render_widget_.get(); |
1157 } | 1161 } |
1158 | 1162 |
1159 #if defined(ENABLE_PLUGINS) | 1163 #if defined(ENABLE_PLUGINS) |
1160 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { | 1164 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { |
1161 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 1165 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
1162 DidCreatePepperPlugin(host)); | 1166 DidCreatePepperPlugin(host)); |
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); | 3920 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); |
3917 } else { | 3921 } else { |
3918 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), | 3922 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), |
3919 WebString::fromUTF8(i.values())); | 3923 WebString::fromUTF8(i.values())); |
3920 } | 3924 } |
3921 } | 3925 } |
3922 } | 3926 } |
3923 | 3927 |
3924 if (!render_view_->renderer_preferences_.enable_referrers) | 3928 if (!render_view_->renderer_preferences_.enable_referrers) |
3925 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); | 3929 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); |
| 3930 |
| 3931 if (extra_data->is_main_frame()) { |
| 3932 frame_service_->GetHostZoomLevel( |
| 3933 request_url, base::Bind(&RenderFrameImpl::OnGotZoomLevel, |
| 3934 weak_factory_.GetWeakPtr())); |
| 3935 } |
3926 } | 3936 } |
3927 | 3937 |
3928 void RenderFrameImpl::didReceiveResponse( | 3938 void RenderFrameImpl::didReceiveResponse( |
3929 unsigned identifier, | 3939 unsigned identifier, |
3930 const blink::WebURLResponse& response) { | 3940 const blink::WebURLResponse& response) { |
3931 // Only do this for responses that correspond to a provisional data source | 3941 // Only do this for responses that correspond to a provisional data source |
3932 // of the top-most frame. If we have a provisional data source, then we | 3942 // of the top-most frame. If we have a provisional data source, then we |
3933 // can't have any sub-resources yet, so we know that this response must | 3943 // can't have any sub-resources yet, so we know that this response must |
3934 // correspond to a frame load. | 3944 // correspond to a frame load. |
3935 if (!frame_->provisionalDataSource() || frame_->parent()) | 3945 if (!frame_->provisionalDataSource() || frame_->parent()) |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4515 // Reset the zoom limits in case a plugin had changed them previously. This | 4525 // Reset the zoom limits in case a plugin had changed them previously. This |
4516 // will also call us back which will cause us to send a message to | 4526 // will also call us back which will cause us to send a message to |
4517 // update WebContentsImpl. | 4527 // update WebContentsImpl. |
4518 render_view_->webview()->zoomLimitsChanged( | 4528 render_view_->webview()->zoomLimitsChanged( |
4519 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 4529 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
4520 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 4530 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
4521 | 4531 |
4522 // Set zoom level, but don't do it for full-page plugin since they don't use | 4532 // Set zoom level, but don't do it for full-page plugin since they don't use |
4523 // the same zoom settings. | 4533 // the same zoom settings. |
4524 HostZoomLevels::iterator host_zoom = | 4534 HostZoomLevels::iterator host_zoom = |
4525 render_view_->host_zoom_levels_.find(GURL(request.url())); | 4535 host_zoom_levels_.find(GURL(request.url())); |
4526 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && | 4536 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && |
4527 render_view_->webview()->mainFrame()->document().isPluginDocument()) { | 4537 render_view_->webview()->mainFrame()->document().isPluginDocument()) { |
4528 // Reset the zoom levels for plugins. | 4538 // Reset the zoom levels for plugins. |
4529 render_view_->SetZoomLevel(0); | 4539 render_view_->SetZoomLevel(0); |
4530 } else { | 4540 } else { |
4531 // If the zoom level is not found, then do nothing. In-page navigation | 4541 // If the zoom level is not found, then do nothing. In-page navigation |
4532 // relies on not changing the zoom level in this case. | 4542 // relies on not changing the zoom level in this case. |
4533 if (host_zoom != render_view_->host_zoom_levels_.end()) | 4543 if (host_zoom != host_zoom_levels_.end()) |
4534 render_view_->SetZoomLevel(host_zoom->second); | 4544 render_view_->SetZoomLevel(host_zoom->second); |
4535 } | 4545 } |
4536 | 4546 |
4537 if (host_zoom != render_view_->host_zoom_levels_.end()) { | 4547 if (host_zoom != host_zoom_levels_.end()) { |
4538 // This zoom level was merely recorded transiently for this load. We can | 4548 // This zoom level was merely recorded transiently for this load. We can |
4539 // erase it now. If at some point we reload this page, the browser will | 4549 // erase it now. If at some point we reload this page, the browser will |
4540 // send us a new, up-to-date zoom level. | 4550 // send us a new, up-to-date zoom level. |
4541 render_view_->host_zoom_levels_.erase(host_zoom); | 4551 host_zoom_levels_.erase(host_zoom); |
4542 } | 4552 } |
4543 | 4553 |
4544 // Update contents MIME type for main frame. | 4554 // Update contents MIME type for main frame. |
4545 params.contents_mime_type = ds->response().mimeType().utf8(); | 4555 params.contents_mime_type = ds->response().mimeType().utf8(); |
4546 | 4556 |
4547 params.transition = navigation_state->GetTransitionType(); | 4557 params.transition = navigation_state->GetTransitionType(); |
4548 if (!ui::PageTransitionIsMainFrame(params.transition)) { | 4558 if (!ui::PageTransitionIsMainFrame(params.transition)) { |
4549 // If the main frame does a load, it should not be reported as a subframe | 4559 // If the main frame does a load, it should not be reported as a subframe |
4550 // navigation. This can occur in the following case: | 4560 // navigation. This can occur in the following case: |
4551 // 1. You're on a site with frames. | 4561 // 1. You're on a site with frames. |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6012 #endif | 6022 #endif |
6013 return decoder_factory_.get(); | 6023 return decoder_factory_.get(); |
6014 } | 6024 } |
6015 | 6025 |
6016 void RenderFrameImpl::RegisterMojoServices() { | 6026 void RenderFrameImpl::RegisterMojoServices() { |
6017 // Only main frame have ImageDownloader service. | 6027 // Only main frame have ImageDownloader service. |
6018 if (!frame_->parent()) { | 6028 if (!frame_->parent()) { |
6019 GetServiceRegistry()->AddService(base::Bind( | 6029 GetServiceRegistry()->AddService(base::Bind( |
6020 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6030 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
6021 } | 6031 } |
| 6032 |
| 6033 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&frame_service_)); |
6022 } | 6034 } |
6023 | 6035 |
6024 template <typename Interface> | 6036 template <typename Interface> |
6025 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { | 6037 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { |
6026 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); | 6038 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); |
6027 } | 6039 } |
6028 | 6040 |
6029 shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( | 6041 shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( |
6030 const GURL& url) { | 6042 const GURL& url) { |
6031 if (!connector_) | 6043 if (!connector_) |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6139 // event target. Potentially a Pepper plugin will receive the event. | 6151 // event target. Potentially a Pepper plugin will receive the event. |
6140 // In order to tell whether a plugin gets the last mouse event and which it | 6152 // In order to tell whether a plugin gets the last mouse event and which it |
6141 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6153 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6142 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6154 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6143 // |pepper_last_mouse_event_target_|. | 6155 // |pepper_last_mouse_event_target_|. |
6144 pepper_last_mouse_event_target_ = nullptr; | 6156 pepper_last_mouse_event_target_ = nullptr; |
6145 #endif | 6157 #endif |
6146 } | 6158 } |
6147 | 6159 |
6148 } // namespace content | 6160 } // namespace content |
OLD | NEW |