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

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: Bug fix + ncarter review comments addressed 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 #include "content/renderer/media/media_stream_renderer_factory.h" 67 #include "content/renderer/media/media_stream_renderer_factory.h"
68 #include "content/renderer/media/midi_dispatcher.h" 68 #include "content/renderer/media/midi_dispatcher.h"
69 #include "content/renderer/media/render_media_log.h" 69 #include "content/renderer/media/render_media_log.h"
70 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 70 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
71 #include "content/renderer/media/webmediaplayer_impl.h" 71 #include "content/renderer/media/webmediaplayer_impl.h"
72 #include "content/renderer/media/webmediaplayer_ms.h" 72 #include "content/renderer/media/webmediaplayer_ms.h"
73 #include "content/renderer/media/webmediaplayer_params.h" 73 #include "content/renderer/media/webmediaplayer_params.h"
74 #include "content/renderer/notification_provider.h" 74 #include "content/renderer/notification_provider.h"
75 #include "content/renderer/npapi/plugin_channel_host.h" 75 #include "content/renderer/npapi/plugin_channel_host.h"
76 #include "content/renderer/push_messaging_dispatcher.h" 76 #include "content/renderer/push_messaging_dispatcher.h"
77 #include "content/renderer/render_frame_proxy.h"
77 #include "content/renderer/render_process.h" 78 #include "content/renderer/render_process.h"
78 #include "content/renderer/render_thread_impl.h" 79 #include "content/renderer/render_thread_impl.h"
79 #include "content/renderer/render_view_impl.h" 80 #include "content/renderer/render_view_impl.h"
80 #include "content/renderer/render_widget_fullscreen_pepper.h" 81 #include "content/renderer/render_widget_fullscreen_pepper.h"
81 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 82 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
82 #include "content/renderer/renderer_webcolorchooser_impl.h" 83 #include "content/renderer/renderer_webcolorchooser_impl.h"
83 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" 84 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
84 #include "content/renderer/shared_worker_repository.h" 85 #include "content/renderer/shared_worker_repository.h"
85 #include "content/renderer/v8_value_converter_impl.h" 86 #include "content/renderer/v8_value_converter_impl.h"
86 #include "content/renderer/websharedworker_proxy.h" 87 #include "content/renderer/websharedworker_proxy.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // static 362 // static
362 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) { 363 RenderFrameImpl* RenderFrameImpl::FromRoutingID(int32 routing_id) {
363 RoutingIDFrameMap::iterator iter = 364 RoutingIDFrameMap::iterator iter =
364 g_routing_id_frame_map.Get().find(routing_id); 365 g_routing_id_frame_map.Get().find(routing_id);
365 if (iter != g_routing_id_frame_map.Get().end()) 366 if (iter != g_routing_id_frame_map.Get().end())
366 return iter->second; 367 return iter->second;
367 return NULL; 368 return NULL;
368 } 369 }
369 370
370 // static 371 // static
372 void RenderFrameImpl::CreateFrame(int routing_id, int parent_routing_id) {
373 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id);
Charlie Reis 2014/07/24 22:36:30 Wait, the comments on this function and the IPC me
kenrb 2014/07/25 23:42:06 I don't know what is intended here, so I left a TO
374
375 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(parent_routing_id);
376
377 // If the browser is sending a valid parent routing id, it better be created
Charlie Reis 2014/07/24 22:36:31 it better be -> it should already be
kenrb 2014/07/25 23:42:06 Done.
378 // and registered.
379 CHECK(proxy);
380 blink::WebRemoteFrame* parent_web_frame = proxy->web_frame();
381
382 // Create the RenderFrame and WebLocalFrame, linking the two.
383 RenderFrameImpl* render_frame =
384 RenderFrameImpl::Create(proxy->render_view(), routing_id);
385 blink::WebLocalFrame* web_frame =
386 parent_web_frame->createLocalChild("", render_frame);
387 render_frame->SetWebFrame(web_frame);
388 render_frame->Initialize();
389 }
390
391 // static
371 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { 392 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) {
372 return RenderFrameImpl::FromWebFrame(web_frame); 393 return RenderFrameImpl::FromWebFrame(web_frame);
373 } 394 }
374 395
396 // static
375 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { 397 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) {
376 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); 398 FrameMap::iterator iter = g_frame_map.Get().find(web_frame);
377 if (iter != g_frame_map.Get().end()) 399 if (iter != g_frame_map.Get().end())
378 return iter->second; 400 return iter->second;
379 return NULL; 401 return NULL;
380 } 402 }
381 403
382 // static 404 // static
383 void RenderFrameImpl::InstallCreateHook( 405 void RenderFrameImpl::InstallCreateHook(
384 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { 406 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 InitializeUserMediaClient(); 683 InitializeUserMediaClient();
662 return web_user_media_client_ ? 684 return web_user_media_client_ ?
663 web_user_media_client_->media_stream_dispatcher() : NULL; 685 web_user_media_client_->media_stream_dispatcher() : NULL;
664 } 686 }
665 687
666 bool RenderFrameImpl::Send(IPC::Message* message) { 688 bool RenderFrameImpl::Send(IPC::Message* message) {
667 if (is_detaching_) { 689 if (is_detaching_) {
668 delete message; 690 delete message;
669 return false; 691 return false;
670 } 692 }
671 if (is_swapped_out_ || render_view_->is_swapped_out()) { 693 if (frame_->parent() == NULL &&
694 (is_swapped_out_ || render_view_->is_swapped_out())) {
672 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { 695 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) {
673 delete message; 696 delete message;
674 return false; 697 return false;
675 } 698 }
699
676 // In most cases, send IPCs through the proxy when swapped out. In some 700 // In most cases, send IPCs through the proxy when swapped out. In some
677 // calls the associated RenderViewImpl routing id is used to send 701 // calls the associated RenderViewImpl routing id is used to send
678 // messages, so don't use the proxy. 702 // messages, so don't use the proxy.
679 if (render_frame_proxy_ && message->routing_id() == routing_id_) 703 if (render_frame_proxy_ && message->routing_id() == routing_id_)
680 return render_frame_proxy_->Send(message); 704 return render_frame_proxy_->Send(message);
681 } 705 }
682 706
683 return RenderThread::Get()->Send(message); 707 return RenderThread::Get()->Send(message);
684 } 708 }
685 709
686 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { 710 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
687 GetContentClient()->SetActiveURL(frame_->document().url()); 711 if (!frame_->document().isNull())
dcheng 2014/07/24 18:23:28 I don't understand why we need this check. Under w
kenrb 2014/07/24 21:06:17 Right now we have RenderFrameProxy wrapping a Rend
712 GetContentClient()->SetActiveURL(frame_->document().url());
688 713
689 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); 714 ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
690 RenderFrameObserver* observer; 715 RenderFrameObserver* observer;
691 while ((observer = it.GetNext()) != NULL) { 716 while ((observer = it.GetNext()) != NULL) {
692 if (observer->OnMessageReceived(msg)) 717 if (observer->OnMessageReceived(msg))
693 return true; 718 return true;
694 } 719 }
695 720
696 bool handled = true; 721 bool handled = true;
697 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) 722 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 bool is_reload = RenderViewImpl::IsReload(params); 773 bool is_reload = RenderViewImpl::IsReload(params);
749 WebURLRequest::CachePolicy cache_policy = 774 WebURLRequest::CachePolicy cache_policy =
750 WebURLRequest::UseProtocolCachePolicy; 775 WebURLRequest::UseProtocolCachePolicy;
751 776
752 // If this is a stale back/forward (due to a recent navigation the browser 777 // If this is a stale back/forward (due to a recent navigation the browser
753 // didn't know about), ignore it. 778 // didn't know about), ignore it.
754 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) 779 if (render_view_->IsBackForwardToStaleEntry(params, is_reload))
755 return; 780 return;
756 781
757 // Swap this renderer back in if necessary. 782 // Swap this renderer back in if necessary.
758 if (render_view_->is_swapped_out_) { 783 if (render_view_->is_swapped_out_ &&
784 GetWebFrame() == render_view_->webview()->mainFrame()) {
759 // We marked the view as hidden when swapping the view out, so be sure to 785 // We marked the view as hidden when swapping the view out, so be sure to
760 // reset the visibility state before navigating to the new URL. 786 // reset the visibility state before navigating to the new URL.
761 render_view_->webview()->setVisibilityState( 787 render_view_->webview()->setVisibilityState(
762 render_view_->visibilityState(), false); 788 render_view_->visibilityState(), false);
763 789
764 // If this is an attempt to reload while we are swapped out, we should not 790 // If this is an attempt to reload while we are swapped out, we should not
765 // reload swappedout://, but the previous page, which is stored in 791 // reload swappedout://, but the previous page, which is stored in
766 // params.state. Setting is_reload to false will treat this like a back 792 // params.state. Setting is_reload to false will treat this like a back
767 // navigation to accomplish that. 793 // navigation to accomplish that.
768 is_reload = false; 794 is_reload = false;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 967 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
942 bool proceed = frame_->dispatchBeforeUnloadEvent(); 968 bool proceed = frame_->dispatchBeforeUnloadEvent();
943 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 969 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
944 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, 970 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed,
945 before_unload_start_time, 971 before_unload_start_time,
946 before_unload_end_time)); 972 before_unload_end_time));
947 } 973 }
948 974
949 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { 975 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
950 RenderFrameProxy* proxy = NULL; 976 RenderFrameProxy* proxy = NULL;
977 bool is_site_per_process =
978 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess);
951 979
952 // Only run unload if we're not swapped out yet, but send the ack either way. 980 // Only run unload if we're not swapped out yet, but send the ack either way.
953 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { 981 if (!is_swapped_out_ || !render_view_->is_swapped_out_) {
954 // Swap this RenderFrame out so the frame can navigate to a page rendered by 982 // Swap this RenderFrame out so the frame can navigate to a page rendered by
955 // a different process. This involves running the unload handler and 983 // a different process. This involves running the unload handler and
956 // clearing the page. Once WasSwappedOut is called, we also allow this 984 // clearing the page. Once WasSwappedOut is called, we also allow this
957 // process to exit if there are no other active RenderFrames in it. 985 // process to exit if there are no other active RenderFrames in it.
958 986
959 // Send an UpdateState message before we get swapped out. Create the 987 // Send an UpdateState message before we get swapped out. Create the
960 // RenderFrameProxy as well so its routing id is registered for receiving 988 // RenderFrameProxy as well so its routing id is registered for receiving
961 // IPC messages. 989 // IPC messages.
962 render_view_->SyncNavigationState(); 990 render_view_->SyncNavigationState();
963 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this, 991 proxy = RenderFrameProxy::CreateProxyToReplaceFrame(this,
964 proxy_routing_id); 992 proxy_routing_id);
965 993
966 // Synchronously run the unload handler before sending the ACK. 994 // Synchronously run the unload handler before sending the ACK.
967 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support 995 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
968 // unload on subframes as well. 996 // unload on subframes as well.
969 if (!frame_->parent()) 997 if (!frame_->parent())
970 frame_->dispatchUnloadEvent(); 998 frame_->dispatchUnloadEvent();
971 999
972 // Swap out and stop sending any IPC messages that are not ACKs. 1000 // Swap out and stop sending any IPC messages that are not ACKs.
973 if (!frame_->parent()) 1001 if (!frame_->parent())
974 render_view_->SetSwappedOut(true); 1002 render_view_->SetSwappedOut(true);
975 is_swapped_out_ = true; 1003 is_swapped_out_ = true;
Charlie Reis 2014/07/24 22:36:31 Do we need RenderFrameImpl::is_swapped_out_ anymor
nasko 2014/07/25 07:13:21 I think a TODO to revisit this is good. I recall t
kenrb 2014/07/25 23:42:06 TODO added.
976 1004
977 // Now that we're swapped out and filtering IPC messages, stop loading to 1005 // Now that we're swapped out and filtering IPC messages, stop loading to
978 // ensure that no other in-progress navigation continues. We do this here 1006 // ensure that no other in-progress navigation continues. We do this here
979 // to avoid sending a DidStopLoading message to the browser process. 1007 // to avoid sending a DidStopLoading message to the browser process.
980 // TODO(creis): Should we be stopping all frames here and using 1008 // TODO(creis): Should we be stopping all frames here and using
981 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this 1009 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this
982 // frame? 1010 // frame?
983 if (!frame_->parent()) 1011 if (!frame_->parent())
984 render_view_->OnStop(); 1012 render_view_->OnStop();
985 else 1013 else
986 frame_->stopLoading(); 1014 frame_->stopLoading();
987 1015
988 // Let subframes know that the frame is now rendered remotely, for the 1016 // Let subframes know that the frame is now rendered remotely, for the
989 // purposes of compositing and input events. 1017 // purposes of compositing and input events.
990 if (frame_->parent()) 1018 if (frame_->parent())
991 frame_->setIsRemote(true); 1019 frame_->setIsRemote(true);
992 1020
993 // Replace the page with a blank dummy URL. The unload handler will not be 1021 // Replace the page with a blank dummy URL. The unload handler will not be
994 // run a second time, thanks to a check in FrameLoader::stopLoading. 1022 // run a second time, thanks to a check in FrameLoader::stopLoading.
995 // TODO(creis): Need to add a better way to do this that avoids running the 1023 // TODO(creis): Need to add a better way to do this that avoids running the
996 // beforeunload handler. For now, we just run it a second time silently. 1024 // beforeunload handler. For now, we just run it a second time silently.
997 render_view_->NavigateToSwappedOutURL(frame_); 1025 if (!is_site_per_process || frame_->parent() == NULL)
1026 render_view_->NavigateToSwappedOutURL(frame_);
998 1027
999 // Let WebKit know that this view is hidden so it can drop resources and 1028 // Let WebKit know that this view is hidden so it can drop resources and
1000 // stop compositing. 1029 // stop compositing.
1001 // TODO(creis): Support this for subframes as well. 1030 // TODO(creis): Support this for subframes as well.
1002 if (!frame_->parent()) { 1031 if (!frame_->parent()) {
1003 render_view_->webview()->setVisibilityState( 1032 render_view_->webview()->setVisibilityState(
1004 blink::WebPageVisibilityStateHidden, false); 1033 blink::WebPageVisibilityStateHidden, false);
1005 } 1034 }
1006 } 1035 }
1007 1036
1008 // It is now safe to show modal dialogs again. 1037 // It is now safe to show modal dialogs again.
1009 // TODO(creis): Deal with modal dialogs from subframes. 1038 // TODO(creis): Deal with modal dialogs from subframes.
1010 if (!frame_->parent()) 1039 if (!frame_->parent())
1011 render_view_->suppress_dialogs_until_swap_out_ = false; 1040 render_view_->suppress_dialogs_until_swap_out_ = false;
1012 1041
1013 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1042 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
1014 1043
1015 // Now that all of the cleanup is complete and the browser side is notified, 1044 // Now that all of the cleanup is complete and the browser side is notified,
1016 // start using the RenderFrameProxy, if one is created. 1045 // start using the RenderFrameProxy, if one is created.
1017 if (proxy) 1046 if (proxy) {
1018 set_render_frame_proxy(proxy); 1047 if (frame_->parent()) {
1048 frame_->swap(proxy->web_frame());
1049 if (is_site_per_process) {
Charlie Reis 2014/07/24 22:36:31 When would this be false? We don't swap out subfr
nasko 2014/07/25 07:13:21 It shouldn't be false. We will only have proxies f
kenrb 2014/07/25 23:42:06 I will leave these for Nasko's follow-up CL.
1050 // TODO(nasko): delete the frame here, since we've replaced it with a
Charlie Reis 2014/07/24 22:36:30 Can we do this now? (Is it a leak if we don't?)
nasko 2014/07/25 07:13:21 It likely is a leak. I left this piece for a follo
1051 // proxy.
1052 }
1053 } else {
1054 set_render_frame_proxy(proxy);
1055 }
1056 }
1019 } 1057 }
1020 1058
1021 void RenderFrameImpl::OnContextMenuClosed( 1059 void RenderFrameImpl::OnContextMenuClosed(
1022 const CustomContextMenuContext& custom_context) { 1060 const CustomContextMenuContext& custom_context) {
1023 if (custom_context.request_id) { 1061 if (custom_context.request_id) {
1024 // External request, should be in our map. 1062 // External request, should be in our map.
1025 ContextMenuClient* client = 1063 ContextMenuClient* client =
1026 pending_context_menus_.Lookup(custom_context.request_id); 1064 pending_context_menus_.Lookup(custom_context.request_id);
1027 if (client) { 1065 if (client) {
1028 client->OnMenuClosed(custom_context.request_id); 1066 client->OnMenuClosed(custom_context.request_id);
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 static_cast<int32>(source_line), 1716 static_cast<int32>(source_line),
1679 source_name)); 1717 source_name));
1680 } 1718 }
1681 1719
1682 void RenderFrameImpl::loadURLExternally( 1720 void RenderFrameImpl::loadURLExternally(
1683 blink::WebLocalFrame* frame, 1721 blink::WebLocalFrame* frame,
1684 const blink::WebURLRequest& request, 1722 const blink::WebURLRequest& request,
1685 blink::WebNavigationPolicy policy, 1723 blink::WebNavigationPolicy policy,
1686 const blink::WebString& suggested_name) { 1724 const blink::WebString& suggested_name) {
1687 DCHECK(!frame_ || frame_ == frame); 1725 DCHECK(!frame_ || frame_ == frame);
1726
1688 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 1727 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
1689 if (policy == blink::WebNavigationPolicyDownload) { 1728 if (policy == blink::WebNavigationPolicyDownload) {
1690 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1729 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1691 request.url(), referrer, 1730 request.url(), referrer,
1692 suggested_name, false)); 1731 suggested_name, false));
1693 } else if (policy == blink::WebNavigationPolicyDownloadTo) { 1732 } else if (policy == blink::WebNavigationPolicyDownloadTo) {
1694 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1733 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1695 request.url(), referrer, 1734 request.url(), referrer,
1696 suggested_name, true)); 1735 suggested_name, true));
1697 } else { 1736 } else {
1698 OpenURL(frame, request.url(), referrer, policy); 1737 OpenURL(frame, request.url(), referrer, policy);
1699 } 1738 }
1700 } 1739 }
1701 1740
1702 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( 1741 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
1703 blink::WebLocalFrame* frame, 1742 blink::WebLocalFrame* frame,
1704 blink::WebDataSource::ExtraData* extra_data, 1743 blink::WebDataSource::ExtraData* extra_data,
1705 const blink::WebURLRequest& request, 1744 const blink::WebURLRequest& request,
1706 blink::WebNavigationType type, 1745 blink::WebNavigationType type,
1707 blink::WebNavigationPolicy default_policy, 1746 blink::WebNavigationPolicy default_policy,
1708 bool is_redirect) { 1747 bool is_redirect) {
1709 DCHECK(!frame_ || frame_ == frame); 1748 DCHECK(!frame_ || frame_ == frame);
1710 return DecidePolicyForNavigation( 1749 WebNavigationPolicy value = DecidePolicyForNavigation(
Charlie Reis 2014/07/24 22:36:31 Why is this change needed? (Leftover from an earl
nasko 2014/07/25 07:13:21 Most likely leftover from debugging statements usi
kenrb 2014/07/25 23:42:06 Done.
1711 this, frame, extra_data, request, type, default_policy, is_redirect); 1750 this, frame, extra_data, request, type, default_policy, is_redirect);
1751 return value;
1712 } 1752 }
1713 1753
1714 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( 1754 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame(
1715 blink::WebFrame* frame) { 1755 blink::WebFrame* frame) {
1716 DCHECK(!frame_ || frame_ == frame); 1756 DCHECK(!frame_ || frame_ == frame);
1717 return render_view_->history_controller()->GetItemForNewChildFrame(this); 1757 return render_view_->history_controller()->GetItemForNewChildFrame(this);
1718 } 1758 }
1719 1759
1720 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, 1760 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame,
1721 const blink::WebFormElement& form) { 1761 const blink::WebFormElement& form) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 1846 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
1807 // handle loading of error pages. 1847 // handle loading of error pages.
1808 document_state->navigation_state()->set_transition_type( 1848 document_state->navigation_state()->set_transition_type(
1809 PAGE_TRANSITION_AUTO_SUBFRAME); 1849 PAGE_TRANSITION_AUTO_SUBFRAME);
1810 } 1850 }
1811 1851
1812 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 1852 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
1813 DidStartProvisionalLoad(frame)); 1853 DidStartProvisionalLoad(frame));
1814 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 1854 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
1815 1855
1816 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(routing_id_, 1856 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
1817 ds->request().url())); 1857 routing_id_, ds->request().url()));
Charlie Reis 2014/07/24 22:36:31 This indent looks wrong. I think it was fine befo
kenrb 2014/07/25 23:42:06 Done.
1818 } 1858 }
1819 1859
1820 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 1860 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
1821 blink::WebLocalFrame* frame) { 1861 blink::WebLocalFrame* frame) {
1822 DCHECK(!frame_ || frame_ == frame); 1862 DCHECK(!frame_ || frame_ == frame);
1823 render_view_->history_controller()->RemoveChildrenForRedirect(this); 1863 render_view_->history_controller()->RemoveChildrenForRedirect(this);
1824 if (frame->parent()) 1864 if (frame->parent())
1825 return; 1865 return;
1826 // Received a redirect on the main frame. 1866 // Received a redirect on the main frame.
1827 WebDataSource* data_source = frame->provisionalDataSource(); 1867 WebDataSource* data_source = frame->provisionalDataSource();
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 // The request my be empty during tests. 2416 // The request my be empty during tests.
2377 if (request.url().isEmpty()) 2417 if (request.url().isEmpty())
2378 return; 2418 return;
2379 2419
2380 // Set the first party for cookies url if it has not been set yet (new 2420 // Set the first party for cookies url if it has not been set yet (new
2381 // requests). For redirects, it is updated by WebURLLoaderImpl. 2421 // requests). For redirects, it is updated by WebURLLoaderImpl.
2382 if (request.firstPartyForCookies().isEmpty()) { 2422 if (request.firstPartyForCookies().isEmpty()) {
2383 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) { 2423 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) {
2384 request.setFirstPartyForCookies(request.url()); 2424 request.setFirstPartyForCookies(request.url());
2385 } else { 2425 } else {
2386 request.setFirstPartyForCookies( 2426 // TODO(nasko): When the top-level frame is remote, there is no document.
2387 frame->top()->document().firstPartyForCookies()); 2427 // This is broken and should be fixed to propagate the URL.
Charlie Reis 2014/07/24 22:36:31 URL -> first party
kenrb 2014/07/25 23:42:06 Done.
2428 WebFrame* top = frame->top();
2429 if (top->isWebLocalFrame()) {
2430 request.setFirstPartyForCookies(
2431 frame->top()->document().firstPartyForCookies());
2432 }
2388 } 2433 }
2389 } 2434 }
2390 2435
2391 WebFrame* top_frame = frame->top(); 2436 WebFrame* top_frame = frame->top();
2392 if (!top_frame) 2437 // TODO(nasko): Hack around asking about top-frame data source.
Charlie Reis 2014/07/24 22:36:31 This could lead to some nasty bugs. We should ela
kenrb 2014/07/25 23:42:06 Done.
2438 if (!top_frame || top_frame->isWebRemoteFrame())
2393 top_frame = frame; 2439 top_frame = frame;
2394 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 2440 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2395 WebDataSource* top_data_source = top_frame->dataSource(); 2441 WebDataSource* top_data_source = top_frame->dataSource();
2396 WebDataSource* data_source = 2442 WebDataSource* data_source =
2397 provisional_data_source ? provisional_data_source : top_data_source; 2443 provisional_data_source ? provisional_data_source : top_data_source;
2398 2444
2399 PageTransition transition_type = PAGE_TRANSITION_LINK; 2445 PageTransition transition_type = PAGE_TRANSITION_LINK;
2400 DocumentState* document_state = DocumentState::FromDataSource(data_source); 2446 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2401 DCHECK(document_state); 2447 DCHECK(document_state);
2402 InternalDocumentStateData* internal_data = 2448 InternalDocumentStateData* internal_data =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2479 DocumentState::FromDataSource(frame->provisionalDataSource())); 2525 DocumentState::FromDataSource(frame->provisionalDataSource()));
2480 provider_id = provider->provider_id(); 2526 provider_id = provider->provider_id();
2481 } 2527 }
2482 } else if (frame->dataSource()) { 2528 } else if (frame->dataSource()) {
2483 ServiceWorkerNetworkProvider* provider = 2529 ServiceWorkerNetworkProvider* provider =
2484 ServiceWorkerNetworkProvider::FromDocumentState( 2530 ServiceWorkerNetworkProvider::FromDocumentState(
2485 DocumentState::FromDataSource(frame->dataSource())); 2531 DocumentState::FromDataSource(frame->dataSource()));
2486 provider_id = provider->provider_id(); 2532 provider_id = provider->provider_id();
2487 } 2533 }
2488 2534
2489 int parent_routing_id = frame->parent() ? 2535 WebFrame* parent = frame->parent();
2490 FromWebFrame(frame->parent())->GetRoutingID() : -1; 2536 int parent_routing_id = MSG_ROUTING_NONE;
2537 if (!parent) {
2538 parent_routing_id = -1;
2539 } else if (parent->isWebLocalFrame()) {
2540 parent_routing_id = FromWebFrame(parent)->GetRoutingID();
2541 } else {
2542 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
2543 }
2544
2491 RequestExtraData* extra_data = new RequestExtraData(); 2545 RequestExtraData* extra_data = new RequestExtraData();
2492 extra_data->set_visibility_state(render_view_->visibilityState()); 2546 extra_data->set_visibility_state(render_view_->visibilityState());
2493 extra_data->set_custom_user_agent(custom_user_agent); 2547 extra_data->set_custom_user_agent(custom_user_agent);
2494 extra_data->set_was_after_preconnect_request(was_after_preconnect_request); 2548 extra_data->set_was_after_preconnect_request(was_after_preconnect_request);
2495 extra_data->set_render_frame_id(routing_id_); 2549 extra_data->set_render_frame_id(routing_id_);
2496 extra_data->set_is_main_frame(frame == top_frame); 2550 extra_data->set_is_main_frame(frame == top_frame);
2497 extra_data->set_frame_origin( 2551 extra_data->set_frame_origin(
2498 GURL(frame->document().securityOrigin().toString())); 2552 GURL(frame->document().securityOrigin().toString()));
2499 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); 2553 extra_data->set_parent_is_main_frame(frame->parent() == top_frame);
2500 extra_data->set_parent_render_frame_id(parent_routing_id); 2554 extra_data->set_parent_render_frame_id(parent_routing_id);
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 frame, 3245 frame,
3192 request, 3246 request,
3193 type, 3247 type,
3194 default_policy, 3248 default_policy,
3195 is_redirect)) { 3249 is_redirect)) {
3196 return blink::WebNavigationPolicyIgnore; 3250 return blink::WebNavigationPolicyIgnore;
3197 } 3251 }
3198 #endif 3252 #endif
3199 3253
3200 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 3254 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
3255 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3201 3256
3202 if (is_swapped_out_ || render_view_->is_swapped_out()) { 3257 bool is_subframe = !!frame->parent();
3203 if (request.url() != GURL(kSwappedOutURL)) { 3258
3204 // Targeted links may try to navigate a swapped out frame. Allow the 3259 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) {
3205 // browser process to navigate the tab instead. Note that it is also 3260 // There's no reason to ignore navigations on subframes (why again?)
Charlie Reis 2014/07/24 22:36:31 "(why again?)"... ? Perhaps this is because subfr
nasko 2014/07/25 07:13:21 Yes, subframes don't use swapout logic, so the exi
kenrb 2014/07/25 23:42:06 Done.
3206 // possible for non-targeted navigations (from this view) to arrive 3261 } else {
3207 // here just after we are swapped out. It's ok to send them to the 3262 if (is_swapped_out_ || render_view_->is_swapped_out()) {
3208 // browser, as long as they're for the top level frame. 3263 if (request.url() != GURL(kSwappedOutURL)) {
3209 // TODO(creis): Ensure this supports targeted form submissions when 3264 // Targeted links may try to navigate a swapped out frame. Allow the
3210 // fixing http://crbug.com/101395. 3265 // browser process to navigate the tab instead. Note that it is also
3211 if (frame->parent() == NULL) { 3266 // possible for non-targeted navigations (from this view) to arrive
3212 OpenURL(frame, request.url(), referrer, default_policy); 3267 // here just after we are swapped out. It's ok to send them to the
3213 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 3268 // browser, as long as they're for the top level frame.
3269 // TODO(creis): Ensure this supports targeted form submissions when
3270 // fixing http://crbug.com/101395.
3271 if (frame->parent() == NULL) {
3272 OpenURL(frame, request.url(), referrer, default_policy);
3273 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
3274 }
3275
3276 // We should otherwise ignore in-process iframe navigations, if they
3277 // arrive just after we are swapped out.
3278 return blink::WebNavigationPolicyIgnore;
3214 } 3279 }
3215 3280
3216 // We should otherwise ignore in-process iframe navigations, if they 3281 // Allow kSwappedOutURL to complete.
3217 // arrive just after we are swapped out. 3282 return default_policy;
3218 return blink::WebNavigationPolicyIgnore;
3219 } 3283 }
3220
3221 // Allow kSwappedOutURL to complete.
3222 return default_policy;
3223 } 3284 }
3224 3285
3225 // Webkit is asking whether to navigate to a new URL. 3286 // Webkit is asking whether to navigate to a new URL.
3226 // This is fine normally, except if we're showing UI from one security 3287 // This is fine normally, except if we're showing UI from one security
3227 // context and they're trying to navigate to a different context. 3288 // context and they're trying to navigate to a different context.
3228 const GURL& url = request.url(); 3289 const GURL& url = request.url();
3229 3290
3230 // A content initiated navigation may have originated from a link-click, 3291 // A content initiated navigation may have originated from a link-click,
3231 // script, drag-n-drop operation, etc. 3292 // script, drag-n-drop operation, etc.
3232 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> 3293 bool is_content_initiated = static_cast<DocumentState*>(extraData)->
3233 navigation_state()->is_content_initiated(); 3294 navigation_state()->is_content_initiated();
3234 3295
3235 // Experimental: 3296 // Experimental:
3236 // If --enable-strict-site-isolation or --site-per-process is enabled, send 3297 // If --enable-strict-site-isolation or --site-per-process is enabled, send
3237 // all top-level navigations to the browser to let it swap processes when 3298 // all top-level navigations to the browser to let it swap processes when
3238 // crossing site boundaries. This is currently expected to break some script 3299 // crossing site boundaries. This is currently expected to break some script
3239 // calls and navigations, such as form submissions. 3300 // calls and navigations, such as form submissions.
3240 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3241 bool force_swap_due_to_flag = 3301 bool force_swap_due_to_flag =
3242 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 3302 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
3243 command_line.HasSwitch(switches::kSitePerProcess); 3303 command_line.HasSwitch(switches::kSitePerProcess);
3244 if (force_swap_due_to_flag && 3304 if (force_swap_due_to_flag &&
3245 !frame->parent() && (is_content_initiated || is_redirect)) { 3305 !frame->parent() && (is_content_initiated || is_redirect)) {
3246 WebString origin_str = frame->document().securityOrigin().toString(); 3306 WebString origin_str = frame->document().securityOrigin().toString();
3247 GURL frame_url(origin_str.utf8().data()); 3307 GURL frame_url(origin_str.utf8().data());
3248 // TODO(cevans): revisit whether this site check is still necessary once 3308 // TODO(cevans): revisit whether this site check is still necessary once
3249 // crbug.com/101395 is fixed. 3309 // crbug.com/101395 is fixed.
3250 bool same_domain_or_host = 3310 bool same_domain_or_host =
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
3604 3664
3605 #if defined(ENABLE_BROWSER_CDMS) 3665 #if defined(ENABLE_BROWSER_CDMS)
3606 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3666 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3607 if (!cdm_manager_) 3667 if (!cdm_manager_)
3608 cdm_manager_ = new RendererCdmManager(this); 3668 cdm_manager_ = new RendererCdmManager(this);
3609 return cdm_manager_; 3669 return cdm_manager_;
3610 } 3670 }
3611 #endif // defined(ENABLE_BROWSER_CDMS) 3671 #endif // defined(ENABLE_BROWSER_CDMS)
3612 3672
3613 } // namespace content 3673 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698