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

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

Issue 241223002: Start using RenderFrameProxyHost objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Commits the right URL now. Created 6 years, 6 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_impl.h" 65 #include "content/renderer/media/media_stream_impl.h"
66 #include "content/renderer/media/media_stream_renderer_factory.h" 66 #include "content/renderer/media/media_stream_renderer_factory.h"
67 #include "content/renderer/media/midi_dispatcher.h" 67 #include "content/renderer/media/midi_dispatcher.h"
68 #include "content/renderer/media/render_media_log.h" 68 #include "content/renderer/media/render_media_log.h"
69 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 69 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
70 #include "content/renderer/media/webmediaplayer_impl.h" 70 #include "content/renderer/media/webmediaplayer_impl.h"
71 #include "content/renderer/media/webmediaplayer_ms.h" 71 #include "content/renderer/media/webmediaplayer_ms.h"
72 #include "content/renderer/media/webmediaplayer_params.h" 72 #include "content/renderer/media/webmediaplayer_params.h"
73 #include "content/renderer/notification_provider.h" 73 #include "content/renderer/notification_provider.h"
74 #include "content/renderer/npapi/plugin_channel_host.h" 74 #include "content/renderer/npapi/plugin_channel_host.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 LOG(ERROR) << "RF::CreateFrame: " << routing_id << ", child of: "
372 << parent_routing_id;
373 CHECK_NE(MSG_ROUTING_NONE, parent_routing_id);
374
375 RenderFrameProxy* proxy = RenderFrameProxy::FromRoutingID(parent_routing_id);
376 LOG(ERROR) << "RF::CreateFrame: " << routing_id << " proxy:" << proxy;
377
378 // If the browser is sending a valid parent routing id, it better be created
379 // and registered.
380 CHECK(proxy);
381 blink::WebRemoteFrame* parent_web_frame = proxy->GetWebFrame();
382 LOG(ERROR) << "RF::CreateFrame: " << routing_id
383 << " render_view:" << proxy->render_view() << ", parent_web_frame:" << par ent_web_frame;
384
385 // Create the RenderFrame and WebLocalFrame, linking the two.
386 RenderFrameImpl* render_frame = RenderFrameImpl::Create(
387 proxy->render_view(), routing_id);
388 blink::WebLocalFrame* web_frame = parent_web_frame->createLocalChild("", rende r_frame);
ncarter (slow) 2014/06/25 01:07:56 Is "" the correct value for the name of the frame?
389 render_frame->SetWebFrame(web_frame);
390 render_frame->Initialize();
391
392 LOG(ERROR) << "RF::CreateFrame: " << routing_id
393 << " frame parent:" << render_frame->frame_->parent();
394 }
395
396 // static
369 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) { 397 RenderFrame* RenderFrame::FromWebFrame(blink::WebFrame* web_frame) {
370 return RenderFrameImpl::FromWebFrame(web_frame); 398 return RenderFrameImpl::FromWebFrame(web_frame);
371 } 399 }
372 400
401 // static
373 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) { 402 RenderFrameImpl* RenderFrameImpl::FromWebFrame(blink::WebFrame* web_frame) {
374 FrameMap::iterator iter = g_frame_map.Get().find(web_frame); 403 FrameMap::iterator iter = g_frame_map.Get().find(web_frame);
375 if (iter != g_frame_map.Get().end()) 404 if (iter != g_frame_map.Get().end())
376 return iter->second; 405 return iter->second;
377 return NULL; 406 return NULL;
378 } 407 }
379 408
380 // static 409 // static
381 void RenderFrameImpl::InstallCreateHook( 410 void RenderFrameImpl::InstallCreateHook(
382 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) { 411 RenderFrameImpl* (*create_render_frame_impl)(RenderViewImpl*, int32)) {
(...skipping 18 matching lines...) Expand all
401 midi_dispatcher_(NULL), 430 midi_dispatcher_(NULL),
402 #if defined(OS_ANDROID) 431 #if defined(OS_ANDROID)
403 media_player_manager_(NULL), 432 media_player_manager_(NULL),
404 #endif 433 #endif
405 #if defined(ENABLE_BROWSER_CDMS) 434 #if defined(ENABLE_BROWSER_CDMS)
406 cdm_manager_(NULL), 435 cdm_manager_(NULL),
407 #endif 436 #endif
408 geolocation_dispatcher_(NULL), 437 geolocation_dispatcher_(NULL),
409 screen_orientation_dispatcher_(NULL), 438 screen_orientation_dispatcher_(NULL),
410 weak_factory_(this) { 439 weak_factory_(this) {
440 LOG(ERROR) << "RF[" << this << "]::RF:"
441 << " routing_id:" << routing_id;
442
411 RenderThread::Get()->AddRoute(routing_id_, this); 443 RenderThread::Get()->AddRoute(routing_id_, this);
412 444
413 std::pair<RoutingIDFrameMap::iterator, bool> result = 445 std::pair<RoutingIDFrameMap::iterator, bool> result =
414 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); 446 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this));
415 CHECK(result.second) << "Inserting a duplicate item."; 447 CHECK(result.second) << "Inserting a duplicate item.";
416 448
417 render_view_->RegisterRenderFrame(this); 449 render_view_->RegisterRenderFrame(this);
418 450
419 #if defined(OS_ANDROID) 451 #if defined(OS_ANDROID)
420 new JavaBridgeDispatcher(this); 452 new JavaBridgeDispatcher(this);
421 #endif 453 #endif
422 454
423 #if defined(ENABLE_NOTIFICATIONS) 455 #if defined(ENABLE_NOTIFICATIONS)
424 notification_provider_ = new NotificationProvider(this); 456 notification_provider_ = new NotificationProvider(this);
425 #endif 457 #endif
426 } 458 }
427 459
428 RenderFrameImpl::~RenderFrameImpl() { 460 RenderFrameImpl::~RenderFrameImpl() {
429 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone()); 461 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, RenderFrameGone());
430 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct()); 462 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnDestruct());
431 463
432 #if defined(OS_ANDROID) && defined(VIDEO_HOLE) 464 #if defined(OS_ANDROID) && defined(VIDEO_HOLE)
433 if (media_player_manager_) 465 if (media_player_manager_)
434 render_view_->UnregisterVideoHoleFrame(this); 466 render_view_->UnregisterVideoHoleFrame(this);
435 #endif 467 #endif
436 468
469 LOG(ERROR) << "RF[" << this << "]::~RF";
470
437 render_view_->UnregisterRenderFrame(this); 471 render_view_->UnregisterRenderFrame(this);
438 g_routing_id_frame_map.Get().erase(routing_id_); 472 g_routing_id_frame_map.Get().erase(routing_id_);
439 RenderThread::Get()->RemoveRoute(routing_id_); 473 RenderThread::Get()->RemoveRoute(routing_id_);
440 } 474 }
441 475
442 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) { 476 void RenderFrameImpl::SetWebFrame(blink::WebLocalFrame* web_frame) {
443 DCHECK(!frame_); 477 DCHECK(!frame_);
444 478
479 LOG(ERROR) << "RF[" << this << "]::SetWebFrame: map.insert(" << web_frame << " , " << this << ")";
445 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert( 480 std::pair<FrameMap::iterator, bool> result = g_frame_map.Get().insert(
446 std::make_pair(web_frame, this)); 481 std::make_pair(web_frame, this));
447 CHECK(result.second) << "Inserting a duplicate item."; 482 CHECK(result.second) << "Inserting a duplicate item.";
448 483
449 frame_ = web_frame; 484 frame_ = web_frame;
450 } 485 }
451 486
452 void RenderFrameImpl::Initialize() { 487 void RenderFrameImpl::Initialize() {
453 #if defined(ENABLE_PLUGINS) 488 #if defined(ENABLE_PLUGINS)
454 new PepperBrowserConnection(this); 489 new PepperBrowserConnection(this);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 pepper_composition_text_.clear(); 681 pepper_composition_text_.clear();
647 } 682 }
648 683
649 #endif // ENABLE_PLUGINS 684 #endif // ENABLE_PLUGINS
650 685
651 bool RenderFrameImpl::Send(IPC::Message* message) { 686 bool RenderFrameImpl::Send(IPC::Message* message) {
652 if (is_detaching_) { 687 if (is_detaching_) {
653 delete message; 688 delete message;
654 return false; 689 return false;
655 } 690 }
656 if (is_swapped_out_ || render_view_->is_swapped_out()) { 691 if (frame_->parent() == NULL &&
692 (is_swapped_out_ || render_view_->is_swapped_out())) {
693 LOG(ERROR) << "RF[" << this << "]::Send:"
694 << " main frame in swapped out state";
657 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { 695 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) {
658 delete message; 696 delete message;
659 return false; 697 return false;
660 } 698 }
699
661 // 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
662 // calls the associated RenderViewImpl routing id is used to send 701 // calls the associated RenderViewImpl routing id is used to send
663 // messages, so don't use the proxy. 702 // messages, so don't use the proxy.
664 if (render_frame_proxy_ && message->routing_id() == routing_id_) 703 if (render_frame_proxy_ && message->routing_id() == routing_id_)
665 return render_frame_proxy_->Send(message); 704 return render_frame_proxy_->Send(message);
666 } 705 }
667 706
668 return RenderThread::Get()->Send(message); 707 return RenderThread::Get()->Send(message);
669 } 708 }
670 709
671 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { 710 bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) {
672 GetContentClient()->SetActiveURL(frame_->document().url()); 711 //GetContentClient()->SetActiveURL(frame_->document().url());
ncarter (slow) 2014/06/25 01:07:56 frame doesn't always have a document. If the frame
673 712
674 ObserverListBase<RenderFrameObserver>::Iterator it(observers_); 713 ObserverListBase<RenderFrameObserver>::Iterator it(observers_);
675 RenderFrameObserver* observer; 714 RenderFrameObserver* observer;
676 while ((observer = it.GetNext()) != NULL) { 715 while ((observer = it.GetNext()) != NULL) {
677 if (observer->OnMessageReceived(msg)) 716 if (observer->OnMessageReceived(msg))
678 return true; 717 return true;
679 } 718 }
680 719
681 bool handled = true; 720 bool handled = true;
682 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) 721 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 OnAddStyleSheetByURL) 753 OnAddStyleSheetByURL)
715 #if defined(OS_MACOSX) 754 #if defined(OS_MACOSX)
716 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) 755 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard)
717 #endif 756 #endif
718 IPC_END_MESSAGE_MAP() 757 IPC_END_MESSAGE_MAP()
719 758
720 return handled; 759 return handled;
721 } 760 }
722 761
723 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) { 762 void RenderFrameImpl::OnNavigate(const FrameMsg_Navigate_Params& params) {
763 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ":" << param s.url;
724 MaybeHandleDebugURL(params.url); 764 MaybeHandleDebugURL(params.url);
725 if (!render_view_->webview()) 765 if (!render_view_->webview()) {
766 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ": no webv iew()";
726 return; 767 return;
768 }
727 769
728 FOR_EACH_OBSERVER( 770 FOR_EACH_OBSERVER(
729 RenderViewObserver, render_view_->observers_, Navigate(params.url)); 771 RenderViewObserver, render_view_->observers_, Navigate(params.url));
730 772
731 bool is_reload = RenderViewImpl::IsReload(params); 773 bool is_reload = RenderViewImpl::IsReload(params);
732 WebURLRequest::CachePolicy cache_policy = 774 WebURLRequest::CachePolicy cache_policy =
733 WebURLRequest::UseProtocolCachePolicy; 775 WebURLRequest::UseProtocolCachePolicy;
734 776
735 // 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
736 // didn't know about), ignore it. 778 // didn't know about), ignore it.
737 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) 779 if (render_view_->IsBackForwardToStaleEntry(params, is_reload)) {
780 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ": stale e ntry";
738 return; 781 return;
782 }
739 783
740 // Swap this renderer back in if necessary. 784 // Swap this renderer back in if necessary.
741 if (render_view_->is_swapped_out_) { 785 if (render_view_->is_swapped_out_ &&
786 GetWebFrame() == render_view_->webview()->mainFrame()) {
ncarter (slow) 2014/06/25 01:07:56 Could the second half of this clause be written as
787 LOG(ERROR) << "RF[" << this << "]::OnNavigate:"
788 << " RV is swapped out, frame is the top-level, so unswap";
742 // We marked the view as hidden when swapping the view out, so be sure to 789 // We marked the view as hidden when swapping the view out, so be sure to
743 // reset the visibility state before navigating to the new URL. 790 // reset the visibility state before navigating to the new URL.
744 render_view_->webview()->setVisibilityState( 791 render_view_->webview()->setVisibilityState(
745 render_view_->visibilityState(), false); 792 render_view_->visibilityState(), false);
746 793
747 // If this is an attempt to reload while we are swapped out, we should not 794 // If this is an attempt to reload while we are swapped out, we should not
748 // reload swappedout://, but the previous page, which is stored in 795 // reload swappedout://, but the previous page, which is stored in
749 // params.state. Setting is_reload to false will treat this like a back 796 // params.state. Setting is_reload to false will treat this like a back
750 // navigation to accomplish that. 797 // navigation to accomplish that.
751 is_reload = false; 798 is_reload = false;
752 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 799 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
753 800
754 // We refresh timezone when a view is swapped in since timezone 801 // We refresh timezone when a view is swapped in since timezone
755 // can get out of sync when the system timezone is updated while 802 // can get out of sync when the system timezone is updated while
756 // the view is swapped out. 803 // the view is swapped out.
757 RenderThreadImpl::NotifyTimezoneChange(); 804 RenderThreadImpl::NotifyTimezoneChange();
758 805
759 render_view_->SetSwappedOut(false); 806 render_view_->SetSwappedOut(false);
760 is_swapped_out_ = false; 807 is_swapped_out_ = false;
808 } else {
809 LOG(ERROR) << "RF[" << this << "]::OnNavigate:"
810 << " RV is swapped out, but frame isn't the top-level one";
761 } 811 }
762 812
763 if (params.should_clear_history_list) { 813 if (params.should_clear_history_list) {
764 CHECK_EQ(params.pending_history_list_offset, -1); 814 CHECK_EQ(params.pending_history_list_offset, -1);
765 CHECK_EQ(params.current_history_list_offset, -1); 815 CHECK_EQ(params.current_history_list_offset, -1);
766 CHECK_EQ(params.current_history_list_length, 0); 816 CHECK_EQ(params.current_history_list_length, 0);
767 } 817 }
768 render_view_->history_list_offset_ = params.current_history_list_offset; 818 render_view_->history_list_offset_ = params.current_history_list_offset;
769 render_view_->history_list_length_ = params.current_history_list_length; 819 render_view_->history_list_length_ = params.current_history_list_length;
770 if (render_view_->history_list_length_ >= 0) { 820 if (render_view_->history_list_length_ >= 0) {
(...skipping 24 matching lines...) Expand all
795 } 845 }
796 846
797 render_view_->pending_navigation_params_.reset( 847 render_view_->pending_navigation_params_.reset(
798 new FrameMsg_Navigate_Params(params)); 848 new FrameMsg_Navigate_Params(params));
799 849
800 // If we are reloading, then WebKit will use the history state of the current 850 // If we are reloading, then WebKit will use the history state of the current
801 // page, so we should just ignore any given history state. Otherwise, if we 851 // page, so we should just ignore any given history state. Otherwise, if we
802 // have history state, then we need to navigate to it, which corresponds to a 852 // have history state, then we need to navigate to it, which corresponds to a
803 // back/forward navigation event. 853 // back/forward navigation event.
804 if (is_reload) { 854 if (is_reload) {
855 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ": reload" ;
805 bool reload_original_url = 856 bool reload_original_url =
806 (params.navigation_type == 857 (params.navigation_type ==
807 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 858 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
808 bool ignore_cache = (params.navigation_type == 859 bool ignore_cache = (params.navigation_type ==
809 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 860 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
810 861
811 if (reload_original_url) 862 if (reload_original_url)
812 frame->reloadWithOverrideURL(params.url, true); 863 frame->reloadWithOverrideURL(params.url, true);
813 else 864 else
814 frame->reload(ignore_cache); 865 frame->reload(ignore_cache);
815 } else if (params.page_state.IsValid()) { 866 } else if (params.page_state.IsValid()) {
867 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ": valid p age state";
816 // We must know the page ID of the page we are navigating back to. 868 // We must know the page ID of the page we are navigating back to.
817 DCHECK_NE(params.page_id, -1); 869 DCHECK_NE(params.page_id, -1);
818 scoped_ptr<HistoryEntry> entry = 870 scoped_ptr<HistoryEntry> entry =
819 PageStateToHistoryEntry(params.page_state); 871 PageStateToHistoryEntry(params.page_state);
820 if (entry) { 872 if (entry) {
821 // Ensure we didn't save the swapped out URL in UpdateState, since the 873 // Ensure we didn't save the swapped out URL in UpdateState, since the
822 // browser should never be telling us to navigate to swappedout://. 874 // browser should never be telling us to navigate to swappedout://.
823 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 875 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
824 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); 876 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy);
825 } 877 }
826 } else if (!params.base_url_for_data_url.is_empty()) { 878 } else if (!params.base_url_for_data_url.is_empty()) {
879 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ": data UR L";
827 // A loadData request with a specified base URL. 880 // A loadData request with a specified base URL.
828 std::string mime_type, charset, data; 881 std::string mime_type, charset, data;
829 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 882 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) {
830 frame->loadData( 883 frame->loadData(
831 WebData(data.c_str(), data.length()), 884 WebData(data.c_str(), data.length()),
832 WebString::fromUTF8(mime_type), 885 WebString::fromUTF8(mime_type),
833 WebString::fromUTF8(charset), 886 WebString::fromUTF8(charset),
834 params.base_url_for_data_url, 887 params.base_url_for_data_url,
835 params.history_url_for_data_url, 888 params.history_url_for_data_url,
836 false); 889 false);
837 } else { 890 } else {
838 CHECK(false) << 891 CHECK(false) <<
839 "Invalid URL passed: " << params.url.possibly_invalid_spec(); 892 "Invalid URL passed: " << params.url.possibly_invalid_spec();
840 } 893 }
841 } else { 894 } else {
842 // Navigate to the given URL. 895 // Navigate to the given URL.
843 WebURLRequest request(params.url); 896 WebURLRequest request(params.url);
897 LOG(ERROR) << "RF[" << this << "]::OnNavigate:" << routing_id_ << ": navigat e to URL";
844 898
845 // A session history navigation should have been accompanied by state. 899 // A session history navigation should have been accompanied by state.
846 CHECK_EQ(params.page_id, -1); 900 CHECK_EQ(params.page_id, -1);
847 901
848 if (frame->isViewSourceModeEnabled()) 902 if (frame->isViewSourceModeEnabled())
849 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); 903 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad);
850 904
851 if (params.referrer.url.is_valid()) { 905 if (params.referrer.url.is_valid()) {
852 WebString referrer = WebSecurityPolicy::generateReferrerHeader( 906 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
853 params.referrer.policy, 907 params.referrer.policy,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); 967 base::TimeTicks before_unload_start_time = base::TimeTicks::Now();
914 bool proceed = frame_->dispatchBeforeUnloadEvent(); 968 bool proceed = frame_->dispatchBeforeUnloadEvent();
915 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); 969 base::TimeTicks before_unload_end_time = base::TimeTicks::Now();
916 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, 970 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed,
917 before_unload_start_time, 971 before_unload_start_time,
918 before_unload_end_time)); 972 before_unload_end_time));
919 } 973 }
920 974
921 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) { 975 void RenderFrameImpl::OnSwapOut(int proxy_routing_id) {
922 RenderFrameProxy* proxy = NULL; 976 RenderFrameProxy* proxy = NULL;
977 bool is_site_per_process =
978 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess);
923 979
924 // 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.
925 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { 981 if (!is_swapped_out_ || !render_view_->is_swapped_out_) {
926 // 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
927 // a different process. This involves running the unload handler and 983 // a different process. This involves running the unload handler and
928 // clearing the page. Once WasSwappedOut is called, we also allow this 984 // clearing the page. Once WasSwappedOut is called, we also allow this
929 // 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.
930 986
931 // Send an UpdateState message before we get swapped out. Create the 987 // Send an UpdateState message before we get swapped out. Create the
932 // RenderFrameProxy as well so its routing id is registered for receiving 988 // RenderFrameProxy as well so its routing id is registered for receiving
933 // IPC messages. 989 // IPC messages.
934 render_view_->SyncNavigationState(); 990 render_view_->SyncNavigationState();
935 proxy = RenderFrameProxy::CreateFrameProxy(proxy_routing_id, routing_id_); 991 proxy = RenderFrameProxy::CreateProxyForFrame(
992 proxy_routing_id, routing_id_);
936 993
937 // Synchronously run the unload handler before sending the ACK. 994 // Synchronously run the unload handler before sending the ACK.
938 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support 995 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support
939 // unload on subframes as well. 996 // unload on subframes as well.
940 if (!frame_->parent()) 997 if (!frame_->parent())
941 frame_->dispatchUnloadEvent(); 998 frame_->dispatchUnloadEvent();
942 999
943 // 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.
944 if (!frame_->parent()) 1001 if (!frame_->parent())
945 render_view_->SetSwappedOut(true); 1002 render_view_->SetSwappedOut(true);
(...skipping 12 matching lines...) Expand all
958 1015
959 // 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
960 // purposes of compositing and input events. 1017 // purposes of compositing and input events.
961 if (frame_->parent()) 1018 if (frame_->parent())
962 frame_->setIsRemote(true); 1019 frame_->setIsRemote(true);
963 1020
964 // 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
965 // run a second time, thanks to a check in FrameLoader::stopLoading. 1022 // run a second time, thanks to a check in FrameLoader::stopLoading.
966 // 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
967 // 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.
968 render_view_->NavigateToSwappedOutURL(frame_); 1025 if (!is_site_per_process || frame_->parent() == NULL) {
1026 LOG(ERROR) << "RF[" << this << "]::OnSwapOut:"
1027 << " navigate to swappedout://";
1028 render_view_->NavigateToSwappedOutURL(frame_);
1029 }
969 1030
970 // Let WebKit know that this view is hidden so it can drop resources and 1031 // Let WebKit know that this view is hidden so it can drop resources and
971 // stop compositing. 1032 // stop compositing.
972 // TODO(creis): Support this for subframes as well. 1033 // TODO(creis): Support this for subframes as well.
973 if (!frame_->parent()) { 1034 if (!frame_->parent()) {
974 render_view_->webview()->setVisibilityState( 1035 render_view_->webview()->setVisibilityState(
975 blink::WebPageVisibilityStateHidden, false); 1036 blink::WebPageVisibilityStateHidden, false);
976 } 1037 }
977 } 1038 }
978 1039
979 // It is now safe to show modal dialogs again. 1040 // It is now safe to show modal dialogs again.
980 // TODO(creis): Deal with modal dialogs from subframes. 1041 // TODO(creis): Deal with modal dialogs from subframes.
981 if (!frame_->parent()) 1042 if (!frame_->parent())
982 render_view_->suppress_dialogs_until_swap_out_ = false; 1043 render_view_->suppress_dialogs_until_swap_out_ = false;
983 1044
984 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); 1045 Send(new FrameHostMsg_SwapOut_ACK(routing_id_));
985 1046
986 // Now that all of the cleanup is complete and the browser side is notified, 1047 // Now that all of the cleanup is complete and the browser side is notified,
987 // start using the RenderFrameProxy, if one is created. 1048 // start using the RenderFrameProxy, if one is created.
988 if (proxy) 1049 if (proxy) {
989 set_render_frame_proxy(proxy); 1050 if (frame_->parent()) {
1051 LOG(ERROR) << "RF[" << this << "]::OnSwapOut:"
1052 << " will swap frames";
1053 frame_->swap(proxy->GetWebFrame());
1054 if (is_site_per_process) {
ncarter (slow) 2014/06/25 01:07:56 This if check might be redundant -- if we're getti
1055 // TODO(nasko): delete the frame here, since we've replaced it with a
1056 // proxy.
ncarter (slow) 2014/06/25 01:07:56 Maybe use DeleteSoon to accomplish this TODO here.
1057 }
1058 } else {
1059 LOG(ERROR) << "RF[" << this << "]::OnSwapOut:"
1060 << " parent, so will reuse RF";
1061 set_render_frame_proxy(proxy);
1062 }
1063 }
990 } 1064 }
991 1065
992 void RenderFrameImpl::OnContextMenuClosed( 1066 void RenderFrameImpl::OnContextMenuClosed(
993 const CustomContextMenuContext& custom_context) { 1067 const CustomContextMenuContext& custom_context) {
994 if (custom_context.request_id) { 1068 if (custom_context.request_id) {
995 // External request, should be in our map. 1069 // External request, should be in our map.
996 ContextMenuClient* client = 1070 ContextMenuClient* client =
997 pending_context_menus_.Lookup(custom_context.request_id); 1071 pending_context_menus_.Lookup(custom_context.request_id);
998 if (client) { 1072 if (client) {
999 client->OnMenuClosed(custom_context.request_id); 1073 client->OnMenuClosed(custom_context.request_id);
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 1593 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
1520 FrameDetached(frame)); 1594 FrameDetached(frame));
1521 1595
1522 // We need to clean up subframes by removing them from the map and deleting 1596 // We need to clean up subframes by removing them from the map and deleting
1523 // the RenderFrameImpl. In contrast, the main frame is owned by its 1597 // the RenderFrameImpl. In contrast, the main frame is owned by its
1524 // containing RenderViewHost (so that they have the same lifetime), so only 1598 // containing RenderViewHost (so that they have the same lifetime), so only
1525 // removal from the map is needed and no deletion. 1599 // removal from the map is needed and no deletion.
1526 FrameMap::iterator it = g_frame_map.Get().find(frame); 1600 FrameMap::iterator it = g_frame_map.Get().find(frame);
1527 CHECK(it != g_frame_map.Get().end()); 1601 CHECK(it != g_frame_map.Get().end());
1528 CHECK_EQ(it->second, this); 1602 CHECK_EQ(it->second, this);
1603 LOG(ERROR) << "RF[" << this << "]::map.erase:" << frame;
1529 g_frame_map.Get().erase(it); 1604 g_frame_map.Get().erase(it);
1530 1605
1531 if (is_subframe) 1606 if (is_subframe)
1532 frame->parent()->removeChild(frame); 1607 frame->parent()->removeChild(frame);
1533 1608
1534 // |frame| is invalid after here. 1609 // |frame| is invalid after here.
1535 frame->close(); 1610 frame->close();
1536 1611
1537 if (is_subframe) { 1612 if (is_subframe) {
1538 delete this; 1613 delete this;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 static_cast<int32>(source_line), 1693 static_cast<int32>(source_line),
1619 source_name)); 1694 source_name));
1620 } 1695 }
1621 1696
1622 void RenderFrameImpl::loadURLExternally( 1697 void RenderFrameImpl::loadURLExternally(
1623 blink::WebLocalFrame* frame, 1698 blink::WebLocalFrame* frame,
1624 const blink::WebURLRequest& request, 1699 const blink::WebURLRequest& request,
1625 blink::WebNavigationPolicy policy, 1700 blink::WebNavigationPolicy policy,
1626 const blink::WebString& suggested_name) { 1701 const blink::WebString& suggested_name) {
1627 DCHECK(!frame_ || frame_ == frame); 1702 DCHECK(!frame_ || frame_ == frame);
1703 LOG(ERROR) << "RF[" << this << "]::loadURLExternally:"
1704 << " url:" << request.url()
1705 << " policy:" << policy;
1706
1628 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 1707 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
1629 if (policy == blink::WebNavigationPolicyDownload) { 1708 if (policy == blink::WebNavigationPolicyDownload) {
1630 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1709 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1631 request.url(), referrer, 1710 request.url(), referrer,
1632 suggested_name, false)); 1711 suggested_name, false));
1633 } else if (policy == blink::WebNavigationPolicyDownloadTo) { 1712 } else if (policy == blink::WebNavigationPolicyDownloadTo) {
1634 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(), 1713 render_view_->Send(new ViewHostMsg_DownloadUrl(render_view_->GetRoutingID(),
1635 request.url(), referrer, 1714 request.url(), referrer,
1636 suggested_name, true)); 1715 suggested_name, true));
1637 } else { 1716 } else {
1638 OpenURL(frame, request.url(), referrer, policy); 1717 OpenURL(frame, request.url(), referrer, policy);
1639 } 1718 }
1640 } 1719 }
1641 1720
1642 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation( 1721 blink::WebNavigationPolicy RenderFrameImpl::decidePolicyForNavigation(
1643 blink::WebLocalFrame* frame, 1722 blink::WebLocalFrame* frame,
1644 blink::WebDataSource::ExtraData* extra_data, 1723 blink::WebDataSource::ExtraData* extra_data,
1645 const blink::WebURLRequest& request, 1724 const blink::WebURLRequest& request,
1646 blink::WebNavigationType type, 1725 blink::WebNavigationType type,
1647 blink::WebNavigationPolicy default_policy, 1726 blink::WebNavigationPolicy default_policy,
1648 bool is_redirect) { 1727 bool is_redirect) {
1649 DCHECK(!frame_ || frame_ == frame); 1728 DCHECK(!frame_ || frame_ == frame);
1650 return DecidePolicyForNavigation( 1729 WebNavigationPolicy value = DecidePolicyForNavigation(
1651 this, frame, extra_data, request, type, default_policy, is_redirect); 1730 this, frame, extra_data, request, type, default_policy, is_redirect);
1731 LOG(ERROR) << "RF[" << this << "]::decidePolicyForNavigation:"
1732 << " returning:" << value;
1733 return value;
1652 } 1734 }
1653 1735
1654 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame( 1736 blink::WebHistoryItem RenderFrameImpl::historyItemForNewChildFrame(
1655 blink::WebFrame* frame) { 1737 blink::WebFrame* frame) {
1656 DCHECK(!frame_ || frame_ == frame); 1738 DCHECK(!frame_ || frame_ == frame);
1657 return render_view_->history_controller()->GetItemForNewChildFrame(this); 1739 return render_view_->history_controller()->GetItemForNewChildFrame(this);
1658 } 1740 }
1659 1741
1660 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame, 1742 void RenderFrameImpl::willSendSubmitEvent(blink::WebLocalFrame* frame,
1661 const blink::WebFormElement& form) { 1743 const blink::WebFormElement& form) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 DCHECK(!frame_ || frame_ == frame); 1795 DCHECK(!frame_ || frame_ == frame);
1714 WebDataSource* ds = frame->provisionalDataSource(); 1796 WebDataSource* ds = frame->provisionalDataSource();
1715 1797
1716 // In fast/loader/stop-provisional-loads.html, we abort the load before this 1798 // In fast/loader/stop-provisional-loads.html, we abort the load before this
1717 // callback is invoked. 1799 // callback is invoked.
1718 if (!ds) 1800 if (!ds)
1719 return; 1801 return;
1720 1802
1721 DocumentState* document_state = DocumentState::FromDataSource(ds); 1803 DocumentState* document_state = DocumentState::FromDataSource(ds);
1722 1804
1805 LOG(ERROR) << "RF[" << this << "]::didStartProvisionalLoad: "
1806 << " frame:" << frame
1807 << " routing:" << routing_id_
1808 << " url:" << ds->request().url();
1723 // We should only navigate to swappedout:// when is_swapped_out_ is true. 1809 // We should only navigate to swappedout:// when is_swapped_out_ is true.
1724 CHECK((ds->request().url() != GURL(kSwappedOutURL)) || 1810 CHECK((ds->request().url() != GURL(kSwappedOutURL)) ||
1725 is_swapped_out_ || 1811 is_swapped_out_ ||
1726 render_view_->is_swapped_out()) << 1812 render_view_->is_swapped_out()) <<
1727 "Heard swappedout:// when not swapped out."; 1813 "Heard swappedout:// when not swapped out.";
1728 1814
1729 // Update the request time if WebKit has better knowledge of it. 1815 // Update the request time if WebKit has better knowledge of it.
1730 if (document_state->request_time().is_null()) { 1816 if (document_state->request_time().is_null()) {
1731 double event_time = ds->triggeringEventTime(); 1817 double event_time = ds->triggeringEventTime();
1732 if (event_time != 0.0) 1818 if (event_time != 0.0)
(...skipping 13 matching lines...) Expand all
1746 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we 1832 // marked with AUTO_SUBFRAME. See also didFailProvisionalLoad for how we
1747 // handle loading of error pages. 1833 // handle loading of error pages.
1748 document_state->navigation_state()->set_transition_type( 1834 document_state->navigation_state()->set_transition_type(
1749 PAGE_TRANSITION_AUTO_SUBFRAME); 1835 PAGE_TRANSITION_AUTO_SUBFRAME);
1750 } 1836 }
1751 1837
1752 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), 1838 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(),
1753 DidStartProvisionalLoad(frame)); 1839 DidStartProvisionalLoad(frame));
1754 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad()); 1840 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidStartProvisionalLoad());
1755 1841
1756 int parent_routing_id = frame->parent() ? 1842 int parent_routing_id = -1;
1757 FromWebFrame(frame->parent())->GetRoutingID() : -1; 1843 if (frame->parent()) {
1844 if (frame->parent()->isWebLocalFrame()) {
ncarter (slow) 2014/06/25 01:07:56 Might be worth extracting this logic into a utilit
1845 LOG(ERROR) << "RF[" << this << "]::didStartProvisionalLoad:"
1846 << " local frame: FromWebFrame(parent): " << FromWebFrame(frame->parent( ));
1847 parent_routing_id = FromWebFrame(frame->parent())->GetRoutingID();
1848 } else {
1849 LOG(ERROR) << "RF[" << this << "]::didStartProvisionalLoad:"
1850 << " remote frame: FromWebFrame(parent): " <<
1851 RenderFrameProxy::FromWebFrame(frame->parent());
1852 parent_routing_id =
1853 RenderFrameProxy::FromWebFrame(frame->parent())->routing_id();
1854 }
1855 }
1758 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( 1856 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame(
1759 routing_id_, parent_routing_id, ds->request().url())); 1857 routing_id_, parent_routing_id, ds->request().url()));
1760 } 1858 }
1761 1859
1762 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad( 1860 void RenderFrameImpl::didReceiveServerRedirectForProvisionalLoad(
1763 blink::WebLocalFrame* frame) { 1861 blink::WebLocalFrame* frame) {
1764 DCHECK(!frame_ || frame_ == frame); 1862 DCHECK(!frame_ || frame_ == frame);
1765 render_view_->history_controller()->RemoveChildrenForRedirect(this); 1863 render_view_->history_controller()->RemoveChildrenForRedirect(this);
1766 if (frame->parent()) 1864 if (frame->parent())
1767 return; 1865 return;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 DCHECK(!frame_ || frame_ == frame); 1992 DCHECK(!frame_ || frame_ == frame);
1895 DocumentState* document_state = 1993 DocumentState* document_state =
1896 DocumentState::FromDataSource(frame->dataSource()); 1994 DocumentState::FromDataSource(frame->dataSource());
1897 NavigationState* navigation_state = document_state->navigation_state(); 1995 NavigationState* navigation_state = document_state->navigation_state();
1898 1996
1899 // When we perform a new navigation, we need to update the last committed 1997 // When we perform a new navigation, we need to update the last committed
1900 // session history entry with state for the page we are leaving. Do this 1998 // session history entry with state for the page we are leaving. Do this
1901 // before updating the HistoryController state. 1999 // before updating the HistoryController state.
1902 render_view_->UpdateSessionHistory(frame); 2000 render_view_->UpdateSessionHistory(frame);
1903 2001
2002 LOG(ERROR) << "RF[" << this << "]::didCommitProvisionalLoad:"
2003 << " frame:" << frame
2004 << " commit:" << commit_type
2005 << " url:" << GetLoadingUrl();
2006
1904 render_view_->history_controller()->UpdateForCommit(this, item, commit_type, 2007 render_view_->history_controller()->UpdateForCommit(this, item, commit_type,
1905 navigation_state->was_within_same_page()); 2008 navigation_state->was_within_same_page());
1906 2009
1907 InternalDocumentStateData* internal_data = 2010 InternalDocumentStateData* internal_data =
1908 InternalDocumentStateData::FromDocumentState(document_state); 2011 InternalDocumentStateData::FromDocumentState(document_state);
1909 2012
1910 if (document_state->commit_load_time().is_null()) 2013 if (document_state->commit_load_time().is_null())
1911 document_state->set_commit_load_time(Time::Now()); 2014 document_state->set_commit_load_time(Time::Now());
1912 2015
1913 if (internal_data->must_reset_scroll_and_scale_state()) { 2016 if (internal_data->must_reset_scroll_and_scale_state()) {
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 // The request my be empty during tests. 2440 // The request my be empty during tests.
2338 if (request.url().isEmpty()) 2441 if (request.url().isEmpty())
2339 return; 2442 return;
2340 2443
2341 // Set the first party for cookies url if it has not been set yet (new 2444 // Set the first party for cookies url if it has not been set yet (new
2342 // requests). For redirects, it is updated by WebURLLoaderImpl. 2445 // requests). For redirects, it is updated by WebURLLoaderImpl.
2343 if (request.firstPartyForCookies().isEmpty()) { 2446 if (request.firstPartyForCookies().isEmpty()) {
2344 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) { 2447 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame) {
2345 request.setFirstPartyForCookies(request.url()); 2448 request.setFirstPartyForCookies(request.url());
2346 } else { 2449 } else {
2347 request.setFirstPartyForCookies( 2450 // TODO(nasko): When the top-level frame is remote, there is no document.
2348 frame->top()->document().firstPartyForCookies()); 2451 // This is broken and should be fixed to propagate the URL.
2452 WebFrame* top = frame->top();
2453 if (top->isWebLocalFrame()) {
2454 request.setFirstPartyForCookies(
2455 frame->top()->document().firstPartyForCookies());
ncarter (slow) 2014/06/25 01:07:56 Just "top". It's cleaner.
2456 }
2349 } 2457 }
2350 } 2458 }
2351 2459
2352 WebFrame* top_frame = frame->top(); 2460 WebFrame* top_frame = frame->top();
2353 if (!top_frame) 2461 // TODO(nasko): Hack around asking about top-frame data source.
2462 if (!top_frame || top_frame->isWebRemoteFrame())
2354 top_frame = frame; 2463 top_frame = frame;
2355 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); 2464 WebDataSource* provisional_data_source = top_frame->provisionalDataSource();
2356 WebDataSource* top_data_source = top_frame->dataSource(); 2465 WebDataSource* top_data_source = top_frame->dataSource();
2357 WebDataSource* data_source = 2466 WebDataSource* data_source =
2358 provisional_data_source ? provisional_data_source : top_data_source; 2467 provisional_data_source ? provisional_data_source : top_data_source;
2359 2468
2360 PageTransition transition_type = PAGE_TRANSITION_LINK; 2469 PageTransition transition_type = PAGE_TRANSITION_LINK;
2361 DocumentState* document_state = DocumentState::FromDataSource(data_source); 2470 DocumentState* document_state = DocumentState::FromDataSource(data_source);
2362 DCHECK(document_state); 2471 DCHECK(document_state);
2363 InternalDocumentStateData* internal_data = 2472 InternalDocumentStateData* internal_data =
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 DocumentState::FromDataSource(frame->provisionalDataSource())); 2545 DocumentState::FromDataSource(frame->provisionalDataSource()));
2437 provider_id = provider->provider_id(); 2546 provider_id = provider->provider_id();
2438 } 2547 }
2439 } else if (frame->dataSource()) { 2548 } else if (frame->dataSource()) {
2440 ServiceWorkerNetworkProvider* provider = 2549 ServiceWorkerNetworkProvider* provider =
2441 ServiceWorkerNetworkProvider::FromDocumentState( 2550 ServiceWorkerNetworkProvider::FromDocumentState(
2442 DocumentState::FromDataSource(frame->dataSource())); 2551 DocumentState::FromDataSource(frame->dataSource()));
2443 provider_id = provider->provider_id(); 2552 provider_id = provider->provider_id();
2444 } 2553 }
2445 2554
2446 int parent_routing_id = frame->parent() ? 2555 WebFrame* parent = frame->parent();
2447 FromWebFrame(frame->parent())->GetRoutingID() : -1; 2556 int parent_routing_id = MSG_ROUTING_NONE;
2557 if (!parent) {
2558 parent_routing_id = -1;
2559 } else if (parent->isWebLocalFrame()) {
2560 parent_routing_id = FromWebFrame(parent)->GetRoutingID();
2561 } else {
2562 parent_routing_id = RenderFrameProxy::FromWebFrame(parent)->routing_id();
2563 }
2564
2448 RequestExtraData* extra_data = new RequestExtraData(); 2565 RequestExtraData* extra_data = new RequestExtraData();
2449 extra_data->set_visibility_state(render_view_->visibilityState()); 2566 extra_data->set_visibility_state(render_view_->visibilityState());
2450 extra_data->set_custom_user_agent(custom_user_agent); 2567 extra_data->set_custom_user_agent(custom_user_agent);
2451 extra_data->set_was_after_preconnect_request(was_after_preconnect_request); 2568 extra_data->set_was_after_preconnect_request(was_after_preconnect_request);
2452 extra_data->set_render_frame_id(routing_id_); 2569 extra_data->set_render_frame_id(routing_id_);
2453 extra_data->set_is_main_frame(frame == top_frame); 2570 extra_data->set_is_main_frame(frame == top_frame);
2454 extra_data->set_frame_origin( 2571 extra_data->set_frame_origin(
2455 GURL(frame->document().securityOrigin().toString())); 2572 GURL(frame->document().securityOrigin().toString()));
2456 extra_data->set_parent_is_main_frame(frame->parent() == top_frame); 2573 extra_data->set_parent_is_main_frame(frame->parent() == top_frame);
2457 extra_data->set_parent_render_frame_id(parent_routing_id); 2574 extra_data->set_parent_render_frame_id(parent_routing_id);
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 } 3225 }
3109 3226
3110 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( 3227 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation(
3111 RenderFrame* render_frame, 3228 RenderFrame* render_frame,
3112 WebFrame* frame, 3229 WebFrame* frame,
3113 WebDataSource::ExtraData* extraData, 3230 WebDataSource::ExtraData* extraData,
3114 const WebURLRequest& request, 3231 const WebURLRequest& request,
3115 WebNavigationType type, 3232 WebNavigationType type,
3116 WebNavigationPolicy default_policy, 3233 WebNavigationPolicy default_policy,
3117 bool is_redirect) { 3234 bool is_redirect) {
3235 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3236 << " url:" << request.url();
3237
3118 #ifdef OS_ANDROID 3238 #ifdef OS_ANDROID
3119 // The handlenavigation API is deprecated and will be removed once 3239 // The handlenavigation API is deprecated and will be removed once
3120 // crbug.com/325351 is resolved. 3240 // crbug.com/325351 is resolved.
3121 if (request.url() != GURL(kSwappedOutURL) && 3241 if (request.url() != GURL(kSwappedOutURL) &&
3122 GetContentClient()->renderer()->HandleNavigation( 3242 GetContentClient()->renderer()->HandleNavigation(
3123 render_frame, 3243 render_frame,
3124 static_cast<DocumentState*>(extraData), 3244 static_cast<DocumentState*>(extraData),
3125 render_view_->opener_id_, 3245 render_view_->opener_id_,
3126 frame, 3246 frame,
3127 request, 3247 request,
3128 type, 3248 type,
3129 default_policy, 3249 default_policy,
3130 is_redirect)) { 3250 is_redirect)) {
3251 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3252 << " url != swapped out && client->HandleNavigation";
3131 return blink::WebNavigationPolicyIgnore; 3253 return blink::WebNavigationPolicyIgnore;
3132 } 3254 }
3133 #endif 3255 #endif
3134 3256
3135 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request)); 3257 Referrer referrer(RenderViewImpl::GetReferrerFromRequest(frame, request));
3258 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3136 3259
3137 if (is_swapped_out_ || render_view_->is_swapped_out()) { 3260 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3138 if (request.url() != GURL(kSwappedOutURL)) { 3261 << " is_swapped_out_:" << is_swapped_out_
3139 // Targeted links may try to navigate a swapped out frame. Allow the 3262 << " rv->is_swapped_out():" << render_view_->is_swapped_out();
3140 // browser process to navigate the tab instead. Note that it is also 3263 bool is_subframe = !!frame->parent();
3141 // possible for non-targeted navigations (from this view) to arrive 3264
3142 // here just after we are swapped out. It's ok to send them to the 3265 if (command_line.HasSwitch(switches::kSitePerProcess) && is_subframe) {
3143 // browser, as long as they're for the top level frame. 3266 LOG(ERROR)
3144 // TODO(creis): Ensure this supports targeted form submissions when 3267 << "RF[" << this << "]::DecidePolicyForNavigation:"
3145 // fixing http://crbug.com/101395. 3268 << " --site-per-process, so ignore swapped out state for subframes";
3146 if (frame->parent() == NULL) { 3269 } else {
3147 OpenURL(frame, request.url(), referrer, default_policy); 3270 if (is_swapped_out_ || render_view_->is_swapped_out()) {
3148 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 3271 if (request.url() != GURL(kSwappedOutURL)) {
3272 // Targeted links may try to navigate a swapped out frame. Allow the
3273 // browser process to navigate the tab instead. Note that it is also
3274 // possible for non-targeted navigations (from this view) to arrive
3275 // here just after we are swapped out. It's ok to send them to the
3276 // browser, as long as they're for the top level frame.
3277 // TODO(creis): Ensure this supports targeted form submissions when
3278 // fixing http://crbug.com/101395.
3279 if (frame->parent() == NULL) {
3280 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3281 << " OpenURL due to no parent frame";
3282 OpenURL(frame, request.url(), referrer, default_policy);
3283 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
3284 }
3285
3286 // We should otherwise ignore in-process iframe navigations, if they
3287 // arrive just after we are swapped out.
3288 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3289 << " ignore iframe navigation in swapped out state";
3290 return blink::WebNavigationPolicyIgnore;
3149 } 3291 }
3150 3292
3151 // We should otherwise ignore in-process iframe navigations, if they 3293 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3152 // arrive just after we are swapped out. 3294 << " allow kSwappedOutURL";
3153 return blink::WebNavigationPolicyIgnore; 3295 // Allow kSwappedOutURL to complete.
3296 return default_policy;
3154 } 3297 }
3155
3156 // Allow kSwappedOutURL to complete.
3157 return default_policy;
3158 } 3298 }
3159 3299
3160 // Webkit is asking whether to navigate to a new URL. 3300 // Webkit is asking whether to navigate to a new URL.
3161 // This is fine normally, except if we're showing UI from one security 3301 // This is fine normally, except if we're showing UI from one security
3162 // context and they're trying to navigate to a different context. 3302 // context and they're trying to navigate to a different context.
3163 const GURL& url = request.url(); 3303 const GURL& url = request.url();
3164 3304
3165 // A content initiated navigation may have originated from a link-click, 3305 // A content initiated navigation may have originated from a link-click,
3166 // script, drag-n-drop operation, etc. 3306 // script, drag-n-drop operation, etc.
3167 bool is_content_initiated = static_cast<DocumentState*>(extraData)-> 3307 bool is_content_initiated = static_cast<DocumentState*>(extraData)->
3168 navigation_state()->is_content_initiated(); 3308 navigation_state()->is_content_initiated();
3169 3309
3170 // Experimental: 3310 // Experimental:
3171 // If --enable-strict-site-isolation or --site-per-process is enabled, send 3311 // If --enable-strict-site-isolation or --site-per-process is enabled, send
3172 // all top-level navigations to the browser to let it swap processes when 3312 // all top-level navigations to the browser to let it swap processes when
3173 // crossing site boundaries. This is currently expected to break some script 3313 // crossing site boundaries. This is currently expected to break some script
3174 // calls and navigations, such as form submissions. 3314 // calls and navigations, such as form submissions.
3175 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
3176 bool force_swap_due_to_flag = 3315 bool force_swap_due_to_flag =
3177 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) || 3316 command_line.HasSwitch(switches::kEnableStrictSiteIsolation) ||
3178 command_line.HasSwitch(switches::kSitePerProcess); 3317 command_line.HasSwitch(switches::kSitePerProcess);
3179 if (force_swap_due_to_flag && 3318 if (force_swap_due_to_flag &&
3180 !frame->parent() && (is_content_initiated || is_redirect)) { 3319 !frame->parent() && (is_content_initiated || is_redirect)) {
3181 WebString origin_str = frame->document().securityOrigin().toString(); 3320 WebString origin_str = frame->document().securityOrigin().toString();
3182 GURL frame_url(origin_str.utf8().data()); 3321 GURL frame_url(origin_str.utf8().data());
3183 // TODO(cevans): revisit whether this site check is still necessary once 3322 // TODO(cevans): revisit whether this site check is still necessary once
3184 // crbug.com/101395 is fixed. 3323 // crbug.com/101395 is fixed.
3185 bool same_domain_or_host = 3324 bool same_domain_or_host =
3186 net::registry_controlled_domains::SameDomainOrHost( 3325 net::registry_controlled_domains::SameDomainOrHost(
3187 frame_url, 3326 frame_url,
3188 url, 3327 url,
3189 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 3328 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
3329 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3330 << " force swap from flags, same_domain:" << same_domain_or_host;
3190 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) { 3331 if (!same_domain_or_host || frame_url.scheme() != url.scheme()) {
3332 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3333 << " OpenURL since force swap and not same domain";
3191 OpenURL(frame, url, referrer, default_policy); 3334 OpenURL(frame, url, referrer, default_policy);
3192 return blink::WebNavigationPolicyIgnore; 3335 return blink::WebNavigationPolicyIgnore;
3193 } 3336 }
3194 } 3337 }
3195 3338
3196 // If the browser is interested, then give it a chance to look at the request. 3339 // If the browser is interested, then give it a chance to look at the request.
3197 if (is_content_initiated) { 3340 if (is_content_initiated) {
3198 bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) || 3341 bool is_form_post = ((type == blink::WebNavigationTypeFormSubmitted) ||
3199 (type == blink::WebNavigationTypeFormResubmitted)) && 3342 (type == blink::WebNavigationTypeFormResubmitted)) &&
3200 EqualsASCII(request.httpMethod(), "POST"); 3343 EqualsASCII(request.httpMethod(), "POST");
3201 bool browser_handles_request = 3344 bool browser_handles_request =
3202 render_view_->renderer_preferences_ 3345 render_view_->renderer_preferences_
3203 .browser_handles_non_local_top_level_requests 3346 .browser_handles_non_local_top_level_requests
3204 && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post); 3347 && IsNonLocalTopLevelNavigation(url, frame, type, is_form_post);
3205 if (!browser_handles_request) { 3348 if (!browser_handles_request) {
3206 browser_handles_request = IsTopLevelNavigation(frame) && 3349 browser_handles_request = IsTopLevelNavigation(frame) &&
3207 render_view_->renderer_preferences_ 3350 render_view_->renderer_preferences_
3208 .browser_handles_all_top_level_requests; 3351 .browser_handles_all_top_level_requests;
3209 } 3352 }
3210 3353
3211 if (browser_handles_request) { 3354 if (browser_handles_request) {
3212 // Reset these counters as the RenderView could be reused for the next 3355 // Reset these counters as the RenderView could be reused for the next
3213 // navigation. 3356 // navigation.
3214 render_view_->page_id_ = -1; 3357 render_view_->page_id_ = -1;
3215 render_view_->last_page_id_sent_to_browser_ = -1; 3358 render_view_->last_page_id_sent_to_browser_ = -1;
3359 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3360 << " OpenURL since browser handles request";
3216 OpenURL(frame, url, referrer, default_policy); 3361 OpenURL(frame, url, referrer, default_policy);
3217 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 3362 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
3218 } 3363 }
3219 } 3364 }
3220 3365
3221 // Use the frame's original request's URL rather than the document's URL for 3366 // Use the frame's original request's URL rather than the document's URL for
3222 // subsequent checks. For a popup, the document's URL may become the opener 3367 // subsequent checks. For a popup, the document's URL may become the opener
3223 // window's URL if the opener has called document.write(). 3368 // window's URL if the opener has called document.write().
3224 // See http://crbug.com/93517. 3369 // See http://crbug.com/93517.
3225 GURL old_url(frame->dataSource()->request().url()); 3370 GURL old_url(frame->dataSource()->request().url());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3269 } 3414 }
3270 3415
3271 if (!should_fork) { 3416 if (!should_fork) {
3272 // Give the embedder a chance. 3417 // Give the embedder a chance.
3273 should_fork = GetContentClient()->renderer()->ShouldFork( 3418 should_fork = GetContentClient()->renderer()->ShouldFork(
3274 frame, url, request.httpMethod().utf8(), is_initial_navigation, 3419 frame, url, request.httpMethod().utf8(), is_initial_navigation,
3275 is_redirect, &send_referrer); 3420 is_redirect, &send_referrer);
3276 } 3421 }
3277 3422
3278 if (should_fork) { 3423 if (should_fork) {
3424 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3425 << " OpenURL since should fork";
3279 OpenURL( 3426 OpenURL(
3280 frame, url, send_referrer ? referrer : Referrer(), default_policy); 3427 frame, url, send_referrer ? referrer : Referrer(), default_policy);
3281 return blink::WebNavigationPolicyIgnore; // Suppress the load here. 3428 return blink::WebNavigationPolicyIgnore; // Suppress the load here.
3282 } 3429 }
3283 } 3430 }
3284 3431
3285 // Detect when a page is "forking" a new tab that can be safely rendered in 3432 // Detect when a page is "forking" a new tab that can be safely rendered in
3286 // its own process. This is done by sites like Gmail that try to open links 3433 // its own process. This is done by sites like Gmail that try to open links
3287 // in new windows without script connections back to the original page. We 3434 // in new windows without script connections back to the original page. We
3288 // treat such cases as browser navigations (in which we will create a new 3435 // treat such cases as browser navigations (in which we will create a new
(...skipping 19 matching lines...) Expand all
3308 // Must be a top-level frame. 3455 // Must be a top-level frame.
3309 frame->parent() == NULL && 3456 frame->parent() == NULL &&
3310 // Must not have issued the request from this page. 3457 // Must not have issued the request from this page.
3311 is_content_initiated && 3458 is_content_initiated &&
3312 // Must be targeted at the current tab. 3459 // Must be targeted at the current tab.
3313 default_policy == blink::WebNavigationPolicyCurrentTab && 3460 default_policy == blink::WebNavigationPolicyCurrentTab &&
3314 // Must be a JavaScript navigation, which appears as "other". 3461 // Must be a JavaScript navigation, which appears as "other".
3315 type == blink::WebNavigationTypeOther; 3462 type == blink::WebNavigationTypeOther;
3316 3463
3317 if (is_fork) { 3464 if (is_fork) {
3465 LOG(ERROR) << "RF[" << this << "]::DecidePolicyForNavigation:"
3466 << " OpenURL since is_fork";
3318 // Open the URL via the browser, not via WebKit. 3467 // Open the URL via the browser, not via WebKit.
3319 OpenURL(frame, url, Referrer(), default_policy); 3468 OpenURL(frame, url, Referrer(), default_policy);
3320 return blink::WebNavigationPolicyIgnore; 3469 return blink::WebNavigationPolicyIgnore;
3321 } 3470 }
3322 3471
3323 return default_policy; 3472 return default_policy;
3324 } 3473 }
3325 3474
3326 void RenderFrameImpl::OpenURL(WebFrame* frame, 3475 void RenderFrameImpl::OpenURL(WebFrame* frame,
3327 const GURL& url, 3476 const GURL& url,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 3704
3556 #if defined(ENABLE_BROWSER_CDMS) 3705 #if defined(ENABLE_BROWSER_CDMS)
3557 RendererCdmManager* RenderFrameImpl::GetCdmManager() { 3706 RendererCdmManager* RenderFrameImpl::GetCdmManager() {
3558 if (!cdm_manager_) 3707 if (!cdm_manager_)
3559 cdm_manager_ = new RendererCdmManager(this); 3708 cdm_manager_ = new RendererCdmManager(this);
3560 return cdm_manager_; 3709 return cdm_manager_;
3561 } 3710 }
3562 #endif // defined(ENABLE_BROWSER_CDMS) 3711 #endif // defined(ENABLE_BROWSER_CDMS)
3563 3712
3564 } // namespace content 3713 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698