| 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 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 // embedder can call GetWebFrame on any RenderFrame. | 1174 // embedder can call GetWebFrame on any RenderFrame. |
| 1175 GetContentClient()->renderer()->RenderFrameCreated(this); | 1175 GetContentClient()->renderer()->RenderFrameCreated(this); |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { | 1178 void RenderFrameImpl::InitializeBlameContext(RenderFrameImpl* parent_frame) { |
| 1179 DCHECK(!blame_context_); | 1179 DCHECK(!blame_context_); |
| 1180 blame_context_ = new FrameBlameContext(this, parent_frame); | 1180 blame_context_ = new FrameBlameContext(this, parent_frame); |
| 1181 blame_context_->Initialize(); | 1181 blame_context_->Initialize(); |
| 1182 } | 1182 } |
| 1183 | 1183 |
| 1184 void RenderFrameImpl::OnGotZoomLevel(const GURL& url, double zoom_level) { |
| 1185 // TODO(wjmaclean): We should see if this restriction is really necessary, |
| 1186 // since it isn't enforced in other parts of the page zoom system (e.g. |
| 1187 // when a users changes the zoom of a currently displayed page). Android |
| 1188 // has no UI for this, so in theory the following code would normally just use |
| 1189 // the default zoom anyways. |
| 1190 #if !defined(OS_ANDROID) |
| 1191 // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
| 1192 // for legacy WebView text scaling emulation. Thus, the code that resets |
| 1193 // the zoom level from this map will be effectively resetting text zoom level. |
| 1194 host_zoom_levels_[url] = zoom_level; |
| 1195 #endif |
| 1196 } |
| 1197 |
| 1184 RenderWidget* RenderFrameImpl::GetRenderWidget() { | 1198 RenderWidget* RenderFrameImpl::GetRenderWidget() { |
| 1185 RenderFrameImpl* local_root = | 1199 RenderFrameImpl* local_root = |
| 1186 RenderFrameImpl::FromWebFrame(frame_->localRoot()); | 1200 RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
| 1187 return local_root->render_widget_.get(); | 1201 return local_root->render_widget_.get(); |
| 1188 } | 1202 } |
| 1189 | 1203 |
| 1190 #if defined(ENABLE_PLUGINS) | 1204 #if defined(ENABLE_PLUGINS) |
| 1191 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { | 1205 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { |
| 1192 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 1206 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| 1193 DidCreatePepperPlugin(host)); | 1207 DidCreatePepperPlugin(host)); |
| (...skipping 2750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3944 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); | 3958 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); |
| 3945 } else { | 3959 } else { |
| 3946 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), | 3960 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 3947 WebString::fromUTF8(i.values())); | 3961 WebString::fromUTF8(i.values())); |
| 3948 } | 3962 } |
| 3949 } | 3963 } |
| 3950 } | 3964 } |
| 3951 | 3965 |
| 3952 if (!render_view_->renderer_preferences_.enable_referrers) | 3966 if (!render_view_->renderer_preferences_.enable_referrers) |
| 3953 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); | 3967 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); |
| 3968 |
| 3969 if (extra_data->is_main_frame()) { |
| 3970 frame_host_->GetHostZoomLevel( |
| 3971 request_url, base::Bind(&RenderFrameImpl::OnGotZoomLevel, |
| 3972 weak_factory_.GetWeakPtr(), request_url)); |
| 3973 } |
| 3954 } | 3974 } |
| 3955 | 3975 |
| 3956 void RenderFrameImpl::didReceiveResponse( | 3976 void RenderFrameImpl::didReceiveResponse( |
| 3957 unsigned identifier, | 3977 unsigned identifier, |
| 3958 const blink::WebURLResponse& response) { | 3978 const blink::WebURLResponse& response) { |
| 3959 // Only do this for responses that correspond to a provisional data source | 3979 // Only do this for responses that correspond to a provisional data source |
| 3960 // of the top-most frame. If we have a provisional data source, then we | 3980 // of the top-most frame. If we have a provisional data source, then we |
| 3961 // can't have any sub-resources yet, so we know that this response must | 3981 // can't have any sub-resources yet, so we know that this response must |
| 3962 // correspond to a frame load. | 3982 // correspond to a frame load. |
| 3963 if (!frame_->provisionalDataSource() || frame_->parent()) | 3983 if (!frame_->provisionalDataSource() || frame_->parent()) |
| (...skipping 551 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 | 4535 // 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 | 4536 // will also call us back which will cause us to send a message to |
| 4517 // update WebContentsImpl. | 4537 // update WebContentsImpl. |
| 4518 render_view_->webview()->zoomLimitsChanged( | 4538 render_view_->webview()->zoomLimitsChanged( |
| 4519 ZoomFactorToZoomLevel(kMinimumZoomFactor), | 4539 ZoomFactorToZoomLevel(kMinimumZoomFactor), |
| 4520 ZoomFactorToZoomLevel(kMaximumZoomFactor)); | 4540 ZoomFactorToZoomLevel(kMaximumZoomFactor)); |
| 4521 | 4541 |
| 4522 // Set zoom level, but don't do it for full-page plugin since they don't use | 4542 // Set zoom level, but don't do it for full-page plugin since they don't use |
| 4523 // the same zoom settings. | 4543 // the same zoom settings. |
| 4524 HostZoomLevels::iterator host_zoom = | 4544 HostZoomLevels::iterator host_zoom = |
| 4525 render_view_->host_zoom_levels_.find(GURL(request.url())); | 4545 host_zoom_levels_.find(GURL(request.url())); |
| 4526 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && | 4546 if (render_view_->webview()->mainFrame()->isWebLocalFrame() && |
| 4527 render_view_->webview()->mainFrame()->document().isPluginDocument()) { | 4547 render_view_->webview()->mainFrame()->document().isPluginDocument()) { |
| 4528 // Reset the zoom levels for plugins. | 4548 // Reset the zoom levels for plugins. |
| 4529 render_view_->SetZoomLevel(0); | 4549 render_view_->SetZoomLevel(0); |
| 4530 } else { | 4550 } else { |
| 4531 // If the zoom level is not found, then do nothing. In-page navigation | 4551 // If the zoom level is not found, then do nothing. In-page navigation |
| 4532 // relies on not changing the zoom level in this case. | 4552 // relies on not changing the zoom level in this case. |
| 4533 if (host_zoom != render_view_->host_zoom_levels_.end()) | 4553 if (host_zoom != host_zoom_levels_.end()) |
| 4534 render_view_->SetZoomLevel(host_zoom->second); | 4554 render_view_->SetZoomLevel(host_zoom->second); |
| 4535 } | 4555 } |
| 4536 | 4556 |
| 4537 if (host_zoom != render_view_->host_zoom_levels_.end()) { | 4557 if (host_zoom != host_zoom_levels_.end()) { |
| 4538 // This zoom level was merely recorded transiently for this load. We can | 4558 // 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 | 4559 // erase it now. If at some point we reload this page, the browser will |
| 4540 // send us a new, up-to-date zoom level. | 4560 // send us a new, up-to-date zoom level. |
| 4541 render_view_->host_zoom_levels_.erase(host_zoom); | 4561 host_zoom_levels_.erase(host_zoom); |
| 4542 } | 4562 } |
| 4543 | 4563 |
| 4544 // Update contents MIME type for main frame. | 4564 // Update contents MIME type for main frame. |
| 4545 params.contents_mime_type = ds->response().mimeType().utf8(); | 4565 params.contents_mime_type = ds->response().mimeType().utf8(); |
| 4546 | 4566 |
| 4547 params.transition = navigation_state->GetTransitionType(); | 4567 params.transition = navigation_state->GetTransitionType(); |
| 4548 if (!ui::PageTransitionIsMainFrame(params.transition)) { | 4568 if (!ui::PageTransitionIsMainFrame(params.transition)) { |
| 4549 // If the main frame does a load, it should not be reported as a subframe | 4569 // If the main frame does a load, it should not be reported as a subframe |
| 4550 // navigation. This can occur in the following case: | 4570 // navigation. This can occur in the following case: |
| 4551 // 1. You're on a site with frames. | 4571 // 1. You're on a site with frames. |
| (...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6009 #endif | 6029 #endif |
| 6010 return decoder_factory_.get(); | 6030 return decoder_factory_.get(); |
| 6011 } | 6031 } |
| 6012 | 6032 |
| 6013 void RenderFrameImpl::RegisterMojoServices() { | 6033 void RenderFrameImpl::RegisterMojoServices() { |
| 6014 // Only main frame have ImageDownloader service. | 6034 // Only main frame have ImageDownloader service. |
| 6015 if (!frame_->parent()) { | 6035 if (!frame_->parent()) { |
| 6016 GetServiceRegistry()->AddService(base::Bind( | 6036 GetServiceRegistry()->AddService(base::Bind( |
| 6017 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); | 6037 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); |
| 6018 } | 6038 } |
| 6039 |
| 6040 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&frame_host_)); |
| 6019 } | 6041 } |
| 6020 | 6042 |
| 6021 template <typename Interface> | 6043 template <typename Interface> |
| 6022 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { | 6044 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { |
| 6023 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); | 6045 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); |
| 6024 } | 6046 } |
| 6025 | 6047 |
| 6026 shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( | 6048 shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( |
| 6027 const GURL& url) { | 6049 const GURL& url) { |
| 6028 if (!connector_) | 6050 if (!connector_) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6136 // event target. Potentially a Pepper plugin will receive the event. | 6158 // event target. Potentially a Pepper plugin will receive the event. |
| 6137 // In order to tell whether a plugin gets the last mouse event and which it | 6159 // In order to tell whether a plugin gets the last mouse event and which it |
| 6138 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6160 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6139 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6161 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6140 // |pepper_last_mouse_event_target_|. | 6162 // |pepper_last_mouse_event_target_|. |
| 6141 pepper_last_mouse_event_target_ = nullptr; | 6163 pepper_last_mouse_event_target_ = nullptr; |
| 6142 #endif | 6164 #endif |
| 6143 } | 6165 } |
| 6144 | 6166 |
| 6145 } // namespace content | 6167 } // namespace content |
| OLD | NEW |