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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 | 903 |
904 RenderFrameImpl* render_frame = | 904 RenderFrameImpl* render_frame = |
905 RenderFrameImpl::Create(render_view, routing_id); | 905 RenderFrameImpl::Create(render_view, routing_id); |
906 render_frame->InitializeBlameContext(nullptr); | 906 render_frame->InitializeBlameContext(nullptr); |
907 WebLocalFrame* web_frame = WebLocalFrame::create( | 907 WebLocalFrame* web_frame = WebLocalFrame::create( |
908 blink::WebTreeScopeType::Document, render_frame, opener); | 908 blink::WebTreeScopeType::Document, render_frame, opener); |
909 render_frame->BindToWebFrame(web_frame); | 909 render_frame->BindToWebFrame(web_frame); |
910 render_view->webview()->setMainFrame(web_frame); | 910 render_view->webview()->setMainFrame(web_frame); |
911 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 911 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
912 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); | 912 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
913 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
914 // WasShown and WasHidden, separating page-level visibility from | |
915 // frame-level visibility. | |
916 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 913 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
917 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) | 914 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) |
918 << "Main frame is no longer reusing the RenderView as its widget! " | 915 << "Main frame is no longer reusing the RenderView as its widget! " |
919 << "Does the RenderFrame need to register itself with the RenderWidget?"; | 916 << "Does the RenderFrame need to register itself with the RenderWidget?"; |
920 return render_frame; | 917 return render_frame; |
921 } | 918 } |
922 | 919 |
923 // static | 920 // static |
924 void RenderFrameImpl::CreateFrame( | 921 void RenderFrameImpl::CreateFrame( |
925 int routing_id, | 922 int routing_id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 | 979 |
983 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 980 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
984 CHECK(!web_frame->parent() || | 981 CHECK(!web_frame->parent() || |
985 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 982 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
986 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 983 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
987 widget_params.routing_id, widget_params.hidden, | 984 widget_params.routing_id, widget_params.hidden, |
988 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 985 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
989 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so | 986 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
990 // avoid double-registering the frame as an observer. | 987 // avoid double-registering the frame as an observer. |
991 // https://crbug.com/545684 | 988 // https://crbug.com/545684 |
992 if (web_frame->parent()) { | 989 if (web_frame->parent()) |
993 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
994 // WasShown and WasHidden, separating page-level visibility from | |
995 // frame-level visibility. | |
996 render_frame->render_widget_->RegisterRenderFrame(render_frame); | 990 render_frame->render_widget_->RegisterRenderFrame(render_frame); |
997 } | |
998 } | 991 } |
999 | 992 |
1000 render_frame->Initialize(); | 993 render_frame->Initialize(); |
1001 } | 994 } |
1002 | 995 |
1003 // static | 996 // static |
1004 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 997 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
1005 return RenderFrameImpl::FromWebFrame(web_frame); | 998 return RenderFrameImpl::FromWebFrame(web_frame); |
1006 } | 999 } |
1007 | 1000 |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 if (is_main_frame_) | 1619 if (is_main_frame_) |
1627 render_view_->SetSwappedOut(true); | 1620 render_view_->SetSwappedOut(true); |
1628 | 1621 |
1629 // Transfer settings such as initial drawing parameters to the remote frame, | 1622 // Transfer settings such as initial drawing parameters to the remote frame, |
1630 // if one is created, that will replace this frame. | 1623 // if one is created, that will replace this frame. |
1631 if (!is_main_frame_) | 1624 if (!is_main_frame_) |
1632 proxy->web_frame()->initializeFromFrame(frame_); | 1625 proxy->web_frame()->initializeFromFrame(frame_); |
1633 | 1626 |
1634 // Let WebKit know that this view is hidden so it can drop resources and | 1627 // Let WebKit know that this view is hidden so it can drop resources and |
1635 // stop compositing. | 1628 // stop compositing. |
1636 // TODO(creis): Support this for subframes as well. | |
1637 if (is_main_frame_) { | 1629 if (is_main_frame_) { |
1638 render_view_->webview()->setVisibilityState( | 1630 render_view_->webview()->setVisibilityState( |
1639 blink::WebPageVisibilityStateHidden, false); | 1631 blink::WebPageVisibilityStateHidden, false); |
1640 } | 1632 } |
1641 | 1633 |
1642 RenderViewImpl* render_view = render_view_.get(); | 1634 RenderViewImpl* render_view = render_view_.get(); |
1643 bool is_main_frame = is_main_frame_; | 1635 bool is_main_frame = is_main_frame_; |
1644 int routing_id = GetRoutingID(); | 1636 int routing_id = GetRoutingID(); |
1645 | 1637 |
1646 // Now that all of the cleanup is complete and the browser side is notified, | 1638 // Now that all of the cleanup is complete and the browser side is notified, |
(...skipping 2250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3897 // Explicitly set the SkipServiceWorker flag here if the renderer process | 3889 // Explicitly set the SkipServiceWorker flag here if the renderer process |
3898 // hasn't received SetControllerServiceWorker message. | 3890 // hasn't received SetControllerServiceWorker message. |
3899 if (!provider->IsControlledByServiceWorker()) | 3891 if (!provider->IsControlledByServiceWorker()) |
3900 request.setSkipServiceWorker(true); | 3892 request.setSkipServiceWorker(true); |
3901 } | 3893 } |
3902 | 3894 |
3903 WebFrame* parent = frame->parent(); | 3895 WebFrame* parent = frame->parent(); |
3904 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 3896 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
3905 | 3897 |
3906 RequestExtraData* extra_data = new RequestExtraData(); | 3898 RequestExtraData* extra_data = new RequestExtraData(); |
3907 extra_data->set_visibility_state(render_view_->visibilityState()); | 3899 extra_data->set_visibility_state(visibilityState()); |
3908 extra_data->set_custom_user_agent(custom_user_agent); | 3900 extra_data->set_custom_user_agent(custom_user_agent); |
3909 extra_data->set_requested_with(requested_with); | 3901 extra_data->set_requested_with(requested_with); |
3910 extra_data->set_render_frame_id(routing_id_); | 3902 extra_data->set_render_frame_id(routing_id_); |
3911 extra_data->set_is_main_frame(!parent); | 3903 extra_data->set_is_main_frame(!parent); |
3912 extra_data->set_frame_origin( | 3904 extra_data->set_frame_origin( |
3913 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); | 3905 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); |
3914 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 3906 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
3915 extra_data->set_parent_render_frame_id(parent_routing_id); | 3907 extra_data->set_parent_render_frame_id(parent_routing_id); |
3916 extra_data->set_allow_download( | 3908 extra_data->set_allow_download( |
3917 navigation_state->common_params().allow_download); | 3909 navigation_state->common_params().allow_download); |
(...skipping 454 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 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6085 media::ConvertToOutputDeviceStatusCB(web_callbacks); | 6075 media::ConvertToOutputDeviceStatusCB(web_callbacks); |
6086 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( | 6076 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( |
6087 routing_id_, 0, sink_id.utf8(), security_origin) | 6077 routing_id_, 0, sink_id.utf8(), security_origin) |
6088 .device_status()); | 6078 .device_status()); |
6089 } | 6079 } |
6090 | 6080 |
6091 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { | 6081 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { |
6092 return &blink_service_registry_; | 6082 return &blink_service_registry_; |
6093 } | 6083 } |
6094 | 6084 |
| 6085 blink::WebPageVisibilityState RenderFrameImpl::visibilityState() const { |
| 6086 RenderFrameImpl* local_root = |
| 6087 RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
| 6088 blink::WebPageVisibilityState current_state = |
| 6089 local_root->render_widget_->is_hidden() |
| 6090 ? blink::WebPageVisibilityStateHidden |
| 6091 : blink::WebPageVisibilityStateVisible; |
| 6092 blink::WebPageVisibilityState override_state = current_state; |
| 6093 if (GetContentClient()->renderer()->ShouldOverridePageVisibilityState( |
| 6094 this, &override_state)) |
| 6095 return override_state; |
| 6096 return current_state; |
| 6097 } |
| 6098 |
| 6099 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { |
| 6100 return visibilityState(); |
| 6101 } |
| 6102 |
6095 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | 6103 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
6096 if (!is_main_frame_) | 6104 if (!is_main_frame_) |
6097 return nullptr; | 6105 return nullptr; |
6098 | 6106 |
6099 if (frame_->document().isPluginDocument()) | 6107 if (frame_->document().isPluginDocument()) |
6100 return frame_->document().to<WebPluginDocument>().plugin(); | 6108 return frame_->document().to<WebPluginDocument>().plugin(); |
6101 | 6109 |
6102 #if defined(ENABLE_PLUGINS) | 6110 #if defined(ENABLE_PLUGINS) |
6103 if (plugin_find_handler_) | 6111 if (plugin_find_handler_) |
6104 return plugin_find_handler_->container()->plugin(); | 6112 return plugin_find_handler_->container()->plugin(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6169 // event target. Potentially a Pepper plugin will receive the event. | 6177 // event target. Potentially a Pepper plugin will receive the event. |
6170 // In order to tell whether a plugin gets the last mouse event and which it | 6178 // In order to tell whether a plugin gets the last mouse event and which it |
6171 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6179 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6172 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6180 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6173 // |pepper_last_mouse_event_target_|. | 6181 // |pepper_last_mouse_event_target_|. |
6174 pepper_last_mouse_event_target_ = nullptr; | 6182 pepper_last_mouse_event_target_ = nullptr; |
6175 #endif | 6183 #endif |
6176 } | 6184 } |
6177 | 6185 |
6178 } // namespace content | 6186 } // namespace content |
OLD | NEW |