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 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 #include "content/renderer/media/media_stream_renderer_factory.h" | 69 #include "content/renderer/media/media_stream_renderer_factory.h" |
70 #include "content/renderer/media/midi_dispatcher.h" | 70 #include "content/renderer/media/midi_dispatcher.h" |
71 #include "content/renderer/media/render_media_log.h" | 71 #include "content/renderer/media/render_media_log.h" |
72 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 72 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
73 #include "content/renderer/media/webmediaplayer_impl.h" | 73 #include "content/renderer/media/webmediaplayer_impl.h" |
74 #include "content/renderer/media/webmediaplayer_ms.h" | 74 #include "content/renderer/media/webmediaplayer_ms.h" |
75 #include "content/renderer/media/webmediaplayer_params.h" | 75 #include "content/renderer/media/webmediaplayer_params.h" |
76 #include "content/renderer/notification_provider.h" | 76 #include "content/renderer/notification_provider.h" |
77 #include "content/renderer/npapi/plugin_channel_host.h" | 77 #include "content/renderer/npapi/plugin_channel_host.h" |
78 #include "content/renderer/push_messaging_dispatcher.h" | 78 #include "content/renderer/push_messaging_dispatcher.h" |
79 #include "content/renderer/render_frame_proxy.h" | |
79 #include "content/renderer/render_process.h" | 80 #include "content/renderer/render_process.h" |
80 #include "content/renderer/render_thread_impl.h" | 81 #include "content/renderer/render_thread_impl.h" |
81 #include "content/renderer/render_view_impl.h" | 82 #include "content/renderer/render_view_impl.h" |
82 #include "content/renderer/render_widget_fullscreen_pepper.h" | 83 #include "content/renderer/render_widget_fullscreen_pepper.h" |
83 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 84 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
84 #include "content/renderer/renderer_webcolorchooser_impl.h" | 85 #include "content/renderer/renderer_webcolorchooser_impl.h" |
85 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" | 86 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" |
86 #include "content/renderer/shared_worker_repository.h" | 87 #include "content/renderer/shared_worker_repository.h" |
87 #include "content/renderer/v8_value_converter_impl.h" | 88 #include "content/renderer/v8_value_converter_impl.h" |
88 #include "content/renderer/websharedworker_proxy.h" | 89 #include "content/renderer/websharedworker_proxy.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 // static | 368 // static |
368 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { | 369 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { |
369 RoutingIDFrameMap::iterator iter = | 370 RoutingIDFrameMap::iterator iter = |
370 g_routing_id_frame_map.Get().find(routing_id); | 371 g_routing_id_frame_map.Get().find(routing_id); |
371 if (iter != g_routing_id_frame_map.Get().end()) | 372 if (iter != g_routing_id_frame_map.Get().end()) |
372 return iter->second; | 373 return iter->second; |
373 return NULL; | 374 return NULL; |
374 } | 375 } |
375 | 376 |
376 // static | 377 // static |
378 void RenderFrameImpl::CreateFrame(int routing_id, int parent_routing_id) { | |
379 // TODO(nasko): The IPC documentation for this message says | |
Charlie Reis
2014/07/28 19:24:28
Let's replace this with the comment from RenderThr
kenrb
2014/07/28 21:07:21
Done.
| |
380 // parent_routing_id can be MSG_ROUTING_NONE for a top-level frame. Is that | |
381 // incorrect? | |
382 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id); | |
383 | |
384 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(parent_routing_id); | |
385 | |
386 // If the browser is sending a valid parent routing id, it should already be | |
387 // created and registered. | |
388 CHECK(proxy); | |
389 blink::WebRemoteFrame* parent_web_frame = proxy->web_frame(); | |
390 | |
391 // Create the RenderFrame and WebLocalFrame, linking the two. | |
392 RenderFrameImpl* render_frame = | |
393 RenderFrameImpl::Create(proxy->render_view(), routing_id); | |
394 blink::WebLocalFrame* web_frame = | |
395 parent_web_frame->createLocalChild("", render_frame); | |
396 render_frame->SetWebFrame(web_frame); | |
397 render_frame->Initialize(); | |
398 } | |
399 | |
400 // static | |
377 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 401 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
378 return RenderFrameImpl::FromWebFrame(web_frame); | 402 return RenderFrameImpl::FromWebFrame(web_frame); |
379 } | 403 } |
380 | 404 |
405 // static | |
381 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { | 406 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { |
382 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 407 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); |
383 if (iter != g_frame_map.Get().end()) | 408 if (iter != g_frame_map.Get().end()) |
384 return iter->second; | 409 return iter->second; |
385 return NULL; | 410 return NULL; |
386 } | 411 } |
387 | 412 |
388 // static | 413 // static |
389 void RenderFrameImpl::InstallCreateHook( | 414 void RenderFrameImpl::InstallCreateHook( |
390 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { | 415 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
667 InitializeUserMediaClient(); | 692 InitializeUserMediaClient(); |
668 return web_user_media_client_ ? | 693 return web_user_media_client_ ? |
669 web_user_media_client_->media_stream_dispatcher() : NULL; | 694 web_user_media_client_->media_stream_dispatcher() : NULL; |
670 } | 695 } |
671 | 696 |
672 bool RenderFrameImpl::Send(IPC::Message* message) { | 697 bool RenderFrameImpl::Send(IPC::Message* message) { |
673 if (is_detaching_) { | 698 if (is_detaching_) { |
674 delete message; | 699 delete message; |
675 return false; | 700 return false; |
676 } | 701 } |
677 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 702 if (frame_->parent() == NULL && |
703 (is_swapped_out_ || render_view_->is_swapped_out())) { | |
678 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { | 704 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { |
679 delete message; | 705 delete message; |
680 return false; | 706 return false; |
681 } | 707 } |
708 | |
682 // In most cases, send IPCs through the proxy when swapped out. In some | 709 // In most cases, send IPCs through the proxy when swapped out. In some |
683 // calls the associated RenderViewImpl routing id is used to send | 710 // calls the associated RenderViewImpl routing id is used to send |
684 // messages, so don't use the proxy. | 711 // messages, so don't use the proxy. |
685 if (render_frame_proxy_ && message->routing_id() == routing_id_) | 712 if (render_frame_proxy_ && message->routing_id() == routing_id_) |
686 return render_frame_proxy_->Send(message); | 713 return render_frame_proxy_->Send(message); |
687 } | 714 } |
688 | 715 |
689 return RenderThread::Get()->Send(message); | 716 return RenderThread::Get()->Send(message); |
690 } | 717 } |
691 | 718 |
692 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { | 719 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { |
693 GetContentClient()->SetActiveURL(frame_->document().url()); | 720 // FIXME: document() should not be null, but as a transitional step |
Charlie Reis
2014/07/28 19:24:28
nit: TODO(kenrb):
kenrb
2014/07/28 21:07:21
Done.
| |
721 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing | |
722 // messages to this method. In that case there is a null document. | |
723 if (!frame_->document().isNull()) | |
724 GetContentClient()->SetActiveURL(frame_->document().url()); | |
694 | 725 |
695 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); | 726 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); |
696 RenderFrameObserver* observer; | 727 RenderFrameObserver* observer; |
697 while ((observer = it.GetNext()) != NULL) { | 728 while ((observer = it.GetNext()) != NULL) { |
698 if (observer->OnMessageReceived(msg)) | 729 if (observer->OnMessageReceived(msg)) |
699 return true; | 730 return true; |
700 } | 731 } |
701 | 732 |
702 bool handled = true; | 733 bool handled = true; |
703 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) | 734 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
754 bool is_reload = RenderViewImpl::IsReload(params); | 785 bool is_reload = RenderViewImpl::IsReload(params); |
755 WebURLRequest::CachePolicy cache_policy = | 786 WebURLRequest::CachePolicy cache_policy = |
756 WebURLRequest::UseProtocolCachePolicy; | 787 WebURLRequest::UseProtocolCachePolicy; |
757 | 788 |
758 // If this is a stale back/forward (due to a recent navigation the browser | 789 // If this is a stale back/forward (due to a recent navigation the browser |
759 // didn't know about), ignore it. | 790 // didn't know about), ignore it. |
760 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) | 791 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) |
761 return; | 792 return; |
762 | 793 |
763 // Swap this renderer back in if necessary. | 794 // Swap this renderer back in if necessary. |
764 if (render_view_->is_swapped_out_) { | 795 if (render_view_->is_swapped_out_ && |
796 GetWebFrame() == render_view_->webview()->mainFrame()) { | |
765 // We marked the view as hidden when swapping the view out, so be sure to | 797 // We marked the view as hidden when swapping the view out, so be sure to |
766 // reset the visibility state before navigating to the new URL. | 798 // reset the visibility state before navigating to the new URL. |
767 render_view_->webview()->setVisibilityState( | 799 render_view_->webview()->setVisibilityState( |
768 render_view_->visibilityState(), false); | 800 render_view_->visibilityState(), false); |
769 | 801 |
770 // If this is an attempt to reload while we are swapped out, we should not | 802 // If this is an attempt to reload while we are swapped out, we should not |
771 // reload swappedout://, but the previous page, which is stored in | 803 // reload swappedout://, but the previous page, which is stored in |
772 // params.state. Setting is_reload to false will treat this like a back | 804 // params.state. Setting is_reload to false will treat this like a back |
773 // navigation to accomplish that. | 805 // navigation to accomplish that. |
774 is_reload = false; | 806 is_reload = false; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 979 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
948 bool proceed = frame_->dispatchBeforeUnloadEvent(); | 980 bool proceed = frame_->dispatchBeforeUnloadEvent(); |
949 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 981 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
950 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 982 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
951 before_unload_start_time, | 983 before_unload_start_time, |
952 before_unload_end_time)); | 984 before_unload_end_time)); |
953 } | 985 } |
954 | 986 |
955 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { | 987 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { |
956 RenderFrameProxy* proxy = NULL; | 988 RenderFrameProxy* proxy = NULL; |
989 bool is_site_per_process = | |
990 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); | |
957 | 991 |
958 // Only run unload if we're not swapped out yet, but send the ack either way. | 992 // Only run unload if we're not swapped out yet, but send the ack either way. |
959 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { | 993 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { |
960 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 994 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
961 // a different process. This involves running the unload handler and | 995 // a different process. This involves running the unload handler and |
962 // clearing the page. Once WasSwappedOut is called, we also allow this | 996 // clearing the page. Once WasSwappedOut is called, we also allow this |
963 // process to exit if there are no other active RenderFrames in it. | 997 // process to exit if there are no other active RenderFrames in it. |
964 | 998 |
965 // Send an UpdateState message before we get swapped out. Create the | 999 // Send an UpdateState message before we get swapped out. Create the |
966 // RenderFrameProxy as well so its routing id is registered for receiving | 1000 // RenderFrameProxy as well so its routing id is registered for receiving |
967 // IPC messages. | 1001 // IPC messages. |
968 render_view_->SyncNavigationState(); | 1002 render_view_->SyncNavigationState(); |
969 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, | 1003 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, |
970 proxy_routing_id); | 1004 proxy_routing_id); |
971 | 1005 |
972 // Synchronously run the unload handler before sending the ACK. | 1006 // Synchronously run the unload handler before sending the ACK. |
973 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 1007 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
974 // unload on subframes as well. | 1008 // unload on subframes as well. |
975 if (!frame_->parent()) | 1009 if (!frame_->parent()) |
976 frame_->dispatchUnloadEvent(); | 1010 frame_->dispatchUnloadEvent(); |
977 | 1011 |
978 // Swap out and stop sending any IPC messages that are not ACKs. | 1012 // Swap out and stop sending any IPC messages that are not ACKs. |
1013 // TODO(nasko): Do we need RenderFrameImpl::is_swapped_out_ anymore? | |
979 if (!frame_->parent()) | 1014 if (!frame_->parent()) |
980 render_view_->SetSwappedOut(true); | 1015 render_view_->SetSwappedOut(true); |
981 is_swapped_out_ = true; | 1016 is_swapped_out_ = true; |
982 | 1017 |
983 // Now that we're swapped out and filtering IPC messages, stop loading to | 1018 // Now that we're swapped out and filtering IPC messages, stop loading to |
984 // ensure that no other in-progress navigation continues. We do this here | 1019 // ensure that no other in-progress navigation continues. We do this here |
985 // to avoid sending a DidStopLoading message to the browser process. | 1020 // to avoid sending a DidStopLoading message to the browser process. |
986 // TODO(creis): Should we be stopping all frames here and using | 1021 // TODO(creis): Should we be stopping all frames here and using |
987 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this | 1022 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this |
988 // frame? | 1023 // frame? |
989 if (!frame_->parent()) | 1024 if (!frame_->parent()) |
990 render_view_->OnStop(); | 1025 render_view_->OnStop(); |
991 else | 1026 else |
992 frame_->stopLoading(); | 1027 frame_->stopLoading(); |
993 | 1028 |
994 // Let subframes know that the frame is now rendered remotely, for the | 1029 // Let subframes know that the frame is now rendered remotely, for the |
995 // purposes of compositing and input events. | 1030 // purposes of compositing and input events. |
996 if (frame_->parent()) | 1031 if (frame_->parent()) |
997 frame_->setIsRemote(true); | 1032 frame_->setIsRemote(true); |
998 | 1033 |
999 // Replace the page with a blank dummy URL. The unload handler will not be | 1034 // Replace the page with a blank dummy URL. The unload handler will not be |
1000 // run a second time, thanks to a check in FrameLoader::stopLoading. | 1035 // run a second time, thanks to a check in FrameLoader::stopLoading. |
1001 // TODO(creis): Need to add a better way to do this that avoids running the | 1036 // TODO(creis): Need to add a better way to do this that avoids running the |
1002 // beforeunload handler. For now, we just run it a second time silently. | 1037 // beforeunload handler. For now, we just run it a second time silently. |
1003 render_view_->NavigateToSwappedOutURL(frame_); | 1038 if (!is_site_per_process || frame_->parent() == NULL) |
1039 render_view_->NavigateToSwappedOutURL(frame_); | |
1004 | 1040 |
1005 // Let WebKit know that this view is hidden so it can drop resources and | 1041 // Let WebKit know that this view is hidden so it can drop resources and |
1006 // stop compositing. | 1042 // stop compositing. |
1007 // TODO(creis): Support this for subframes as well. | 1043 // TODO(creis): Support this for subframes as well. |
1008 if (!frame_->parent()) { | 1044 if (!frame_->parent()) { |
1009 render_view_->webview()->setVisibilityState( | 1045 render_view_->webview()->setVisibilityState( |
1010 blink::WebPageVisibilityStateHidden, false); | 1046 blink::WebPageVisibilityStateHidden, false); |
1011 } | 1047 } |
1012 } | 1048 } |
1013 | 1049 |
1014 // It is now safe to show modal dialogs again. | 1050 // It is now safe to show modal dialogs again. |
1015 // TODO(creis): Deal with modal dialogs from subframes. | 1051 // TODO(creis): Deal with modal dialogs from subframes. |
1016 if (!frame_->parent()) | 1052 if (!frame_->parent()) |
1017 render_view_->suppress_dialogs_until_swap_out_ = false; | 1053 render_view_->suppress_dialogs_until_swap_out_ = false; |
1018 | 1054 |
1019 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 1055 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
1020 | 1056 |
1021 // Now that all of the cleanup is complete and the browser side is notified, | 1057 // Now that all of the cleanup is complete and the browser side is notified, |
1022 // start using the RenderFrameProxy, if one is created. | 1058 // start using the RenderFrameProxy, if one is created. |
1023 if (proxy) | 1059 if (proxy) { |
1024 set_render_frame_proxy(proxy); | 1060 if (frame_->parent()) { |
1061 frame_->swap(proxy->web_frame()); | |
1062 if (is_site_per_process) { | |
1063 // TODO(nasko): delete the frame here, since we've replaced it with a | |
1064 // proxy. | |
1065 } | |
1066 } else { | |
1067 set_render_frame_proxy(proxy); | |
1068 } | |
1069 } | |
1025 } | 1070 } |
1026 | 1071 |
1027 void RenderFrameImpl::OnContextMenuClosed( | 1072 void RenderFrameImpl::OnContextMenuClosed( |
1028 const CustomContextMenuContext& custom_context) { | 1073 const CustomContextMenuContext& custom_context) { |
1029 if (custom_context.request_id) { | 1074 if (custom_context.request_id) { |
1030 // External request, should be in our map. | 1075 // External request, should be in our map. |
1031 ContextMenuClient* client = | 1076 ContextMenuClient* client = |
1032 pending_context_menus_.Lookup(custom_context.request_id); | 1077 pending_context_menus_.Lookup(custom_context.request_id); |
1033 if (client) { | 1078 if (client) { |
1034 client->OnMenuClosed(custom_context.request_id); | 1079 client->OnMenuClosed(custom_context.request_id); |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1695 static_cast<int32>(source_line), | 1740 static_cast<int32>(source_line), |
1696 source_name)); | 1741 source_name)); |
1697 } | 1742 } |
1698 | 1743 |
1699 void RenderFrameImpl::loadURLExternally( | 1744 void RenderFrameImpl::loadURLExternally( |
1700 blink::WebLocalFrame* frame, | 1745 blink::WebLocalFrame* frame, |
1701 const blink::WebURLRequest& request, | 1746 const blink::WebURLRequest& request, |
1702 blink::WebNavigationPolicy policy, | 1747 blink::WebNavigationPolicy policy, |
1703 const blink::WebString& suggested_name) { | 1748 const blink::WebString& suggested_name) { |
1704 DCHECK(!frame_ || frame_ == frame); | 1749 DCHECK(!frame_ || frame_ == frame); |
1750 | |
1705 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); | 1751 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); |
1706 if (policy == blink::WebNavigationPolicyDownload) { | 1752 if (policy == blink::WebNavigationPolicyDownload) { |
1707 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 1753 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
1708 request.url(), referrer, | 1754 request.url(), referrer, |
1709 suggested_name, false)); | 1755 suggested_name, false)); |
1710 } else if (policy == blink::WebNavigationPolicyDownloadTo) { | 1756 } else if (policy == blink::WebNavigationPolicyDownloadTo) { |
1711 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), | 1757 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), |
1712 request.url(), referrer, | 1758 request.url(), referrer, |
1713 suggested_name, true)); | 1759 suggested_name, true)); |
1714 } else { | 1760 } else { |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2393 // The request my be empty during tests. | 2439 // The request my be empty during tests. |
2394 if (request.url().isEmpty()) | 2440 if (request.url().isEmpty()) |
2395 return; | 2441 return; |
2396 | 2442 |
2397 // Set the first party for cookies url if it has not been set yet (new | 2443 // Set the first party for cookies url if it has not been set yet (new |
2398 // requests). For redirects, it is updated by WebURLLoaderImpl. | 2444 // requests). For redirects, it is updated by WebURLLoaderImpl. |
2399 if (request.firstPartyForCookies().isEmpty()) { | 2445 if (request.firstPartyForCookies().isEmpty()) { |
2400 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { | 2446 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { |
2401 request.setFirstPartyForCookies(request.url()); | 2447 request.setFirstPartyForCookies(request.url()); |
2402 } else { | 2448 } else { |
2403 request.setFirstPartyForCookies( | 2449 // TODO(nasko): When the top-level frame is remote, there is no document. |
2404 frame->top()->document().firstPartyForCookies()); | 2450 // This is broken and should be fixed to propagate the first party. |
2451 WebFrame* top = frame->top(); | |
2452 if (top->isWebLocalFrame()) { | |
2453 request.setFirstPartyForCookies( | |
2454 frame->top()->document().firstPartyForCookies()); | |
2455 } | |
2405 } | 2456 } |
2406 } | 2457 } |
2407 | 2458 |
2408 WebFrame* top_frame = frame->top(); | 2459 WebFrame* top_frame = frame->top(); |
2409 if (!top_frame) | 2460 // TODO(nasko): Hack around asking about top-frame data source. This means |
2461 // for out-of-process iframes we are treating the current frame as the | |
2462 // top-level frame, which is wrong. | |
2463 if (!top_frame || top_frame->isWebRemoteFrame()) | |
2410 top_frame = frame; | 2464 top_frame = frame; |
2411 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | 2465 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
2412 WebDataSource* top_data_source = top_frame->dataSource(); | 2466 WebDataSource* top_data_source = top_frame->dataSource(); |
2413 WebDataSource* data_source = | 2467 WebDataSource* data_source = |
2414 provisional_data_source ? provisional_data_source : top_data_source; | 2468 provisional_data_source ? provisional_data_source : top_data_source; |
2415 | 2469 |
2416 PageTransition transition_type = PAGE_TRANSITION_LINK; | 2470 PageTransition transition_type = PAGE_TRANSITION_LINK; |
2417 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 2471 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
2418 DCHECK(document_state); | 2472 DCHECK(document_state); |
2419 InternalDocumentStateData* internal_data = | 2473 InternalDocumentStateData* internal_data = |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2496 DocumentState::FromDataSource(frame->provisionalDataSource())); | 2550 DocumentState::FromDataSource(frame->provisionalDataSource())); |
2497 provider_id = provider->provider_id(); | 2551 provider_id = provider->provider_id(); |
2498 } | 2552 } |
2499 } else if (frame->dataSource()) { | 2553 } else if (frame->dataSource()) { |
2500 ServiceWorkerNetworkProvider* provider = | 2554 ServiceWorkerNetworkProvider* provider = |
2501 ServiceWorkerNetworkProvider::FromDocumentState( | 2555 ServiceWorkerNetworkProvider::FromDocumentState( |
2502 DocumentState::FromDataSource(frame->dataSource())); | 2556 DocumentState::FromDataSource(frame->dataSource())); |
2503 provider_id = provider->provider_id(); | 2557 provider_id = provider->provider_id(); |
2504 } | 2558 } |
2505 | 2559 |
2506 int parent_routing_id = frame->parent() ? | 2560 WebFrame* parent = frame->parent(); |
2507 FromWebFrame(frame->parent())->GetRoutingID() : -1; | 2561 int parent_routing_id = MSG_ROUTING_NONE; |
2562 if (!parent) { | |
2563 parent_routing_id = -1; | |
2564 } else if (parent->isWebLocalFrame()) { | |
2565 parent_routing_id = FromWebFrame(parent)->GetRoutingID(); | |
2566 } else { | |
2567 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id(); | |
2568 } | |
2569 | |
2508 RequestExtraData* extra_data = new RequestExtraData(); | 2570 RequestExtraData* extra_data = new RequestExtraData(); |
2509 extra_data->set_visibility_state(render_view_->visibilityState()); | 2571 extra_data->set_visibility_state(render_view_->visibilityState()); |
2510 extra_data->set_custom_user_agent(custom_user_agent); | 2572 extra_data->set_custom_user_agent(custom_user_agent); |
2511 extra_data->set_was_after_preconnect_request(was_after_preconnect_request); | 2573 extra_data->set_was_after_preconnect_request(was_after_preconnect_request); |
2512 extra_data->set_render_frame_id(routing_id_); | 2574 extra_data->set_render_frame_id(routing_id_); |
2513 extra_data->set_is_main_frame(frame == top_frame); | 2575 extra_data->set_is_main_frame(frame == top_frame); |
2514 extra_data->set_frame_origin( | 2576 extra_data->set_frame_origin( |
2515 GURL(frame->document().securityOrigin().toString())); | 2577 GURL(frame->document().securityOrigin().toString())); |
2516 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); | 2578 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); |
2517 extra_data->set_parent_render_frame_id(parent_routing_id); | 2579 extra_data->set_parent_render_frame_id(parent_routing_id); |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3219 frame, | 3281 frame, |
3220 request, | 3282 request, |
3221 type, | 3283 type, |
3222 default_policy, | 3284 default_policy, |
3223 is_redirect)) { | 3285 is_redirect)) { |
3224 return blink::WebNavigationPolicyIgnore; | 3286 return blink::WebNavigationPolicyIgnore; |
3225 } | 3287 } |
3226 #endif | 3288 #endif |
3227 | 3289 |
3228 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); | 3290 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); |
3291 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
3229 | 3292 |
3230 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 3293 bool is_subframe = !!frame->parent(); |
3231 if (request.url() != GURL(kSwappedOutURL)) { | 3294 |
3232 // Targeted links may try to navigate a swapped out frame. Allow the | 3295 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) { |
3233 // browser process to navigate the tab instead. Note that it is also | 3296 // There's no reason to ignore navigations on subframes, swap out logic |
Charlie Reis
2014/07/28 19:24:29
nit: subframes, since the swap out logic no longer
kenrb
2014/07/28 21:07:21
Done.
| |
3234 // possible for non-targeted navigations (from this view) to arrive | 3297 // no longer applies. |
3235 // here just after we are swapped out. It's ok to send them to the | 3298 } else { |
3236 // browser, as long as they're for the top level frame. | 3299 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
3237 // TODO(creis): Ensure this supports targeted form submissions when | 3300 if (request.url() != GURL(kSwappedOutURL)) { |
3238 // fixing http://crbug.com/101395. | 3301 // Targeted links may try to navigate a swapped out frame. Allow the |
3239 if (frame->parent() == NULL) { | 3302 // browser process to navigate the tab instead. Note that it is also |
3240 OpenURL(frame, request.url(), referrer, default_policy); | 3303 // possible for non-targeted navigations (from this view) to arrive |
3241 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | 3304 // here just after we are swapped out. It's ok to send them to the |
3305 // browser, as long as they're for the top level frame. | |
3306 // TODO(creis): Ensure this supports targeted form submissions when | |
3307 // fixing http://crbug.com/101395. | |
3308 if (frame->parent() == NULL) { | |
3309 OpenURL(frame, request.url(), referrer, default_policy); | |
3310 return blink::WebNavigationPolicyIgnore; // Suppress the load here. | |
3311 } | |
3312 | |
3313 // We should otherwise ignore in-process iframe navigations, if they | |
3314 // arrive just after we are swapped out. | |
3315 return blink::WebNavigationPolicyIgnore; | |
3242 } | 3316 } |
3243 | 3317 |
3244 // We should otherwise ignore in-process iframe navigations, if they | 3318 // Allow kSwappedOutURL to complete. |
3245 // arrive just after we are swapped out. | 3319 return default_policy; |
3246 return blink::WebNavigationPolicyIgnore; | |
3247 } | 3320 } |
3248 | |
3249 // Allow kSwappedOutURL to complete. | |
3250 return default_policy; | |
3251 } | 3321 } |
3252 | 3322 |
3253 // Webkit is asking whether to navigate to a new URL. | 3323 // Webkit is asking whether to navigate to a new URL. |
3254 // This is fine normally, except if we're showing UI from one security | 3324 // This is fine normally, except if we're showing UI from one security |
3255 // context and they're trying to navigate to a different context. | 3325 // context and they're trying to navigate to a different context. |
3256 const GURL& url = request.url(); | 3326 const GURL& url = request.url(); |
3257 | 3327 |
3258 // A content initiated navigation may have originated from a link-click, | 3328 // A content initiated navigation may have originated from a link-click, |
3259 // script, drag-n-drop operation, etc. | 3329 // script, drag-n-drop operation, etc. |
3260 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> | 3330 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> |
3261 navigation_state()->is_content_initiated(); | 3331 navigation_state()->is_content_initiated(); |
3262 | 3332 |
3263 // Experimental: | 3333 // Experimental: |
3264 // If --enable-strict-site-isolation or --site-per-process is enabled, send | 3334 // If --enable-strict-site-isolation or --site-per-process is enabled, send |
3265 // all top-level navigations to the browser to let it swap processes when | 3335 // all top-level navigations to the browser to let it swap processes when |
3266 // crossing site boundaries. This is currently expected to break some script | 3336 // crossing site boundaries. This is currently expected to break some script |
3267 // calls and navigations, such as form submissions. | 3337 // calls and navigations, such as form submissions. |
3268 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
3269 bool force_swap_due_to_flag = | 3338 bool force_swap_due_to_flag = |
3270 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 3339 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
3271 command_line.HasSwitch(switches::kSitePerProcess); | 3340 command_line.HasSwitch(switches::kSitePerProcess); |
3272 if (force_swap_due_to_flag && | 3341 if (force_swap_due_to_flag && |
3273 !frame->parent() && (is_content_initiated || is_redirect)) { | 3342 !frame->parent() && (is_content_initiated || is_redirect)) { |
3274 WebString origin_str = frame->document().securityOrigin().toString(); | 3343 WebString origin_str = frame->document().securityOrigin().toString(); |
3275 GURL frame_url(origin_str.utf8().data()); | 3344 GURL frame_url(origin_str.utf8().data()); |
3276 // TODO(cevans): revisit whether this site check is still necessary once | 3345 // TODO(cevans): revisit whether this site check is still necessary once |
3277 // crbug.com/101395 is fixed. | 3346 // crbug.com/101395 is fixed. |
3278 bool same_domain_or_host = | 3347 bool same_domain_or_host = |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3632 | 3701 |
3633 #if defined(ENABLE_BROWSER_CDMS) | 3702 #if defined(ENABLE_BROWSER_CDMS) |
3634 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3703 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
3635 if (!cdm_manager_) | 3704 if (!cdm_manager_) |
3636 cdm_manager_ = new RendererCdmManager(this); | 3705 cdm_manager_ = new RendererCdmManager(this); |
3637 return cdm_manager_; | 3706 return cdm_manager_; |
3638 } | 3707 } |
3639 #endif // defined(ENABLE_BROWSER_CDMS) | 3708 #endif // defined(ENABLE_BROWSER_CDMS) |
3640 | 3709 |
3641 } // namespace content | 3710 } // namespace content |
OLD | NEW |