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

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

Issue 404613005: Start using RenderFrameProxyHost objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more tweaks 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 | Annotate | Revision Log
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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): For now, this message is only sent for subframes, as the
380 // top level frame is created when the RenderView is created through the
381 // ViewMsg_New IPC.
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
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 // TODO(kenrb): document() should not be null, but as a transitional step
721 // we have RenderFrameProxy 'wrapping' a RenderFrameImpl, passing messages
722 // to this method. This happens for a top-level remote frame, where a
723 // document-less RenderFrame is replaced by a RenderFrameProxy but kept
724 // around and is still able to receive messages.
725 if (!frame_->document().isNull())
726 GetContentClient()->SetActiveURL(frame_->document().url());
694 727
695 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); 728 ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
696 RenderFrameObserver* observer; 729 RenderFrameObserver* observer;
697 while ((observer = it.GetNext()) != NULL) { 730 while ((observer = it.GetNext()) != NULL) {
698 if (observer->OnMessageReceived(msg)) 731 if (observer->OnMessageReceived(msg))
699 return true; 732 return true;
700 } 733 }
701 734
702 bool handled = true; 735 bool handled = true;
703 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) 736 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 bool is_reload = RenderViewImpl::IsReload(params); 787 bool is_reload = RenderViewImpl::IsReload(params);
755 WebURLRequest::CachePolicy cache_policy = 788 WebURLRequest::CachePolicy cache_policy =
756 WebURLRequest::UseProtocolCachePolicy; 789 WebURLRequest::UseProtocolCachePolicy;
757 790
758 // If this is a stale back/forward (due to a recent navigation the browser 791 // If this is a stale back/forward (due to a recent navigation the browser
759 // didn't know about), ignore it. 792 // didn't know about), ignore it.
760 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) 793 if (render_view_->IsBackForwardToStaleEntry(params, is_reload))
761 return; 794 return;
762 795
763 // Swap this renderer back in if necessary. 796 // Swap this renderer back in if necessary.
764 if (render_view_->is_swapped_out_) { 797 if (render_view_->is_swapped_out_ &&
798 GetWebFrame() == render_view_->webview()->mainFrame()) {
765 // We marked the view as hidden when swapping the view out, so be sure to 799 // 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. 800 // reset the visibility state before navigating to the new URL.
767 render_view_->webview()->setVisibilityState( 801 render_view_->webview()->setVisibilityState(
768 render_view_->visibilityState(), false); 802 render_view_->visibilityState(), false);
769 803
770 // If this is an attempt to reload while we are swapped out, we should not 804 // 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 805 // reload swappedout://, but the previous page, which is stored in
772 // params.state. Setting is_reload to false will treat this like a back 806 // params.state. Setting is_reload to false will treat this like a back
773 // navigation to accomplish that. 807 // navigation to accomplish that.
774 is_reload = false; 808 is_reload = false;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 981 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
948 bool proceed = frame_->dispatchBeforeUnloadEvent(); 982 bool proceed = frame_->dispatchBeforeUnloadEvent();
949 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 983 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
950 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, 984 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed,
951 before_unload_start_time, 985 before_unload_start_time,
952 before_unload_end_time)); 986 before_unload_end_time));
953 } 987 }
954 988
955 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { 989 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
956 RenderFrameProxy* proxy = NULL; 990 RenderFrameProxy* proxy = NULL;
991 bool is_site_per_process =
992 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess);
957 993
958 // Only run unload if we're not swapped out yet, but send the ack either way. 994 // 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_) { 995 if (!is_swapped_out_ || !render_view_->is_swapped_out_) {
960 // Swap this RenderFrame out so the frame can navigate to a page rendered by 996 // 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 997 // a different process. This involves running the unload handler and
962 // clearing the page. Once WasSwappedOut is called, we also allow this 998 // clearing the page. Once WasSwappedOut is called, we also allow this
963 // process to exit if there are no other active RenderFrames in it. 999 // process to exit if there are no other active RenderFrames in it.
964 1000
965 // Send an UpdateState message before we get swapped out. Create the 1001 // Send an UpdateState message before we get swapped out. Create the
966 // RenderFrameProxy as well so its routing id is registered for receiving 1002 // RenderFrameProxy as well so its routing id is registered for receiving
967 // IPC messages. 1003 // IPC messages.
968 render_view_->SyncNavigationState(); 1004 render_view_->SyncNavigationState();
969 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, 1005 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this,
970 proxy_routing_id); 1006 proxy_routing_id);
971 1007
972 // Synchronously run the unload handler before sending the ACK. 1008 // Synchronously run the unload handler before sending the ACK.
973 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support 1009 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
974 // unload on subframes as well. 1010 // unload on subframes as well.
975 if (!frame_->parent()) 1011 if (!frame_->parent())
976 frame_->dispatchUnloadEvent(); 1012 frame_->dispatchUnloadEvent();
977 1013
978 // Swap out and stop sending any IPC messages that are not ACKs. 1014 // Swap out and stop sending any IPC messages that are not ACKs.
1015 // TODO(nasko): Do we need RenderFrameImpl::is_swapped_out_ anymore?
979 if (!frame_->parent()) 1016 if (!frame_->parent())
980 render_view_->SetSwappedOut(true); 1017 render_view_->SetSwappedOut(true);
981 is_swapped_out_ = true; 1018 is_swapped_out_ = true;
982 1019
983 // Now that we're swapped out and filtering IPC messages, stop loading to 1020 // 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 1021 // ensure that no other in-progress navigation continues. We do this here
985 // to avoid sending a DidStopLoading message to the browser process. 1022 // to avoid sending a DidStopLoading message to the browser process.
986 // TODO(creis): Should we be stopping all frames here and using 1023 // TODO(creis): Should we be stopping all frames here and using
987 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this 1024 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this
988 // frame? 1025 // frame?
989 if (!frame_->parent()) 1026 if (!frame_->parent())
990 render_view_->OnStop(); 1027 render_view_->OnStop();
991 else 1028 else
992 frame_->stopLoading(); 1029 frame_->stopLoading();
993 1030
994 // Let subframes know that the frame is now rendered remotely, for the 1031 // Let subframes know that the frame is now rendered remotely, for the
995 // purposes of compositing and input events. 1032 // purposes of compositing and input events.
996 if (frame_->parent()) 1033 if (frame_->parent())
997 frame_->setIsRemote(true); 1034 frame_->setIsRemote(true);
998 1035
999 // Replace the page with a blank dummy URL. The unload handler will not be 1036 // 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. 1037 // 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 1038 // 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. 1039 // beforeunload handler. For now, we just run it a second time silently.
1003 render_view_->NavigateToSwappedOutURL(frame_); 1040 if (!is_site_per_process || frame_->parent() == NULL)
1041 render_view_->NavigateToSwappedOutURL(frame_);
1004 1042
1005 // Let WebKit know that this view is hidden so it can drop resources and 1043 // Let WebKit know that this view is hidden so it can drop resources and
1006 // stop compositing. 1044 // stop compositing.
1007 // TODO(creis): Support this for subframes as well. 1045 // TODO(creis): Support this for subframes as well.
1008 if (!frame_->parent()) { 1046 if (!frame_->parent()) {
1009 render_view_->webview()->setVisibilityState( 1047 render_view_->webview()->setVisibilityState(
1010 blink::WebPageVisibilityStateHidden, false); 1048 blink::WebPageVisibilityStateHidden, false);
1011 } 1049 }
1012 } 1050 }
1013 1051
1014 // It is now safe to show modal dialogs again. 1052 // It is now safe to show modal dialogs again.
1015 // TODO(creis): Deal with modal dialogs from subframes. 1053 // TODO(creis): Deal with modal dialogs from subframes.
1016 if (!frame_->parent()) 1054 if (!frame_->parent())
1017 render_view_->suppress_dialogs_until_swap_out_ = false; 1055 render_view_->suppress_dialogs_until_swap_out_ = false;
1018 1056
1019 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1057 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1020 1058
1021 // Now that all of the cleanup is complete and the browser side is notified, 1059 // Now that all of the cleanup is complete and the browser side is notified,
1022 // start using the RenderFrameProxy, if one is created. 1060 // start using the RenderFrameProxy, if one is created.
1023 if (proxy) 1061 if (proxy) {
1024 set_render_frame_proxy(proxy); 1062 if (frame_->parent()) {
1063 frame_->swap(proxy->web_frame());
1064 if (is_site_per_process) {
1065 // TODO(nasko): delete the frame here, since we've replaced it with a
1066 // proxy.
1067 }
1068 } else {
1069 set_render_frame_proxy(proxy);
1070 }
1071 }
1025 } 1072 }
1026 1073
1027 void RenderFrameImpl::OnContextMenuClosed( 1074 void RenderFrameImpl::OnContextMenuClosed(
1028 const CustomContextMenuContext& custom_context) { 1075 const CustomContextMenuContext& custom_context) {
1029 if (custom_context.request_id) { 1076 if (custom_context.request_id) {
1030 // External request, should be in our map. 1077 // External request, should be in our map.
1031 ContextMenuClient* client = 1078 ContextMenuClient* client =
1032 pending_context_menus_.Lookup(custom_context.request_id); 1079 pending_context_menus_.Lookup(custom_context.request_id);
1033 if (client) { 1080 if (client) {
1034 client->OnMenuClosed(custom_context.request_id); 1081 client->OnMenuClosed(custom_context.request_id);
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 static_cast<int32>(source_line), 1742 static_cast<int32>(source_line),
1696 source_name)); 1743 source_name));
1697 } 1744 }
1698 1745
1699 void RenderFrameImpl::loadURLExternally( 1746 void RenderFrameImpl::loadURLExternally(
1700 blink::WebLocalFrame* frame, 1747 blink::WebLocalFrame* frame,
1701 const blink::WebURLRequest& request, 1748 const blink::WebURLRequest& request,
1702 blink::WebNavigationPolicy policy, 1749 blink::WebNavigationPolicy policy,
1703 const blink::WebString& suggested_name) { 1750 const blink::WebString& suggested_name) {
1704 DCHECK(!frame_ || frame_ == frame); 1751 DCHECK(!frame_ || frame_ == frame);
1752
1705 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 1753 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
1706 if (policy == blink::WebNavigationPolicyDownload) { 1754 if (policy == blink::WebNavigationPolicyDownload) {
1707 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1755 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1708 request.url(), referrer, 1756 request.url(), referrer,
1709 suggested_name, false)); 1757 suggested_name, false));
1710 } else if (policy == blink::WebNavigationPolicyDownloadTo) { 1758 } else if (policy == blink::WebNavigationPolicyDownloadTo) {
1711 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1759 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1712 request.url(), referrer, 1760 request.url(), referrer,
1713 suggested_name, true)); 1761 suggested_name, true));
1714 } else { 1762 } else {
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 // The request my be empty during tests. 2441 // The request my be empty during tests.
2394 if (request.url().isEmpty()) 2442 if (request.url().isEmpty())
2395 return; 2443 return;
2396 2444
2397 // Set the first party for cookies url if it has not been set yet (new 2445 // Set the first party for cookies url if it has not been set yet (new
2398 // requests). For redirects, it is updated by WebURLLoaderImpl. 2446 // requests). For redirects, it is updated by WebURLLoaderImpl.
2399 if (request.firstPartyForCookies().isEmpty()) { 2447 if (request.firstPartyForCookies().isEmpty()) {
2400 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) { 2448 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel) {
2401 request.setFirstPartyForCookies(request.url()); 2449 request.setFirstPartyForCookies(request.url());
2402 } else { 2450 } else {
2403 request.setFirstPartyForCookies( 2451 // TODO(nasko): When the top-level frame is remote, there is no document.
2404 frame->top()->document().firstPartyForCookies()); 2452 // This is broken and should be fixed to propagate the first party.
2453 WebFrame* top = frame->top();
2454 if (top->isWebLocalFrame()) {
2455 request.setFirstPartyForCookies(
2456 frame->top()->document().firstPartyForCookies());
2457 }
2405 } 2458 }
2406 } 2459 }
2407 2460
2408 WebFrame* top_frame = frame->top(); 2461 WebFrame* top_frame = frame->top();
2409 if (!top_frame) 2462 // TODO(nasko): Hack around asking about top-frame data source. This means
2463 // for out-of-process iframes we are treating the current frame as the
2464 // top-level frame, which is wrong.
2465 if (!top_frame || top_frame->isWebRemoteFrame())
2410 top_frame = frame; 2466 top_frame = frame;
2411 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 2467 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2412 WebDataSource* top_data_source = top_frame->dataSource(); 2468 WebDataSource* top_data_source = top_frame->dataSource();
2413 WebDataSource* data_source = 2469 WebDataSource* data_source =
2414 provisional_data_source ? provisional_data_source : top_data_source; 2470 provisional_data_source ? provisional_data_source : top_data_source;
2415 2471
2416 PageTransition transition_type = PAGE_TRANSITION_LINK; 2472 PageTransition transition_type = PAGE_TRANSITION_LINK;
2417 DocumentState* document_state = DocumentState::FromDataSource(data_source); 2473 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2418 DCHECK(document_state); 2474 DCHECK(document_state);
2419 InternalDocumentStateData* internal_data = 2475 InternalDocumentStateData* internal_data =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 DocumentState::FromDataSource(frame->provisionalDataSource())); 2552 DocumentState::FromDataSource(frame->provisionalDataSource()));
2497 provider_id = provider->provider_id(); 2553 provider_id = provider->provider_id();
2498 } 2554 }
2499 } else if (frame->dataSource()) { 2555 } else if (frame->dataSource()) {
2500 ServiceWorkerNetworkProvider* provider = 2556 ServiceWorkerNetworkProvider* provider =
2501 ServiceWorkerNetworkProvider::FromDocumentState( 2557 ServiceWorkerNetworkProvider::FromDocumentState(
2502 DocumentState::FromDataSource(frame->dataSource())); 2558 DocumentState::FromDataSource(frame->dataSource()));
2503 provider_id = provider->provider_id(); 2559 provider_id = provider->provider_id();
2504 } 2560 }
2505 2561
2506 int parent_routing_id = frame->parent() ? 2562 WebFrame* parent = frame->parent();
2507 FromWebFrame(frame->parent())->GetRoutingID() : -1; 2563 int parent_routing_id = MSG_ROUTING_NONE;
2564 if (!parent) {
2565 parent_routing_id = -1;
2566 } else if (parent->isWebLocalFrame()) {
2567 parent_routing_id = FromWebFrame(parent)->GetRoutingID();
2568 } else {
2569 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
2570 }
2571
2508 RequestExtraData* extra_data = new RequestExtraData(); 2572 RequestExtraData* extra_data = new RequestExtraData();
2509 extra_data->set_visibility_state(render_view_->visibilityState()); 2573 extra_data->set_visibility_state(render_view_->visibilityState());
2510 extra_data->set_custom_user_agent(custom_user_agent); 2574 extra_data->set_custom_user_agent(custom_user_agent);
2511 extra_data->set_was_after_preconnect_request(was_after_preconnect_request); 2575 extra_data->set_was_after_preconnect_request(was_after_preconnect_request);
2512 extra_data->set_render_frame_id(routing_id_); 2576 extra_data->set_render_frame_id(routing_id_);
2513 extra_data->set_is_main_frame(frame == top_frame); 2577 extra_data->set_is_main_frame(frame == top_frame);
2514 extra_data->set_frame_origin( 2578 extra_data->set_frame_origin(
2515 GURL(frame->document().securityOrigin().toString())); 2579 GURL(frame->document().securityOrigin().toString()));
2516 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); 2580 extra_data->set_parent_is_main_frame(frame->parent() == top_frame);
2517 extra_data->set_parent_render_frame_id(parent_routing_id); 2581 extra_data->set_parent_render_frame_id(parent_routing_id);
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
3219 frame, 3283 frame,
3220 request, 3284 request,
3221 type, 3285 type,
3222 default_policy, 3286 default_policy,
3223 is_redirect)) { 3287 is_redirect)) {
3224 return blink::WebNavigationPolicyIgnore; 3288 return blink::WebNavigationPolicyIgnore;
3225 } 3289 }
3226 #endif 3290 #endif
3227 3291
3228 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 3292 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
3293 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3229 3294
3230 if (is_swapped_out_ || render_view_->is_swapped_out()) { 3295 bool is_subframe = !!frame->parent();
3231 if (request.url() != GURL(kSwappedOutURL)) { 3296
3232 // Targeted links may try to navigate a swapped out frame. Allow the 3297 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) {
3233 // browser process to navigate the tab instead. Note that it is also 3298 // There's no reason to ignore navigations on subframes, since the swap out
3234 // possible for non-targeted navigations (from this view) to arrive 3299 // logic no longer applies.
3235 // here just after we are swapped out. It's ok to send them to the 3300 } else {
3236 // browser, as long as they're for the top level frame. 3301 if (is_swapped_out_ || render_view_->is_swapped_out()) {
3237 // TODO(creis): Ensure this supports targeted form submissions when 3302 if (request.url() != GURL(kSwappedOutURL)) {
3238 // fixing http://crbug.com/101395. 3303 // Targeted links may try to navigate a swapped out frame. Allow the
3239 if (frame->parent() == NULL) { 3304 // browser process to navigate the tab instead. Note that it is also
3240 OpenURL(frame, request.url(), referrer, default_policy); 3305 // possible for non-targeted navigations (from this view) to arrive
3241 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 3306 // here just after we are swapped out. It's ok to send them to the
3307 // browser, as long as they're for the top level frame.
3308 // TODO(creis): Ensure this supports targeted form submissions when
3309 // fixing http://crbug.com/101395.
3310 if (frame->parent() == NULL) {
3311 OpenURL(frame, request.url(), referrer, default_policy);
3312 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
3313 }
3314
3315 // We should otherwise ignore in-process iframe navigations, if they
3316 // arrive just after we are swapped out.
3317 return blink::WebNavigationPolicyIgnore;
3242 } 3318 }
3243 3319
3244 // We should otherwise ignore in-process iframe navigations, if they 3320 // Allow kSwappedOutURL to complete.
3245 // arrive just after we are swapped out. 3321 return default_policy;
3246 return blink::WebNavigationPolicyIgnore;
3247 } 3322 }
3248
3249 // Allow kSwappedOutURL to complete.
3250 return default_policy;
3251 } 3323 }
3252 3324
3253 // Webkit is asking whether to navigate to a new URL. 3325 // Webkit is asking whether to navigate to a new URL.
3254 // This is fine normally, except if we're showing UI from one security 3326 // 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. 3327 // context and they're trying to navigate to a different context.
3256 const GURL& url = request.url(); 3328 const GURL& url = request.url();
3257 3329
3258 // A content initiated navigation may have originated from a link-click, 3330 // A content initiated navigation may have originated from a link-click,
3259 // script, drag-n-drop operation, etc. 3331 // script, drag-n-drop operation, etc.
3260 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> 3332 bool is_content_initiated = static_cast<DocumentState*>(extraData)->
3261 navigation_state()->is_content_initiated(); 3333 navigation_state()->is_content_initiated();
3262 3334
3263 // Experimental: 3335 // Experimental:
3264 // If --enable-strict-site-isolation or --site-per-process is enabled, send 3336 // 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 3337 // 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 3338 // crossing site boundaries. This is currently expected to break some script
3267 // calls and navigations, such as form submissions. 3339 // calls and navigations, such as form submissions.
3268 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3269 bool force_swap_due_to_flag = 3340 bool force_swap_due_to_flag =
3270 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 3341 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
3271 command_line.HasSwitch(switches::kSitePerProcess); 3342 command_line.HasSwitch(switches::kSitePerProcess);
3272 if (force_swap_due_to_flag && 3343 if (force_swap_due_to_flag &&
3273 !frame->parent() && (is_content_initiated || is_redirect)) { 3344 !frame->parent() && (is_content_initiated || is_redirect)) {
3274 WebString origin_str = frame->document().securityOrigin().toString(); 3345 WebString origin_str = frame->document().securityOrigin().toString();
3275 GURL frame_url(origin_str.utf8().data()); 3346 GURL frame_url(origin_str.utf8().data());
3276 // TODO(cevans): revisit whether this site check is still necessary once 3347 // TODO(cevans): revisit whether this site check is still necessary once
3277 // crbug.com/101395 is fixed. 3348 // crbug.com/101395 is fixed.
3278 bool same_domain_or_host = 3349 bool same_domain_or_host =
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3632 3703
3633 #if defined(ENABLE_BROWSER_CDMS) 3704 #if defined(ENABLE_BROWSER_CDMS)
3634 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3705 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3635 if (!cdm_manager_) 3706 if (!cdm_manager_)
3636 cdm_manager_ = new RendererCdmManager(this); 3707 cdm_manager_ = new RendererCdmManager(this);
3637 return cdm_manager_; 3708 return cdm_manager_;
3638 } 3709 }
3639 #endif // defined(ENABLE_BROWSER_CDMS) 3710 #endif // defined(ENABLE_BROWSER_CDMS)
3640 3711
3641 } // namespace content 3712 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698