Chromium Code Reviews| 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. | |
|
Charlie Reis
2016/06/06 23:15:09
Did this turn out to be wrong? I see the Register
lfg
2016/06/08 20:00:24
Yes, RegisterRenderFrame() is used for many things
Charlie Reis
2016/06/08 21:39:07
Acknowledged.
| |
| 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 2252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3891 // Explicitly set the SkipServiceWorker flag here if the renderer process | 3883 // Explicitly set the SkipServiceWorker flag here if the renderer process |
| 3892 // hasn't received SetControllerServiceWorker message. | 3884 // hasn't received SetControllerServiceWorker message. |
| 3893 if (!provider->IsControlledByServiceWorker()) | 3885 if (!provider->IsControlledByServiceWorker()) |
| 3894 request.setSkipServiceWorker(true); | 3886 request.setSkipServiceWorker(true); |
| 3895 } | 3887 } |
| 3896 | 3888 |
| 3897 WebFrame* parent = frame->parent(); | 3889 WebFrame* parent = frame->parent(); |
| 3898 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 3890 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
| 3899 | 3891 |
| 3900 RequestExtraData* extra_data = new RequestExtraData(); | 3892 RequestExtraData* extra_data = new RequestExtraData(); |
| 3901 extra_data->set_visibility_state(render_view_->visibilityState()); | 3893 extra_data->set_visibility_state(visibilityState()); |
| 3902 extra_data->set_custom_user_agent(custom_user_agent); | 3894 extra_data->set_custom_user_agent(custom_user_agent); |
| 3903 extra_data->set_requested_with(requested_with); | 3895 extra_data->set_requested_with(requested_with); |
| 3904 extra_data->set_render_frame_id(routing_id_); | 3896 extra_data->set_render_frame_id(routing_id_); |
| 3905 extra_data->set_is_main_frame(!parent); | 3897 extra_data->set_is_main_frame(!parent); |
| 3906 extra_data->set_frame_origin( | 3898 extra_data->set_frame_origin( |
| 3907 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); | 3899 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); |
| 3908 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 3900 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
| 3909 extra_data->set_parent_render_frame_id(parent_routing_id); | 3901 extra_data->set_parent_render_frame_id(parent_routing_id); |
| 3910 extra_data->set_allow_download( | 3902 extra_data->set_allow_download( |
| 3911 navigation_state->common_params().allow_download); | 3903 navigation_state->common_params().allow_download); |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4366 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4358 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
| 4367 } | 4359 } |
| 4368 | 4360 |
| 4369 void RenderFrameImpl::WasHidden() { | 4361 void RenderFrameImpl::WasHidden() { |
| 4370 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4362 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
| 4371 | 4363 |
| 4372 #if defined(ENABLE_PLUGINS) | 4364 #if defined(ENABLE_PLUGINS) |
| 4373 for (auto* plugin : active_pepper_instances_) | 4365 for (auto* plugin : active_pepper_instances_) |
| 4374 plugin->PageVisibilityChanged(false); | 4366 plugin->PageVisibilityChanged(false); |
| 4375 #endif // ENABLE_PLUGINS | 4367 #endif // ENABLE_PLUGINS |
| 4368 | |
| 4369 if (GetWebFrame()->frameWidget()) { | |
| 4370 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) | |
| 4371 ->setVisibilityState(visibilityState()); | |
| 4372 } | |
| 4376 } | 4373 } |
| 4377 | 4374 |
| 4378 void RenderFrameImpl::WasShown() { | 4375 void RenderFrameImpl::WasShown() { |
| 4379 // TODO(kenrb): Need to figure out how to do this better. Should | |
| 4380 // VisibilityState remain a page-level concept or move to frames? | |
| 4381 // The semantics of 'Show' might have to change here. | |
| 4382 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | |
| 4383 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) | |
| 4384 << "The main render frame is no longer reusing the RenderView as its " | |
| 4385 << "RenderWidget!"; | |
| 4386 if (render_widget_ && render_widget_->webwidget() && | |
| 4387 render_view_.get() != render_widget_.get()) { | |
| 4388 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | |
| 4389 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | |
| 4390 } | |
| 4391 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4376 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
| 4392 | 4377 |
| 4393 #if defined(ENABLE_PLUGINS) | 4378 #if defined(ENABLE_PLUGINS) |
| 4394 for (auto* plugin : active_pepper_instances_) | 4379 for (auto* plugin : active_pepper_instances_) |
| 4395 plugin->PageVisibilityChanged(true); | 4380 plugin->PageVisibilityChanged(true); |
| 4396 #endif // ENABLE_PLUGINS | 4381 #endif // ENABLE_PLUGINS |
| 4382 | |
| 4383 if (GetWebFrame()->frameWidget()) { | |
| 4384 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) | |
| 4385 ->setVisibilityState(visibilityState()); | |
| 4386 } | |
| 4397 } | 4387 } |
| 4398 | 4388 |
| 4399 void RenderFrameImpl::WidgetWillClose() { | 4389 void RenderFrameImpl::WidgetWillClose() { |
| 4400 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4390 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
| 4401 } | 4391 } |
| 4402 | 4392 |
| 4403 bool RenderFrameImpl::IsMainFrame() { | 4393 bool RenderFrameImpl::IsMainFrame() { |
| 4404 return is_main_frame_; | 4394 return is_main_frame_; |
| 4405 } | 4395 } |
| 4406 | 4396 |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6083 media::ConvertToOutputDeviceStatusCB(web_callbacks); | 6073 media::ConvertToOutputDeviceStatusCB(web_callbacks); |
| 6084 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( | 6074 callback.Run(AudioDeviceFactory::GetOutputDeviceInfo( |
| 6085 routing_id_, 0, sink_id.utf8(), security_origin) | 6075 routing_id_, 0, sink_id.utf8(), security_origin) |
| 6086 .device_status()); | 6076 .device_status()); |
| 6087 } | 6077 } |
| 6088 | 6078 |
| 6089 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { | 6079 blink::ServiceRegistry* RenderFrameImpl::serviceRegistry() { |
| 6090 return &blink_service_registry_; | 6080 return &blink_service_registry_; |
| 6091 } | 6081 } |
| 6092 | 6082 |
| 6083 blink::WebPageVisibilityState RenderFrameImpl::visibilityState() const { | |
| 6084 RenderFrameImpl* local_root = | |
| 6085 RenderFrameImpl::FromWebFrame(frame_->localRoot()); | |
| 6086 blink::WebPageVisibilityState current_state = | |
| 6087 local_root->render_widget_->is_hidden() | |
| 6088 ? blink::WebPageVisibilityStateHidden | |
| 6089 : blink::WebPageVisibilityStateVisible; | |
| 6090 blink::WebPageVisibilityState override_state = current_state; | |
| 6091 if (GetContentClient()->renderer()->ShouldOverridePageVisibilityState( | |
| 6092 this, &override_state)) | |
| 6093 return override_state; | |
| 6094 return current_state; | |
| 6095 } | |
| 6096 | |
| 6097 blink::WebPageVisibilityState RenderFrameImpl::GetVisibilityState() const { | |
| 6098 return visibilityState(); | |
| 6099 } | |
| 6100 | |
| 6093 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | 6101 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { |
| 6094 if (!is_main_frame_) | 6102 if (!is_main_frame_) |
| 6095 return nullptr; | 6103 return nullptr; |
| 6096 | 6104 |
| 6097 if (frame_->document().isPluginDocument()) | 6105 if (frame_->document().isPluginDocument()) |
| 6098 return frame_->document().to<WebPluginDocument>().plugin(); | 6106 return frame_->document().to<WebPluginDocument>().plugin(); |
| 6099 | 6107 |
| 6100 #if defined(ENABLE_PLUGINS) | 6108 #if defined(ENABLE_PLUGINS) |
| 6101 if (plugin_find_handler_) | 6109 if (plugin_find_handler_) |
| 6102 return plugin_find_handler_->container()->plugin(); | 6110 return plugin_find_handler_->container()->plugin(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6167 // event target. Potentially a Pepper plugin will receive the event. | 6175 // event target. Potentially a Pepper plugin will receive the event. |
| 6168 // In order to tell whether a plugin gets the last mouse event and which it | 6176 // In order to tell whether a plugin gets the last mouse event and which it |
| 6169 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6177 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6170 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6178 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6171 // |pepper_last_mouse_event_target_|. | 6179 // |pepper_last_mouse_event_target_|. |
| 6172 pepper_last_mouse_event_target_ = nullptr; | 6180 pepper_last_mouse_event_target_ = nullptr; |
| 6173 #endif | 6181 #endif |
| 6174 } | 6182 } |
| 6175 | 6183 |
| 6176 } // namespace content | 6184 } // namespace content |
| OLD | NEW |