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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #include "content/renderer/media/midi_dispatcher.h" | 71 #include "content/renderer/media/midi_dispatcher.h" |
72 #include "content/renderer/media/render_media_log.h" | 72 #include "content/renderer/media/render_media_log.h" |
73 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 73 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
74 #include "content/renderer/media/webmediaplayer_impl.h" | 74 #include "content/renderer/media/webmediaplayer_impl.h" |
75 #include "content/renderer/media/webmediaplayer_ms.h" | 75 #include "content/renderer/media/webmediaplayer_ms.h" |
76 #include "content/renderer/media/webmediaplayer_params.h" | 76 #include "content/renderer/media/webmediaplayer_params.h" |
77 #include "content/renderer/notification_permission_dispatcher.h" | 77 #include "content/renderer/notification_permission_dispatcher.h" |
78 #include "content/renderer/notification_provider.h" | 78 #include "content/renderer/notification_provider.h" |
79 #include "content/renderer/npapi/plugin_channel_host.h" | 79 #include "content/renderer/npapi/plugin_channel_host.h" |
80 #include "content/renderer/push_messaging_dispatcher.h" | 80 #include "content/renderer/push_messaging_dispatcher.h" |
81 #include "content/renderer/render_frame_proxy.h" | |
82 #include "content/renderer/render_process.h" | 81 #include "content/renderer/render_process.h" |
83 #include "content/renderer/render_thread_impl.h" | 82 #include "content/renderer/render_thread_impl.h" |
84 #include "content/renderer/render_view_impl.h" | 83 #include "content/renderer/render_view_impl.h" |
85 #include "content/renderer/render_widget_fullscreen_pepper.h" | 84 #include "content/renderer/render_widget_fullscreen_pepper.h" |
86 #include "content/renderer/renderer_webapplicationcachehost_impl.h" | 85 #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
87 #include "content/renderer/renderer_webcolorchooser_impl.h" | 86 #include "content/renderer/renderer_webcolorchooser_impl.h" |
88 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" | 87 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" |
89 #include "content/renderer/shared_worker_repository.h" | 88 #include "content/renderer/shared_worker_repository.h" |
90 #include "content/renderer/v8_value_converter_impl.h" | 89 #include "content/renderer/v8_value_converter_impl.h" |
91 #include "content/renderer/websharedworker_proxy.h" | 90 #include "content/renderer/websharedworker_proxy.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 // static | 369 // static |
371 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { | 370 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { |
372 RoutingIDFrameMap::iterator iter = | 371 RoutingIDFrameMap::iterator iter = |
373 g_routing_id_frame_map.Get().find(routing_id); | 372 g_routing_id_frame_map.Get().find(routing_id); |
374 if (iter != g_routing_id_frame_map.Get().end()) | 373 if (iter != g_routing_id_frame_map.Get().end()) |
375 return iter->second; | 374 return iter->second; |
376 return NULL; | 375 return NULL; |
377 } | 376 } |
378 | 377 |
379 // static | 378 // static |
380 void RenderFrameImpl::CreateFrame(int routing_id, int parent_routing_id) { | |
381 // TODO(nasko): For now, this message is only sent for subframes, as the | |
382 // top level frame is created when the RenderView is created through the | |
383 // ViewMsg_New IPC. | |
384 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id); | |
385 | |
386 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(parent_routing_id); | |
387 | |
388 // If the browser is sending a valid parent routing id, it should already be | |
389 // created and registered. | |
390 CHECK(proxy); | |
391 blink::WebRemoteFrame* parent_web_frame = proxy->web_frame(); | |
392 | |
393 // Create the RenderFrame and WebLocalFrame, linking the two. | |
394 RenderFrameImpl* render_frame = | |
395 RenderFrameImpl::Create(proxy->render_view(), routing_id); | |
396 blink::WebLocalFrame* web_frame = | |
397 parent_web_frame->createLocalChild("", render_frame); | |
398 render_frame->SetWebFrame(web_frame); | |
399 render_frame->Initialize(); | |
400 } | |
401 | |
402 // static | |
403 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { | 379 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { |
404 return RenderFrameImpl::FromWebFrame(web_frame); | 380 return RenderFrameImpl::FromWebFrame(web_frame); |
405 } | 381 } |
406 | 382 |
407 // static | |
408 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { | 383 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { |
409 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); | 384 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); |
410 if (iter != g_frame_map.Get().end()) | 385 if (iter != g_frame_map.Get().end()) |
411 return iter->second; | 386 return iter->second; |
412 return NULL; | 387 return NULL; |
413 } | 388 } |
414 | 389 |
415 // static | 390 // static |
416 void RenderFrameImpl::InstallCreateHook( | 391 void RenderFrameImpl::InstallCreateHook( |
417 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { | 392 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 InitializeUserMediaClient(); | 670 InitializeUserMediaClient(); |
696 return web_user_media_client_ ? | 671 return web_user_media_client_ ? |
697 web_user_media_client_->media_stream_dispatcher() : NULL; | 672 web_user_media_client_->media_stream_dispatcher() : NULL; |
698 } | 673 } |
699 | 674 |
700 bool RenderFrameImpl::Send(IPC::Message* message) { | 675 bool RenderFrameImpl::Send(IPC::Message* message) { |
701 if (is_detaching_) { | 676 if (is_detaching_) { |
702 delete message; | 677 delete message; |
703 return false; | 678 return false; |
704 } | 679 } |
705 if (frame_->parent() == NULL && | 680 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
706 (is_swapped_out_ || render_view_->is_swapped_out())) { | |
707 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { | 681 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { |
708 delete message; | 682 delete message; |
709 return false; | 683 return false; |
710 } | 684 } |
711 | |
712 // In most cases, send IPCs through the proxy when swapped out. In some | 685 // In most cases, send IPCs through the proxy when swapped out. In some |
713 // calls the associated RenderViewImpl routing id is used to send | 686 // calls the associated RenderViewImpl routing id is used to send |
714 // messages, so don't use the proxy. | 687 // messages, so don't use the proxy. |
715 if (render_frame_proxy_ && message->routing_id() == routing_id_) | 688 if (render_frame_proxy_ && message->routing_id() == routing_id_) |
716 return render_frame_proxy_->Send(message); | 689 return render_frame_proxy_->Send(message); |
717 } | 690 } |
718 | 691 |
719 return RenderThread::Get()->Send(message); | 692 return RenderThread::Get()->Send(message); |
720 } | 693 } |
721 | 694 |
722 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { | 695 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { |
723 // TODO(kenrb): document() should not be null, but as a transitional step | 696 GetContentClient()->SetActiveURL(frame_->document().url()); |
724 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages | |
725 // to this method. This happens for a top-level remote frame, where a | |
726 // document-less RenderFrame is replaced by a RenderFrameProxy but kept | |
727 // around and is still able to receive messages. | |
728 if (!frame_->document().isNull()) | |
729 GetContentClient()->SetActiveURL(frame_->document().url()); | |
730 | 697 |
731 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); | 698 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); |
732 RenderFrameObserver* observer; | 699 RenderFrameObserver* observer; |
733 while ((observer = it.GetNext()) != NULL) { | 700 while ((observer = it.GetNext()) != NULL) { |
734 if (observer->OnMessageReceived(msg)) | 701 if (observer->OnMessageReceived(msg)) |
735 return true; | 702 return true; |
736 } | 703 } |
737 | 704 |
738 bool handled = true; | 705 bool handled = true; |
739 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) | 706 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 bool is_reload = RenderViewImpl::IsReload(params); | 757 bool is_reload = RenderViewImpl::IsReload(params); |
791 WebURLRequest::CachePolicy cache_policy = | 758 WebURLRequest::CachePolicy cache_policy = |
792 WebURLRequest::UseProtocolCachePolicy; | 759 WebURLRequest::UseProtocolCachePolicy; |
793 | 760 |
794 // If this is a stale back/forward (due to a recent navigation the browser | 761 // If this is a stale back/forward (due to a recent navigation the browser |
795 // didn't know about), ignore it. | 762 // didn't know about), ignore it. |
796 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) | 763 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) |
797 return; | 764 return; |
798 | 765 |
799 // Swap this renderer back in if necessary. | 766 // Swap this renderer back in if necessary. |
800 if (render_view_->is_swapped_out_ && | 767 if (render_view_->is_swapped_out_) { |
801 GetWebFrame() == render_view_->webview()->mainFrame()) { | |
802 // We marked the view as hidden when swapping the view out, so be sure to | 768 // We marked the view as hidden when swapping the view out, so be sure to |
803 // reset the visibility state before navigating to the new URL. | 769 // reset the visibility state before navigating to the new URL. |
804 render_view_->webview()->setVisibilityState( | 770 render_view_->webview()->setVisibilityState( |
805 render_view_->visibilityState(), false); | 771 render_view_->visibilityState(), false); |
806 | 772 |
807 // If this is an attempt to reload while we are swapped out, we should not | 773 // If this is an attempt to reload while we are swapped out, we should not |
808 // reload swappedout://, but the previous page, which is stored in | 774 // reload swappedout://, but the previous page, which is stored in |
809 // params.state. Setting is_reload to false will treat this like a back | 775 // params.state. Setting is_reload to false will treat this like a back |
810 // navigation to accomplish that. | 776 // navigation to accomplish that. |
811 is_reload = false; | 777 is_reload = false; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 950 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
985 bool proceed = frame_->dispatchBeforeUnloadEvent(); | 951 bool proceed = frame_->dispatchBeforeUnloadEvent(); |
986 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 952 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
987 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 953 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
988 before_unload_start_time, | 954 before_unload_start_time, |
989 before_unload_end_time)); | 955 before_unload_end_time)); |
990 } | 956 } |
991 | 957 |
992 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { | 958 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { |
993 RenderFrameProxy* proxy = NULL; | 959 RenderFrameProxy* proxy = NULL; |
994 bool is_site_per_process = | |
995 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess); | |
996 | 960 |
997 // Only run unload if we're not swapped out yet, but send the ack either way. | 961 // Only run unload if we're not swapped out yet, but send the ack either way. |
998 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { | 962 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { |
999 // Swap this RenderFrame out so the frame can navigate to a page rendered by | 963 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
1000 // a different process. This involves running the unload handler and | 964 // a different process. This involves running the unload handler and |
1001 // clearing the page. Once WasSwappedOut is called, we also allow this | 965 // clearing the page. Once WasSwappedOut is called, we also allow this |
1002 // process to exit if there are no other active RenderFrames in it. | 966 // process to exit if there are no other active RenderFrames in it. |
1003 | 967 |
1004 // Send an UpdateState message before we get swapped out. Create the | 968 // Send an UpdateState message before we get swapped out. Create the |
1005 // RenderFrameProxy as well so its routing id is registered for receiving | 969 // RenderFrameProxy as well so its routing id is registered for receiving |
1006 // IPC messages. | 970 // IPC messages. |
1007 render_view_->SyncNavigationState(); | 971 render_view_->SyncNavigationState(); |
1008 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, | 972 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, |
1009 proxy_routing_id); | 973 proxy_routing_id); |
1010 | 974 |
1011 // Synchronously run the unload handler before sending the ACK. | 975 // Synchronously run the unload handler before sending the ACK. |
1012 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 976 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
1013 // unload on subframes as well. | 977 // unload on subframes as well. |
1014 if (!frame_->parent()) | 978 if (!frame_->parent()) |
1015 frame_->dispatchUnloadEvent(); | 979 frame_->dispatchUnloadEvent(); |
1016 | 980 |
1017 // Swap out and stop sending any IPC messages that are not ACKs. | 981 // Swap out and stop sending any IPC messages that are not ACKs. |
1018 // TODO(nasko): Do we need RenderFrameImpl::is_swapped_out_ anymore? | |
1019 if (!frame_->parent()) | 982 if (!frame_->parent()) |
1020 render_view_->SetSwappedOut(true); | 983 render_view_->SetSwappedOut(true); |
1021 is_swapped_out_ = true; | 984 is_swapped_out_ = true; |
1022 | 985 |
1023 // Now that we're swapped out and filtering IPC messages, stop loading to | 986 // Now that we're swapped out and filtering IPC messages, stop loading to |
1024 // ensure that no other in-progress navigation continues. We do this here | 987 // ensure that no other in-progress navigation continues. We do this here |
1025 // to avoid sending a DidStopLoading message to the browser process. | 988 // to avoid sending a DidStopLoading message to the browser process. |
1026 // TODO(creis): Should we be stopping all frames here and using | 989 // TODO(creis): Should we be stopping all frames here and using |
1027 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this | 990 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this |
1028 // frame? | 991 // frame? |
1029 if (!frame_->parent()) | 992 if (!frame_->parent()) |
1030 render_view_->OnStop(); | 993 render_view_->OnStop(); |
1031 else | 994 else |
1032 frame_->stopLoading(); | 995 frame_->stopLoading(); |
1033 | 996 |
1034 // Let subframes know that the frame is now rendered remotely, for the | 997 // Let subframes know that the frame is now rendered remotely, for the |
1035 // purposes of compositing and input events. | 998 // purposes of compositing and input events. |
1036 if (frame_->parent()) | 999 if (frame_->parent()) |
1037 frame_->setIsRemote(true); | 1000 frame_->setIsRemote(true); |
1038 | 1001 |
1039 // Replace the page with a blank dummy URL. The unload handler will not be | 1002 // Replace the page with a blank dummy URL. The unload handler will not be |
1040 // run a second time, thanks to a check in FrameLoader::stopLoading. | 1003 // run a second time, thanks to a check in FrameLoader::stopLoading. |
1041 // TODO(creis): Need to add a better way to do this that avoids running the | 1004 // TODO(creis): Need to add a better way to do this that avoids running the |
1042 // beforeunload handler. For now, we just run it a second time silently. | 1005 // beforeunload handler. For now, we just run it a second time silently. |
1043 if (!is_site_per_process || frame_->parent() == NULL) | 1006 render_view_->NavigateToSwappedOutURL(frame_); |
1044 render_view_->NavigateToSwappedOutURL(frame_); | |
1045 | 1007 |
1046 // Let WebKit know that this view is hidden so it can drop resources and | 1008 // Let WebKit know that this view is hidden so it can drop resources and |
1047 // stop compositing. | 1009 // stop compositing. |
1048 // TODO(creis): Support this for subframes as well. | 1010 // TODO(creis): Support this for subframes as well. |
1049 if (!frame_->parent()) { | 1011 if (!frame_->parent()) { |
1050 render_view_->webview()->setVisibilityState( | 1012 render_view_->webview()->setVisibilityState( |
1051 blink::WebPageVisibilityStateHidden, false); | 1013 blink::WebPageVisibilityStateHidden, false); |
1052 } | 1014 } |
1053 } | 1015 } |
1054 | 1016 |
1055 // It is now safe to show modal dialogs again. | 1017 // It is now safe to show modal dialogs again. |
1056 // TODO(creis): Deal with modal dialogs from subframes. | 1018 // TODO(creis): Deal with modal dialogs from subframes. |
1057 if (!frame_->parent()) | 1019 if (!frame_->parent()) |
1058 render_view_->suppress_dialogs_until_swap_out_ = false; | 1020 render_view_->suppress_dialogs_until_swap_out_ = false; |
1059 | 1021 |
1060 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 1022 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
1061 | 1023 |
1062 // Now that all of the cleanup is complete and the browser side is notified, | 1024 // Now that all of the cleanup is complete and the browser side is notified, |
1063 // start using the RenderFrameProxy, if one is created. | 1025 // start using the RenderFrameProxy, if one is created. |
1064 if (proxy) { | 1026 if (proxy) |
1065 if (frame_->parent()) { | 1027 set_render_frame_proxy(proxy); |
1066 frame_->swap(proxy->web_frame()); | |
1067 if (is_site_per_process) { | |
1068 // TODO(nasko): delete the frame here, since we've replaced it with a | |
1069 // proxy. | |
1070 } | |
1071 } else { | |
1072 set_render_frame_proxy(proxy); | |
1073 } | |
1074 } | |
1075 } | 1028 } |
1076 | 1029 |
1077 void RenderFrameImpl::OnContextMenuClosed( | 1030 void RenderFrameImpl::OnContextMenuClosed( |
1078 const CustomContextMenuContext& custom_context) { | 1031 const CustomContextMenuContext& custom_context) { |
1079 if (custom_context.request_id) { | 1032 if (custom_context.request_id) { |
1080 // External request, should be in our map. | 1033 // External request, should be in our map. |
1081 ContextMenuClient* client = | 1034 ContextMenuClient* client = |
1082 pending_context_menus_.Lookup(custom_context.request_id); | 1035 pending_context_menus_.Lookup(custom_context.request_id); |
1083 if (client) { | 1036 if (client) { |
1084 client->OnMenuClosed(custom_context.request_id); | 1037 client->OnMenuClosed(custom_context.request_id); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 // handle loading of error pages. | 1822 // handle loading of error pages. |
1870 document_state->navigation_state()->set_transition_type( | 1823 document_state->navigation_state()->set_transition_type( |
1871 PAGE_TRANSITION_AUTO_SUBFRAME); | 1824 PAGE_TRANSITION_AUTO_SUBFRAME); |
1872 } | 1825 } |
1873 | 1826 |
1874 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 1827 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
1875 DidStartProvisionalLoad(frame)); | 1828 DidStartProvisionalLoad(frame)); |
1876 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); | 1829 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); |
1877 | 1830 |
1878 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( | 1831 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
1879 routing_id_, ds->request().url(), is_transition_navigation)); | 1832 routing_id_, ds->request().url(), is_transition_navigation)); |
1880 } | 1833 } |
1881 | 1834 |
1882 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( | 1835 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( |
1883 blink::WebLocalFrame* frame) { | 1836 blink::WebLocalFrame* frame) { |
1884 DCHECK(!frame_ || frame_ == frame); | 1837 DCHECK(!frame_ || frame_ == frame); |
1885 render_view_->history_controller()->RemoveChildrenForRedirect(this); | 1838 render_view_->history_controller()->RemoveChildrenForRedirect(this); |
1886 if (frame->parent()) | 1839 if (frame->parent()) |
1887 return; | 1840 return; |
1888 // Received a redirect on the main frame. | 1841 // Received a redirect on the main frame. |
1889 WebDataSource* data_source = frame->provisionalDataSource(); | 1842 WebDataSource* data_source = frame->provisionalDataSource(); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 // The request my be empty during tests. | 2402 // The request my be empty during tests. |
2450 if (request.url().isEmpty()) | 2403 if (request.url().isEmpty()) |
2451 return; | 2404 return; |
2452 | 2405 |
2453 // Set the first party for cookies url if it has not been set yet (new | 2406 // Set the first party for cookies url if it has not been set yet (new |
2454 // requests). For redirects, it is updated by WebURLLoaderImpl. | 2407 // requests). For redirects, it is updated by WebURLLoaderImpl. |
2455 if (request.firstPartyForCookies().isEmpty()) { | 2408 if (request.firstPartyForCookies().isEmpty()) { |
2456 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { | 2409 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { |
2457 request.setFirstPartyForCookies(request.url()); | 2410 request.setFirstPartyForCookies(request.url()); |
2458 } else { | 2411 } else { |
2459 // TODO(nasko): When the top-level frame is remote, there is no document. | 2412 request.setFirstPartyForCookies( |
2460 // This is broken and should be fixed to propagate the first party. | 2413 frame->top()->document().firstPartyForCookies()); |
2461 WebFrame* top = frame->top(); | |
2462 if (top->isWebLocalFrame()) { | |
2463 request.setFirstPartyForCookies( | |
2464 frame->top()->document().firstPartyForCookies()); | |
2465 } | |
2466 } | 2414 } |
2467 } | 2415 } |
2468 | 2416 |
2469 WebFrame* top_frame = frame->top(); | 2417 WebFrame* top_frame = frame->top(); |
2470 // TODO(nasko): Hack around asking about top-frame data source. This means | 2418 if (!top_frame) |
2471 // for out-of-process iframes we are treating the current frame as the | |
2472 // top-level frame, which is wrong. | |
2473 if (!top_frame || top_frame->isWebRemoteFrame()) | |
2474 top_frame = frame; | 2419 top_frame = frame; |
2475 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | 2420 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
2476 WebDataSource* top_data_source = top_frame->dataSource(); | 2421 WebDataSource* top_data_source = top_frame->dataSource(); |
2477 WebDataSource* data_source = | 2422 WebDataSource* data_source = |
2478 provisional_data_source ? provisional_data_source : top_data_source; | 2423 provisional_data_source ? provisional_data_source : top_data_source; |
2479 | 2424 |
2480 PageTransition transition_type = PAGE_TRANSITION_LINK; | 2425 PageTransition transition_type = PAGE_TRANSITION_LINK; |
2481 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 2426 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
2482 DCHECK(document_state); | 2427 DCHECK(document_state); |
2483 InternalDocumentStateData* internal_data = | 2428 InternalDocumentStateData* internal_data = |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2557 DocumentState::FromDataSource(frame->provisionalDataSource())); | 2502 DocumentState::FromDataSource(frame->provisionalDataSource())); |
2558 provider_id = provider->provider_id(); | 2503 provider_id = provider->provider_id(); |
2559 } | 2504 } |
2560 } else if (frame->dataSource()) { | 2505 } else if (frame->dataSource()) { |
2561 ServiceWorkerNetworkProvider* provider = | 2506 ServiceWorkerNetworkProvider* provider = |
2562 ServiceWorkerNetworkProvider::FromDocumentState( | 2507 ServiceWorkerNetworkProvider::FromDocumentState( |
2563 DocumentState::FromDataSource(frame->dataSource())); | 2508 DocumentState::FromDataSource(frame->dataSource())); |
2564 provider_id = provider->provider_id(); | 2509 provider_id = provider->provider_id(); |
2565 } | 2510 } |
2566 | 2511 |
2567 WebFrame* parent = frame->parent(); | 2512 int parent_routing_id = frame->parent() ? |
2568 int parent_routing_id = MSG_ROUTING_NONE; | 2513 FromWebFrame(frame->parent())->GetRoutingID() : -1; |
2569 if (!parent) { | |
2570 parent_routing_id = -1; | |
2571 } else if (parent->isWebLocalFrame()) { | |
2572 parent_routing_id = FromWebFrame(parent)->GetRoutingID(); | |
2573 } else { | |
2574 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id(); | |
2575 } | |
2576 | |
2577 RequestExtraData* extra_data = new RequestExtraData(); | 2514 RequestExtraData* extra_data = new RequestExtraData(); |
2578 extra_data->set_visibility_state(render_view_->visibilityState()); | 2515 extra_data->set_visibility_state(render_view_->visibilityState()); |
2579 extra_data->set_custom_user_agent(custom_user_agent); | 2516 extra_data->set_custom_user_agent(custom_user_agent); |
2580 extra_data->set_render_frame_id(routing_id_); | 2517 extra_data->set_render_frame_id(routing_id_); |
2581 extra_data->set_is_main_frame(frame == top_frame); | 2518 extra_data->set_is_main_frame(frame == top_frame); |
2582 extra_data->set_frame_origin( | 2519 extra_data->set_frame_origin( |
2583 GURL(frame->document().securityOrigin().toString())); | 2520 GURL(frame->document().securityOrigin().toString())); |
2584 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); | 2521 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); |
2585 extra_data->set_parent_render_frame_id(parent_routing_id); | 2522 extra_data->set_parent_render_frame_id(parent_routing_id); |
2586 extra_data->set_allow_download(navigation_state->allow_download()); | 2523 extra_data->set_allow_download(navigation_state->allow_download()); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3280 info.urlRequest, | 3217 info.urlRequest, |
3281 info.navigationType, | 3218 info.navigationType, |
3282 info.defaultPolicy, | 3219 info.defaultPolicy, |
3283 info.isRedirect)) { | 3220 info.isRedirect)) { |
3284 return blink::WebNavigationPolicyIgnore; | 3221 return blink::WebNavigationPolicyIgnore; |
3285 } | 3222 } |
3286 #endif | 3223 #endif |
3287 | 3224 |
3288 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame, | 3225 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(info.frame, |
3289 info.urlRequest)); | 3226 info.urlRequest)); |
3290 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
3291 | 3227 |
3292 bool is_subframe = !!info.frame->parent(); | 3228 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
3293 | 3229 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { |
3294 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) { | 3230 // Targeted links may try to navigate a swapped out frame. Allow the |
3295 // There's no reason to ignore navigations on subframes, since the swap out | 3231 // browser process to navigate the tab instead. Note that it is also |
3296 // logic no longer applies. | 3232 // possible for non-targeted navigations (from this view) to arrive |
3297 } else { | 3233 // here just after we are swapped out. It's ok to send them to the |
3298 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 3234 // browser, as long as they're for the top level frame. |
3299 if (info.urlRequest.url() != GURL(kSwappedOutURL)) { | 3235 // TODO(creis): Ensure this supports targeted form submissions when |
3300 // Targeted links may try to navigate a swapped out frame. Allow the | 3236 // fixing http://crbug.com/101395. |
3301 // browser process to navigate the tab instead. Note that it is also | 3237 if (info.frame->parent() == NULL) { |
3302 // possible for non-targeted navigations (from this view) to arrive | 3238 OpenURL(info.frame, info.urlRequest.url(), referrer, |
3303 // here just after we are swapped out. It's ok to send them to the | 3239 info.defaultPolicy); |
3304 // browser, as long as they're for the top level frame. | 3240 return blink::WebNavigationPolicyIgnore; // Suppress the load here. |
3305 // TODO(creis): Ensure this supports targeted form submissions when | |
3306 // fixing http://crbug.com/101395. | |
3307 if (info.frame->parent() == NULL) { | |
3308 OpenURL(info.frame, info.urlRequest.url(), referrer, | |
3309 info.defaultPolicy); | |
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; | |
3316 } | 3241 } |
3317 | 3242 |
3318 // Allow kSwappedOutURL to complete. | 3243 // We should otherwise ignore in-process iframe navigations, if they |
3319 return info.defaultPolicy; | 3244 // arrive just after we are swapped out. |
| 3245 return blink::WebNavigationPolicyIgnore; |
3320 } | 3246 } |
| 3247 |
| 3248 // Allow kSwappedOutURL to complete. |
| 3249 return info.defaultPolicy; |
3321 } | 3250 } |
3322 | 3251 |
3323 // Webkit is asking whether to navigate to a new URL. | 3252 // Webkit is asking whether to navigate to a new URL. |
3324 // This is fine normally, except if we're showing UI from one security | 3253 // This is fine normally, except if we're showing UI from one security |
3325 // context and they're trying to navigate to a different context. | 3254 // context and they're trying to navigate to a different context. |
3326 const GURL& url = info.urlRequest.url(); | 3255 const GURL& url = info.urlRequest.url(); |
3327 | 3256 |
3328 // A content initiated navigation may have originated from a link-click, | 3257 // A content initiated navigation may have originated from a link-click, |
3329 // script, drag-n-drop operation, etc. | 3258 // script, drag-n-drop operation, etc. |
3330 bool is_content_initiated = static_cast<DocumentState*>(info.extraData)-> | 3259 bool is_content_initiated = static_cast<DocumentState*>(info.extraData)-> |
3331 navigation_state()->is_content_initiated(); | 3260 navigation_state()->is_content_initiated(); |
3332 | 3261 |
3333 // Experimental: | 3262 // Experimental: |
3334 // If --enable-strict-site-isolation or --site-per-process is enabled, send | 3263 // If --enable-strict-site-isolation or --site-per-process is enabled, send |
3335 // all top-level navigations to the browser to let it swap processes when | 3264 // all top-level navigations to the browser to let it swap processes when |
3336 // crossing site boundaries. This is currently expected to break some script | 3265 // crossing site boundaries. This is currently expected to break some script |
3337 // calls and navigations, such as form submissions. | 3266 // calls and navigations, such as form submissions. |
| 3267 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
3338 bool force_swap_due_to_flag = | 3268 bool force_swap_due_to_flag = |
3339 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || | 3269 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || |
3340 command_line.HasSwitch(switches::kSitePerProcess); | 3270 command_line.HasSwitch(switches::kSitePerProcess); |
3341 if (force_swap_due_to_flag && | 3271 if (force_swap_due_to_flag && |
3342 !info.frame->parent() && (is_content_initiated || info.isRedirect)) { | 3272 !info.frame->parent() && (is_content_initiated || info.isRedirect)) { |
3343 WebString origin_str = info.frame->document().securityOrigin().toString(); | 3273 WebString origin_str = info.frame->document().securityOrigin().toString(); |
3344 GURL frame_url(origin_str.utf8().data()); | 3274 GURL frame_url(origin_str.utf8().data()); |
3345 // TODO(cevans): revisit whether this site check is still necessary once | 3275 // TODO(cevans): revisit whether this site check is still necessary once |
3346 // crbug.com/101395 is fixed. | 3276 // crbug.com/101395 is fixed. |
3347 bool same_domain_or_host = | 3277 bool same_domain_or_host = |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3704 | 3634 |
3705 #if defined(ENABLE_BROWSER_CDMS) | 3635 #if defined(ENABLE_BROWSER_CDMS) |
3706 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 3636 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
3707 if (!cdm_manager_) | 3637 if (!cdm_manager_) |
3708 cdm_manager_ = new RendererCdmManager(this); | 3638 cdm_manager_ = new RendererCdmManager(this); |
3709 return cdm_manager_; | 3639 return cdm_manager_; |
3710 } | 3640 } |
3711 #endif // defined(ENABLE_BROWSER_CDMS) | 3641 #endif // defined(ENABLE_BROWSER_CDMS) |
3712 | 3642 |
3713 } // namespace content | 3643 } // namespace content |
OLD | NEW |