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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 887 |
888 RenderFrameImpl* render_frame = | 888 RenderFrameImpl* render_frame = |
889 RenderFrameImpl::Create(render_view, routing_id); | 889 RenderFrameImpl::Create(render_view, routing_id); |
890 render_frame->InitializeBlameContext(nullptr); | 890 render_frame->InitializeBlameContext(nullptr); |
891 WebLocalFrame* web_frame = WebLocalFrame::create( | 891 WebLocalFrame* web_frame = WebLocalFrame::create( |
892 blink::WebTreeScopeType::Document, render_frame, opener); | 892 blink::WebTreeScopeType::Document, render_frame, opener); |
893 render_frame->BindToWebFrame(web_frame); | 893 render_frame->BindToWebFrame(web_frame); |
894 render_view->webview()->setMainFrame(web_frame); | 894 render_view->webview()->setMainFrame(web_frame); |
895 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 895 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
896 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); | 896 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
897 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
898 // WasShown and WasHidden, separating page-level visibility from | |
899 // frame-level visibility. | |
900 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 897 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
901 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) | 898 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) |
902 << "Main frame is no longer reusing the RenderView as its widget! " | 899 << "Main frame is no longer reusing the RenderView as its widget! " |
903 << "Does the RenderFrame need to register itself with the RenderWidget?"; | 900 << "Does the RenderFrame need to register itself with the RenderWidget?"; |
904 return render_frame; | 901 return render_frame; |
905 } | 902 } |
906 | 903 |
907 // static | 904 // static |
908 void RenderFrameImpl::CreateFrame( | 905 void RenderFrameImpl::CreateFrame( |
909 int routing_id, | 906 int routing_id, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 | 963 |
967 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 964 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
968 CHECK(!web_frame->parent() || | 965 CHECK(!web_frame->parent() || |
969 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 966 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
970 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 967 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
971 widget_params.routing_id, widget_params.hidden, | 968 widget_params.routing_id, widget_params.hidden, |
972 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 969 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
973 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so | 970 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
974 // avoid double-registering the frame as an observer. | 971 // avoid double-registering the frame as an observer. |
975 // https://crbug.com/545684 | 972 // https://crbug.com/545684 |
976 if (web_frame->parent()) { | 973 if (web_frame->parent()) |
977 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
978 // WasShown and WasHidden, separating page-level visibility from | |
979 // frame-level visibility. | |
980 render_frame->render_widget_->RegisterRenderFrame(render_frame); | 974 render_frame->render_widget_->RegisterRenderFrame(render_frame); |
981 } | |
982 } | 975 } |
983 | 976 |
984 render_frame->Initialize(); | 977 render_frame->Initialize(); |
985 } | 978 } |
986 | 979 |
987 // static | 980 // static |
988 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 981 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
989 return RenderFrameImpl::FromWebFrame(web_frame); | 982 return RenderFrameImpl::FromWebFrame(web_frame); |
990 } | 983 } |
991 | 984 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 if (is_main_frame_) | 1611 if (is_main_frame_) |
1619 render_view_->SetSwappedOut(true); | 1612 render_view_->SetSwappedOut(true); |
1620 | 1613 |
1621 // Transfer settings such as initial drawing parameters to the remote frame, | 1614 // Transfer settings such as initial drawing parameters to the remote frame, |
1622 // if one is created, that will replace this frame. | 1615 // if one is created, that will replace this frame. |
1623 if (!is_main_frame_) | 1616 if (!is_main_frame_) |
1624 proxy->web_frame()->initializeFromFrame(frame_); | 1617 proxy->web_frame()->initializeFromFrame(frame_); |
1625 | 1618 |
1626 // Let WebKit know that this view is hidden so it can drop resources and | 1619 // Let WebKit know that this view is hidden so it can drop resources and |
1627 // stop compositing. | 1620 // stop compositing. |
1628 // TODO(creis): Support this for subframes as well. | |
1629 if (is_main_frame_) { | 1621 if (is_main_frame_) { |
1630 render_view_->webview()->setVisibilityState( | 1622 render_view_->webview()->setVisibilityState( |
1631 blink::WebPageVisibilityStateHidden, false); | 1623 blink::WebPageVisibilityStateHidden, false); |
1632 } | 1624 } |
1633 | 1625 |
1634 RenderViewImpl* render_view = render_view_.get(); | 1626 RenderViewImpl* render_view = render_view_.get(); |
1635 bool is_main_frame = is_main_frame_; | 1627 bool is_main_frame = is_main_frame_; |
1636 int routing_id = GetRoutingID(); | 1628 int routing_id = GetRoutingID(); |
1637 | 1629 |
1638 // Now that all of the cleanup is complete and the browser side is notified, | 1630 // 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... |
3889 // Explicitly set the SkipServiceWorker flag here if the renderer process | 3881 // Explicitly set the SkipServiceWorker flag here if the renderer process |
3890 // hasn't received SetControllerServiceWorker message. | 3882 // hasn't received SetControllerServiceWorker message. |
3891 if (!provider->IsControlledByServiceWorker()) | 3883 if (!provider->IsControlledByServiceWorker()) |
3892 request.setSkipServiceWorker(true); | 3884 request.setSkipServiceWorker(true); |
3893 } | 3885 } |
3894 | 3886 |
3895 WebFrame* parent = frame->parent(); | 3887 WebFrame* parent = frame->parent(); |
3896 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 3888 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
3897 | 3889 |
3898 RequestExtraData* extra_data = new RequestExtraData(); | 3890 RequestExtraData* extra_data = new RequestExtraData(); |
3899 extra_data->set_visibility_state(render_view_->visibilityState()); | 3891 extra_data->set_visibility_state(visibilityState()); |
3900 extra_data->set_custom_user_agent(custom_user_agent); | 3892 extra_data->set_custom_user_agent(custom_user_agent); |
3901 extra_data->set_requested_with(requested_with); | 3893 extra_data->set_requested_with(requested_with); |
3902 extra_data->set_render_frame_id(routing_id_); | 3894 extra_data->set_render_frame_id(routing_id_); |
3903 extra_data->set_is_main_frame(!parent); | 3895 extra_data->set_is_main_frame(!parent); |
3904 extra_data->set_frame_origin( | 3896 extra_data->set_frame_origin( |
3905 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); | 3897 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); |
3906 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 3898 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
3907 extra_data->set_parent_render_frame_id(parent_routing_id); | 3899 extra_data->set_parent_render_frame_id(parent_routing_id); |
3908 extra_data->set_allow_download( | 3900 extra_data->set_allow_download( |
3909 navigation_state->common_params().allow_download); | 3901 navigation_state->common_params().allow_download); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4364 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4356 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
4365 } | 4357 } |
4366 | 4358 |
4367 void RenderFrameImpl::WasHidden() { | 4359 void RenderFrameImpl::WasHidden() { |
4368 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4360 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
4369 | 4361 |
4370 #if defined(ENABLE_PLUGINS) | 4362 #if defined(ENABLE_PLUGINS) |
4371 for (auto* plugin : active_pepper_instances_) | 4363 for (auto* plugin : active_pepper_instances_) |
4372 plugin->PageVisibilityChanged(false); | 4364 plugin->PageVisibilityChanged(false); |
4373 #endif // ENABLE_PLUGINS | 4365 #endif // ENABLE_PLUGINS |
| 4366 |
| 4367 if (GetWebFrame()->frameWidget()) { |
| 4368 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) |
| 4369 ->setVisibilityState(visibilityState()); |
| 4370 } |
4374 } | 4371 } |
4375 | 4372 |
4376 void RenderFrameImpl::WasShown() { | 4373 void RenderFrameImpl::WasShown() { |
4377 // TODO(kenrb): Need to figure out how to do this better. Should | |
4378 // VisibilityState remain a page-level concept or move to frames? | |
4379 // The semantics of 'Show' might have to change here. | |
4380 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | |
4381 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) | |
4382 << "The main render frame is no longer reusing the RenderView as its " | |
4383 << "RenderWidget!"; | |
4384 if (render_widget_ && render_widget_->webwidget() && | |
4385 render_view_.get() != render_widget_.get()) { | |
4386 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | |
4387 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | |
4388 } | |
4389 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4374 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
4390 | 4375 |
4391 #if defined(ENABLE_PLUGINS) | 4376 #if defined(ENABLE_PLUGINS) |
4392 for (auto* plugin : active_pepper_instances_) | 4377 for (auto* plugin : active_pepper_instances_) |
4393 plugin->PageVisibilityChanged(true); | 4378 plugin->PageVisibilityChanged(true); |
4394 #endif // ENABLE_PLUGINS | 4379 #endif // ENABLE_PLUGINS |
| 4380 |
| 4381 if (GetWebFrame()->frameWidget()) { |
| 4382 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) |
| 4383 ->setVisibilityState(visibilityState()); |
| 4384 } |
4395 } | 4385 } |
4396 | 4386 |
4397 void RenderFrameImpl::WidgetWillClose() { | 4387 void RenderFrameImpl::WidgetWillClose() { |
4398 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4388 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
4399 } | 4389 } |
4400 | 4390 |
4401 bool RenderFrameImpl::IsMainFrame() { | 4391 bool RenderFrameImpl::IsMainFrame() { |
4402 return is_main_frame_; | 4392 return is_main_frame_; |
4403 } | 4393 } |
4404 | 4394 |
(...skipping 1677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6082 media::ConvertToOutputDeviceStatusCB(web_callbacks); | 6072 media::ConvertToOutputDeviceStatusCB(web_callbacks); |
6083 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( | 6073 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( |
6084 routing_id_, 0, sink_id.utf8(), security_origin) | 6074 routing_id_, 0, sink_id.utf8(), security_origin) |
6085 .device_status()); | 6075 .device_status()); |
6086 } | 6076 } |
6087 | 6077 |
6088 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { | 6078 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { |
6089 return &blink_service_registry_; | 6079 return &blink_service_registry_; |
6090 } | 6080 } |
6091 | 6081 |
| 6082 blink::WebPageVisibilityState RenderFrameImpl::visibilityState() const { |
| 6083 RenderFrameImpl* local_root = |
| 6084 RenderFrameImpl::FromWebFrame(frame_->localRoot()); |
| 6085 blink::WebPageVisibilityState current_state = |
| 6086 local_root->render_widget_->is_hidden() |
| 6087 ? blink::WebPageVisibilityStateHidden |
| 6088 : blink::WebPageVisibilityStateVisible; |
| 6089 blink::WebPageVisibilityState override_state = current_state; |
| 6090 if (GetContentClient()->renderer()->ShouldOverridePageVisibilityState( |
| 6091 this, &override_state)) |
| 6092 return override_state; |
| 6093 return current_state; |
| 6094 } |
| 6095 |
| 6096 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { |
| 6097 return visibilityState(); |
| 6098 } |
| 6099 |
6092 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | 6100 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
6093 if (!is_main_frame_) | 6101 if (!is_main_frame_) |
6094 return nullptr; | 6102 return nullptr; |
6095 | 6103 |
6096 if (frame_->document().isPluginDocument()) | 6104 if (frame_->document().isPluginDocument()) |
6097 return frame_->document().to<WebPluginDocument>().plugin(); | 6105 return frame_->document().to<WebPluginDocument>().plugin(); |
6098 | 6106 |
6099 #if defined(ENABLE_PLUGINS) | 6107 #if defined(ENABLE_PLUGINS) |
6100 if (plugin_find_handler_) | 6108 if (plugin_find_handler_) |
6101 return plugin_find_handler_->container()->plugin(); | 6109 return plugin_find_handler_->container()->plugin(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6166 // event target. Potentially a Pepper plugin will receive the event. | 6174 // event target. Potentially a Pepper plugin will receive the event. |
6167 // In order to tell whether a plugin gets the last mouse event and which it | 6175 // In order to tell whether a plugin gets the last mouse event and which it |
6168 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6176 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6169 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6177 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6170 // |pepper_last_mouse_event_target_|. | 6178 // |pepper_last_mouse_event_target_|. |
6171 pepper_last_mouse_event_target_ = nullptr; | 6179 pepper_last_mouse_event_target_ = nullptr; |
6172 #endif | 6180 #endif |
6173 } | 6181 } |
6174 | 6182 |
6175 } // namespace content | 6183 } // namespace content |
OLD | NEW |