| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1573 | 1573 |
| 1574 void WebContentsImpl::RenderViewForInterstitialPageCreated( | 1574 void WebContentsImpl::RenderViewForInterstitialPageCreated( |
| 1575 RenderViewHost* render_view_host) { | 1575 RenderViewHost* render_view_host) { |
| 1576 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1576 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1577 RenderViewForInterstitialPageCreated(render_view_host)); | 1577 RenderViewForInterstitialPageCreated(render_view_host)); |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 void WebContentsImpl::AttachInterstitialPage( | 1580 void WebContentsImpl::AttachInterstitialPage( |
| 1581 InterstitialPageImpl* interstitial_page) { | 1581 InterstitialPageImpl* interstitial_page) { |
| 1582 DCHECK(interstitial_page); | 1582 DCHECK(interstitial_page); |
| 1583 render_manager_.set_interstitial_page(interstitial_page); | 1583 GetRenderManager()->set_interstitial_page(interstitial_page); |
| 1584 | 1584 |
| 1585 // Cancel any visible dialogs so that they don't interfere with the | 1585 // Cancel any visible dialogs so that they don't interfere with the |
| 1586 // interstitial. | 1586 // interstitial. |
| 1587 if (dialog_manager_) | 1587 if (dialog_manager_) |
| 1588 dialog_manager_->CancelActiveAndPendingDialogs(this); | 1588 dialog_manager_->CancelActiveAndPendingDialogs(this); |
| 1589 | 1589 |
| 1590 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1590 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1591 DidAttachInterstitialPage()); | 1591 DidAttachInterstitialPage()); |
| 1592 } | 1592 } |
| 1593 | 1593 |
| 1594 void WebContentsImpl::DetachInterstitialPage() { | 1594 void WebContentsImpl::DetachInterstitialPage() { |
| 1595 if (GetInterstitialPage()) | 1595 if (GetInterstitialPage()) |
| 1596 render_manager_.remove_interstitial_page(); | 1596 GetRenderManager()->remove_interstitial_page(); |
| 1597 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1597 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 1598 DidDetachInterstitialPage()); | 1598 DidDetachInterstitialPage()); |
| 1599 } | 1599 } |
| 1600 | 1600 |
| 1601 bool WebContentsImpl::NavigateToEntry( | 1601 bool WebContentsImpl::NavigateToEntry( |
| 1602 const NavigationEntryImpl& entry, | 1602 const NavigationEntryImpl& entry, |
| 1603 NavigationController::ReloadType reload_type) { | 1603 NavigationController::ReloadType reload_type) { |
| 1604 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); | 1604 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); |
| 1605 | 1605 |
| 1606 // The renderer will reject IPC messages with URLs longer than | 1606 // The renderer will reject IPC messages with URLs longer than |
| 1607 // this limit, so don't attempt to navigate with a longer URL. | 1607 // this limit, so don't attempt to navigate with a longer URL. |
| 1608 if (entry.GetURL().spec().size() > kMaxURLChars) { | 1608 if (entry.GetURL().spec().size() > kMaxURLChars) { |
| 1609 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars | 1609 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars |
| 1610 << " characters."; | 1610 << " characters."; |
| 1611 return false; | 1611 return false; |
| 1612 } | 1612 } |
| 1613 | 1613 |
| 1614 RenderViewHostImpl* dest_render_view_host = | 1614 RenderViewHostImpl* dest_render_view_host = |
| 1615 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1615 static_cast<RenderViewHostImpl*>(GetRenderManager()->Navigate(entry)); |
| 1616 if (!dest_render_view_host) | 1616 if (!dest_render_view_host) |
| 1617 return false; // Unable to create the desired render view host. | 1617 return false; // Unable to create the desired render view host. |
| 1618 | 1618 |
| 1619 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1619 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
| 1620 // Double check that here. | 1620 // Double check that here. |
| 1621 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1621 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
| 1622 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1622 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
| 1623 bool is_allowed_in_web_ui_renderer = | 1623 bool is_allowed_in_web_ui_renderer = |
| 1624 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 1624 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
| 1625 GetBrowserContext(), entry.GetURL(), data_urls_allowed); | 1625 GetBrowserContext(), entry.GetURL(), data_urls_allowed); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 | 1664 |
| 1665 return true; | 1665 return true; |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 void WebContentsImpl::SetHistoryLengthAndPrune( | 1668 void WebContentsImpl::SetHistoryLengthAndPrune( |
| 1669 const SiteInstance* site_instance, | 1669 const SiteInstance* site_instance, |
| 1670 int history_length, | 1670 int history_length, |
| 1671 int32 minimum_page_id) { | 1671 int32 minimum_page_id) { |
| 1672 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site | 1672 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site |
| 1673 // navigations. Callers should ensure that this is the case. | 1673 // navigations. Callers should ensure that this is the case. |
| 1674 if (render_manager_.pending_render_view_host()) { | 1674 if (GetRenderManager()->pending_render_view_host()) { |
| 1675 NOTREACHED(); | 1675 NOTREACHED(); |
| 1676 return; | 1676 return; |
| 1677 } | 1677 } |
| 1678 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); | 1678 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); |
| 1679 if (!rvh) { | 1679 if (!rvh) { |
| 1680 NOTREACHED(); | 1680 NOTREACHED(); |
| 1681 return; | 1681 return; |
| 1682 } | 1682 } |
| 1683 if (site_instance && rvh->GetSiteInstance() != site_instance) { | 1683 if (site_instance && rvh->GetSiteInstance() != site_instance) { |
| 1684 NOTREACHED(); | 1684 NOTREACHED(); |
| 1685 return; | 1685 return; |
| 1686 } | 1686 } |
| 1687 Send(new ViewMsg_SetHistoryLengthAndPrune(GetRoutingID(), | 1687 Send(new ViewMsg_SetHistoryLengthAndPrune(GetRoutingID(), |
| 1688 history_length, | 1688 history_length, |
| 1689 minimum_page_id)); | 1689 minimum_page_id)); |
| 1690 } | 1690 } |
| 1691 | 1691 |
| 1692 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) { | 1692 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) { |
| 1693 if (ShowingInterstitialPage()) { | 1693 if (ShowingInterstitialPage()) { |
| 1694 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse); | 1694 GetRenderManager()->interstitial_page()->FocusThroughTabTraversal(reverse); |
| 1695 return; | 1695 return; |
| 1696 } | 1696 } |
| 1697 GetRenderViewHostImpl()->SetInitialFocus(reverse); | 1697 GetRenderViewHostImpl()->SetInitialFocus(reverse); |
| 1698 } | 1698 } |
| 1699 | 1699 |
| 1700 bool WebContentsImpl::ShowingInterstitialPage() const { | 1700 bool WebContentsImpl::ShowingInterstitialPage() const { |
| 1701 return render_manager_.interstitial_page() != NULL; | 1701 return GetRenderManager()->interstitial_page() != NULL; |
| 1702 } | 1702 } |
| 1703 | 1703 |
| 1704 InterstitialPage* WebContentsImpl::GetInterstitialPage() const { | 1704 InterstitialPage* WebContentsImpl::GetInterstitialPage() const { |
| 1705 return render_manager_.interstitial_page(); | 1705 return GetRenderManager()->interstitial_page(); |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 bool WebContentsImpl::IsSavable() { | 1708 bool WebContentsImpl::IsSavable() { |
| 1709 // WebKit creates Document object when MIME type is application/xhtml+xml, | 1709 // WebKit creates Document object when MIME type is application/xhtml+xml, |
| 1710 // so we also support this MIME type. | 1710 // so we also support this MIME type. |
| 1711 return contents_mime_type_ == "text/html" || | 1711 return contents_mime_type_ == "text/html" || |
| 1712 contents_mime_type_ == "text/xml" || | 1712 contents_mime_type_ == "text/xml" || |
| 1713 contents_mime_type_ == "application/xhtml+xml" || | 1713 contents_mime_type_ == "application/xhtml+xml" || |
| 1714 contents_mime_type_ == "text/plain" || | 1714 contents_mime_type_ == "text/plain" || |
| 1715 contents_mime_type_ == "text/css" || | 1715 contents_mime_type_ == "text/css" || |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 // Because this will not tear down the interstitial properly, if "back" is | 2087 // Because this will not tear down the interstitial properly, if "back" is |
| 2088 // back to another tab type, the interstitial will still be somewhat alive | 2088 // back to another tab type, the interstitial will still be somewhat alive |
| 2089 // in the previous tab type. If you navigate somewhere that activates the | 2089 // in the previous tab type. If you navigate somewhere that activates the |
| 2090 // tab with the interstitial again, you'll see a flash before the new load | 2090 // tab with the interstitial again, you'll see a flash before the new load |
| 2091 // commits of the interstitial page. | 2091 // commits of the interstitial page. |
| 2092 if (ShowingInterstitialPage()) { | 2092 if (ShowingInterstitialPage()) { |
| 2093 LOG(WARNING) << "Discarding message during interstitial."; | 2093 LOG(WARNING) << "Discarding message during interstitial."; |
| 2094 return; | 2094 return; |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 render_manager_.RendererAbortedProvisionalLoad(render_view_host); | 2097 GetRenderManager()->RendererAbortedProvisionalLoad(render_view_host); |
| 2098 } | 2098 } |
| 2099 | 2099 |
| 2100 // Do not usually clear the pending entry if one exists, so that the user's | 2100 // Do not usually clear the pending entry if one exists, so that the user's |
| 2101 // typed URL is not lost when a navigation fails or is aborted. However, in | 2101 // typed URL is not lost when a navigation fails or is aborted. However, in |
| 2102 // cases that we don't show the pending entry (e.g., renderer-initiated | 2102 // cases that we don't show the pending entry (e.g., renderer-initiated |
| 2103 // navigations in an existing tab), we don't keep it around. That prevents | 2103 // navigations in an existing tab), we don't keep it around. That prevents |
| 2104 // spoofs on in-page navigations that don't go through | 2104 // spoofs on in-page navigations that don't go through |
| 2105 // DidStartProvisionalLoadForFrame. | 2105 // DidStartProvisionalLoadForFrame. |
| 2106 // In general, we allow the view to clear the pending entry and typed URL if | 2106 // In general, we allow the view to clear the pending entry and typed URL if |
| 2107 // the user requests (e.g., hitting Escape with focus in the address bar). | 2107 // 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 Loading... |
| 2494 if (is_loading == is_loading_) | 2494 if (is_loading == is_loading_) |
| 2495 return; | 2495 return; |
| 2496 | 2496 |
| 2497 if (!is_loading) { | 2497 if (!is_loading) { |
| 2498 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2498 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
| 2499 load_state_host_.clear(); | 2499 load_state_host_.clear(); |
| 2500 upload_size_ = 0; | 2500 upload_size_ = 0; |
| 2501 upload_position_ = 0; | 2501 upload_position_ = 0; |
| 2502 } | 2502 } |
| 2503 | 2503 |
| 2504 render_manager_.SetIsLoading(is_loading); | 2504 GetRenderManager()->SetIsLoading(is_loading); |
| 2505 | 2505 |
| 2506 is_loading_ = is_loading; | 2506 is_loading_ = is_loading; |
| 2507 waiting_for_response_ = is_loading; | 2507 waiting_for_response_ = is_loading; |
| 2508 | 2508 |
| 2509 if (delegate_) | 2509 if (delegate_) |
| 2510 delegate_->LoadingStateChanged(this); | 2510 delegate_->LoadingStateChanged(this); |
| 2511 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | 2511 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); |
| 2512 | 2512 |
| 2513 const char* url = | 2513 const char* url = |
| 2514 (details ? details->url.possibly_invalid_spec().c_str() : "NULL"); | 2514 (details ? details->url.possibly_invalid_spec().c_str() : "NULL"); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2685 FOR_EACH_OBSERVER( | 2685 FOR_EACH_OBSERVER( |
| 2686 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); | 2686 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); |
| 2687 } | 2687 } |
| 2688 | 2688 |
| 2689 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { | 2689 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { |
| 2690 return render_view_host_delegate_view_; | 2690 return render_view_host_delegate_view_; |
| 2691 } | 2691 } |
| 2692 | 2692 |
| 2693 RenderViewHostDelegate::RendererManagement* | 2693 RenderViewHostDelegate::RendererManagement* |
| 2694 WebContentsImpl::GetRendererManagementDelegate() { | 2694 WebContentsImpl::GetRendererManagementDelegate() { |
| 2695 return &render_manager_; | 2695 return GetRenderManager(); |
| 2696 } | 2696 } |
| 2697 | 2697 |
| 2698 RendererPreferences WebContentsImpl::GetRendererPrefs( | 2698 RendererPreferences WebContentsImpl::GetRendererPrefs( |
| 2699 BrowserContext* browser_context) const { | 2699 BrowserContext* browser_context) const { |
| 2700 return renderer_preferences_; | 2700 return renderer_preferences_; |
| 2701 } | 2701 } |
| 2702 | 2702 |
| 2703 WebContents* WebContentsImpl::GetAsWebContents() { | 2703 WebContents* WebContentsImpl::GetAsWebContents() { |
| 2704 return this; | 2704 return this; |
| 2705 } | 2705 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2725 if (delegate_) | 2725 if (delegate_) |
| 2726 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 2726 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
| 2727 | 2727 |
| 2728 NotificationService::current()->Notify( | 2728 NotificationService::current()->Notify( |
| 2729 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2729 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 2730 Source<WebContents>(this), | 2730 Source<WebContents>(this), |
| 2731 Details<RenderViewHost>(render_view_host)); | 2731 Details<RenderViewHost>(render_view_host)); |
| 2732 | 2732 |
| 2733 // When we're creating views, we're still doing initial setup, so we always | 2733 // When we're creating views, we're still doing initial setup, so we always |
| 2734 // use the pending Web UI rather than any possibly existing committed one. | 2734 // use the pending Web UI rather than any possibly existing committed one. |
| 2735 if (render_manager_.pending_web_ui()) | 2735 if (GetRenderManager()->pending_web_ui()) |
| 2736 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); | 2736 GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host); |
| 2737 | 2737 |
| 2738 NavigationEntry* entry = controller_.GetPendingEntry(); | 2738 NavigationEntry* entry = controller_.GetPendingEntry(); |
| 2739 if (entry && entry->IsViewSourceMode()) { | 2739 if (entry && entry->IsViewSourceMode()) { |
| 2740 // Put the renderer in view source mode. | 2740 // Put the renderer in view source mode. |
| 2741 render_view_host->Send( | 2741 render_view_host->Send( |
| 2742 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); | 2742 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); |
| 2743 } | 2743 } |
| 2744 | 2744 |
| 2745 view_->RenderViewCreated(render_view_host); | 2745 view_->RenderViewCreated(render_view_host); |
| 2746 | 2746 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2789 SetIsCrashed(status, error_code); | 2789 SetIsCrashed(status, error_code); |
| 2790 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); | 2790 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); |
| 2791 | 2791 |
| 2792 FOR_EACH_OBSERVER(WebContentsObserver, | 2792 FOR_EACH_OBSERVER(WebContentsObserver, |
| 2793 observers_, | 2793 observers_, |
| 2794 RenderProcessGone(GetCrashedStatus())); | 2794 RenderProcessGone(GetCrashedStatus())); |
| 2795 } | 2795 } |
| 2796 | 2796 |
| 2797 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 2797 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| 2798 ClearPowerSaveBlockers(rvh); | 2798 ClearPowerSaveBlockers(rvh); |
| 2799 render_manager_.RenderViewDeleted(rvh); | 2799 GetRenderManager()->RenderViewDeleted(rvh); |
| 2800 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); | 2800 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 void WebContentsImpl::DidGetResourceResponseStart( | 2803 void WebContentsImpl::DidGetResourceResponseStart( |
| 2804 const ResourceRequestDetails& details) { | 2804 const ResourceRequestDetails& details) { |
| 2805 controller_.ssl_manager()->DidStartResourceResponse(details); | 2805 controller_.ssl_manager()->DidStartResourceResponse(details); |
| 2806 | 2806 |
| 2807 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2807 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 2808 DidGetResourceResponseStart(details)); | 2808 DidGetResourceResponseStart(details)); |
| 2809 | 2809 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2840 if (PageTransitionIsMainFrame(params.transition)) { | 2840 if (PageTransitionIsMainFrame(params.transition)) { |
| 2841 // When overscroll navigation gesture is enabled, a screenshot of the page | 2841 // When overscroll navigation gesture is enabled, a screenshot of the page |
| 2842 // in its current state is taken so that it can be used during the | 2842 // in its current state is taken so that it can be used during the |
| 2843 // nav-gesture. It is necessary to take the screenshot here, before calling | 2843 // nav-gesture. It is necessary to take the screenshot here, before calling |
| 2844 // RenderViewHostManager::DidNavigateMainFrame, because that can change | 2844 // RenderViewHostManager::DidNavigateMainFrame, because that can change |
| 2845 // WebContents::GetRenderViewHost to return the new host, instead of the one | 2845 // WebContents::GetRenderViewHost to return the new host, instead of the one |
| 2846 // that may have just been swapped out. | 2846 // that may have just been swapped out. |
| 2847 if (delegate_ && delegate_->CanOverscrollContent()) | 2847 if (delegate_ && delegate_->CanOverscrollContent()) |
| 2848 controller_.TakeScreenshot(); | 2848 controller_.TakeScreenshot(); |
| 2849 | 2849 |
| 2850 render_manager_.DidNavigateMainFrame(rvh); | 2850 GetRenderManager()->DidNavigateMainFrame(rvh); |
| 2851 } | 2851 } |
| 2852 | 2852 |
| 2853 // Update the site of the SiteInstance if it doesn't have one yet, unless | 2853 // Update the site of the SiteInstance if it doesn't have one yet, unless |
| 2854 // assigning a site is not necessary for this URL. In that case, the | 2854 // assigning a site is not necessary for this URL. In that case, the |
| 2855 // SiteInstance can still be considered unused until a navigation to a real | 2855 // SiteInstance can still be considered unused until a navigation to a real |
| 2856 // page. | 2856 // page. |
| 2857 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && | 2857 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && |
| 2858 ShouldAssignSiteForURL(params.url)) { | 2858 ShouldAssignSiteForURL(params.url)) { |
| 2859 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); | 2859 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); |
| 2860 } | 2860 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2925 } | 2925 } |
| 2926 } | 2926 } |
| 2927 DidNavigateAnyFramePostCommit(rvh, details, params); | 2927 DidNavigateAnyFramePostCommit(rvh, details, params); |
| 2928 } | 2928 } |
| 2929 | 2929 |
| 2930 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 2930 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
| 2931 int32 page_id, | 2931 int32 page_id, |
| 2932 const PageState& page_state) { | 2932 const PageState& page_state) { |
| 2933 // Ensure that this state update comes from either the active RVH or one of | 2933 // Ensure that this state update comes from either the active RVH or one of |
| 2934 // the swapped out RVHs. We don't expect to hear from any other RVHs. | 2934 // the swapped out RVHs. We don't expect to hear from any other RVHs. |
| 2935 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsOnSwappedOutList(rvh)); | 2935 DCHECK(rvh == GetRenderViewHost() || |
| 2936 GetRenderManager()->IsOnSwappedOutList(rvh)); |
| 2936 | 2937 |
| 2937 // We must be prepared to handle state updates for any page, these occur | 2938 // We must be prepared to handle state updates for any page, these occur |
| 2938 // when the user is scrolling and entering form data, as well as when we're | 2939 // when the user is scrolling and entering form data, as well as when we're |
| 2939 // leaving a page, in which case our state may have already been moved to | 2940 // leaving a page, in which case our state may have already been moved to |
| 2940 // the next page. The navigation controller will look up the appropriate | 2941 // the next page. The navigation controller will look up the appropriate |
| 2941 // NavigationEntry and update it when it is notified via the delegate. | 2942 // NavigationEntry and update it when it is notified via the delegate. |
| 2942 | 2943 |
| 2943 int entry_index = controller_.GetEntryIndexWithPageID( | 2944 int entry_index = controller_.GetEntryIndexWithPageID( |
| 2944 rvh->GetSiteInstance(), page_id); | 2945 rvh->GetSiteInstance(), page_id); |
| 2945 if (entry_index < 0) | 2946 if (entry_index < 0) |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3008 // Ignore this if it comes from a RenderViewHost that we aren't showing. | 3009 // Ignore this if it comes from a RenderViewHost that we aren't showing. |
| 3009 if (delegate_ && rvh == GetRenderViewHost()) | 3010 if (delegate_ && rvh == GetRenderViewHost()) |
| 3010 delegate_->CloseContents(this); | 3011 delegate_->CloseContents(this); |
| 3011 } | 3012 } |
| 3012 | 3013 |
| 3013 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { | 3014 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { |
| 3014 if (delegate_ && rvh == GetRenderViewHost()) | 3015 if (delegate_ && rvh == GetRenderViewHost()) |
| 3015 delegate_->SwappedOut(this); | 3016 delegate_->SwappedOut(this); |
| 3016 | 3017 |
| 3017 // Allow the navigation to proceed. | 3018 // Allow the navigation to proceed. |
| 3018 render_manager_.SwappedOut(rvh); | 3019 GetRenderManager()->SwappedOut(rvh); |
| 3019 } | 3020 } |
| 3020 | 3021 |
| 3021 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3022 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
| 3022 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3023 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
| 3023 delegate_->MoveContents(this, new_bounds); | 3024 delegate_->MoveContents(this, new_bounds); |
| 3024 } | 3025 } |
| 3025 | 3026 |
| 3026 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { | 3027 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { |
| 3027 SetIsLoading(render_view_host, true, NULL); | 3028 SetIsLoading(render_view_host, true, NULL); |
| 3028 } | 3029 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3066 if (opener_) { | 3067 if (opener_) { |
| 3067 // Clear our opener so that future cross-process navigations don't have an | 3068 // Clear our opener so that future cross-process navigations don't have an |
| 3068 // opener assigned. | 3069 // opener assigned. |
| 3069 RemoveDestructionObserver(opener_); | 3070 RemoveDestructionObserver(opener_); |
| 3070 opener_ = NULL; | 3071 opener_ = NULL; |
| 3071 } | 3072 } |
| 3072 | 3073 |
| 3073 // Notify all swapped out RenderViewHosts for this tab. This is important | 3074 // Notify all swapped out RenderViewHosts for this tab. This is important |
| 3074 // in case we go back to them, or if another window in those processes tries | 3075 // in case we go back to them, or if another window in those processes tries |
| 3075 // to access window.opener. | 3076 // to access window.opener. |
| 3076 render_manager_.DidDisownOpener(rvh); | 3077 GetRenderManager()->DidDisownOpener(rvh); |
| 3077 } | 3078 } |
| 3078 | 3079 |
| 3079 void WebContentsImpl::DidAccessInitialDocument() { | 3080 void WebContentsImpl::DidAccessInitialDocument() { |
| 3080 // Update the URL display. | 3081 // Update the URL display. |
| 3081 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | 3082 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); |
| 3082 } | 3083 } |
| 3083 | 3084 |
| 3084 void WebContentsImpl::DocumentAvailableInMainFrame( | 3085 void WebContentsImpl::DocumentAvailableInMainFrame( |
| 3085 RenderViewHost* render_view_host) { | 3086 RenderViewHost* render_view_host) { |
| 3086 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3087 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3141 dest_url = GURL(kAboutBlankURL); | 3142 dest_url = GURL(kAboutBlankURL); |
| 3142 | 3143 |
| 3143 OpenURLParams params(dest_url, referrer, source_frame_id, disposition, | 3144 OpenURLParams params(dest_url, referrer, source_frame_id, disposition, |
| 3144 page_transition, true /* is_renderer_initiated */); | 3145 page_transition, true /* is_renderer_initiated */); |
| 3145 if (redirect_chain.size() > 0) | 3146 if (redirect_chain.size() > 0) |
| 3146 params.redirect_chain = redirect_chain; | 3147 params.redirect_chain = redirect_chain; |
| 3147 params.transferred_global_request_id = old_request_id; | 3148 params.transferred_global_request_id = old_request_id; |
| 3148 params.should_replace_current_entry = should_replace_current_entry; | 3149 params.should_replace_current_entry = should_replace_current_entry; |
| 3149 params.user_gesture = user_gesture; | 3150 params.user_gesture = user_gesture; |
| 3150 | 3151 |
| 3151 if (render_manager_.web_ui()) { | 3152 if (GetRenderManager()->web_ui()) { |
| 3152 // Web UI pages sometimes want to override the page transition type for | 3153 // Web UI pages sometimes want to override the page transition type for |
| 3153 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 3154 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
| 3154 // automatically generated suggestions). We don't override other types | 3155 // automatically generated suggestions). We don't override other types |
| 3155 // like TYPED because they have different implications (e.g., autocomplete). | 3156 // like TYPED because they have different implications (e.g., autocomplete). |
| 3156 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) | 3157 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) |
| 3157 params.transition = render_manager_.web_ui()->GetLinkTransitionType(); | 3158 params.transition = GetRenderManager()->web_ui()->GetLinkTransitionType(); |
| 3158 | 3159 |
| 3159 // Note also that we hide the referrer for Web UI pages. We don't really | 3160 // Note also that we hide the referrer for Web UI pages. We don't really |
| 3160 // want web sites to see a referrer of "chrome://blah" (and some | 3161 // want web sites to see a referrer of "chrome://blah" (and some |
| 3161 // chrome: URLs might have search terms or other stuff we don't want to | 3162 // chrome: URLs might have search terms or other stuff we don't want to |
| 3162 // send to the site), so we send no referrer. | 3163 // send to the site), so we send no referrer. |
| 3163 params.referrer = Referrer(); | 3164 params.referrer = Referrer(); |
| 3164 | 3165 |
| 3165 // Navigations in Web UI pages count as browser-initiated navigations. | 3166 // Navigations in Web UI pages count as browser-initiated navigations. |
| 3166 params.is_renderer_initiated = false; | 3167 params.is_renderer_initiated = false; |
| 3167 | 3168 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 } | 3352 } |
| 3352 | 3353 |
| 3353 WebPreferences WebContentsImpl::GetWebkitPrefs() { | 3354 WebPreferences WebContentsImpl::GetWebkitPrefs() { |
| 3354 // We want to base the page config off of the actual URL, rather than the | 3355 // We want to base the page config off of the actual URL, rather than the |
| 3355 // virtual URL. | 3356 // virtual URL. |
| 3356 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, | 3357 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, |
| 3357 // as it is deprecated and can be out of sync with GetRenderViewHost(). | 3358 // as it is deprecated and can be out of sync with GetRenderViewHost(). |
| 3358 GURL url = controller_.GetActiveEntry() | 3359 GURL url = controller_.GetActiveEntry() |
| 3359 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3360 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
| 3360 | 3361 |
| 3361 return render_manager_.current_host()->GetWebkitPrefs(url); | 3362 return GetRenderManager()->current_host()->GetWebkitPrefs(url); |
| 3362 } | 3363 } |
| 3363 | 3364 |
| 3364 int WebContentsImpl::CreateSwappedOutRenderView( | 3365 int WebContentsImpl::CreateSwappedOutRenderView( |
| 3365 SiteInstance* instance) { | 3366 SiteInstance* instance) { |
| 3366 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, | 3367 return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE, |
| 3367 true, true); | 3368 true, true); |
| 3368 } | 3369 } |
| 3369 | 3370 |
| 3370 void WebContentsImpl::OnUserGesture() { | 3371 void WebContentsImpl::OnUserGesture() { |
| 3371 // Notify observers. | 3372 // Notify observers. |
| 3372 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3373 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
| 3373 | 3374 |
| 3374 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3375 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 3375 if (rdh) // NULL in unittests. | 3376 if (rdh) // NULL in unittests. |
| 3376 rdh->OnUserGesture(this); | 3377 rdh->OnUserGesture(this); |
| 3377 } | 3378 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3394 // since the event may be a result of the renderer sitting on a breakpoint. | 3395 // since the event may be a result of the renderer sitting on a breakpoint. |
| 3395 // See http://crbug.com/65458 | 3396 // See http://crbug.com/65458 |
| 3396 if (DevToolsAgentHost::IsDebuggerAttached(this)) | 3397 if (DevToolsAgentHost::IsDebuggerAttached(this)) |
| 3397 return; | 3398 return; |
| 3398 | 3399 |
| 3399 if (is_during_beforeunload || is_during_unload) { | 3400 if (is_during_beforeunload || is_during_unload) { |
| 3400 // Hang occurred while firing the beforeunload/unload handler. | 3401 // Hang occurred while firing the beforeunload/unload handler. |
| 3401 // Pretend the handler fired so tab closing continues as if it had. | 3402 // Pretend the handler fired so tab closing continues as if it had. |
| 3402 rvhi->set_sudden_termination_allowed(true); | 3403 rvhi->set_sudden_termination_allowed(true); |
| 3403 | 3404 |
| 3404 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) | 3405 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) |
| 3405 return; | 3406 return; |
| 3406 | 3407 |
| 3407 // If the tab hangs in the beforeunload/unload handler there's really | 3408 // If the tab hangs in the beforeunload/unload handler there's really |
| 3408 // nothing we can do to recover. If the hang is in the beforeunload handler, | 3409 // nothing we can do to recover. If the hang is in the beforeunload handler, |
| 3409 // pretend the beforeunload listeners have all fired and allow the delegate | 3410 // pretend the beforeunload listeners have all fired and allow the delegate |
| 3410 // to continue closing; the user will not have the option of cancelling the | 3411 // to continue closing; the user will not have the option of cancelling the |
| 3411 // close. Otherwise, pretend the unload listeners have all fired and close | 3412 // close. Otherwise, pretend the unload listeners have all fired and close |
| 3412 // the tab. | 3413 // the tab. |
| 3413 bool close = true; | 3414 bool close = true; |
| 3414 if (is_during_beforeunload) { | 3415 if (is_during_beforeunload) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3511 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { | 3512 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { |
| 3512 int opener_route_id = MSG_ROUTING_NONE; | 3513 int opener_route_id = MSG_ROUTING_NONE; |
| 3513 | 3514 |
| 3514 // If this tab has an opener, ensure it has a RenderView in the given | 3515 // If this tab has an opener, ensure it has a RenderView in the given |
| 3515 // SiteInstance as well. | 3516 // SiteInstance as well. |
| 3516 if (opener_) | 3517 if (opener_) |
| 3517 opener_route_id = opener_->CreateOpenerRenderViews(instance); | 3518 opener_route_id = opener_->CreateOpenerRenderViews(instance); |
| 3518 | 3519 |
| 3519 // If any of the renderers (current, pending, or swapped out) for this | 3520 // If any of the renderers (current, pending, or swapped out) for this |
| 3520 // WebContents has the same SiteInstance, use it. | 3521 // WebContents has the same SiteInstance, use it. |
| 3521 if (render_manager_.current_host()->GetSiteInstance() == instance) | 3522 if (GetRenderManager()->current_host()->GetSiteInstance() == instance) |
| 3522 return render_manager_.current_host()->GetRoutingID(); | 3523 return GetRenderManager()->current_host()->GetRoutingID(); |
| 3523 | 3524 |
| 3524 if (render_manager_.pending_render_view_host() && | 3525 if (GetRenderManager()->pending_render_view_host() && |
| 3525 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) | 3526 GetRenderManager()->pending_render_view_host()->GetSiteInstance() == |
| 3526 return render_manager_.pending_render_view_host()->GetRoutingID(); | 3527 instance) |
| 3528 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
| 3527 | 3529 |
| 3528 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( | 3530 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
| 3529 instance); | 3531 instance); |
| 3530 if (rvh) | 3532 if (rvh) |
| 3531 return rvh->GetRoutingID(); | 3533 return rvh->GetRoutingID(); |
| 3532 | 3534 |
| 3533 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3535 // Create a swapped out RenderView in the given SiteInstance if none exists, |
| 3534 // setting its opener to the given route_id. Return the new view's route_id. | 3536 // setting its opener to the given route_id. Return the new view's route_id. |
| 3535 return render_manager_.CreateRenderView(instance, opener_route_id, | 3537 return GetRenderManager()->CreateRenderView(instance, opener_route_id, |
| 3536 true, true); | 3538 true, true); |
| 3537 } | 3539 } |
| 3538 | 3540 |
| 3539 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3541 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
| 3540 return GetController(); | 3542 return GetController(); |
| 3541 } | 3543 } |
| 3542 | 3544 |
| 3543 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3545 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
| 3544 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3546 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
| 3545 } | 3547 } |
| 3546 | 3548 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3617 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); | 3619 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(rvh); |
| 3618 // Can be NULL during tests. | 3620 // Can be NULL during tests. |
| 3619 if (rwh_view) | 3621 if (rwh_view) |
| 3620 rwh_view->SetSize(GetView()->GetContainerSize()); | 3622 rwh_view->SetSize(GetView()->GetContainerSize()); |
| 3621 } | 3623 } |
| 3622 | 3624 |
| 3623 bool WebContentsImpl::IsHidden() { | 3625 bool WebContentsImpl::IsHidden() { |
| 3624 return capturer_count_ == 0 && !should_normally_be_visible_; | 3626 return capturer_count_ == 0 && !should_normally_be_visible_; |
| 3625 } | 3627 } |
| 3626 | 3628 |
| 3629 RenderViewHostManager* WebContentsImpl::GetRenderManager() const { |
| 3630 return frame_tree_.root()->render_manager(); |
| 3631 } |
| 3632 |
| 3627 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 3633 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
| 3628 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 3634 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
| 3629 } | 3635 } |
| 3630 | 3636 |
| 3631 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { | 3637 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() const { |
| 3632 return browser_plugin_guest_.get(); | 3638 return browser_plugin_guest_.get(); |
| 3633 } | 3639 } |
| 3634 | 3640 |
| 3635 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { | 3641 void WebContentsImpl::SetBrowserPluginGuest(BrowserPluginGuest* guest) { |
| 3636 CHECK(!browser_plugin_guest_); | 3642 CHECK(!browser_plugin_guest_); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3671 } | 3677 } |
| 3672 | 3678 |
| 3673 void WebContentsImpl::OnFrameRemoved( | 3679 void WebContentsImpl::OnFrameRemoved( |
| 3674 RenderViewHostImpl* render_view_host, | 3680 RenderViewHostImpl* render_view_host, |
| 3675 int64 frame_id) { | 3681 int64 frame_id) { |
| 3676 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3682 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3677 FrameDetached(render_view_host, frame_id)); | 3683 FrameDetached(render_view_host, frame_id)); |
| 3678 } | 3684 } |
| 3679 | 3685 |
| 3680 } // namespace content | 3686 } // namespace content |
| OLD | NEW |