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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
891 | 891 |
892 RenderFrameImpl* render_frame = | 892 RenderFrameImpl* render_frame = |
893 RenderFrameImpl::Create(render_view, routing_id); | 893 RenderFrameImpl::Create(render_view, routing_id); |
894 render_frame->InitializeBlameContext(nullptr); | 894 render_frame->InitializeBlameContext(nullptr); |
895 WebLocalFrame* web_frame = WebLocalFrame::create( | 895 WebLocalFrame* web_frame = WebLocalFrame::create( |
896 blink::WebTreeScopeType::Document, render_frame, opener); | 896 blink::WebTreeScopeType::Document, render_frame, opener); |
897 render_frame->BindToWebFrame(web_frame); | 897 render_frame->BindToWebFrame(web_frame); |
898 render_view->webview()->setMainFrame(web_frame); | 898 render_view->webview()->setMainFrame(web_frame); |
899 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 899 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
900 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); | 900 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
901 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
902 // WasShown and WasHidden, separating page-level visibility from | |
903 // frame-level visibility. | |
904 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 901 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
905 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) | 902 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) |
906 << "Main frame is no longer reusing the RenderView as its widget! " | 903 << "Main frame is no longer reusing the RenderView as its widget! " |
907 << "Does the RenderFrame need to register itself with the RenderWidget?"; | 904 << "Does the RenderFrame need to register itself with the RenderWidget?"; |
908 return render_frame; | 905 return render_frame; |
909 } | 906 } |
910 | 907 |
911 // static | 908 // static |
912 void RenderFrameImpl::CreateFrame( | 909 void RenderFrameImpl::CreateFrame( |
913 int routing_id, | 910 int routing_id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 | 967 |
971 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 968 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
972 CHECK(!web_frame->parent() || | 969 CHECK(!web_frame->parent() || |
973 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 970 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
974 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 971 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
975 widget_params.routing_id, widget_params.hidden, | 972 widget_params.routing_id, widget_params.hidden, |
976 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 973 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
977 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so | 974 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
978 // avoid double-registering the frame as an observer. | 975 // avoid double-registering the frame as an observer. |
979 // https://crbug.com/545684 | 976 // https://crbug.com/545684 |
980 if (web_frame->parent()) { | 977 if (web_frame->parent()) |
981 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
982 // WasShown and WasHidden, separating page-level visibility from | |
983 // frame-level visibility. | |
984 render_frame->render_widget_->RegisterRenderFrame(render_frame); | 978 render_frame->render_widget_->RegisterRenderFrame(render_frame); |
985 } | |
986 } | 979 } |
987 | 980 |
988 render_frame->Initialize(); | 981 render_frame->Initialize(); |
989 } | 982 } |
990 | 983 |
991 // static | 984 // static |
992 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 985 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
993 return RenderFrameImpl::FromWebFrame(web_frame); | 986 return RenderFrameImpl::FromWebFrame(web_frame); |
994 } | 987 } |
995 | 988 |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1625 if (is_main_frame_) | 1618 if (is_main_frame_) |
1626 render_view_->SetSwappedOut(true); | 1619 render_view_->SetSwappedOut(true); |
1627 | 1620 |
1628 // Transfer settings such as initial drawing parameters to the remote frame, | 1621 // Transfer settings such as initial drawing parameters to the remote frame, |
1629 // if one is created, that will replace this frame. | 1622 // if one is created, that will replace this frame. |
1630 if (!is_main_frame_) | 1623 if (!is_main_frame_) |
1631 proxy->web_frame()->initializeFromFrame(frame_); | 1624 proxy->web_frame()->initializeFromFrame(frame_); |
1632 | 1625 |
1633 // Let WebKit know that this view is hidden so it can drop resources and | 1626 // Let WebKit know that this view is hidden so it can drop resources and |
1634 // stop compositing. | 1627 // stop compositing. |
1635 // TODO(creis): Support this for subframes as well. | |
Charlie Reis
2016/06/08 21:39:07
Hopefully this happens via another path (e.g., a W
lfg
2016/06/08 21:53:50
There's actually nothing that would handle this. H
Charlie Reis
2016/06/08 22:18:35
This happens if you have proxies due to a referenc
lfg
2016/06/08 22:47:34
I see. I think the correct way to do this, is to d
| |
1636 if (is_main_frame_) { | 1628 if (is_main_frame_) { |
1637 render_view_->webview()->setVisibilityState( | 1629 render_view_->webview()->setVisibilityState( |
1638 blink::WebPageVisibilityStateHidden, false); | 1630 blink::WebPageVisibilityStateHidden, false); |
1639 } | 1631 } |
1640 | 1632 |
1641 RenderViewImpl* render_view = render_view_.get(); | 1633 RenderViewImpl* render_view = render_view_.get(); |
1642 bool is_main_frame = is_main_frame_; | 1634 bool is_main_frame = is_main_frame_; |
1643 int routing_id = GetRoutingID(); | 1635 int routing_id = GetRoutingID(); |
1644 | 1636 |
1645 // Now that all of the cleanup is complete and the browser side is notified, | 1637 // Now that all of the cleanup is complete and the browser side is notified, |
(...skipping 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3898 // Explicitly set the SkipServiceWorker flag here if the renderer process | 3890 // Explicitly set the SkipServiceWorker flag here if the renderer process |
3899 // hasn't received SetControllerServiceWorker message. | 3891 // hasn't received SetControllerServiceWorker message. |
3900 if (!provider->IsControlledByServiceWorker()) | 3892 if (!provider->IsControlledByServiceWorker()) |
3901 request.setSkipServiceWorker(true); | 3893 request.setSkipServiceWorker(true); |
3902 } | 3894 } |
3903 | 3895 |
3904 WebFrame* parent = frame->parent(); | 3896 WebFrame* parent = frame->parent(); |
3905 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 3897 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
3906 | 3898 |
3907 RequestExtraData* extra_data = new RequestExtraData(); | 3899 RequestExtraData* extra_data = new RequestExtraData(); |
3908 extra_data->set_visibility_state(render_view_->visibilityState()); | 3900 extra_data->set_visibility_state(visibilityState()); |
3909 extra_data->set_custom_user_agent(custom_user_agent); | 3901 extra_data->set_custom_user_agent(custom_user_agent); |
3910 extra_data->set_requested_with(requested_with); | 3902 extra_data->set_requested_with(requested_with); |
3911 extra_data->set_render_frame_id(routing_id_); | 3903 extra_data->set_render_frame_id(routing_id_); |
3912 extra_data->set_is_main_frame(!parent); | 3904 extra_data->set_is_main_frame(!parent); |
3913 extra_data->set_frame_origin( | 3905 extra_data->set_frame_origin( |
3914 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); | 3906 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); |
3915 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 3907 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
3916 extra_data->set_parent_render_frame_id(parent_routing_id); | 3908 extra_data->set_parent_render_frame_id(parent_routing_id); |
3917 extra_data->set_allow_download( | 3909 extra_data->set_allow_download( |
3918 navigation_state->common_params().allow_download); | 3910 navigation_state->common_params().allow_download); |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4372 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4364 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
4373 } | 4365 } |
4374 | 4366 |
4375 void RenderFrameImpl::WasHidden() { | 4367 void RenderFrameImpl::WasHidden() { |
4376 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4368 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
4377 | 4369 |
4378 #if defined(ENABLE_PLUGINS) | 4370 #if defined(ENABLE_PLUGINS) |
4379 for (auto* plugin : active_pepper_instances_) | 4371 for (auto* plugin : active_pepper_instances_) |
4380 plugin->PageVisibilityChanged(false); | 4372 plugin->PageVisibilityChanged(false); |
4381 #endif // ENABLE_PLUGINS | 4373 #endif // ENABLE_PLUGINS |
4374 | |
4375 if (GetWebFrame()->frameWidget()) { | |
4376 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) | |
4377 ->setVisibilityState(visibilityState()); | |
4378 } | |
4382 } | 4379 } |
4383 | 4380 |
4384 void RenderFrameImpl::WasShown() { | 4381 void RenderFrameImpl::WasShown() { |
4385 // TODO(kenrb): Need to figure out how to do this better. Should | |
4386 // VisibilityState remain a page-level concept or move to frames? | |
4387 // The semantics of 'Show' might have to change here. | |
4388 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | |
4389 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) | |
4390 << "The main render frame is no longer reusing the RenderView as its " | |
4391 << "RenderWidget!"; | |
4392 if (render_widget_ && render_widget_->webwidget() && | |
4393 render_view_.get() != render_widget_.get()) { | |
4394 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | |
4395 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | |
4396 } | |
4397 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4382 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
4398 | 4383 |
4399 #if defined(ENABLE_PLUGINS) | 4384 #if defined(ENABLE_PLUGINS) |
4400 for (auto* plugin : active_pepper_instances_) | 4385 for (auto* plugin : active_pepper_instances_) |
4401 plugin->PageVisibilityChanged(true); | 4386 plugin->PageVisibilityChanged(true); |
4402 #endif // ENABLE_PLUGINS | 4387 #endif // ENABLE_PLUGINS |
4388 | |
4389 if (GetWebFrame()->frameWidget()) { | |
4390 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) | |
4391 ->setVisibilityState(visibilityState()); | |
4392 } | |
4403 } | 4393 } |
4404 | 4394 |
4405 void RenderFrameImpl::WidgetWillClose() { | 4395 void RenderFrameImpl::WidgetWillClose() { |
4406 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4396 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
4407 } | 4397 } |
4408 | 4398 |
4409 bool RenderFrameImpl::IsMainFrame() { | 4399 bool RenderFrameImpl::IsMainFrame() { |
4410 return is_main_frame_; | 4400 return is_main_frame_; |
4411 } | 4401 } |
4412 | 4402 |
(...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6016 media::ConvertToOutputDeviceStatusCB(web_callbacks); | 6006 media::ConvertToOutputDeviceStatusCB(web_callbacks); |
6017 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( | 6007 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( |
6018 routing_id_, 0, sink_id.utf8(), security_origin) | 6008 routing_id_, 0, sink_id.utf8(), security_origin) |
6019 .device_status()); | 6009 .device_status()); |
6020 } | 6010 } |
6021 | 6011 |
6022 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { | 6012 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { |
6023 return &blink_service_registry_; | 6013 return &blink_service_registry_; |
6024 } | 6014 } |
6025 | 6015 |
6016 blink::WebPageVisibilityState RenderFrameImpl::visibilityState() const { | |
6017 RenderFrameImpl* local_root = | |
6018 RenderFrameImpl::FromWebFrame(frame_->localRoot()); | |
6019 blink::WebPageVisibilityState current_state = | |
6020 local_root->render_widget_->is_hidden() | |
6021 ? blink::WebPageVisibilityStateHidden | |
6022 : blink::WebPageVisibilityStateVisible; | |
6023 blink::WebPageVisibilityState override_state = current_state; | |
6024 if (GetContentClient()->renderer()->ShouldOverridePageVisibilityState( | |
6025 this, &override_state)) | |
6026 return override_state; | |
6027 return current_state; | |
6028 } | |
6029 | |
6030 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { | |
6031 return visibilityState(); | |
6032 } | |
6033 | |
6026 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | 6034 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
6027 if (frame_->document().isPluginDocument()) | 6035 if (frame_->document().isPluginDocument()) |
6028 return frame_->document().to<WebPluginDocument>().plugin(); | 6036 return frame_->document().to<WebPluginDocument>().plugin(); |
6029 | 6037 |
6030 #if defined(ENABLE_PLUGINS) | 6038 #if defined(ENABLE_PLUGINS) |
6031 if (plugin_find_handler_) | 6039 if (plugin_find_handler_) |
6032 return plugin_find_handler_->container()->plugin(); | 6040 return plugin_find_handler_->container()->plugin(); |
6033 #endif | 6041 #endif |
6034 | 6042 |
6035 return nullptr; | 6043 return nullptr; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6104 // event target. Potentially a Pepper plugin will receive the event. | 6112 // event target. Potentially a Pepper plugin will receive the event. |
6105 // In order to tell whether a plugin gets the last mouse event and which it | 6113 // In order to tell whether a plugin gets the last mouse event and which it |
6106 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6114 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6107 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6115 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6108 // |pepper_last_mouse_event_target_|. | 6116 // |pepper_last_mouse_event_target_|. |
6109 pepper_last_mouse_event_target_ = nullptr; | 6117 pepper_last_mouse_event_target_ = nullptr; |
6110 #endif | 6118 #endif |
6111 } | 6119 } |
6112 | 6120 |
6113 } // namespace content | 6121 } // namespace content |
OLD | NEW |