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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 | 879 |
| 880 RenderFrameImpl* render_frame = | 880 RenderFrameImpl* render_frame = |
| 881 RenderFrameImpl::Create(render_view, routing_id); | 881 RenderFrameImpl::Create(render_view, routing_id); |
| 882 render_frame->InitializeBlameContext(nullptr); | 882 render_frame->InitializeBlameContext(nullptr); |
| 883 WebLocalFrame* web_frame = WebLocalFrame::create( | 883 WebLocalFrame* web_frame = WebLocalFrame::create( |
| 884 blink::WebTreeScopeType::Document, render_frame, opener); | 884 blink::WebTreeScopeType::Document, render_frame, opener); |
| 885 render_frame->BindToWebFrame(web_frame); | 885 render_frame->BindToWebFrame(web_frame); |
| 886 render_view->webview()->setMainFrame(web_frame); | 886 render_view->webview()->setMainFrame(web_frame); |
| 887 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 887 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
| 888 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); | 888 widget_routing_id, hidden, screen_info, compositor_deps, web_frame); |
| 889 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
| 890 // WasShown and WasHidden, separating page-level visibility from | |
| 891 // frame-level visibility. | |
| 892 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 889 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
| 893 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) | 890 DCHECK_EQ(render_view->GetWidget(), render_frame->render_widget_) |
| 894 << "Main frame is no longer reusing the RenderView as its widget! " | 891 << "Main frame is no longer reusing the RenderView as its widget! " |
| 895 << "Does the RenderFrame need to register itself with the RenderWidget?"; | 892 << "Does the RenderFrame need to register itself with the RenderWidget?"; |
| 896 return render_frame; | 893 return render_frame; |
| 897 } | 894 } |
| 898 | 895 |
| 899 // static | 896 // static |
| 900 void RenderFrameImpl::CreateFrame( | 897 void RenderFrameImpl::CreateFrame( |
| 901 int routing_id, | 898 int routing_id, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 959 | 956 |
| 960 if (widget_params.routing_id != MSG_ROUTING_NONE) { | 957 if (widget_params.routing_id != MSG_ROUTING_NONE) { |
| 961 CHECK(!web_frame->parent() || | 958 CHECK(!web_frame->parent() || |
| 962 SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 959 SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 963 render_frame->render_widget_ = RenderWidget::CreateForFrame( | 960 render_frame->render_widget_ = RenderWidget::CreateForFrame( |
| 964 widget_params.routing_id, widget_params.hidden, | 961 widget_params.routing_id, widget_params.hidden, |
| 965 render_frame->render_view_->screen_info(), compositor_deps, web_frame); | 962 render_frame->render_view_->screen_info(), compositor_deps, web_frame); |
| 966 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so | 963 // TODO(avi): The main frame re-uses the RenderViewImpl as its widget, so |
| 967 // avoid double-registering the frame as an observer. | 964 // avoid double-registering the frame as an observer. |
| 968 // https://crbug.com/545684 | 965 // https://crbug.com/545684 |
| 969 if (web_frame->parent()) { | 966 if (web_frame->parent()) |
| 970 // TODO(kenrb): Observing shouldn't be necessary when we sort out | |
| 971 // WasShown and WasHidden, separating page-level visibility from | |
| 972 // frame-level visibility. | |
| 973 render_frame->render_widget_->RegisterRenderFrame(render_frame); | 967 render_frame->render_widget_->RegisterRenderFrame(render_frame); |
| 974 } | |
| 975 } | 968 } |
| 976 | 969 |
| 977 render_frame->Initialize(); | 970 render_frame->Initialize(); |
| 978 } | 971 } |
| 979 | 972 |
| 980 // static | 973 // static |
| 981 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 974 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
| 982 return RenderFrameImpl::FromWebFrame(web_frame); | 975 return RenderFrameImpl::FromWebFrame(web_frame); |
| 983 } | 976 } |
| 984 | 977 |
| (...skipping 633 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 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3899 // Explicitly set the SkipServiceWorker flag here if the renderer process | 3891 // Explicitly set the SkipServiceWorker flag here if the renderer process |
| 3900 // hasn't received SetControllerServiceWorker message. | 3892 // hasn't received SetControllerServiceWorker message. |
| 3901 if (!provider->IsControlledByServiceWorker()) | 3893 if (!provider->IsControlledByServiceWorker()) |
| 3902 request.setSkipServiceWorker(true); | 3894 request.setSkipServiceWorker(true); |
| 3903 } | 3895 } |
| 3904 | 3896 |
| 3905 WebFrame* parent = frame->parent(); | 3897 WebFrame* parent = frame->parent(); |
| 3906 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; | 3898 int parent_routing_id = parent ? GetRoutingIdForFrameOrProxy(parent) : -1; |
| 3907 | 3899 |
| 3908 RequestExtraData* extra_data = new RequestExtraData(); | 3900 RequestExtraData* extra_data = new RequestExtraData(); |
| 3909 extra_data->set_visibility_state(render_view_->visibilityState()); | 3901 extra_data->set_visibility_state(visibilityState()); |
| 3910 extra_data->set_custom_user_agent(custom_user_agent); | 3902 extra_data->set_custom_user_agent(custom_user_agent); |
| 3911 extra_data->set_requested_with(requested_with); | 3903 extra_data->set_requested_with(requested_with); |
| 3912 extra_data->set_render_frame_id(routing_id_); | 3904 extra_data->set_render_frame_id(routing_id_); |
| 3913 extra_data->set_is_main_frame(!parent); | 3905 extra_data->set_is_main_frame(!parent); |
| 3914 extra_data->set_frame_origin( | 3906 extra_data->set_frame_origin( |
| 3915 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); | 3907 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString())); |
| 3916 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 3908 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
| 3917 extra_data->set_parent_render_frame_id(parent_routing_id); | 3909 extra_data->set_parent_render_frame_id(parent_routing_id); |
| 3918 extra_data->set_allow_download( | 3910 extra_data->set_allow_download( |
| 3919 navigation_state->common_params().allow_download); | 3911 navigation_state->common_params().allow_download); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4384 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4376 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
| 4385 } | 4377 } |
| 4386 | 4378 |
| 4387 void RenderFrameImpl::WasHidden() { | 4379 void RenderFrameImpl::WasHidden() { |
| 4388 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4380 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
| 4389 | 4381 |
| 4390 #if defined(ENABLE_PLUGINS) | 4382 #if defined(ENABLE_PLUGINS) |
| 4391 for (auto* plugin : active_pepper_instances_) | 4383 for (auto* plugin : active_pepper_instances_) |
| 4392 plugin->PageVisibilityChanged(false); | 4384 plugin->PageVisibilityChanged(false); |
| 4393 #endif // ENABLE_PLUGINS | 4385 #endif // ENABLE_PLUGINS |
| 4386 | |
| 4387 if (IsLocalRoot() && GetWebFrame()->frameWidget()) { | |
|
dcheng
2016/05/24 20:38:24
Why do we need both checks here? I would expect on
lfg
2016/05/24 23:33:50
Removed.
| |
| 4388 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) | |
| 4389 ->setVisibilityState(visibilityState()); | |
| 4390 } | |
| 4394 } | 4391 } |
| 4395 | 4392 |
| 4396 void RenderFrameImpl::WasShown() { | 4393 void RenderFrameImpl::WasShown() { |
| 4397 // TODO(kenrb): Need to figure out how to do this better. Should | |
| 4398 // VisibilityState remain a page-level concept or move to frames? | |
| 4399 // The semantics of 'Show' might have to change here. | |
| 4400 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | |
| 4401 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) | |
| 4402 << "The main render frame is no longer reusing the RenderView as its " | |
| 4403 << "RenderWidget!"; | |
| 4404 if (render_widget_ && render_widget_->webwidget() && | |
| 4405 render_view_.get() != render_widget_.get()) { | |
| 4406 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | |
| 4407 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | |
| 4408 } | |
| 4409 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4394 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
| 4410 | 4395 |
| 4411 #if defined(ENABLE_PLUGINS) | 4396 #if defined(ENABLE_PLUGINS) |
| 4412 for (auto* plugin : active_pepper_instances_) | 4397 for (auto* plugin : active_pepper_instances_) |
| 4413 plugin->PageVisibilityChanged(true); | 4398 plugin->PageVisibilityChanged(true); |
| 4414 #endif // ENABLE_PLUGINS | 4399 #endif // ENABLE_PLUGINS |
| 4400 | |
| 4401 if (IsLocalRoot() && GetWebFrame()->frameWidget()) { | |
|
kenrb
2016/05/24 20:25:18
Can GetWebFrame() return nullptr here, if this is
lfg
2016/05/24 23:33:50
No, the RenderFrameImpl is synchronously deleted i
| |
| 4402 static_cast<blink::WebFrameWidget*>(GetWebFrame()->frameWidget()) | |
| 4403 ->setVisibilityState(visibilityState()); | |
| 4404 } | |
| 4415 } | 4405 } |
| 4416 | 4406 |
| 4417 void RenderFrameImpl::WidgetWillClose() { | 4407 void RenderFrameImpl::WidgetWillClose() { |
| 4418 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4408 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
| 4419 } | 4409 } |
| 4420 | 4410 |
| 4421 bool RenderFrameImpl::IsMainFrame() { | 4411 bool RenderFrameImpl::IsMainFrame() { |
| 4422 return is_main_frame_; | 4412 return is_main_frame_; |
| 4423 } | 4413 } |
| 4424 | 4414 |
| (...skipping 1657 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 |