Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1964273002: Add FrameHost mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unbind Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // TODO(wjmaclean): We should see if this restriction is really necessary,
1155 // since it isn't enforced in other parts of the page zoom system (e.g.
1156 // when a users changes the zoom of a currently displayed page). Android
1157 // has no UI for this, so in theory the following code would normally just use
1158 // the default zoom anyways.
1159 #if !defined(OS_ANDROID)
1160 // On Android, page zoom isn't used, and in case of WebView, text zoom is used
1161 // for legacy WebView text scaling emulation. Thus, the code that resets
1162 // the zoom level from this map will be effectively resetting text zoom level.
1163 host_zoom_levels_[url] = zoom_level;
1164 #endif
1165 }
1166
1153 RenderWidget* RenderFrameImpl::GetRenderWidget() { 1167 RenderWidget* RenderFrameImpl::GetRenderWidget() {
1154 RenderFrameImpl* local_root = 1168 RenderFrameImpl* local_root =
1155 RenderFrameImpl::FromWebFrame(frame_->localRoot()); 1169 RenderFrameImpl::FromWebFrame(frame_->localRoot());
1156 return local_root->render_widget_.get(); 1170 return local_root->render_widget_.get();
1157 } 1171 }
1158 1172
1159 #if defined(ENABLE_PLUGINS) 1173 #if defined(ENABLE_PLUGINS)
1160 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) { 1174 void RenderFrameImpl::PepperPluginCreated(RendererPpapiHost* host) {
1161 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, 1175 FOR_EACH_OBSERVER(RenderFrameObserver, observers_,
1162 DidCreatePepperPlugin(host)); 1176 DidCreatePepperPlugin(host));
(...skipping 2753 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault); 3930 request.setHTTPReferrer(referrer, blink::WebReferrerPolicyDefault);
3917 } else { 3931 } else {
3918 request.setHTTPHeaderField(WebString::fromUTF8(i.name()), 3932 request.setHTTPHeaderField(WebString::fromUTF8(i.name()),
3919 WebString::fromUTF8(i.values())); 3933 WebString::fromUTF8(i.values()));
3920 } 3934 }
3921 } 3935 }
3922 } 3936 }
3923 3937
3924 if (!render_view_->renderer_preferences_.enable_referrers) 3938 if (!render_view_->renderer_preferences_.enable_referrers)
3925 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault); 3939 request.setHTTPReferrer(WebString(), blink::WebReferrerPolicyDefault);
3940
3941 if (extra_data->is_main_frame()) {
3942 frame_host_->GetHostZoomLevel(request_url,
3943 base::Bind(&RenderFrameImpl::OnGotZoomLevel,
3944 weak_factory_.GetWeakPtr()));
dcheng 2016/05/18 04:46:17 Why pass the URL through like this? Seems like we
scottmg 2016/05/18 18:31:44 I was sort of thinking of a message protocol where
3945 }
3926 } 3946 }
3927 3947
3928 void RenderFrameImpl::didReceiveResponse( 3948 void RenderFrameImpl::didReceiveResponse(
3929 unsigned identifier, 3949 unsigned identifier,
3930 const blink::WebURLResponse& response) { 3950 const blink::WebURLResponse& response) {
3931 // Only do this for responses that correspond to a provisional data source 3951 // 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 3952 // 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 3953 // can't have any sub-resources yet, so we know that this response must
3934 // correspond to a frame load. 3954 // correspond to a frame load.
3935 if (!frame_->provisionalDataSource() || frame_->parent()) 3955 if (!frame_->provisionalDataSource() || frame_->parent())
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after
6012 #endif 6032 #endif
6013 return decoder_factory_.get(); 6033 return decoder_factory_.get();
6014 } 6034 }
6015 6035
6016 void RenderFrameImpl::RegisterMojoServices() { 6036 void RenderFrameImpl::RegisterMojoServices() {
6017 // Only main frame have ImageDownloader service. 6037 // Only main frame have ImageDownloader service.
6018 if (!frame_->parent()) { 6038 if (!frame_->parent()) {
6019 GetServiceRegistry()->AddService(base::Bind( 6039 GetServiceRegistry()->AddService(base::Bind(
6020 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this))); 6040 &ImageDownloaderImpl::CreateMojoService, base::Unretained(this)));
6021 } 6041 }
6042
6043 GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&frame_host_));
6022 } 6044 }
6023 6045
6024 template <typename Interface> 6046 template <typename Interface>
6025 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) { 6047 void RenderFrameImpl::GetInterface(mojo::InterfaceRequest<Interface> request) {
6026 GetServiceRegistry()->ConnectToRemoteService(std::move(request)); 6048 GetServiceRegistry()->ConnectToRemoteService(std::move(request));
6027 } 6049 }
6028 6050
6029 shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication( 6051 shell::mojom::InterfaceProviderPtr RenderFrameImpl::ConnectToApplication(
6030 const GURL& url) { 6052 const GURL& url) {
6031 if (!connector_) 6053 if (!connector_)
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
6139 // event target. Potentially a Pepper plugin will receive the event. 6161 // 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 6162 // 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 6163 // 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 6164 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6143 // |pepper_last_mouse_event_target_|. 6165 // |pepper_last_mouse_event_target_|.
6144 pepper_last_mouse_event_target_ = nullptr; 6166 pepper_last_mouse_event_target_ = nullptr;
6145 #endif 6167 #endif
6146 } 6168 }
6147 6169
6148 } // namespace content 6170 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698