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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 | 913 |
914 RenderFrameImpl* render_frame = | 914 RenderFrameImpl* render_frame = |
915 RenderFrameImpl::Create(render_view, routing_id); | 915 RenderFrameImpl::Create(render_view, routing_id); |
916 render_frame->InitializeBlameContext(nullptr); | 916 render_frame->InitializeBlameContext(nullptr); |
917 WebLocalFrame* web_frame = WebLocalFrame::create( | 917 WebLocalFrame* web_frame = WebLocalFrame::create( |
918 blink::WebTreeScopeType::Document, render_frame, opener); | 918 blink::WebTreeScopeType::Document, render_frame, opener); |
919 render_frame->BindToWebFrame(web_frame); | 919 render_frame->BindToWebFrame(web_frame); |
920 render_view->webview()->setMainFrame(web_frame); | 920 render_view->webview()->setMainFrame(web_frame); |
921 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 921 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
922 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); | 922 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
923 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
924 // WasShown and WasHidden, separating page-level visibility from | |
925 // frame-level visibility. | |
926 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 923 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
927 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) | 924 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) |
928 << "Main frame is no longer reusing the RenderView as its widget! " | 925 << "Main frame is no longer reusing the RenderView as its widget! " |
929 << "Does the RenderFrame need to register itself with the RenderWidget?"; | 926 << "Does the RenderFrame need to register itself with the RenderWidget?"; |
930 return render_frame; | 927 return render_frame; |
931 } | 928 } |
932 | 929 |
933 // static | 930 // static |
934 void RenderFrameImpl::CreateFrame( | 931 void RenderFrameImpl::CreateFrame( |
935 int routing_id, | 932 int routing_id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 | 989 |
993 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 990 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
994 CHECK(!web_frame->parent() || | 991 CHECK(!web_frame->parent() || |
995 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 992 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
996 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 993 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
997 widget_params.routing_id, widget_params.hidden, | 994 widget_params.routing_id, widget_params.hidden, |
998 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 995 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
999 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so | 996 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
1000 // avoid double-registering the frame as an observer. | 997 // avoid double-registering the frame as an observer. |
1001 // https://crbug.com/545684 | 998 // https://crbug.com/545684 |
1002 if (web_frame->parent()) { | 999 if (web_frame->parent()) |
1003 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
1004 // WasShown and WasHidden, separating page-level visibility from | |
1005 // frame-level visibility. | |
1006 render_frame->render_widget_->RegisterRenderFrame(render_frame); | 1000 render_frame->render_widget_->RegisterRenderFrame(render_frame); |
1007 } | |
1008 } | 1001 } |
1009 | 1002 |
1010 render_frame->Initialize(); | 1003 render_frame->Initialize(); |
1011 } | 1004 } |
1012 | 1005 |
1013 // static | 1006 // static |
1014 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 1007 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
1015 return RenderFrameImpl::FromWebFrame(web_frame); | 1008 return RenderFrameImpl::FromWebFrame(web_frame); |
1016 } | 1009 } |
1017 | 1010 |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 | 1675 |
1683 // Swap out and stop sending any IPC messages that are not ACKs. | 1676 // Swap out and stop sending any IPC messages that are not ACKs. |
1684 if (is_main_frame_) | 1677 if (is_main_frame_) |
1685 render_view_->SetSwappedOut(true); | 1678 render_view_->SetSwappedOut(true); |
1686 | 1679 |
1687 // Transfer settings such as initial drawing parameters to the remote frame, | 1680 // Transfer settings such as initial drawing parameters to the remote frame, |
1688 // if one is created, that will replace this frame. | 1681 // if one is created, that will replace this frame. |
1689 if (!is_main_frame_) | 1682 if (!is_main_frame_) |
1690 proxy->web_frame()->initializeFromFrame(frame_); | 1683 proxy->web_frame()->initializeFromFrame(frame_); |
1691 | 1684 |
1692 // Let WebKit know that this view is hidden so it can drop resources and | |
1693 // stop compositing. | |
1694 // TODO(creis): Support this for subframes as well. | |
1695 if (is_main_frame_) { | |
1696 render_view_->webview()->setVisibilityState( | |
1697 blink::WebPageVisibilityStateHidden, false); | |
1698 } | |
1699 | |
1700 RenderViewImpl* render_view = render_view_.get(); | 1685 RenderViewImpl* render_view = render_view_.get(); |
1701 bool is_main_frame = is_main_frame_; | 1686 bool is_main_frame = is_main_frame_; |
1702 int routing_id = GetRoutingID(); | 1687 int routing_id = GetRoutingID(); |
1703 | 1688 |
1704 // Now that all of the cleanup is complete and the browser side is notified, | 1689 // Now that all of the cleanup is complete and the browser side is notified, |
1705 // start using the RenderFrameProxy. | 1690 // start using the RenderFrameProxy. |
1706 // | 1691 // |
1707 // The swap call deletes this RenderFrame via frameDetached. Do not access | 1692 // The swap call deletes this RenderFrame via frameDetached. Do not access |
1708 // any members after this call. | 1693 // any members after this call. |
1709 // | 1694 // |
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4044 // Explicitly set the SkipServiceWorker flag here if the renderer process | 4029 // Explicitly set the SkipServiceWorker flag here if the renderer process |
4045 // hasn't received SetControllerServiceWorker message. | 4030 // hasn't received SetControllerServiceWorker message. |
4046 if (!provider->IsControlledByServiceWorker()) | 4031 if (!provider->IsControlledByServiceWorker()) |
4047 request.setSkipServiceWorker(true); | 4032 request.setSkipServiceWorker(true); |
4048 } | 4033 } |
4049 | 4034 |
4050 WebFrame* parent = frame->parent(); | 4035 WebFrame* parent = frame->parent(); |
4051 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 4036 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
4052 | 4037 |
4053 RequestExtraData* extra_data = new RequestExtraData(); | 4038 RequestExtraData* extra_data = new RequestExtraData(); |
4054 extra_data->set_visibility_state(render_view_->visibilityState()); | 4039 extra_data->set_visibility_state(visibilityState()); |
4055 extra_data->set_custom_user_agent(custom_user_agent); | 4040 extra_data->set_custom_user_agent(custom_user_agent); |
4056 extra_data->set_requested_with(requested_with); | 4041 extra_data->set_requested_with(requested_with); |
4057 extra_data->set_render_frame_id(routing_id_); | 4042 extra_data->set_render_frame_id(routing_id_); |
4058 extra_data->set_is_main_frame(!parent); | 4043 extra_data->set_is_main_frame(!parent); |
4059 extra_data->set_frame_origin( | 4044 extra_data->set_frame_origin( |
4060 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); | 4045 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); |
4061 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 4046 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
4062 extra_data->set_parent_render_frame_id(parent_routing_id); | 4047 extra_data->set_parent_render_frame_id(parent_routing_id); |
4063 extra_data->set_allow_download( | 4048 extra_data->set_allow_download( |
4064 navigation_state->common_params().allow_download); | 4049 navigation_state->common_params().allow_download); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4521 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4506 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
4522 } | 4507 } |
4523 | 4508 |
4524 void RenderFrameImpl::WasHidden() { | 4509 void RenderFrameImpl::WasHidden() { |
4525 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4510 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
4526 | 4511 |
4527 #if defined(ENABLE_PLUGINS) | 4512 #if defined(ENABLE_PLUGINS) |
4528 for (auto* plugin : active_pepper_instances_) | 4513 for (auto* plugin : active_pepper_instances_) |
4529 plugin->PageVisibilityChanged(false); | 4514 plugin->PageVisibilityChanged(false); |
4530 #endif // ENABLE_PLUGINS | 4515 #endif // ENABLE_PLUGINS |
| 4516 |
| 4517 if (GetWebFrame()->frameWidget()) { |
| 4518 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) |
| 4519 ->setVisibilityState(visibilityState()); |
| 4520 } |
4531 } | 4521 } |
4532 | 4522 |
4533 void RenderFrameImpl::WasShown() { | 4523 void RenderFrameImpl::WasShown() { |
4534 // TODO(kenrb): Need to figure out how to do this better. Should | |
4535 // VisibilityState remain a page-level concept or move to frames? | |
4536 // The semantics of 'Show' might have to change here. | |
4537 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | |
4538 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) | |
4539 << "The main render frame is no longer reusing the RenderView as its " | |
4540 << "RenderWidget!"; | |
4541 if (render_widget_ && render_widget_->webwidget() && | |
4542 render_view_.get() != render_widget_.get()) { | |
4543 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | |
4544 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | |
4545 } | |
4546 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4524 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
4547 | 4525 |
4548 #if defined(ENABLE_PLUGINS) | 4526 #if defined(ENABLE_PLUGINS) |
4549 for (auto* plugin : active_pepper_instances_) | 4527 for (auto* plugin : active_pepper_instances_) |
4550 plugin->PageVisibilityChanged(true); | 4528 plugin->PageVisibilityChanged(true); |
4551 #endif // ENABLE_PLUGINS | 4529 #endif // ENABLE_PLUGINS |
| 4530 |
| 4531 if (GetWebFrame()->frameWidget()) { |
| 4532 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) |
| 4533 ->setVisibilityState(visibilityState()); |
| 4534 } |
4552 } | 4535 } |
4553 | 4536 |
4554 void RenderFrameImpl::WidgetWillClose() { | 4537 void RenderFrameImpl::WidgetWillClose() { |
4555 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4538 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
4556 } | 4539 } |
4557 | 4540 |
4558 bool RenderFrameImpl::IsMainFrame() { | 4541 bool RenderFrameImpl::IsMainFrame() { |
4559 return is_main_frame_; | 4542 return is_main_frame_; |
4560 } | 4543 } |
4561 | 4544 |
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6206 media::ConvertToOutputDeviceStatusCB(web_callbacks); | 6189 media::ConvertToOutputDeviceStatusCB(web_callbacks); |
6207 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( | 6190 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( |
6208 routing_id_, 0, sink_id.utf8(), security_origin) | 6191 routing_id_, 0, sink_id.utf8(), security_origin) |
6209 .device_status()); | 6192 .device_status()); |
6210 } | 6193 } |
6211 | 6194 |
6212 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { | 6195 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { |
6213 return blink_service_registry_.get(); | 6196 return blink_service_registry_.get(); |
6214 } | 6197 } |
6215 | 6198 |
| 6199 blink::WebPageVisibilityState RenderFrameImpl::visibilityState() const { |
| 6200 RenderFrameImpl* local_root = |
| 6201 RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
| 6202 blink::WebPageVisibilityState current_state = |
| 6203 local_root->render_widget_->is_hidden() |
| 6204 ? blink::WebPageVisibilityStateHidden |
| 6205 : blink::WebPageVisibilityStateVisible; |
| 6206 blink::WebPageVisibilityState override_state = current_state; |
| 6207 if (GetContentClient()->renderer()->ShouldOverridePageVisibilityState( |
| 6208 this, &override_state)) |
| 6209 return override_state; |
| 6210 return current_state; |
| 6211 } |
| 6212 |
| 6213 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { |
| 6214 return visibilityState(); |
| 6215 } |
| 6216 |
6216 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | 6217 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
6217 if (frame_->document().isPluginDocument()) | 6218 if (frame_->document().isPluginDocument()) |
6218 return frame_->document().to<WebPluginDocument>().plugin(); | 6219 return frame_->document().to<WebPluginDocument>().plugin(); |
6219 | 6220 |
6220 #if defined(ENABLE_PLUGINS) | 6221 #if defined(ENABLE_PLUGINS) |
6221 if (plugin_find_handler_) | 6222 if (plugin_find_handler_) |
6222 return plugin_find_handler_->container()->plugin(); | 6223 return plugin_find_handler_->container()->plugin(); |
6223 #endif | 6224 #endif |
6224 | 6225 |
6225 return nullptr; | 6226 return nullptr; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6310 // event target. Potentially a Pepper plugin will receive the event. | 6311 // event target. Potentially a Pepper plugin will receive the event. |
6311 // In order to tell whether a plugin gets the last mouse event and which it | 6312 // In order to tell whether a plugin gets the last mouse event and which it |
6312 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6313 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6313 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6314 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6314 // |pepper_last_mouse_event_target_|. | 6315 // |pepper_last_mouse_event_target_|. |
6315 pepper_last_mouse_event_target_ = nullptr; | 6316 pepper_last_mouse_event_target_ = nullptr; |
6316 #endif | 6317 #endif |
6317 } | 6318 } |
6318 | 6319 |
6319 } // namespace content | 6320 } // namespace content |
OLD | NEW |