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

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: Created 6 years, 5 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 #include "content/renderer/media/media_stream_renderer_factory.h" 65 #include "content/renderer/media/media_stream_renderer_factory.h"
66 #include "content/renderer/media/midi_dispatcher.h" 66 #include "content/renderer/media/midi_dispatcher.h"
67 #include "content/renderer/media/render_media_log.h" 67 #include "content/renderer/media/render_media_log.h"
68 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 68 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
69 #include "content/renderer/media/webmediaplayer_impl.h" 69 #include "content/renderer/media/webmediaplayer_impl.h"
70 #include "content/renderer/media/webmediaplayer_ms.h" 70 #include "content/renderer/media/webmediaplayer_ms.h"
71 #include "content/renderer/media/webmediaplayer_params.h" 71 #include "content/renderer/media/webmediaplayer_params.h"
72 #include "content/renderer/notification_provider.h" 72 #include "content/renderer/notification_provider.h"
73 #include "content/renderer/npapi/plugin_channel_host.h" 73 #include "content/renderer/npapi/plugin_channel_host.h"
74 #include "content/renderer/push_messaging_dispatcher.h" 74 #include "content/renderer/push_messaging_dispatcher.h"
75 #include "content/renderer/render_frame_proxy.h"
75 #include "content/renderer/render_process.h" 76 #include "content/renderer/render_process.h"
76 #include "content/renderer/render_thread_impl.h" 77 #include "content/renderer/render_thread_impl.h"
77 #include "content/renderer/render_view_impl.h" 78 #include "content/renderer/render_view_impl.h"
78 #include "content/renderer/render_widget_fullscreen_pepper.h" 79 #include "content/renderer/render_widget_fullscreen_pepper.h"
79 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 80 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
80 #include "content/renderer/renderer_webcolorchooser_impl.h" 81 #include "content/renderer/renderer_webcolorchooser_impl.h"
81 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" 82 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
82 #include "content/renderer/shared_worker_repository.h" 83 #include "content/renderer/shared_worker_repository.h"
83 #include "content/renderer/v8_value_converter_impl.h" 84 #include "content/renderer/v8_value_converter_impl.h"
84 #include "content/renderer/websharedworker_proxy.h" 85 #include "content/renderer/websharedworker_proxy.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // static 360 // static
360 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { 361 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) {
361 RoutingIDFrameMap::iterator iter = 362 RoutingIDFrameMap::iterator iter =
362 g_routing_id_frame_map.Get().find(routing_id); 363 g_routing_id_frame_map.Get().find(routing_id);
363 if (iter != g_routing_id_frame_map.Get().end()) 364 if (iter != g_routing_id_frame_map.Get().end())
364 return iter->second; 365 return iter->second;
365 return NULL; 366 return NULL;
366 } 367 }
367 368
368 // static 369 // static
370 void RenderFrameImpl::CreateFrame(int routing_id, int parent_routing_id) {
371 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id);
372
373 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(parent_routing_id);
374
375 // If the browser is sending a valid parent routing id, it better be created
376 // and registered.
377 CHECK(proxy);
378 blink::WebRemoteFrame* parent_web_frame = proxy->web_frame();
379
380 // Create the RenderFrame and WebLocalFrame, linking the two.
381 RenderFrameImpl* render_frame =
382 RenderFrameImpl::Create(proxy->render_view(), routing_id);
383 blink::WebLocalFrame* web_frame =
384 parent_web_frame->createLocalChild("", render_frame);
385 render_frame->SetWebFrame(web_frame);
386 render_frame->Initialize();
387 }
388
389 // static
369 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { 390 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) {
370 return RenderFrameImpl::FromWebFrame(web_frame); 391 return RenderFrameImpl::FromWebFrame(web_frame);
371 } 392 }
372 393
394 // static
373 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { 395 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) {
374 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); 396 FrameMap::iterator iter = g_frame_map.Get().find(web_frame);
375 if (iter != g_frame_map.Get().end()) 397 if (iter != g_frame_map.Get().end())
376 return iter->second; 398 return iter->second;
377 return NULL; 399 return NULL;
378 } 400 }
379 401
380 // static 402 // static
381 void RenderFrameImpl::InstallCreateHook( 403 void RenderFrameImpl::InstallCreateHook(
382 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { 404 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) {
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 InitializeUserMediaClient(); 679 InitializeUserMediaClient();
658 return web_user_media_client_ ? 680 return web_user_media_client_ ?
659 web_user_media_client_->media_stream_dispatcher() : NULL; 681 web_user_media_client_->media_stream_dispatcher() : NULL;
660 } 682 }
661 683
662 bool RenderFrameImpl::Send(IPC::Message* message) { 684 bool RenderFrameImpl::Send(IPC::Message* message) {
663 if (is_detaching_) { 685 if (is_detaching_) {
664 delete message; 686 delete message;
665 return false; 687 return false;
666 } 688 }
667 if (is_swapped_out_ || render_view_->is_swapped_out()) { 689 if (frame_->parent() == NULL &&
690 (is_swapped_out_ || render_view_->is_swapped_out())) {
668 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { 691 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) {
669 delete message; 692 delete message;
670 return false; 693 return false;
671 } 694 }
695
672 // In most cases, send IPCs through the proxy when swapped out. In some 696 // In most cases, send IPCs through the proxy when swapped out. In some
673 // calls the associated RenderViewImpl routing id is used to send 697 // calls the associated RenderViewImpl routing id is used to send
674 // messages, so don't use the proxy. 698 // messages, so don't use the proxy.
675 if (render_frame_proxy_ && message->routing_id() == routing_id_) 699 if (render_frame_proxy_ && message->routing_id() == routing_id_)
676 return render_frame_proxy_->Send(message); 700 return render_frame_proxy_->Send(message);
677 } 701 }
678 702
679 return RenderThread::Get()->Send(message); 703 return RenderThread::Get()->Send(message);
680 } 704 }
681 705
682 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { 706 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
683 GetContentClient()->SetActiveURL(frame_->document().url()); 707 if (!frame_->document().isNull())
708 GetContentClient()->SetActiveURL(frame_->document().url());
684 709
685 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); 710 ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
686 RenderFrameObserver* observer; 711 RenderFrameObserver* observer;
687 while ((observer = it.GetNext()) != NULL) { 712 while ((observer = it.GetNext()) != NULL) {
688 if (observer->OnMessageReceived(msg)) 713 if (observer->OnMessageReceived(msg))
689 return true; 714 return true;
690 } 715 }
691 716
692 bool handled = true; 717 bool handled = true;
693 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) 718 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 bool is_reload = RenderViewImpl::IsReload(params); 767 bool is_reload = RenderViewImpl::IsReload(params);
743 WebURLRequest::CachePolicy cache_policy = 768 WebURLRequest::CachePolicy cache_policy =
744 WebURLRequest::UseProtocolCachePolicy; 769 WebURLRequest::UseProtocolCachePolicy;
745 770
746 // If this is a stale back/forward (due to a recent navigation the browser 771 // If this is a stale back/forward (due to a recent navigation the browser
747 // didn't know about), ignore it. 772 // didn't know about), ignore it.
748 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) 773 if (render_view_->IsBackForwardToStaleEntry(params, is_reload))
749 return; 774 return;
750 775
751 // Swap this renderer back in if necessary. 776 // Swap this renderer back in if necessary.
752 if (render_view_->is_swapped_out_) { 777 if (render_view_->is_swapped_out_ &&
778 GetWebFrame() == render_view_->webview()->mainFrame()) {
753 // We marked the view as hidden when swapping the view out, so be sure to 779 // We marked the view as hidden when swapping the view out, so be sure to
754 // reset the visibility state before navigating to the new URL. 780 // reset the visibility state before navigating to the new URL.
755 render_view_->webview()->setVisibilityState( 781 render_view_->webview()->setVisibilityState(
756 render_view_->visibilityState(), false); 782 render_view_->visibilityState(), false);
757 783
758 // If this is an attempt to reload while we are swapped out, we should not 784 // If this is an attempt to reload while we are swapped out, we should not
759 // reload swappedout://, but the previous page, which is stored in 785 // reload swappedout://, but the previous page, which is stored in
760 // params.state. Setting is_reload to false will treat this like a back 786 // params.state. Setting is_reload to false will treat this like a back
761 // navigation to accomplish that. 787 // navigation to accomplish that.
762 is_reload = false; 788 is_reload = false;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 961 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
936 bool proceed = frame_->dispatchBeforeUnloadEvent(); 962 bool proceed = frame_->dispatchBeforeUnloadEvent();
937 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 963 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
938 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, 964 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed,
939 before_unload_start_time, 965 before_unload_start_time,
940 before_unload_end_time)); 966 before_unload_end_time));
941 } 967 }
942 968
943 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { 969 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
944 RenderFrameProxy* proxy = NULL; 970 RenderFrameProxy* proxy = NULL;
971 bool is_site_per_process =
972 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess);
945 973
946 // Only run unload if we're not swapped out yet, but send the ack either way. 974 // Only run unload if we're not swapped out yet, but send the ack either way.
947 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { 975 if (!is_swapped_out_ || !render_view_->is_swapped_out_) {
948 // Swap this RenderFrame out so the frame can navigate to a page rendered by 976 // Swap this RenderFrame out so the frame can navigate to a page rendered by
949 // a different process. This involves running the unload handler and 977 // a different process. This involves running the unload handler and
950 // clearing the page. Once WasSwappedOut is called, we also allow this 978 // clearing the page. Once WasSwappedOut is called, we also allow this
951 // process to exit if there are no other active RenderFrames in it. 979 // process to exit if there are no other active RenderFrames in it.
952 980
953 // Send an UpdateState message before we get swapped out. Create the 981 // Send an UpdateState message before we get swapped out. Create the
954 // RenderFrameProxy as well so its routing id is registered for receiving 982 // RenderFrameProxy as well so its routing id is registered for receiving
955 // IPC messages. 983 // IPC messages.
956 render_view_->SyncNavigationState(); 984 render_view_->SyncNavigationState();
957 proxy = RenderFrameProxy::CreateFrameProxy(proxy_routing_id, routing_id_); 985 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this,
986 proxy_routing_id);
958 987
959 // Synchronously run the unload handler before sending the ACK. 988 // Synchronously run the unload handler before sending the ACK.
960 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support 989 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
961 // unload on subframes as well. 990 // unload on subframes as well.
962 if (!frame_->parent()) 991 if (!frame_->parent())
963 frame_->dispatchUnloadEvent(); 992 frame_->dispatchUnloadEvent();
964 993
965 // Swap out and stop sending any IPC messages that are not ACKs. 994 // Swap out and stop sending any IPC messages that are not ACKs.
966 if (!frame_->parent()) 995 if (!frame_->parent())
967 render_view_->SetSwappedOut(true); 996 render_view_->SetSwappedOut(true);
(...skipping 12 matching lines...) Expand all
980 1009
981 // Let subframes know that the frame is now rendered remotely, for the 1010 // Let subframes know that the frame is now rendered remotely, for the
982 // purposes of compositing and input events. 1011 // purposes of compositing and input events.
983 if (frame_->parent()) 1012 if (frame_->parent())
984 frame_->setIsRemote(true); 1013 frame_->setIsRemote(true);
985 1014
986 // Replace the page with a blank dummy URL. The unload handler will not be 1015 // Replace the page with a blank dummy URL. The unload handler will not be
987 // run a second time, thanks to a check in FrameLoader::stopLoading. 1016 // run a second time, thanks to a check in FrameLoader::stopLoading.
988 // TODO(creis): Need to add a better way to do this that avoids running the 1017 // TODO(creis): Need to add a better way to do this that avoids running the
989 // beforeunload handler. For now, we just run it a second time silently. 1018 // beforeunload handler. For now, we just run it a second time silently.
990 render_view_->NavigateToSwappedOutURL(frame_); 1019 if (!is_site_per_process || frame_->parent() == NULL)
1020 render_view_->NavigateToSwappedOutURL(frame_);
991 1021
992 // Let WebKit know that this view is hidden so it can drop resources and 1022 // Let WebKit know that this view is hidden so it can drop resources and
993 // stop compositing. 1023 // stop compositing.
994 // TODO(creis): Support this for subframes as well. 1024 // TODO(creis): Support this for subframes as well.
995 if (!frame_->parent()) { 1025 if (!frame_->parent()) {
996 render_view_->webview()->setVisibilityState( 1026 render_view_->webview()->setVisibilityState(
997 blink::WebPageVisibilityStateHidden, false); 1027 blink::WebPageVisibilityStateHidden, false);
998 } 1028 }
999 } 1029 }
1000 1030
1001 // It is now safe to show modal dialogs again. 1031 // It is now safe to show modal dialogs again.
1002 // TODO(creis): Deal with modal dialogs from subframes. 1032 // TODO(creis): Deal with modal dialogs from subframes.
1003 if (!frame_->parent()) 1033 if (!frame_->parent())
1004 render_view_->suppress_dialogs_until_swap_out_ = false; 1034 render_view_->suppress_dialogs_until_swap_out_ = false;
1005 1035
1006 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1036 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1007 1037
1008 // Now that all of the cleanup is complete and the browser side is notified, 1038 // Now that all of the cleanup is complete and the browser side is notified,
1009 // start using the RenderFrameProxy, if one is created. 1039 // start using the RenderFrameProxy, if one is created.
1010 if (proxy) 1040 if (proxy) {
1011 set_render_frame_proxy(proxy); 1041 if (frame_->parent()) {
1042 frame_->swap(proxy->web_frame());
1043 if (is_site_per_process) {
1044 // TODO(nasko): delete the frame here, since we've replaced it with a
1045 // proxy.
1046 }
1047 } else {
1048 set_render_frame_proxy(proxy);
1049 }
1050 }
1012 } 1051 }
1013 1052
1014 void RenderFrameImpl::OnContextMenuClosed( 1053 void RenderFrameImpl::OnContextMenuClosed(
1015 const CustomContextMenuContext& custom_context) { 1054 const CustomContextMenuContext& custom_context) {
1016 if (custom_context.request_id) { 1055 if (custom_context.request_id) {
1017 // External request, should be in our map. 1056 // External request, should be in our map.
1018 ContextMenuClient* client = 1057 ContextMenuClient* client =
1019 pending_context_menus_.Lookup(custom_context.request_id); 1058 pending_context_menus_.Lookup(custom_context.request_id);
1020 if (client) { 1059 if (client) {
1021 client->OnMenuClosed(custom_context.request_id); 1060 client->OnMenuClosed(custom_context.request_id);
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 static_cast<int32>(source_line), 1691 static_cast<int32>(source_line),
1653 source_name)); 1692 source_name));
1654 } 1693 }
1655 1694
1656 void RenderFrameImpl::loadURLExternally( 1695 void RenderFrameImpl::loadURLExternally(
1657 blink::WebLocalFrame* frame, 1696 blink::WebLocalFrame* frame,
1658 const blink::WebURLRequest& request, 1697 const blink::WebURLRequest& request,
1659 blink::WebNavigationPolicy policy, 1698 blink::WebNavigationPolicy policy,
1660 const blink::WebString& suggested_name) { 1699 const blink::WebString& suggested_name) {
1661 DCHECK(!frame_ || frame_ == frame); 1700 DCHECK(!frame_ || frame_ == frame);
1701
1662 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 1702 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
1663 if (policy == blink::WebNavigationPolicyDownload) { 1703 if (policy == blink::WebNavigationPolicyDownload) {
1664 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1704 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1665 request.url(), referrer, 1705 request.url(), referrer,
1666 suggested_name, false)); 1706 suggested_name, false));
1667 } else if (policy == blink::WebNavigationPolicyDownloadTo) { 1707 } else if (policy == blink::WebNavigationPolicyDownloadTo) {
1668 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1708 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1669 request.url(), referrer, 1709 request.url(), referrer,
1670 suggested_name, true)); 1710 suggested_name, true));
1671 } else { 1711 } else {
1672 OpenURL(frame, request.url(), referrer, policy); 1712 OpenURL(frame, request.url(), referrer, policy);
1673 } 1713 }
1674 } 1714 }
1675 1715
1676 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( 1716 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
1677 blink::WebLocalFrame* frame, 1717 blink::WebLocalFrame* frame,
1678 blink::WebDataSource::ExtraData* extra_data, 1718 blink::WebDataSource::ExtraData* extra_data,
1679 const blink::WebURLRequest& request, 1719 const blink::WebURLRequest& request,
1680 blink::WebNavigationType type, 1720 blink::WebNavigationType type,
1681 blink::WebNavigationPolicy default_policy, 1721 blink::WebNavigationPolicy default_policy,
1682 bool is_redirect) { 1722 bool is_redirect) {
1683 DCHECK(!frame_ || frame_ == frame); 1723 DCHECK(!frame_ || frame_ == frame);
1684 return DecidePolicyForNavigation( 1724 WebNavigationPolicy value = DecidePolicyForNavigation(
1685 this, frame, extra_data, request, type, default_policy, is_redirect); 1725 this, frame, extra_data, request, type, default_policy, is_redirect);
1726 return value;
1686 } 1727 }
1687 1728
1688 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( 1729 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame(
1689 blink::WebFrame* frame) { 1730 blink::WebFrame* frame) {
1690 DCHECK(!frame_ || frame_ == frame); 1731 DCHECK(!frame_ || frame_ == frame);
1691 return render_view_->history_controller()->GetItemForNewChildFrame(this); 1732 return render_view_->history_controller()->GetItemForNewChildFrame(this);
1692 } 1733 }
1693 1734
1694 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, 1735 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame,
1695 const blink::WebFormElement& form) { 1736 const blink::WebFormElement& form) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 1821 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
1781 // handle loading of error pages. 1822 // handle loading of error pages.
1782 document_state->navigation_state()->set_transition_type( 1823 document_state->navigation_state()->set_transition_type(
1783 PAGE_TRANSITION_AUTO_SUBFRAME); 1824 PAGE_TRANSITION_AUTO_SUBFRAME);
1784 } 1825 }
1785 1826
1786 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 1827 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
1787 DidStartProvisionalLoad(frame)); 1828 DidStartProvisionalLoad(frame));
1788 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 1829 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
1789 1830
1790 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(routing_id_, 1831 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
1791 ds->request().url())); 1832 routing_id_, ds->request().url()));
1792 } 1833 }
1793 1834
1794 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 1835 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
1795 blink::WebLocalFrame* frame) { 1836 blink::WebLocalFrame* frame) {
1796 DCHECK(!frame_ || frame_ == frame); 1837 DCHECK(!frame_ || frame_ == frame);
1797 render_view_->history_controller()->RemoveChildrenForRedirect(this); 1838 render_view_->history_controller()->RemoveChildrenForRedirect(this);
1798 if (frame->parent()) 1839 if (frame->parent())
1799 return; 1840 return;
1800 // Received a redirect on the main frame. 1841 // Received a redirect on the main frame.
1801 WebDataSource* data_source = frame->provisionalDataSource(); 1842 WebDataSource* data_source = frame->provisionalDataSource();
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 // The request my be empty during tests. 2391 // The request my be empty during tests.
2351 if (request.url().isEmpty()) 2392 if (request.url().isEmpty())
2352 return; 2393 return;
2353 2394
2354 // Set the first party for cookies url if it has not been set yet (new 2395 // Set the first party for cookies url if it has not been set yet (new
2355 // requests). For redirects, it is updated by WebURLLoaderImpl. 2396 // requests). For redirects, it is updated by WebURLLoaderImpl.
2356 if (request.firstPartyForCookies().isEmpty()) { 2397 if (request.firstPartyForCookies().isEmpty()) {
2357 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) { 2398 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) {
2358 request.setFirstPartyForCookies(request.url()); 2399 request.setFirstPartyForCookies(request.url());
2359 } else { 2400 } else {
2360 request.setFirstPartyForCookies( 2401 // TODO(nasko): When the top-level frame is remote, there is no document.
2361 frame->top()->document().firstPartyForCookies()); 2402 // This is broken and should be fixed to propagate the URL.
2403 WebFrame* top = frame->top();
2404 if (top->isWebLocalFrame()) {
2405 request.setFirstPartyForCookies(
2406 frame->top()->document().firstPartyForCookies());
2407 }
2362 } 2408 }
2363 } 2409 }
2364 2410
2365 WebFrame* top_frame = frame->top(); 2411 WebFrame* top_frame = frame->top();
2366 if (!top_frame) 2412 // TODO(nasko): Hack around asking about top-frame data source.
2413 if (!top_frame || top_frame->isWebRemoteFrame())
2367 top_frame = frame; 2414 top_frame = frame;
2368 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 2415 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2369 WebDataSource* top_data_source = top_frame->dataSource(); 2416 WebDataSource* top_data_source = top_frame->dataSource();
2370 WebDataSource* data_source = 2417 WebDataSource* data_source =
2371 provisional_data_source ? provisional_data_source : top_data_source; 2418 provisional_data_source ? provisional_data_source : top_data_source;
2372 2419
2373 PageTransition transition_type = PAGE_TRANSITION_LINK; 2420 PageTransition transition_type = PAGE_TRANSITION_LINK;
2374 DocumentState* document_state = DocumentState::FromDataSource(data_source); 2421 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2375 DCHECK(document_state); 2422 DCHECK(document_state);
2376 InternalDocumentStateData* internal_data = 2423 InternalDocumentStateData* internal_data =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 DocumentState::FromDataSource(frame->provisionalDataSource())); 2500 DocumentState::FromDataSource(frame->provisionalDataSource()));
2454 provider_id = provider->provider_id(); 2501 provider_id = provider->provider_id();
2455 } 2502 }
2456 } else if (frame->dataSource()) { 2503 } else if (frame->dataSource()) {
2457 ServiceWorkerNetworkProvider* provider = 2504 ServiceWorkerNetworkProvider* provider =
2458 ServiceWorkerNetworkProvider::FromDocumentState( 2505 ServiceWorkerNetworkProvider::FromDocumentState(
2459 DocumentState::FromDataSource(frame->dataSource())); 2506 DocumentState::FromDataSource(frame->dataSource()));
2460 provider_id = provider->provider_id(); 2507 provider_id = provider->provider_id();
2461 } 2508 }
2462 2509
2463 int parent_routing_id = frame->parent() ? 2510 WebFrame* parent = frame->parent();
2464 FromWebFrame(frame->parent())->GetRoutingID() : -1; 2511 int parent_routing_id = MSG_ROUTING_NONE;
2512 if (!parent) {
2513 parent_routing_id = -1;
2514 } else if (parent->isWebLocalFrame()) {
2515 parent_routing_id = FromWebFrame(parent)->GetRoutingID();
2516 } else {
2517 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
2518 }
2519
2465 RequestExtraData* extra_data = new RequestExtraData(); 2520 RequestExtraData* extra_data = new RequestExtraData();
2466 extra_data->set_visibility_state(render_view_->visibilityState()); 2521 extra_data->set_visibility_state(render_view_->visibilityState());
2467 extra_data->set_custom_user_agent(custom_user_agent); 2522 extra_data->set_custom_user_agent(custom_user_agent);
2468 extra_data->set_was_after_preconnect_request(was_after_preconnect_request); 2523 extra_data->set_was_after_preconnect_request(was_after_preconnect_request);
2469 extra_data->set_render_frame_id(routing_id_); 2524 extra_data->set_render_frame_id(routing_id_);
2470 extra_data->set_is_main_frame(frame == top_frame); 2525 extra_data->set_is_main_frame(frame == top_frame);
2471 extra_data->set_frame_origin( 2526 extra_data->set_frame_origin(
2472 GURL(frame->document().securityOrigin().toString())); 2527 GURL(frame->document().securityOrigin().toString()));
2473 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); 2528 extra_data->set_parent_is_main_frame(frame->parent() == top_frame);
2474 extra_data->set_parent_render_frame_id(parent_routing_id); 2529 extra_data->set_parent_render_frame_id(parent_routing_id);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
3153 frame, 3208 frame,
3154 request, 3209 request,
3155 type, 3210 type,
3156 default_policy, 3211 default_policy,
3157 is_redirect)) { 3212 is_redirect)) {
3158 return blink::WebNavigationPolicyIgnore; 3213 return blink::WebNavigationPolicyIgnore;
3159 } 3214 }
3160 #endif 3215 #endif
3161 3216
3162 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 3217 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
3218 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3163 3219
3164 if (is_swapped_out_ || render_view_->is_swapped_out()) { 3220 bool is_subframe = !!frame->parent();
3165 if (request.url() != GURL(kSwappedOutURL)) { 3221
3166 // Targeted links may try to navigate a swapped out frame. Allow the 3222 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) {
3167 // browser process to navigate the tab instead. Note that it is also 3223 // There's no reason to ignore navigations on subframes (why again?)
3168 // possible for non-targeted navigations (from this view) to arrive 3224 } else {
3169 // here just after we are swapped out. It's ok to send them to the 3225 if (is_swapped_out_ || render_view_->is_swapped_out()) {
3170 // browser, as long as they're for the top level frame. 3226 if (request.url() != GURL(kSwappedOutURL)) {
3171 // TODO(creis): Ensure this supports targeted form submissions when 3227 // Targeted links may try to navigate a swapped out frame. Allow the
3172 // fixing http://crbug.com/101395. 3228 // browser process to navigate the tab instead. Note that it is also
3173 if (frame->parent() == NULL) { 3229 // possible for non-targeted navigations (from this view) to arrive
3174 OpenURL(frame, request.url(), referrer, default_policy); 3230 // here just after we are swapped out. It's ok to send them to the
3175 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 3231 // browser, as long as they're for the top level frame.
3232 // TODO(creis): Ensure this supports targeted form submissions when
3233 // fixing http://crbug.com/101395.
3234 if (frame->parent() == NULL) {
3235 OpenURL(frame, request.url(), referrer, default_policy);
3236 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
3237 }
3238
3239 // We should otherwise ignore in-process iframe navigations, if they
3240 // arrive just after we are swapped out.
3241 return blink::WebNavigationPolicyIgnore;
3176 } 3242 }
3177 3243
3178 // We should otherwise ignore in-process iframe navigations, if they 3244 // Allow kSwappedOutURL to complete.
3179 // arrive just after we are swapped out. 3245 return default_policy;
3180 return blink::WebNavigationPolicyIgnore;
3181 } 3246 }
3182
3183 // Allow kSwappedOutURL to complete.
3184 return default_policy;
3185 } 3247 }
3186 3248
3187 // Webkit is asking whether to navigate to a new URL. 3249 // Webkit is asking whether to navigate to a new URL.
3188 // This is fine normally, except if we're showing UI from one security 3250 // This is fine normally, except if we're showing UI from one security
3189 // context and they're trying to navigate to a different context. 3251 // context and they're trying to navigate to a different context.
3190 const GURL& url = request.url(); 3252 const GURL& url = request.url();
3191 3253
3192 // A content initiated navigation may have originated from a link-click, 3254 // A content initiated navigation may have originated from a link-click,
3193 // script, drag-n-drop operation, etc. 3255 // script, drag-n-drop operation, etc.
3194 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> 3256 bool is_content_initiated = static_cast<DocumentState*>(extraData)->
3195 navigation_state()->is_content_initiated(); 3257 navigation_state()->is_content_initiated();
3196 3258
3197 // Experimental: 3259 // Experimental:
3198 // If --enable-strict-site-isolation or --site-per-process is enabled, send 3260 // If --enable-strict-site-isolation or --site-per-process is enabled, send
3199 // all top-level navigations to the browser to let it swap processes when 3261 // all top-level navigations to the browser to let it swap processes when
3200 // crossing site boundaries. This is currently expected to break some script 3262 // crossing site boundaries. This is currently expected to break some script
3201 // calls and navigations, such as form submissions. 3263 // calls and navigations, such as form submissions.
3202 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3203 bool force_swap_due_to_flag = 3264 bool force_swap_due_to_flag =
3204 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 3265 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
3205 command_line.HasSwitch(switches::kSitePerProcess); 3266 command_line.HasSwitch(switches::kSitePerProcess);
3206 if (force_swap_due_to_flag && 3267 if (force_swap_due_to_flag &&
3207 !frame->parent() && (is_content_initiated || is_redirect)) { 3268 !frame->parent() && (is_content_initiated || is_redirect)) {
3208 WebString origin_str = frame->document().securityOrigin().toString(); 3269 WebString origin_str = frame->document().securityOrigin().toString();
3209 GURL frame_url(origin_str.utf8().data()); 3270 GURL frame_url(origin_str.utf8().data());
3210 // TODO(cevans): revisit whether this site check is still necessary once 3271 // TODO(cevans): revisit whether this site check is still necessary once
3211 // crbug.com/101395 is fixed. 3272 // crbug.com/101395 is fixed.
3212 bool same_domain_or_host = 3273 bool same_domain_or_host =
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 3627
3567 #if defined(ENABLE_BROWSER_CDMS) 3628 #if defined(ENABLE_BROWSER_CDMS)
3568 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3629 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3569 if (!cdm_manager_) 3630 if (!cdm_manager_)
3570 cdm_manager_ = new RendererCdmManager(this); 3631 cdm_manager_ = new RendererCdmManager(this);
3571 return cdm_manager_; 3632 return cdm_manager_;
3572 } 3633 }
3573 #endif // defined(ENABLE_BROWSER_CDMS) 3634 #endif // defined(ENABLE_BROWSER_CDMS)
3574 3635
3575 } // namespace content 3636 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698