Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: content/renderer/render_frame_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698