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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 72233002: Move RenderViewHostManager from WebContents to FrameTreeNode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial patch Created 7 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 WebContentsImpl::WebContentsImpl( 335 WebContentsImpl::WebContentsImpl(
336 BrowserContext* browser_context, 336 BrowserContext* browser_context,
337 WebContentsImpl* opener) 337 WebContentsImpl* opener)
338 : delegate_(NULL), 338 : delegate_(NULL),
339 controller_(this, browser_context), 339 controller_(this, browser_context),
340 render_view_host_delegate_view_(NULL), 340 render_view_host_delegate_view_(NULL),
341 opener_(opener), 341 opener_(opener),
342 #if defined(OS_WIN) && defined(USE_AURA) 342 #if defined(OS_WIN) && defined(USE_AURA)
343 accessible_parent_(NULL), 343 accessible_parent_(NULL),
344 #endif 344 #endif
345 render_manager_(this, this, this), 345 frame_tree_(new Navigator(&controller_, this), this, this, this),
346 frame_tree_(new Navigator(&controller_, this)),
347 is_loading_(false), 346 is_loading_(false),
348 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 347 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
349 crashed_error_code_(0), 348 crashed_error_code_(0),
350 waiting_for_response_(false), 349 waiting_for_response_(false),
351 load_state_(net::LOAD_STATE_IDLE, string16()), 350 load_state_(net::LOAD_STATE_IDLE, string16()),
352 upload_size_(0), 351 upload_size_(0),
353 upload_position_(0), 352 upload_position_(0),
354 displayed_insecure_content_(false), 353 displayed_insecure_content_(false),
355 capturer_count_(0), 354 capturer_count_(0),
356 should_normally_be_visible_(true), 355 should_normally_be_visible_(true),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 #if defined(OS_WIN) && !defined(USE_AURA) 401 #if defined(OS_WIN) && !defined(USE_AURA)
403 // If we still have a window handle, destroy it. GetNativeView can return 402 // If we still have a window handle, destroy it. GetNativeView can return
404 // NULL if this contents was part of a window that closed. 403 // NULL if this contents was part of a window that closed.
405 if (view_->GetNativeView()) { 404 if (view_->GetNativeView()) {
406 RenderViewHost* host = GetRenderViewHost(); 405 RenderViewHost* host = GetRenderViewHost();
407 if (host && host->GetView()) 406 if (host && host->GetView())
408 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); 407 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy();
409 } 408 }
410 #endif 409 #endif
411 410
412 RenderViewHost* pending_rvh = render_manager_.pending_render_view_host(); 411 RenderViewHost* pending_rvh = GetRenderManager()->pending_render_view_host();
413 if (pending_rvh) { 412 if (pending_rvh) {
414 FOR_EACH_OBSERVER(WebContentsObserver, 413 FOR_EACH_OBSERVER(WebContentsObserver,
415 observers_, 414 observers_,
416 RenderViewDeleted(pending_rvh)); 415 RenderViewDeleted(pending_rvh));
417 } 416 }
418 417
419 FOR_EACH_OBSERVER(WebContentsObserver, 418 FOR_EACH_OBSERVER(WebContentsObserver,
420 observers_, 419 observers_,
421 RenderViewDeleted(render_manager_.current_host())); 420 RenderViewDeleted(GetRenderManager()->current_host()));
422 421
423 FOR_EACH_OBSERVER(WebContentsObserver, 422 FOR_EACH_OBSERVER(WebContentsObserver,
424 observers_, 423 observers_,
425 WebContentsImplDestroyed()); 424 WebContentsImplDestroyed());
426 425
427 SetDelegate(NULL); 426 SetDelegate(NULL);
428 427
429 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), 428 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(),
430 destruction_observers_.end()); 429 destruction_observers_.end());
431 } 430 }
(...skipping 27 matching lines...) Expand all
459 458
460 // We are instantiating a WebContents for browser plugin. Set its subframe bit 459 // We are instantiating a WebContents for browser plugin. Set its subframe bit
461 // to true. 460 // to true.
462 static_cast<RenderViewHostImpl*>( 461 static_cast<RenderViewHostImpl*>(
463 new_contents->GetRenderViewHost())->set_is_subframe(true); 462 new_contents->GetRenderViewHost())->set_is_subframe(true);
464 463
465 return new_contents->browser_plugin_guest_.get(); 464 return new_contents->browser_plugin_guest_.get();
466 } 465 }
467 466
468 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { 467 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() {
469 return &render_manager_; 468 return GetRenderManager();
470 } 469 }
471 470
472 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, 471 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host,
473 const IPC::Message& message) { 472 const IPC::Message& message) {
474 if (GetWebUI() && 473 if (GetWebUI() &&
475 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { 474 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) {
476 return true; 475 return true;
477 } 476 }
478 477
479 ObserverListBase<WebContentsObserver>::Iterator it(observers_); 478 ObserverListBase<WebContentsObserver>::Iterator it(observers_);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 delegate_ = delegate; 594 delegate_ = delegate;
596 if (delegate_) { 595 if (delegate_) {
597 delegate_->Attach(this); 596 delegate_->Attach(this);
598 // Ensure the visible RVH reflects the new delegate's preferences. 597 // Ensure the visible RVH reflects the new delegate's preferences.
599 if (view_) 598 if (view_)
600 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); 599 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent());
601 } 600 }
602 } 601 }
603 602
604 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { 603 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const {
605 RenderViewHostImpl* host = render_manager_.current_host(); 604 RenderViewHostImpl* host = GetRenderManager()->current_host();
606 return host ? host->GetProcess() : NULL; 605 return host ? host->GetProcess() : NULL;
607 } 606 }
608 607
609 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { 608 RenderViewHost* WebContentsImpl::GetRenderViewHost() const {
610 return render_manager_.current_host(); 609 return GetRenderManager()->current_host();
611 } 610 }
612 611
613 void WebContentsImpl::GetRenderViewHostAtPosition( 612 void WebContentsImpl::GetRenderViewHostAtPosition(
614 int x, 613 int x,
615 int y, 614 int y,
616 const base::Callback<void(RenderViewHost*, int, int)>& callback) { 615 const base::Callback<void(RenderViewHost*, int, int)>& callback) {
617 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder(); 616 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder();
618 if (embedder) 617 if (embedder)
619 embedder->GetRenderViewHostAtPosition(x, y, callback); 618 embedder->GetRenderViewHostAtPosition(x, y, callback);
620 else 619 else
(...skipping 19 matching lines...) Expand all
640 return MSG_ROUTING_NONE; 639 return MSG_ROUTING_NONE;
641 640
642 return GetRenderViewHost()->GetRoutingID(); 641 return GetRenderViewHost()->GetRoutingID();
643 } 642 }
644 643
645 int WebContentsImpl::GetFullscreenWidgetRoutingID() const { 644 int WebContentsImpl::GetFullscreenWidgetRoutingID() const {
646 return fullscreen_widget_routing_id_; 645 return fullscreen_widget_routing_id_;
647 } 646 }
648 647
649 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { 648 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const {
650 return render_manager_.GetRenderWidgetHostView(); 649 return GetRenderManager()->GetRenderWidgetHostView();
651 } 650 }
652 651
653 RenderWidgetHostViewPort* WebContentsImpl::GetRenderWidgetHostViewPort() const { 652 RenderWidgetHostViewPort* WebContentsImpl::GetRenderWidgetHostViewPort() const {
654 BrowserPluginGuest* guest = GetBrowserPluginGuest(); 653 BrowserPluginGuest* guest = GetBrowserPluginGuest();
655 if (guest && guest->embedder_web_contents()) { 654 if (guest && guest->embedder_web_contents()) {
656 return guest->embedder_web_contents()->GetRenderWidgetHostViewPort(); 655 return guest->embedder_web_contents()->GetRenderWidgetHostViewPort();
657 } 656 }
658 return RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); 657 return RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView());
659 } 658 }
660 659
(...skipping 17 matching lines...) Expand all
678 web_ui->AddMessageHandler(new GenericHandler()); 677 web_ui->AddMessageHandler(new GenericHandler());
679 web_ui->SetController(controller); 678 web_ui->SetController(controller);
680 return web_ui; 679 return web_ui;
681 } 680 }
682 681
683 delete web_ui; 682 delete web_ui;
684 return NULL; 683 return NULL;
685 } 684 }
686 685
687 WebUI* WebContentsImpl::GetWebUI() const { 686 WebUI* WebContentsImpl::GetWebUI() const {
688 return render_manager_.web_ui() ? render_manager_.web_ui() 687 return GetRenderManager()->web_ui() ? GetRenderManager()->web_ui()
689 : render_manager_.pending_web_ui(); 688 : GetRenderManager()->pending_web_ui();
690 } 689 }
691 690
692 WebUI* WebContentsImpl::GetCommittedWebUI() const { 691 WebUI* WebContentsImpl::GetCommittedWebUI() const {
693 return render_manager_.web_ui(); 692 return GetRenderManager()->web_ui();
694 } 693 }
695 694
696 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { 695 void WebContentsImpl::SetUserAgentOverride(const std::string& override) {
697 if (GetUserAgentOverride() == override) 696 if (GetUserAgentOverride() == override)
698 return; 697 return;
699 698
700 renderer_preferences_.user_agent_override = override; 699 renderer_preferences_.user_agent_override = override;
701 700
702 // Send the new override string to the renderer. 701 // Send the new override string to the renderer.
703 RenderViewHost* host = GetRenderViewHost(); 702 RenderViewHost* host = GetRenderViewHost();
(...skipping 26 matching lines...) Expand all
730 const string16& WebContentsImpl::GetTitle() const { 729 const string16& WebContentsImpl::GetTitle() const {
731 // Transient entries take precedence. They are used for interstitial pages 730 // Transient entries take precedence. They are used for interstitial pages
732 // that are shown on top of existing pages. 731 // that are shown on top of existing pages.
733 NavigationEntry* entry = controller_.GetTransientEntry(); 732 NavigationEntry* entry = controller_.GetTransientEntry();
734 std::string accept_languages = 733 std::string accept_languages =
735 GetContentClient()->browser()->GetAcceptLangs( 734 GetContentClient()->browser()->GetAcceptLangs(
736 GetBrowserContext()); 735 GetBrowserContext());
737 if (entry) { 736 if (entry) {
738 return entry->GetTitleForDisplay(accept_languages); 737 return entry->GetTitleForDisplay(accept_languages);
739 } 738 }
740 WebUI* our_web_ui = render_manager_.pending_web_ui() ? 739 WebUI* our_web_ui = GetRenderManager()->pending_web_ui() ?
741 render_manager_.pending_web_ui() : render_manager_.web_ui(); 740 GetRenderManager()->pending_web_ui() : GetRenderManager()->web_ui();
742 if (our_web_ui) { 741 if (our_web_ui) {
743 // Don't override the title in view source mode. 742 // Don't override the title in view source mode.
744 entry = controller_.GetVisibleEntry(); 743 entry = controller_.GetVisibleEntry();
745 if (!(entry && entry->IsViewSourceMode())) { 744 if (!(entry && entry->IsViewSourceMode())) {
746 // Give the Web UI the chance to override our title. 745 // Give the Web UI the chance to override our title.
747 const string16& title = our_web_ui->GetOverriddenTitle(); 746 const string16& title = our_web_ui->GetOverriddenTitle();
748 if (!title.empty()) 747 if (!title.empty())
749 return title; 748 return title;
750 } 749 }
751 } 750 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) 791 if (GetMaxPageIDForSiteInstance(site_instance) < page_id)
793 max_page_ids_[site_instance->GetId()] = page_id; 792 max_page_ids_[site_instance->GetId()] = page_id;
794 } 793 }
795 794
796 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) { 795 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) {
797 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents); 796 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents);
798 max_page_ids_ = contents->max_page_ids_; 797 max_page_ids_ = contents->max_page_ids_;
799 } 798 }
800 799
801 SiteInstance* WebContentsImpl::GetSiteInstance() const { 800 SiteInstance* WebContentsImpl::GetSiteInstance() const {
802 return render_manager_.current_host()->GetSiteInstance(); 801 return GetRenderManager()->current_host()->GetSiteInstance();
803 } 802 }
804 803
805 SiteInstance* WebContentsImpl::GetPendingSiteInstance() const { 804 SiteInstance* WebContentsImpl::GetPendingSiteInstance() const {
806 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? 805 RenderViewHost* dest_rvh = GetRenderManager()->pending_render_view_host() ?
807 render_manager_.pending_render_view_host() : 806 GetRenderManager()->pending_render_view_host() :
808 render_manager_.current_host(); 807 GetRenderManager()->current_host();
809 return dest_rvh->GetSiteInstance(); 808 return dest_rvh->GetSiteInstance();
810 } 809 }
811 810
812 bool WebContentsImpl::IsLoading() const { 811 bool WebContentsImpl::IsLoading() const {
813 return is_loading_; 812 return is_loading_;
814 } 813 }
815 814
816 bool WebContentsImpl::IsWaitingForResponse() const { 815 bool WebContentsImpl::IsWaitingForResponse() const {
817 return waiting_for_response_; 816 return waiting_for_response_;
818 } 817 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 956
958 bool WebContentsImpl::NeedToFireBeforeUnload() { 957 bool WebContentsImpl::NeedToFireBeforeUnload() {
959 // TODO(creis): Should we fire even for interstitial pages? 958 // TODO(creis): Should we fire even for interstitial pages?
960 return WillNotifyDisconnection() && 959 return WillNotifyDisconnection() &&
961 !ShowingInterstitialPage() && 960 !ShowingInterstitialPage() &&
962 !static_cast<RenderViewHostImpl*>( 961 !static_cast<RenderViewHostImpl*>(
963 GetRenderViewHost())->SuddenTerminationAllowed(); 962 GetRenderViewHost())->SuddenTerminationAllowed();
964 } 963 }
965 964
966 void WebContentsImpl::Stop() { 965 void WebContentsImpl::Stop() {
967 render_manager_.Stop(); 966 GetRenderManager()->Stop();
968 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped()); 967 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped());
969 } 968 }
970 969
971 WebContents* WebContentsImpl::Clone() { 970 WebContents* WebContentsImpl::Clone() {
972 // We use our current SiteInstance since the cloned entry will use it anyway. 971 // We use our current SiteInstance since the cloned entry will use it anyway.
973 // We pass our own opener so that the cloned page can access it if it was 972 // We pass our own opener so that the cloned page can access it if it was
974 // before. 973 // before.
975 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); 974 CreateParams create_params(GetBrowserContext(), GetSiteInstance());
976 create_params.initial_size = view_->GetContainerSize(); 975 create_params.initial_size = view_->GetContainerSize();
977 WebContentsImpl* tc = CreateWithOpener(create_params, opener_); 976 WebContentsImpl* tc = CreateWithOpener(create_params, opener_);
(...skipping 22 matching lines...) Expand all
1000 default: 999 default:
1001 NOTREACHED(); 1000 NOTREACHED();
1002 } 1001 }
1003 } 1002 }
1004 1003
1005 WebContents* WebContentsImpl::GetWebContents() { 1004 WebContents* WebContentsImpl::GetWebContents() {
1006 return this; 1005 return this;
1007 } 1006 }
1008 1007
1009 void WebContentsImpl::Init(const WebContents::CreateParams& params) { 1008 void WebContentsImpl::Init(const WebContents::CreateParams& params) {
1010 // This is set before initializing the render_manager_ since render_manager_ 1009 // This is set before initializing the render manager since
1011 // init calls back into us via its delegate to ask if it should be hidden. 1010 // RenderViewHostManager::Init calls back into us via its delegate to ask if
1011 // it should be hidden.
1012 should_normally_be_visible_ = !params.initially_hidden; 1012 should_normally_be_visible_ = !params.initially_hidden;
1013 1013
1014 render_manager_.Init( 1014 GetRenderManager()->Init(
1015 params.browser_context, params.site_instance, params.routing_id, 1015 params.browser_context, params.site_instance, params.routing_id,
1016 params.main_frame_routing_id); 1016 params.main_frame_routing_id);
1017 1017
1018 view_.reset(GetContentClient()->browser()-> 1018 view_.reset(GetContentClient()->browser()->
1019 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); 1019 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_));
1020 if (view_) { 1020 if (view_) {
1021 CHECK(render_view_host_delegate_view_); 1021 CHECK(render_view_host_delegate_view_);
1022 } else { 1022 } else {
1023 WebContentsViewDelegate* delegate = 1023 WebContentsViewDelegate* delegate =
1024 GetContentClient()->browser()->GetWebContentsViewDelegate(this); 1024 GetContentClient()->browser()->GetWebContentsViewDelegate(this);
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 1571
1572 void WebContentsImpl::RenderViewForInterstitialPageCreated( 1572 void WebContentsImpl::RenderViewForInterstitialPageCreated(
1573 RenderViewHost* render_view_host) { 1573 RenderViewHost* render_view_host) {
1574 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1574 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1575 RenderViewForInterstitialPageCreated(render_view_host)); 1575 RenderViewForInterstitialPageCreated(render_view_host));
1576 } 1576 }
1577 1577
1578 void WebContentsImpl::AttachInterstitialPage( 1578 void WebContentsImpl::AttachInterstitialPage(
1579 InterstitialPageImpl* interstitial_page) { 1579 InterstitialPageImpl* interstitial_page) {
1580 DCHECK(interstitial_page); 1580 DCHECK(interstitial_page);
1581 render_manager_.set_interstitial_page(interstitial_page); 1581 GetRenderManager()->set_interstitial_page(interstitial_page);
1582 1582
1583 // Cancel any visible dialogs so that they don't interfere with the 1583 // Cancel any visible dialogs so that they don't interfere with the
1584 // interstitial. 1584 // interstitial.
1585 if (dialog_manager_) 1585 if (dialog_manager_)
1586 dialog_manager_->CancelActiveAndPendingDialogs(this); 1586 dialog_manager_->CancelActiveAndPendingDialogs(this);
1587 1587
1588 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1588 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1589 DidAttachInterstitialPage()); 1589 DidAttachInterstitialPage());
1590 } 1590 }
1591 1591
1592 void WebContentsImpl::DetachInterstitialPage() { 1592 void WebContentsImpl::DetachInterstitialPage() {
1593 if (GetInterstitialPage()) 1593 if (GetInterstitialPage())
1594 render_manager_.remove_interstitial_page(); 1594 GetRenderManager()->remove_interstitial_page();
1595 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1595 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1596 DidDetachInterstitialPage()); 1596 DidDetachInterstitialPage());
1597 } 1597 }
1598 1598
1599 bool WebContentsImpl::NavigateToEntry( 1599 bool WebContentsImpl::NavigateToEntry(
1600 const NavigationEntryImpl& entry, 1600 const NavigationEntryImpl& entry,
1601 NavigationController::ReloadType reload_type) { 1601 NavigationController::ReloadType reload_type) {
1602 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); 1602 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry");
1603 1603
1604 // The renderer will reject IPC messages with URLs longer than 1604 // The renderer will reject IPC messages with URLs longer than
1605 // this limit, so don't attempt to navigate with a longer URL. 1605 // this limit, so don't attempt to navigate with a longer URL.
1606 if (entry.GetURL().spec().size() > kMaxURLChars) { 1606 if (entry.GetURL().spec().size() > kMaxURLChars) {
1607 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars 1607 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars
1608 << " characters."; 1608 << " characters.";
1609 return false; 1609 return false;
1610 } 1610 }
1611 1611
1612 RenderViewHostImpl* dest_render_view_host = 1612 RenderViewHostImpl* dest_render_view_host =
1613 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); 1613 static_cast<RenderViewHostImpl*>(GetRenderManager()->Navigate(entry));
1614 if (!dest_render_view_host) 1614 if (!dest_render_view_host)
1615 return false; // Unable to create the desired render view host. 1615 return false; // Unable to create the desired render view host.
1616 1616
1617 // For security, we should never send non-Web-UI URLs to a Web UI renderer. 1617 // For security, we should never send non-Web-UI URLs to a Web UI renderer.
1618 // Double check that here. 1618 // Double check that here.
1619 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); 1619 int enabled_bindings = dest_render_view_host->GetEnabledBindings();
1620 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); 1620 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI();
1621 bool is_allowed_in_web_ui_renderer = 1621 bool is_allowed_in_web_ui_renderer =
1622 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 1622 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
1623 GetBrowserContext(), entry.GetURL(), data_urls_allowed); 1623 GetBrowserContext(), entry.GetURL(), data_urls_allowed);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 1662
1663 return true; 1663 return true;
1664 } 1664 }
1665 1665
1666 void WebContentsImpl::SetHistoryLengthAndPrune( 1666 void WebContentsImpl::SetHistoryLengthAndPrune(
1667 const SiteInstance* site_instance, 1667 const SiteInstance* site_instance,
1668 int history_length, 1668 int history_length,
1669 int32 minimum_page_id) { 1669 int32 minimum_page_id) {
1670 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site 1670 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site
1671 // navigations. Callers should ensure that this is the case. 1671 // navigations. Callers should ensure that this is the case.
1672 if (render_manager_.pending_render_view_host()) { 1672 if (GetRenderManager()->pending_render_view_host()) {
1673 NOTREACHED(); 1673 NOTREACHED();
1674 return; 1674 return;
1675 } 1675 }
1676 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); 1676 RenderViewHostImpl* rvh = GetRenderViewHostImpl();
1677 if (!rvh) { 1677 if (!rvh) {
1678 NOTREACHED(); 1678 NOTREACHED();
1679 return; 1679 return;
1680 } 1680 }
1681 if (site_instance && rvh->GetSiteInstance() != site_instance) { 1681 if (site_instance && rvh->GetSiteInstance() != site_instance) {
1682 NOTREACHED(); 1682 NOTREACHED();
1683 return; 1683 return;
1684 } 1684 }
1685 Send(new ViewMsg_SetHistoryLengthAndPrune(GetRoutingID(), 1685 Send(new ViewMsg_SetHistoryLengthAndPrune(GetRoutingID(),
1686 history_length, 1686 history_length,
1687 minimum_page_id)); 1687 minimum_page_id));
1688 } 1688 }
1689 1689
1690 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) { 1690 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) {
1691 if (ShowingInterstitialPage()) { 1691 if (ShowingInterstitialPage()) {
1692 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse); 1692 GetRenderManager()->interstitial_page()->FocusThroughTabTraversal(reverse);
1693 return; 1693 return;
1694 } 1694 }
1695 GetRenderViewHostImpl()->SetInitialFocus(reverse); 1695 GetRenderViewHostImpl()->SetInitialFocus(reverse);
1696 } 1696 }
1697 1697
1698 bool WebContentsImpl::ShowingInterstitialPage() const { 1698 bool WebContentsImpl::ShowingInterstitialPage() const {
1699 return render_manager_.interstitial_page() != NULL; 1699 return GetRenderManager()->interstitial_page() != NULL;
1700 } 1700 }
1701 1701
1702 InterstitialPage* WebContentsImpl::GetInterstitialPage() const { 1702 InterstitialPage* WebContentsImpl::GetInterstitialPage() const {
1703 return render_manager_.interstitial_page(); 1703 return GetRenderManager()->interstitial_page();
1704 } 1704 }
1705 1705
1706 bool WebContentsImpl::IsSavable() { 1706 bool WebContentsImpl::IsSavable() {
1707 // WebKit creates Document object when MIME type is application/xhtml+xml, 1707 // WebKit creates Document object when MIME type is application/xhtml+xml,
1708 // so we also support this MIME type. 1708 // so we also support this MIME type.
1709 return contents_mime_type_ == "text/html" || 1709 return contents_mime_type_ == "text/html" ||
1710 contents_mime_type_ == "text/xml" || 1710 contents_mime_type_ == "text/xml" ||
1711 contents_mime_type_ == "application/xhtml+xml" || 1711 contents_mime_type_ == "application/xhtml+xml" ||
1712 contents_mime_type_ == "text/plain" || 1712 contents_mime_type_ == "text/plain" ||
1713 contents_mime_type_ == "text/css" || 1713 contents_mime_type_ == "text/css" ||
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 // Because this will not tear down the interstitial properly, if "back" is 2085 // Because this will not tear down the interstitial properly, if "back" is
2086 // back to another tab type, the interstitial will still be somewhat alive 2086 // back to another tab type, the interstitial will still be somewhat alive
2087 // in the previous tab type. If you navigate somewhere that activates the 2087 // in the previous tab type. If you navigate somewhere that activates the
2088 // tab with the interstitial again, you'll see a flash before the new load 2088 // tab with the interstitial again, you'll see a flash before the new load
2089 // commits of the interstitial page. 2089 // commits of the interstitial page.
2090 if (ShowingInterstitialPage()) { 2090 if (ShowingInterstitialPage()) {
2091 LOG(WARNING) << "Discarding message during interstitial."; 2091 LOG(WARNING) << "Discarding message during interstitial.";
2092 return; 2092 return;
2093 } 2093 }
2094 2094
2095 render_manager_.RendererAbortedProvisionalLoad(render_view_host); 2095 GetRenderManager()->RendererAbortedProvisionalLoad(render_view_host);
2096 } 2096 }
2097 2097
2098 // Do not usually clear the pending entry if one exists, so that the user's 2098 // Do not usually clear the pending entry if one exists, so that the user's
2099 // typed URL is not lost when a navigation fails or is aborted. However, in 2099 // typed URL is not lost when a navigation fails or is aborted. However, in
2100 // cases that we don't show the pending entry (e.g., renderer-initiated 2100 // cases that we don't show the pending entry (e.g., renderer-initiated
2101 // navigations in an existing tab), we don't keep it around. That prevents 2101 // navigations in an existing tab), we don't keep it around. That prevents
2102 // spoofs on in-page navigations that don't go through 2102 // spoofs on in-page navigations that don't go through
2103 // DidStartProvisionalLoadForFrame. 2103 // DidStartProvisionalLoadForFrame.
2104 // In general, we allow the view to clear the pending entry and typed URL if 2104 // In general, we allow the view to clear the pending entry and typed URL if
2105 // the user requests (e.g., hitting Escape with focus in the address bar). 2105 // the user requests (e.g., hitting Escape with focus in the address bar).
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2492 if (is_loading == is_loading_) 2492 if (is_loading == is_loading_)
2493 return; 2493 return;
2494 2494
2495 if (!is_loading) { 2495 if (!is_loading) {
2496 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); 2496 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16());
2497 load_state_host_.clear(); 2497 load_state_host_.clear();
2498 upload_size_ = 0; 2498 upload_size_ = 0;
2499 upload_position_ = 0; 2499 upload_position_ = 0;
2500 } 2500 }
2501 2501
2502 render_manager_.SetIsLoading(is_loading); 2502 GetRenderManager()->SetIsLoading(is_loading);
2503 2503
2504 is_loading_ = is_loading; 2504 is_loading_ = is_loading;
2505 waiting_for_response_ = is_loading; 2505 waiting_for_response_ = is_loading;
2506 2506
2507 if (delegate_) 2507 if (delegate_)
2508 delegate_->LoadingStateChanged(this); 2508 delegate_->LoadingStateChanged(this);
2509 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); 2509 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD);
2510 2510
2511 const char* url = 2511 const char* url =
2512 (details ? details->url.possibly_invalid_spec().c_str() : "NULL"); 2512 (details ? details->url.possibly_invalid_spec().c_str() : "NULL");
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2683 FOR_EACH_OBSERVER( 2683 FOR_EACH_OBSERVER(
2684 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); 2684 WebContentsObserver, observers_, NavigationEntryCommitted(load_details));
2685 } 2685 }
2686 2686
2687 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { 2687 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() {
2688 return render_view_host_delegate_view_; 2688 return render_view_host_delegate_view_;
2689 } 2689 }
2690 2690
2691 RenderViewHostDelegate::RendererManagement* 2691 RenderViewHostDelegate::RendererManagement*
2692 WebContentsImpl::GetRendererManagementDelegate() { 2692 WebContentsImpl::GetRendererManagementDelegate() {
2693 return &render_manager_; 2693 return GetRenderManager();
2694 } 2694 }
2695 2695
2696 RendererPreferences WebContentsImpl::GetRendererPrefs( 2696 RendererPreferences WebContentsImpl::GetRendererPrefs(
2697 BrowserContext* browser_context) const { 2697 BrowserContext* browser_context) const {
2698 return renderer_preferences_; 2698 return renderer_preferences_;
2699 } 2699 }
2700 2700
2701 WebContents* WebContentsImpl::GetAsWebContents() { 2701 WebContents* WebContentsImpl::GetAsWebContents() {
2702 return this; 2702 return this;
2703 } 2703 }
(...skipping 19 matching lines...) Expand all
2723 if (delegate_) 2723 if (delegate_)
2724 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); 2724 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent());
2725 2725
2726 NotificationService::current()->Notify( 2726 NotificationService::current()->Notify(
2727 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 2727 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
2728 Source<WebContents>(this), 2728 Source<WebContents>(this),
2729 Details<RenderViewHost>(render_view_host)); 2729 Details<RenderViewHost>(render_view_host));
2730 2730
2731 // When we're creating views, we're still doing initial setup, so we always 2731 // When we're creating views, we're still doing initial setup, so we always
2732 // use the pending Web UI rather than any possibly existing committed one. 2732 // use the pending Web UI rather than any possibly existing committed one.
2733 if (render_manager_.pending_web_ui()) 2733 if (GetRenderManager()->pending_web_ui())
2734 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); 2734 GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host);
2735 2735
2736 NavigationEntry* entry = controller_.GetPendingEntry(); 2736 NavigationEntry* entry = controller_.GetPendingEntry();
2737 if (entry && entry->IsViewSourceMode()) { 2737 if (entry && entry->IsViewSourceMode()) {
2738 // Put the renderer in view source mode. 2738 // Put the renderer in view source mode.
2739 render_view_host->Send( 2739 render_view_host->Send(
2740 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); 2740 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID()));
2741 } 2741 }
2742 2742
2743 view_->RenderViewCreated(render_view_host); 2743 view_->RenderViewCreated(render_view_host);
2744 2744
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 SetIsCrashed(status, error_code); 2787 SetIsCrashed(status, error_code);
2788 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); 2788 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_);
2789 2789
2790 FOR_EACH_OBSERVER(WebContentsObserver, 2790 FOR_EACH_OBSERVER(WebContentsObserver,
2791 observers_, 2791 observers_,
2792 RenderProcessGone(GetCrashedStatus())); 2792 RenderProcessGone(GetCrashedStatus()));
2793 } 2793 }
2794 2794
2795 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { 2795 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) {
2796 ClearPowerSaveBlockers(rvh); 2796 ClearPowerSaveBlockers(rvh);
2797 render_manager_.RenderViewDeleted(rvh); 2797 GetRenderManager()->RenderViewDeleted(rvh);
2798 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); 2798 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh));
2799 } 2799 }
2800 2800
2801 void WebContentsImpl::DidGetResourceResponseStart( 2801 void WebContentsImpl::DidGetResourceResponseStart(
2802 const ResourceRequestDetails& details) { 2802 const ResourceRequestDetails& details) {
2803 controller_.ssl_manager()->DidStartResourceResponse(details); 2803 controller_.ssl_manager()->DidStartResourceResponse(details);
2804 2804
2805 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2805 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2806 DidGetResourceResponseStart(details)); 2806 DidGetResourceResponseStart(details));
2807 2807
(...skipping 30 matching lines...) Expand all
2838 if (PageTransitionIsMainFrame(params.transition)) { 2838 if (PageTransitionIsMainFrame(params.transition)) {
2839 // When overscroll navigation gesture is enabled, a screenshot of the page 2839 // When overscroll navigation gesture is enabled, a screenshot of the page
2840 // in its current state is taken so that it can be used during the 2840 // in its current state is taken so that it can be used during the
2841 // nav-gesture. It is necessary to take the screenshot here, before calling 2841 // nav-gesture. It is necessary to take the screenshot here, before calling
2842 // RenderViewHostManager::DidNavigateMainFrame, because that can change 2842 // RenderViewHostManager::DidNavigateMainFrame, because that can change
2843 // WebContents::GetRenderViewHost to return the new host, instead of the one 2843 // WebContents::GetRenderViewHost to return the new host, instead of the one
2844 // that may have just been swapped out. 2844 // that may have just been swapped out.
2845 if (delegate_ && delegate_->CanOverscrollContent()) 2845 if (delegate_ && delegate_->CanOverscrollContent())
2846 controller_.TakeScreenshot(); 2846 controller_.TakeScreenshot();
2847 2847
2848 render_manager_.DidNavigateMainFrame(rvh); 2848 GetRenderManager()->DidNavigateMainFrame(rvh);
2849 } 2849 }
2850 2850
2851 // Update the site of the SiteInstance if it doesn't have one yet, unless 2851 // Update the site of the SiteInstance if it doesn't have one yet, unless
2852 // assigning a site is not necessary for this URL. In that case, the 2852 // assigning a site is not necessary for this URL. In that case, the
2853 // SiteInstance can still be considered unused until a navigation to a real 2853 // SiteInstance can still be considered unused until a navigation to a real
2854 // page. 2854 // page.
2855 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && 2855 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() &&
2856 ShouldAssignSiteForURL(params.url)) { 2856 ShouldAssignSiteForURL(params.url)) {
2857 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); 2857 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url);
2858 } 2858 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2923 } 2923 }
2924 } 2924 }
2925 DidNavigateAnyFramePostCommit(rvh, details, params); 2925 DidNavigateAnyFramePostCommit(rvh, details, params);
2926 } 2926 }
2927 2927
2928 void WebContentsImpl::UpdateState(RenderViewHost* rvh, 2928 void WebContentsImpl::UpdateState(RenderViewHost* rvh,
2929 int32 page_id, 2929 int32 page_id,
2930 const PageState& page_state) { 2930 const PageState& page_state) {
2931 // Ensure that this state update comes from either the active RVH or one of 2931 // Ensure that this state update comes from either the active RVH or one of
2932 // the swapped out RVHs. We don't expect to hear from any other RVHs. 2932 // the swapped out RVHs. We don't expect to hear from any other RVHs.
2933 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsOnSwappedOutList(rvh)); 2933 DCHECK(rvh == GetRenderViewHost() ||
2934 GetRenderManager()->IsOnSwappedOutList(rvh));
2934 2935
2935 // We must be prepared to handle state updates for any page, these occur 2936 // We must be prepared to handle state updates for any page, these occur
2936 // when the user is scrolling and entering form data, as well as when we're 2937 // when the user is scrolling and entering form data, as well as when we're
2937 // leaving a page, in which case our state may have already been moved to 2938 // leaving a page, in which case our state may have already been moved to
2938 // the next page. The navigation controller will look up the appropriate 2939 // the next page. The navigation controller will look up the appropriate
2939 // NavigationEntry and update it when it is notified via the delegate. 2940 // NavigationEntry and update it when it is notified via the delegate.
2940 2941
2941 int entry_index = controller_.GetEntryIndexWithPageID( 2942 int entry_index = controller_.GetEntryIndexWithPageID(
2942 rvh->GetSiteInstance(), page_id); 2943 rvh->GetSiteInstance(), page_id);
2943 if (entry_index < 0) 2944 if (entry_index < 0)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
3006 // Ignore this if it comes from a RenderViewHost that we aren't showing. 3007 // Ignore this if it comes from a RenderViewHost that we aren't showing.
3007 if (delegate_ && rvh == GetRenderViewHost()) 3008 if (delegate_ && rvh == GetRenderViewHost())
3008 delegate_->CloseContents(this); 3009 delegate_->CloseContents(this);
3009 } 3010 }
3010 3011
3011 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { 3012 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) {
3012 if (delegate_ && rvh == GetRenderViewHost()) 3013 if (delegate_ && rvh == GetRenderViewHost())
3013 delegate_->SwappedOut(this); 3014 delegate_->SwappedOut(this);
3014 3015
3015 // Allow the navigation to proceed. 3016 // Allow the navigation to proceed.
3016 render_manager_.SwappedOut(rvh); 3017 GetRenderManager()->SwappedOut(rvh);
3017 } 3018 }
3018 3019
3019 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { 3020 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) {
3020 if (delegate_ && delegate_->IsPopupOrPanel(this)) 3021 if (delegate_ && delegate_->IsPopupOrPanel(this))
3021 delegate_->MoveContents(this, new_bounds); 3022 delegate_->MoveContents(this, new_bounds);
3022 } 3023 }
3023 3024
3024 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { 3025 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) {
3025 SetIsLoading(render_view_host, true, NULL); 3026 SetIsLoading(render_view_host, true, NULL);
3026 } 3027 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3064 if (opener_) { 3065 if (opener_) {
3065 // Clear our opener so that future cross-process navigations don't have an 3066 // Clear our opener so that future cross-process navigations don't have an
3066 // opener assigned. 3067 // opener assigned.
3067 RemoveDestructionObserver(opener_); 3068 RemoveDestructionObserver(opener_);
3068 opener_ = NULL; 3069 opener_ = NULL;
3069 } 3070 }
3070 3071
3071 // Notify all swapped out RenderViewHosts for this tab. This is important 3072 // Notify all swapped out RenderViewHosts for this tab. This is important
3072 // in case we go back to them, or if another window in those processes tries 3073 // in case we go back to them, or if another window in those processes tries
3073 // to access window.opener. 3074 // to access window.opener.
3074 render_manager_.DidDisownOpener(rvh); 3075 GetRenderManager()->DidDisownOpener(rvh);
3075 } 3076 }
3076 3077
3077 void WebContentsImpl::DidAccessInitialDocument() { 3078 void WebContentsImpl::DidAccessInitialDocument() {
3078 // Update the URL display. 3079 // Update the URL display.
3079 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); 3080 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);
3080 } 3081 }
3081 3082
3082 void WebContentsImpl::DocumentAvailableInMainFrame( 3083 void WebContentsImpl::DocumentAvailableInMainFrame(
3083 RenderViewHost* render_view_host) { 3084 RenderViewHost* render_view_host) {
3084 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3085 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3139 dest_url = GURL(kAboutBlankURL); 3140 dest_url = GURL(kAboutBlankURL);
3140 3141
3141 OpenURLParams params(dest_url, referrer, source_frame_id, disposition, 3142 OpenURLParams params(dest_url, referrer, source_frame_id, disposition,
3142 page_transition, true /* is_renderer_initiated */); 3143 page_transition, true /* is_renderer_initiated */);
3143 if (redirect_chain.size() > 0) 3144 if (redirect_chain.size() > 0)
3144 params.redirect_chain = redirect_chain; 3145 params.redirect_chain = redirect_chain;
3145 params.transferred_global_request_id = old_request_id; 3146 params.transferred_global_request_id = old_request_id;
3146 params.should_replace_current_entry = should_replace_current_entry; 3147 params.should_replace_current_entry = should_replace_current_entry;
3147 params.user_gesture = user_gesture; 3148 params.user_gesture = user_gesture;
3148 3149
3149 if (render_manager_.web_ui()) { 3150 if (GetRenderManager()->web_ui()) {
3150 // Web UI pages sometimes want to override the page transition type for 3151 // Web UI pages sometimes want to override the page transition type for
3151 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for 3152 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for
3152 // automatically generated suggestions). We don't override other types 3153 // automatically generated suggestions). We don't override other types
3153 // like TYPED because they have different implications (e.g., autocomplete). 3154 // like TYPED because they have different implications (e.g., autocomplete).
3154 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) 3155 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK))
3155 params.transition = render_manager_.web_ui()->GetLinkTransitionType(); 3156 params.transition = GetRenderManager()->web_ui()->GetLinkTransitionType();
3156 3157
3157 // Note also that we hide the referrer for Web UI pages. We don't really 3158 // Note also that we hide the referrer for Web UI pages. We don't really
3158 // want web sites to see a referrer of "chrome://blah" (and some 3159 // want web sites to see a referrer of "chrome://blah" (and some
3159 // chrome: URLs might have search terms or other stuff we don't want to 3160 // chrome: URLs might have search terms or other stuff we don't want to
3160 // send to the site), so we send no referrer. 3161 // send to the site), so we send no referrer.
3161 params.referrer = Referrer(); 3162 params.referrer = Referrer();
3162 3163
3163 // Navigations in Web UI pages count as browser-initiated navigations. 3164 // Navigations in Web UI pages count as browser-initiated navigations.
3164 params.is_renderer_initiated = false; 3165 params.is_renderer_initiated = false;
3165 3166
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
3349 } 3350 }
3350 3351
3351 WebPreferences WebContentsImpl::GetWebkitPrefs() { 3352 WebPreferences WebContentsImpl::GetWebkitPrefs() {
3352 // We want to base the page config off of the actual URL, rather than the 3353 // We want to base the page config off of the actual URL, rather than the
3353 // virtual URL. 3354 // virtual URL.
3354 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, 3355 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here,
3355 // as it is deprecated and can be out of sync with GetRenderViewHost(). 3356 // as it is deprecated and can be out of sync with GetRenderViewHost().
3356 GURL url = controller_.GetActiveEntry() 3357 GURL url = controller_.GetActiveEntry()
3357 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); 3358 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL();
3358 3359
3359 return render_manager_.current_host()->GetWebkitPrefs(url); 3360 return GetRenderManager()->current_host()->GetWebkitPrefs(url);
3360 } 3361 }
3361 3362
3362 int WebContentsImpl::CreateSwappedOutRenderView( 3363 int WebContentsImpl::CreateSwappedOutRenderView(
3363 SiteInstance* instance) { 3364 SiteInstance* instance) {
3364 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, 3365 return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE,
3365 true, true); 3366 true, true);
3366 } 3367 }
3367 3368
3368 void WebContentsImpl::OnUserGesture() { 3369 void WebContentsImpl::OnUserGesture() {
3369 // Notify observers. 3370 // Notify observers.
3370 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); 3371 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture());
3371 3372
3372 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); 3373 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get();
3373 if (rdh) // NULL in unittests. 3374 if (rdh) // NULL in unittests.
3374 rdh->OnUserGesture(this); 3375 rdh->OnUserGesture(this);
3375 } 3376 }
(...skipping 16 matching lines...) Expand all
3392 // since the event may be a result of the renderer sitting on a breakpoint. 3393 // since the event may be a result of the renderer sitting on a breakpoint.
3393 // See http://crbug.com/65458 3394 // See http://crbug.com/65458
3394 if (DevToolsAgentHost::IsDebuggerAttached(this)) 3395 if (DevToolsAgentHost::IsDebuggerAttached(this))
3395 return; 3396 return;
3396 3397
3397 if (is_during_beforeunload || is_during_unload) { 3398 if (is_during_beforeunload || is_during_unload) {
3398 // Hang occurred while firing the beforeunload/unload handler. 3399 // Hang occurred while firing the beforeunload/unload handler.
3399 // Pretend the handler fired so tab closing continues as if it had. 3400 // Pretend the handler fired so tab closing continues as if it had.
3400 rvhi->set_sudden_termination_allowed(true); 3401 rvhi->set_sudden_termination_allowed(true);
3401 3402
3402 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) 3403 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer())
3403 return; 3404 return;
3404 3405
3405 // If the tab hangs in the beforeunload/unload handler there's really 3406 // If the tab hangs in the beforeunload/unload handler there's really
3406 // nothing we can do to recover. If the hang is in the beforeunload handler, 3407 // nothing we can do to recover. If the hang is in the beforeunload handler,
3407 // pretend the beforeunload listeners have all fired and allow the delegate 3408 // pretend the beforeunload listeners have all fired and allow the delegate
3408 // to continue closing; the user will not have the option of cancelling the 3409 // to continue closing; the user will not have the option of cancelling the
3409 // close. Otherwise, pretend the unload listeners have all fired and close 3410 // close. Otherwise, pretend the unload listeners have all fired and close
3410 // the tab. 3411 // the tab.
3411 bool close = true; 3412 bool close = true;
3412 if (is_during_beforeunload) { 3413 if (is_during_beforeunload) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { 3510 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) {
3510 int opener_route_id = MSG_ROUTING_NONE; 3511 int opener_route_id = MSG_ROUTING_NONE;
3511 3512
3512 // If this tab has an opener, ensure it has a RenderView in the given 3513 // If this tab has an opener, ensure it has a RenderView in the given
3513 // SiteInstance as well. 3514 // SiteInstance as well.
3514 if (opener_) 3515 if (opener_)
3515 opener_route_id = opener_->CreateOpenerRenderViews(instance); 3516 opener_route_id = opener_->CreateOpenerRenderViews(instance);
3516 3517
3517 // If any of the renderers (current, pending, or swapped out) for this 3518 // If any of the renderers (current, pending, or swapped out) for this
3518 // WebContents has the same SiteInstance, use it. 3519 // WebContents has the same SiteInstance, use it.
3519 if (render_manager_.current_host()->GetSiteInstance() == instance) 3520 if (GetRenderManager()->current_host()->GetSiteInstance() == instance)
3520 return render_manager_.current_host()->GetRoutingID(); 3521 return GetRenderManager()->current_host()->GetRoutingID();
3521 3522
3522 if (render_manager_.pending_render_view_host() && 3523 if (GetRenderManager()->pending_render_view_host() &&
3523 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) 3524 GetRenderManager()->pending_render_view_host()->GetSiteInstance() ==
3524 return render_manager_.pending_render_view_host()->GetRoutingID(); 3525 instance)
3526 return GetRenderManager()->pending_render_view_host()->GetRoutingID();
3525 3527
3526 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( 3528 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost(
3527 instance); 3529 instance);
3528 if (rvh) 3530 if (rvh)
3529 return rvh->GetRoutingID(); 3531 return rvh->GetRoutingID();
3530 3532
3531 // Create a swapped out RenderView in the given SiteInstance if none exists, 3533 // Create a swapped out RenderView in the given SiteInstance if none exists,
3532 // setting its opener to the given route_id. Return the new view's route_id. 3534 // setting its opener to the given route_id. Return the new view's route_id.
3533 return render_manager_.CreateRenderView(instance, opener_route_id, 3535 return GetRenderManager()->CreateRenderView(instance, opener_route_id,
3534 true, true); 3536 true, true);
3535 } 3537 }
3536 3538
3537 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { 3539 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
3538 return GetController(); 3540 return GetController();
3539 } 3541 }
3540 3542
3541 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { 3543 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) {
3542 return static_cast<WebUIImpl*>(CreateWebUI(url)); 3544 return static_cast<WebUIImpl*>(CreateWebUI(url));
3543 } 3545 }
3544 3546
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3615 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); 3617 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh);
3616 // Can be NULL during tests. 3618 // Can be NULL during tests.
3617 if (rwh_view) 3619 if (rwh_view)
3618 rwh_view->SetSize(GetView()->GetContainerSize()); 3620 rwh_view->SetSize(GetView()->GetContainerSize());
3619 } 3621 }
3620 3622
3621 bool WebContentsImpl::IsHidden() { 3623 bool WebContentsImpl::IsHidden() {
3622 return capturer_count_ == 0 && !should_normally_be_visible_; 3624 return capturer_count_ == 0 && !should_normally_be_visible_;
3623 } 3625 }
3624 3626
3627 RenderViewHostManager* WebContentsImpl::GetRenderManager() const {
3628 return frame_tree_.root()->render_manager();
3629 }
3630
3625 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { 3631 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() {
3626 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); 3632 return static_cast<RenderViewHostImpl*>(GetRenderViewHost());
3627 } 3633 }
3628 3634
3629 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { 3635 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const {
3630 return browser_plugin_guest_.get(); 3636 return browser_plugin_guest_.get();
3631 } 3637 }
3632 3638
3633 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { 3639 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) {
3634 CHECK(!browser_plugin_guest_); 3640 CHECK(!browser_plugin_guest_);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 } 3675 }
3670 3676
3671 void WebContentsImpl::OnFrameRemoved( 3677 void WebContentsImpl::OnFrameRemoved(
3672 RenderViewHostImpl* render_view_host, 3678 RenderViewHostImpl* render_view_host,
3673 int64 frame_id) { 3679 int64 frame_id) {
3674 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3680 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3675 FrameDetached(render_view_host, frame_id)); 3681 FrameDetached(render_view_host, frame_id));
3676 } 3682 }
3677 3683
3678 } // namespace content 3684 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698