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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); | 213 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); |
214 params->current_history_list_offset = | 214 params->current_history_list_offset = |
215 controller.GetLastCommittedEntryIndex(); | 215 controller.GetLastCommittedEntryIndex(); |
216 params->current_history_list_length = controller.GetEntryCount(); | 216 params->current_history_list_length = controller.GetEntryCount(); |
217 } | 217 } |
218 params->url = entry.GetURL(); | 218 params->url = entry.GetURL(); |
219 if (!entry.GetBaseURLForDataURL().is_empty()) { | 219 if (!entry.GetBaseURLForDataURL().is_empty()) { |
220 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); | 220 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); |
221 params->history_url_for_data_url = entry.GetVirtualURL(); | 221 params->history_url_for_data_url = entry.GetVirtualURL(); |
222 } | 222 } |
| 223 |
| 224 // TODO(creis): Store the renderer-specific frame ID on params. We'll |
| 225 // eventually use the RenderFrameHost routing ID, but for now we may need to |
| 226 // search the RenderViewHost's frame_id_map. |
| 227 //int64 frame_id = -1; |
| 228 //params->frame_id = frame_id; |
| 229 |
223 params->referrer = entry.GetReferrer(); | 230 params->referrer = entry.GetReferrer(); |
224 params->transition = entry.GetTransitionType(); | 231 params->transition = entry.GetTransitionType(); |
225 params->page_state = entry.GetPageState(); | 232 params->page_state = entry.GetPageState(); |
226 params->navigation_type = | 233 params->navigation_type = |
227 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); | 234 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); |
228 params->request_time = base::Time::Now(); | 235 params->request_time = base::Time::Now(); |
229 params->extra_headers = entry.extra_headers(); | 236 params->extra_headers = entry.extra_headers(); |
230 params->transferred_request_child_id = | 237 params->transferred_request_child_id = |
231 entry.transferred_global_request_id().child_id; | 238 entry.transferred_global_request_id().child_id; |
232 params->transferred_request_request_id = | 239 params->transferred_request_request_id = |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 WebContentsImpl::WebContentsImpl( | 341 WebContentsImpl::WebContentsImpl( |
335 BrowserContext* browser_context, | 342 BrowserContext* browser_context, |
336 WebContentsImpl* opener) | 343 WebContentsImpl* opener) |
337 : delegate_(NULL), | 344 : delegate_(NULL), |
338 controller_(this, browser_context), | 345 controller_(this, browser_context), |
339 render_view_host_delegate_view_(NULL), | 346 render_view_host_delegate_view_(NULL), |
340 opener_(opener), | 347 opener_(opener), |
341 #if defined(OS_WIN) && defined(USE_AURA) | 348 #if defined(OS_WIN) && defined(USE_AURA) |
342 accessible_parent_(NULL), | 349 accessible_parent_(NULL), |
343 #endif | 350 #endif |
344 render_manager_(this, this, this), | 351 frame_tree_(this, this, this), |
345 is_loading_(false), | 352 is_loading_(false), |
346 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 353 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
347 crashed_error_code_(0), | 354 crashed_error_code_(0), |
348 waiting_for_response_(false), | 355 waiting_for_response_(false), |
349 load_state_(net::LOAD_STATE_IDLE, string16()), | 356 load_state_(net::LOAD_STATE_IDLE, string16()), |
350 upload_size_(0), | 357 upload_size_(0), |
351 upload_position_(0), | 358 upload_position_(0), |
352 displayed_insecure_content_(false), | 359 displayed_insecure_content_(false), |
353 capturer_count_(0), | 360 capturer_count_(0), |
354 should_normally_be_visible_(true), | 361 should_normally_be_visible_(true), |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 #if defined(OS_WIN) && !defined(USE_AURA) | 407 #if defined(OS_WIN) && !defined(USE_AURA) |
401 // If we still have a window handle, destroy it. GetNativeView can return | 408 // If we still have a window handle, destroy it. GetNativeView can return |
402 // NULL if this contents was part of a window that closed. | 409 // NULL if this contents was part of a window that closed. |
403 if (view_->GetNativeView()) { | 410 if (view_->GetNativeView()) { |
404 RenderViewHost* host = GetRenderViewHost(); | 411 RenderViewHost* host = GetRenderViewHost(); |
405 if (host && host->GetView()) | 412 if (host && host->GetView()) |
406 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); | 413 RenderWidgetHostViewPort::FromRWHV(host->GetView())->WillWmDestroy(); |
407 } | 414 } |
408 #endif | 415 #endif |
409 | 416 |
410 RenderViewHost* pending_rvh = render_manager_.pending_render_view_host(); | 417 RenderViewHost* pending_rvh = GetRenderManager()->pending_render_view_host(); |
411 if (pending_rvh) { | 418 if (pending_rvh) { |
412 FOR_EACH_OBSERVER(WebContentsObserver, | 419 FOR_EACH_OBSERVER(WebContentsObserver, |
413 observers_, | 420 observers_, |
414 RenderViewDeleted(pending_rvh)); | 421 RenderViewDeleted(pending_rvh)); |
415 } | 422 } |
416 | 423 |
417 FOR_EACH_OBSERVER(WebContentsObserver, | 424 FOR_EACH_OBSERVER(WebContentsObserver, |
418 observers_, | 425 observers_, |
419 RenderViewDeleted(render_manager_.current_host())); | 426 RenderViewDeleted(GetRenderManager()->current_host())); |
420 | 427 |
421 FOR_EACH_OBSERVER(WebContentsObserver, | 428 FOR_EACH_OBSERVER(WebContentsObserver, |
422 observers_, | 429 observers_, |
423 WebContentsImplDestroyed()); | 430 WebContentsImplDestroyed()); |
424 | 431 |
425 SetDelegate(NULL); | 432 SetDelegate(NULL); |
426 | 433 |
427 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), | 434 STLDeleteContainerPairSecondPointers(destruction_observers_.begin(), |
428 destruction_observers_.end()); | 435 destruction_observers_.end()); |
429 } | 436 } |
(...skipping 27 matching lines...) Expand all Loading... |
457 | 464 |
458 // We are instantiating a WebContents for browser plugin. Set its subframe bit | 465 // We are instantiating a WebContents for browser plugin. Set its subframe bit |
459 // to true. | 466 // to true. |
460 static_cast<RenderViewHostImpl*>( | 467 static_cast<RenderViewHostImpl*>( |
461 new_contents->GetRenderViewHost())->set_is_subframe(true); | 468 new_contents->GetRenderViewHost())->set_is_subframe(true); |
462 | 469 |
463 return new_contents->browser_plugin_guest_.get(); | 470 return new_contents->browser_plugin_guest_.get(); |
464 } | 471 } |
465 | 472 |
466 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 473 RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
467 return &render_manager_; | 474 return GetRenderManager(); |
468 } | 475 } |
469 | 476 |
470 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 477 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
471 const IPC::Message& message) { | 478 const IPC::Message& message) { |
472 if (GetWebUI() && | 479 if (GetWebUI() && |
473 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { | 480 static_cast<WebUIImpl*>(GetWebUI())->OnMessageReceived(message)) { |
474 return true; | 481 return true; |
475 } | 482 } |
476 | 483 |
477 ObserverListBase<WebContentsObserver>::Iterator it(observers_); | 484 ObserverListBase<WebContentsObserver>::Iterator it(observers_); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 delegate_ = delegate; | 598 delegate_ = delegate; |
592 if (delegate_) { | 599 if (delegate_) { |
593 delegate_->Attach(this); | 600 delegate_->Attach(this); |
594 // Ensure the visible RVH reflects the new delegate's preferences. | 601 // Ensure the visible RVH reflects the new delegate's preferences. |
595 if (view_) | 602 if (view_) |
596 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); | 603 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); |
597 } | 604 } |
598 } | 605 } |
599 | 606 |
600 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { | 607 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { |
601 RenderViewHostImpl* host = render_manager_.current_host(); | 608 RenderViewHostImpl* host = GetRenderManager()->current_host(); |
602 return host ? host->GetProcess() : NULL; | 609 return host ? host->GetProcess() : NULL; |
603 } | 610 } |
604 | 611 |
605 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { | 612 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { |
606 return render_manager_.current_host(); | 613 return GetRenderManager()->current_host(); |
607 } | 614 } |
608 | 615 |
609 void WebContentsImpl::GetRenderViewHostAtPosition( | 616 void WebContentsImpl::GetRenderViewHostAtPosition( |
610 int x, | 617 int x, |
611 int y, | 618 int y, |
612 const base::Callback<void(RenderViewHost*, int, int)>& callback) { | 619 const base::Callback<void(RenderViewHost*, int, int)>& callback) { |
613 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder(); | 620 BrowserPluginEmbedder* embedder = GetBrowserPluginEmbedder(); |
614 if (embedder) | 621 if (embedder) |
615 embedder->GetRenderViewHostAtPosition(x, y, callback); | 622 embedder->GetRenderViewHostAtPosition(x, y, callback); |
616 else | 623 else |
(...skipping 19 matching lines...) Expand all Loading... |
636 return MSG_ROUTING_NONE; | 643 return MSG_ROUTING_NONE; |
637 | 644 |
638 return GetRenderViewHost()->GetRoutingID(); | 645 return GetRenderViewHost()->GetRoutingID(); |
639 } | 646 } |
640 | 647 |
641 int WebContentsImpl::GetFullscreenWidgetRoutingID() const { | 648 int WebContentsImpl::GetFullscreenWidgetRoutingID() const { |
642 return fullscreen_widget_routing_id_; | 649 return fullscreen_widget_routing_id_; |
643 } | 650 } |
644 | 651 |
645 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { | 652 RenderWidgetHostView* WebContentsImpl::GetRenderWidgetHostView() const { |
646 return render_manager_.GetRenderWidgetHostView(); | 653 return GetRenderManager()->GetRenderWidgetHostView(); |
647 } | 654 } |
648 | 655 |
649 RenderWidgetHostViewPort* WebContentsImpl::GetRenderWidgetHostViewPort() const { | 656 RenderWidgetHostViewPort* WebContentsImpl::GetRenderWidgetHostViewPort() const { |
650 BrowserPluginGuest* guest = GetBrowserPluginGuest(); | 657 BrowserPluginGuest* guest = GetBrowserPluginGuest(); |
651 if (guest && guest->embedder_web_contents()) { | 658 if (guest && guest->embedder_web_contents()) { |
652 return guest->embedder_web_contents()->GetRenderWidgetHostViewPort(); | 659 return guest->embedder_web_contents()->GetRenderWidgetHostViewPort(); |
653 } | 660 } |
654 return RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); | 661 return RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
655 } | 662 } |
656 | 663 |
(...skipping 17 matching lines...) Expand all Loading... |
674 web_ui->AddMessageHandler(new GenericHandler()); | 681 web_ui->AddMessageHandler(new GenericHandler()); |
675 web_ui->SetController(controller); | 682 web_ui->SetController(controller); |
676 return web_ui; | 683 return web_ui; |
677 } | 684 } |
678 | 685 |
679 delete web_ui; | 686 delete web_ui; |
680 return NULL; | 687 return NULL; |
681 } | 688 } |
682 | 689 |
683 WebUI* WebContentsImpl::GetWebUI() const { | 690 WebUI* WebContentsImpl::GetWebUI() const { |
684 return render_manager_.web_ui() ? render_manager_.web_ui() | 691 return GetRenderManager()->web_ui() ? GetRenderManager()->web_ui() |
685 : render_manager_.pending_web_ui(); | 692 : GetRenderManager()->pending_web_ui(); |
686 } | 693 } |
687 | 694 |
688 WebUI* WebContentsImpl::GetCommittedWebUI() const { | 695 WebUI* WebContentsImpl::GetCommittedWebUI() const { |
689 return render_manager_.web_ui(); | 696 return GetRenderManager()->web_ui(); |
690 } | 697 } |
691 | 698 |
692 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { | 699 void WebContentsImpl::SetUserAgentOverride(const std::string& override) { |
693 if (GetUserAgentOverride() == override) | 700 if (GetUserAgentOverride() == override) |
694 return; | 701 return; |
695 | 702 |
696 renderer_preferences_.user_agent_override = override; | 703 renderer_preferences_.user_agent_override = override; |
697 | 704 |
698 // Send the new override string to the renderer. | 705 // Send the new override string to the renderer. |
699 RenderViewHost* host = GetRenderViewHost(); | 706 RenderViewHost* host = GetRenderViewHost(); |
(...skipping 26 matching lines...) Expand all Loading... |
726 const string16& WebContentsImpl::GetTitle() const { | 733 const string16& WebContentsImpl::GetTitle() const { |
727 // Transient entries take precedence. They are used for interstitial pages | 734 // Transient entries take precedence. They are used for interstitial pages |
728 // that are shown on top of existing pages. | 735 // that are shown on top of existing pages. |
729 NavigationEntry* entry = controller_.GetTransientEntry(); | 736 NavigationEntry* entry = controller_.GetTransientEntry(); |
730 std::string accept_languages = | 737 std::string accept_languages = |
731 GetContentClient()->browser()->GetAcceptLangs( | 738 GetContentClient()->browser()->GetAcceptLangs( |
732 GetBrowserContext()); | 739 GetBrowserContext()); |
733 if (entry) { | 740 if (entry) { |
734 return entry->GetTitleForDisplay(accept_languages); | 741 return entry->GetTitleForDisplay(accept_languages); |
735 } | 742 } |
736 WebUI* our_web_ui = render_manager_.pending_web_ui() ? | 743 WebUI* our_web_ui = GetRenderManager()->pending_web_ui() ? |
737 render_manager_.pending_web_ui() : render_manager_.web_ui(); | 744 GetRenderManager()->pending_web_ui() : GetRenderManager()->web_ui(); |
738 if (our_web_ui) { | 745 if (our_web_ui) { |
739 // Don't override the title in view source mode. | 746 // Don't override the title in view source mode. |
740 entry = controller_.GetVisibleEntry(); | 747 entry = controller_.GetVisibleEntry(); |
741 if (!(entry && entry->IsViewSourceMode())) { | 748 if (!(entry && entry->IsViewSourceMode())) { |
742 // Give the Web UI the chance to override our title. | 749 // Give the Web UI the chance to override our title. |
743 const string16& title = our_web_ui->GetOverriddenTitle(); | 750 const string16& title = our_web_ui->GetOverriddenTitle(); |
744 if (!title.empty()) | 751 if (!title.empty()) |
745 return title; | 752 return title; |
746 } | 753 } |
747 } | 754 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) | 795 if (GetMaxPageIDForSiteInstance(site_instance) < page_id) |
789 max_page_ids_[site_instance->GetId()] = page_id; | 796 max_page_ids_[site_instance->GetId()] = page_id; |
790 } | 797 } |
791 | 798 |
792 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) { | 799 void WebContentsImpl::CopyMaxPageIDsFrom(WebContents* web_contents) { |
793 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents); | 800 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents); |
794 max_page_ids_ = contents->max_page_ids_; | 801 max_page_ids_ = contents->max_page_ids_; |
795 } | 802 } |
796 | 803 |
797 SiteInstance* WebContentsImpl::GetSiteInstance() const { | 804 SiteInstance* WebContentsImpl::GetSiteInstance() const { |
798 return render_manager_.current_host()->GetSiteInstance(); | 805 return GetRenderManager()->current_host()->GetSiteInstance(); |
799 } | 806 } |
800 | 807 |
801 SiteInstance* WebContentsImpl::GetPendingSiteInstance() const { | 808 SiteInstance* WebContentsImpl::GetPendingSiteInstance() const { |
802 RenderViewHost* dest_rvh = render_manager_.pending_render_view_host() ? | 809 RenderViewHost* dest_rvh = GetRenderManager()->pending_render_view_host() ? |
803 render_manager_.pending_render_view_host() : | 810 GetRenderManager()->pending_render_view_host() : |
804 render_manager_.current_host(); | 811 GetRenderManager()->current_host(); |
805 return dest_rvh->GetSiteInstance(); | 812 return dest_rvh->GetSiteInstance(); |
806 } | 813 } |
807 | 814 |
808 bool WebContentsImpl::IsLoading() const { | 815 bool WebContentsImpl::IsLoading() const { |
809 return is_loading_; | 816 return is_loading_; |
810 } | 817 } |
811 | 818 |
812 bool WebContentsImpl::IsWaitingForResponse() const { | 819 bool WebContentsImpl::IsWaitingForResponse() const { |
813 return waiting_for_response_; | 820 return waiting_for_response_; |
814 } | 821 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 | 960 |
954 bool WebContentsImpl::NeedToFireBeforeUnload() { | 961 bool WebContentsImpl::NeedToFireBeforeUnload() { |
955 // TODO(creis): Should we fire even for interstitial pages? | 962 // TODO(creis): Should we fire even for interstitial pages? |
956 return WillNotifyDisconnection() && | 963 return WillNotifyDisconnection() && |
957 !ShowingInterstitialPage() && | 964 !ShowingInterstitialPage() && |
958 !static_cast<RenderViewHostImpl*>( | 965 !static_cast<RenderViewHostImpl*>( |
959 GetRenderViewHost())->SuddenTerminationAllowed(); | 966 GetRenderViewHost())->SuddenTerminationAllowed(); |
960 } | 967 } |
961 | 968 |
962 void WebContentsImpl::Stop() { | 969 void WebContentsImpl::Stop() { |
963 render_manager_.Stop(); | 970 GetRenderManager()->Stop(); |
964 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped()); | 971 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped()); |
965 } | 972 } |
966 | 973 |
967 WebContents* WebContentsImpl::Clone() { | 974 WebContents* WebContentsImpl::Clone() { |
968 // We use our current SiteInstance since the cloned entry will use it anyway. | 975 // We use our current SiteInstance since the cloned entry will use it anyway. |
969 // We pass our own opener so that the cloned page can access it if it was | 976 // We pass our own opener so that the cloned page can access it if it was |
970 // before. | 977 // before. |
971 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); | 978 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); |
972 create_params.initial_size = view_->GetContainerSize(); | 979 create_params.initial_size = view_->GetContainerSize(); |
973 WebContentsImpl* tc = CreateWithOpener(create_params, opener_); | 980 WebContentsImpl* tc = CreateWithOpener(create_params, opener_); |
(...skipping 26 matching lines...) Expand all Loading... |
1000 | 1007 |
1001 WebContents* WebContentsImpl::GetWebContents() { | 1008 WebContents* WebContentsImpl::GetWebContents() { |
1002 return this; | 1009 return this; |
1003 } | 1010 } |
1004 | 1011 |
1005 void WebContentsImpl::Init(const WebContents::CreateParams& params) { | 1012 void WebContentsImpl::Init(const WebContents::CreateParams& params) { |
1006 // This is set before initializing the render_manager_ since render_manager_ | 1013 // This is set before initializing the render_manager_ since render_manager_ |
1007 // init calls back into us via its delegate to ask if it should be hidden. | 1014 // init calls back into us via its delegate to ask if it should be hidden. |
1008 should_normally_be_visible_ = !params.initially_hidden; | 1015 should_normally_be_visible_ = !params.initially_hidden; |
1009 | 1016 |
1010 render_manager_.Init( | 1017 GetRenderManager()->Init( |
1011 params.browser_context, params.site_instance, params.routing_id, | 1018 params.browser_context, params.site_instance, params.routing_id, |
1012 params.main_frame_routing_id); | 1019 params.main_frame_routing_id); |
1013 | 1020 |
1014 view_.reset(GetContentClient()->browser()-> | 1021 view_.reset(GetContentClient()->browser()-> |
1015 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); | 1022 OverrideCreateWebContentsView(this, &render_view_host_delegate_view_)); |
1016 if (view_) { | 1023 if (view_) { |
1017 CHECK(render_view_host_delegate_view_); | 1024 CHECK(render_view_host_delegate_view_); |
1018 } else { | 1025 } else { |
1019 WebContentsViewDelegate* delegate = | 1026 WebContentsViewDelegate* delegate = |
1020 GetContentClient()->browser()->GetWebContentsViewDelegate(this); | 1027 GetContentClient()->browser()->GetWebContentsViewDelegate(this); |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 | 1574 |
1568 void WebContentsImpl::RenderViewForInterstitialPageCreated( | 1575 void WebContentsImpl::RenderViewForInterstitialPageCreated( |
1569 RenderViewHost* render_view_host) { | 1576 RenderViewHost* render_view_host) { |
1570 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1577 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1571 RenderViewForInterstitialPageCreated(render_view_host)); | 1578 RenderViewForInterstitialPageCreated(render_view_host)); |
1572 } | 1579 } |
1573 | 1580 |
1574 void WebContentsImpl::AttachInterstitialPage( | 1581 void WebContentsImpl::AttachInterstitialPage( |
1575 InterstitialPageImpl* interstitial_page) { | 1582 InterstitialPageImpl* interstitial_page) { |
1576 DCHECK(interstitial_page); | 1583 DCHECK(interstitial_page); |
1577 render_manager_.set_interstitial_page(interstitial_page); | 1584 GetRenderManager()->set_interstitial_page(interstitial_page); |
1578 | 1585 |
1579 // Cancel any visible dialogs so that they don't interfere with the | 1586 // Cancel any visible dialogs so that they don't interfere with the |
1580 // interstitial. | 1587 // interstitial. |
1581 if (dialog_manager_) | 1588 if (dialog_manager_) |
1582 dialog_manager_->CancelActiveAndPendingDialogs(this); | 1589 dialog_manager_->CancelActiveAndPendingDialogs(this); |
1583 | 1590 |
1584 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1591 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1585 DidAttachInterstitialPage()); | 1592 DidAttachInterstitialPage()); |
1586 } | 1593 } |
1587 | 1594 |
1588 void WebContentsImpl::DetachInterstitialPage() { | 1595 void WebContentsImpl::DetachInterstitialPage() { |
1589 if (GetInterstitialPage()) | 1596 if (GetInterstitialPage()) |
1590 render_manager_.remove_interstitial_page(); | 1597 GetRenderManager()->remove_interstitial_page(); |
1591 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1598 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
1592 DidDetachInterstitialPage()); | 1599 DidDetachInterstitialPage()); |
1593 } | 1600 } |
1594 | 1601 |
1595 bool WebContentsImpl::NavigateToEntry( | 1602 bool WebContentsImpl::NavigateToEntry( |
1596 const NavigationEntryImpl& entry, | 1603 const NavigationEntryImpl& entry, |
1597 NavigationController::ReloadType reload_type) { | 1604 NavigationController::ReloadType reload_type) { |
1598 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); | 1605 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); |
1599 | 1606 |
1600 // The renderer will reject IPC messages with URLs longer than | 1607 // The renderer will reject IPC messages with URLs longer than |
1601 // this limit, so don't attempt to navigate with a longer URL. | 1608 // this limit, so don't attempt to navigate with a longer URL. |
1602 if (entry.GetURL().spec().size() > kMaxURLChars) { | 1609 if (entry.GetURL().spec().size() > kMaxURLChars) { |
1603 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars | 1610 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars |
1604 << " characters."; | 1611 << " characters."; |
1605 return false; | 1612 return false; |
1606 } | 1613 } |
1607 | 1614 |
| 1615 // TODO(creis): We need to store the frame ID on entry and use that to find |
| 1616 // the correct RenderManager. |
| 1617 int64 frame_tree_node_id = frame_tree_.root()->frame_tree_node_id(); |
| 1618 if (entry.frame_tree_node_id() != -1) |
| 1619 frame_tree_node_id = entry.frame_tree_node_id(); |
| 1620 |
| 1621 RenderViewHostManager* manager = |
| 1622 frame_tree_.FindByID(frame_tree_node_id)->render_manager(); |
1608 RenderViewHostImpl* dest_render_view_host = | 1623 RenderViewHostImpl* dest_render_view_host = |
1609 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); | 1624 static_cast<RenderViewHostImpl*>(manager->Navigate(entry)); |
1610 if (!dest_render_view_host) | 1625 if (!dest_render_view_host) |
1611 return false; // Unable to create the desired render view host. | 1626 return false; // Unable to create the desired render view host. |
1612 | 1627 |
1613 // For security, we should never send non-Web-UI URLs to a Web UI renderer. | 1628 // For security, we should never send non-Web-UI URLs to a Web UI renderer. |
1614 // Double check that here. | 1629 // Double check that here. |
1615 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); | 1630 int enabled_bindings = dest_render_view_host->GetEnabledBindings(); |
1616 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); | 1631 bool data_urls_allowed = delegate_ && delegate_->CanLoadDataURLsInWebUI(); |
1617 bool is_allowed_in_web_ui_renderer = | 1632 bool is_allowed_in_web_ui_renderer = |
1618 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 1633 WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
1619 GetBrowserContext(), entry.GetURL(), data_urls_allowed); | 1634 GetBrowserContext(), entry.GetURL(), data_urls_allowed); |
1620 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && | 1635 if ((enabled_bindings & BINDINGS_POLICY_WEB_UI) && |
1621 !is_allowed_in_web_ui_renderer) { | 1636 !is_allowed_in_web_ui_renderer) { |
1622 // Log the URL to help us diagnose any future failures of this CHECK. | 1637 // Log the URL to help us diagnose any future failures of this CHECK. |
1623 GetContentClient()->SetActiveURL(entry.GetURL()); | 1638 GetContentClient()->SetActiveURL(entry.GetURL()); |
1624 CHECK(0); | 1639 CHECK(0); |
1625 } | 1640 } |
1626 | 1641 |
1627 // Notify observers that we will navigate in this RV. | 1642 // Notify observers that we will navigate in this RV. |
1628 FOR_EACH_OBSERVER(WebContentsObserver, | 1643 FOR_EACH_OBSERVER(WebContentsObserver, |
1629 observers_, | 1644 observers_, |
1630 AboutToNavigateRenderView(dest_render_view_host)); | 1645 AboutToNavigateRenderView(dest_render_view_host)); |
1631 | 1646 |
1632 // Used for page load time metrics. | 1647 // Used for page load time metrics. |
1633 current_load_start_ = base::TimeTicks::Now(); | 1648 current_load_start_ = base::TimeTicks::Now(); |
1634 | 1649 |
1635 // Navigate in the desired RenderViewHost. | 1650 // Navigate in the desired RenderViewHost. |
| 1651 // TODO(creis): Put frame ID in ViewMsg_Navigate_Params so that we can tell |
| 1652 // the renderer which frame to navigate. Problem: it has to be the frame ID |
| 1653 // in the destination renderer process, not the frame ID in the open params. |
| 1654 // Or... just handle named frames for now. |
1636 ViewMsg_Navigate_Params navigate_params; | 1655 ViewMsg_Navigate_Params navigate_params; |
1637 MakeNavigateParams(entry, controller_, delegate_, reload_type, | 1656 MakeNavigateParams(entry, controller_, delegate_, reload_type, |
1638 &navigate_params); | 1657 &navigate_params); |
1639 dest_render_view_host->Navigate(navigate_params); | 1658 dest_render_view_host->Navigate(navigate_params); |
1640 | 1659 |
1641 if (entry.GetPageID() == -1) { | 1660 if (entry.GetPageID() == -1) { |
1642 // HACK!! This code suppresses javascript: URLs from being added to | 1661 // HACK!! This code suppresses javascript: URLs from being added to |
1643 // session history, which is what we want to do for javascript: URLs that | 1662 // session history, which is what we want to do for javascript: URLs that |
1644 // do not generate content. What we really need is a message from the | 1663 // do not generate content. What we really need is a message from the |
1645 // renderer telling us that a new page was not created. The same message | 1664 // renderer telling us that a new page was not created. The same message |
(...skipping 12 matching lines...) Expand all Loading... |
1658 | 1677 |
1659 return true; | 1678 return true; |
1660 } | 1679 } |
1661 | 1680 |
1662 void WebContentsImpl::SetHistoryLengthAndPrune( | 1681 void WebContentsImpl::SetHistoryLengthAndPrune( |
1663 const SiteInstance* site_instance, | 1682 const SiteInstance* site_instance, |
1664 int history_length, | 1683 int history_length, |
1665 int32 minimum_page_id) { | 1684 int32 minimum_page_id) { |
1666 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site | 1685 // SetHistoryLengthAndPrune doesn't work when there are pending cross-site |
1667 // navigations. Callers should ensure that this is the case. | 1686 // navigations. Callers should ensure that this is the case. |
1668 if (render_manager_.pending_render_view_host()) { | 1687 if (GetRenderManager()->pending_render_view_host()) { |
1669 NOTREACHED(); | 1688 NOTREACHED(); |
1670 return; | 1689 return; |
1671 } | 1690 } |
1672 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); | 1691 RenderViewHostImpl* rvh = GetRenderViewHostImpl(); |
1673 if (!rvh) { | 1692 if (!rvh) { |
1674 NOTREACHED(); | 1693 NOTREACHED(); |
1675 return; | 1694 return; |
1676 } | 1695 } |
1677 if (site_instance && rvh->GetSiteInstance() != site_instance) { | 1696 if (site_instance && rvh->GetSiteInstance() != site_instance) { |
1678 NOTREACHED(); | 1697 NOTREACHED(); |
1679 return; | 1698 return; |
1680 } | 1699 } |
1681 Send(new ViewMsg_SetHistoryLengthAndPrune(GetRoutingID(), | 1700 Send(new ViewMsg_SetHistoryLengthAndPrune(GetRoutingID(), |
1682 history_length, | 1701 history_length, |
1683 minimum_page_id)); | 1702 minimum_page_id)); |
1684 } | 1703 } |
1685 | 1704 |
1686 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) { | 1705 void WebContentsImpl::FocusThroughTabTraversal(bool reverse) { |
1687 if (ShowingInterstitialPage()) { | 1706 if (ShowingInterstitialPage()) { |
1688 render_manager_.interstitial_page()->FocusThroughTabTraversal(reverse); | 1707 GetRenderManager()->interstitial_page()->FocusThroughTabTraversal(reverse); |
1689 return; | 1708 return; |
1690 } | 1709 } |
1691 GetRenderViewHostImpl()->SetInitialFocus(reverse); | 1710 GetRenderViewHostImpl()->SetInitialFocus(reverse); |
1692 } | 1711 } |
1693 | 1712 |
1694 bool WebContentsImpl::ShowingInterstitialPage() const { | 1713 bool WebContentsImpl::ShowingInterstitialPage() const { |
1695 return render_manager_.interstitial_page() != NULL; | 1714 return GetRenderManager()->interstitial_page() != NULL; |
1696 } | 1715 } |
1697 | 1716 |
1698 InterstitialPage* WebContentsImpl::GetInterstitialPage() const { | 1717 InterstitialPage* WebContentsImpl::GetInterstitialPage() const { |
1699 return render_manager_.interstitial_page(); | 1718 return GetRenderManager()->interstitial_page(); |
1700 } | 1719 } |
1701 | 1720 |
1702 bool WebContentsImpl::IsSavable() { | 1721 bool WebContentsImpl::IsSavable() { |
1703 // WebKit creates Document object when MIME type is application/xhtml+xml, | 1722 // WebKit creates Document object when MIME type is application/xhtml+xml, |
1704 // so we also support this MIME type. | 1723 // so we also support this MIME type. |
1705 return contents_mime_type_ == "text/html" || | 1724 return contents_mime_type_ == "text/html" || |
1706 contents_mime_type_ == "text/xml" || | 1725 contents_mime_type_ == "text/xml" || |
1707 contents_mime_type_ == "application/xhtml+xml" || | 1726 contents_mime_type_ == "application/xhtml+xml" || |
1708 contents_mime_type_ == "text/plain" || | 1727 contents_mime_type_ == "text/plain" || |
1709 contents_mime_type_ == "text/css" || | 1728 contents_mime_type_ == "text/css" || |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1963 int64 parent_frame_id, | 1982 int64 parent_frame_id, |
1964 bool is_main_frame, | 1983 bool is_main_frame, |
1965 const GURL& url) { | 1984 const GURL& url) { |
1966 bool is_error_page = (url.spec() == kUnreachableWebDataURL); | 1985 bool is_error_page = (url.spec() == kUnreachableWebDataURL); |
1967 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); | 1986 bool is_iframe_srcdoc = (url.spec() == kAboutSrcDocURL); |
1968 GURL validated_url(url); | 1987 GURL validated_url(url); |
1969 RenderProcessHost* render_process_host = | 1988 RenderProcessHost* render_process_host = |
1970 render_view_host->GetProcess(); | 1989 render_view_host->GetProcess(); |
1971 RenderViewHost::FilterURL(render_process_host, false, &validated_url); | 1990 RenderViewHost::FilterURL(render_process_host, false, &validated_url); |
1972 | 1991 |
| 1992 // TODO(creis): This is a hack for now, until we mirror the frame tree and do |
| 1993 // cross-process subframe navigations in actual subframes. |
| 1994 NavigationEntryImpl* pending_entry = |
| 1995 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); |
| 1996 if (pending_entry && pending_entry->frame_tree_node_id() != -1) |
| 1997 is_main_frame = false; |
| 1998 |
1973 if (is_main_frame) { | 1999 if (is_main_frame) { |
1974 DidChangeLoadProgress(0); | 2000 DidChangeLoadProgress(0); |
1975 | 2001 |
1976 // If there is no browser-initiated pending entry for this navigation and it | 2002 // If there is no browser-initiated pending entry for this navigation and it |
1977 // is not for the error URL, create a pending entry using the current | 2003 // is not for the error URL, create a pending entry using the current |
1978 // SiteInstance, and ensure the address bar updates accordingly. We don't | 2004 // SiteInstance, and ensure the address bar updates accordingly. We don't |
1979 // know the referrer or extra headers at this point, but the referrer will | 2005 // know the referrer or extra headers at this point, but the referrer will |
1980 // be set properly upon commit. | 2006 // be set properly upon commit. |
1981 NavigationEntryImpl* pending_entry = | |
1982 NavigationEntryImpl::FromNavigationEntry(controller_.GetPendingEntry()); | |
1983 bool has_browser_initiated_pending_entry = pending_entry && | 2007 bool has_browser_initiated_pending_entry = pending_entry && |
1984 !pending_entry->is_renderer_initiated(); | 2008 !pending_entry->is_renderer_initiated(); |
1985 if (!has_browser_initiated_pending_entry && !is_error_page) { | 2009 if (!has_browser_initiated_pending_entry && !is_error_page) { |
1986 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( | 2010 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry( |
1987 controller_.CreateNavigationEntry(validated_url, | 2011 controller_.CreateNavigationEntry(validated_url, |
1988 content::Referrer(), | 2012 content::Referrer(), |
1989 content::PAGE_TRANSITION_LINK, | 2013 content::PAGE_TRANSITION_LINK, |
1990 true /* is_renderer_initiated */, | 2014 true /* is_renderer_initiated */, |
1991 std::string(), | 2015 std::string(), |
1992 GetBrowserContext())); | 2016 GetBrowserContext())); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 // Because this will not tear down the interstitial properly, if "back" is | 2105 // Because this will not tear down the interstitial properly, if "back" is |
2082 // back to another tab type, the interstitial will still be somewhat alive | 2106 // back to another tab type, the interstitial will still be somewhat alive |
2083 // in the previous tab type. If you navigate somewhere that activates the | 2107 // in the previous tab type. If you navigate somewhere that activates the |
2084 // tab with the interstitial again, you'll see a flash before the new load | 2108 // tab with the interstitial again, you'll see a flash before the new load |
2085 // commits of the interstitial page. | 2109 // commits of the interstitial page. |
2086 if (ShowingInterstitialPage()) { | 2110 if (ShowingInterstitialPage()) { |
2087 LOG(WARNING) << "Discarding message during interstitial."; | 2111 LOG(WARNING) << "Discarding message during interstitial."; |
2088 return; | 2112 return; |
2089 } | 2113 } |
2090 | 2114 |
2091 render_manager_.RendererAbortedProvisionalLoad(render_view_host); | 2115 GetRenderManager()->RendererAbortedProvisionalLoad(render_view_host); |
2092 } | 2116 } |
2093 | 2117 |
2094 // Do not usually clear the pending entry if one exists, so that the user's | 2118 // Do not usually clear the pending entry if one exists, so that the user's |
2095 // typed URL is not lost when a navigation fails or is aborted. However, in | 2119 // typed URL is not lost when a navigation fails or is aborted. However, in |
2096 // cases that we don't show the pending entry (e.g., renderer-initiated | 2120 // cases that we don't show the pending entry (e.g., renderer-initiated |
2097 // navigations in an existing tab), we don't keep it around. That prevents | 2121 // navigations in an existing tab), we don't keep it around. That prevents |
2098 // spoofs on in-page navigations that don't go through | 2122 // spoofs on in-page navigations that don't go through |
2099 // DidStartProvisionalLoadForFrame. | 2123 // DidStartProvisionalLoadForFrame. |
2100 // In general, we allow the view to clear the pending entry and typed URL if | 2124 // In general, we allow the view to clear the pending entry and typed URL if |
2101 // the user requests (e.g., hitting Escape with focus in the address bar). | 2125 // the user requests (e.g., hitting Escape with focus in the address bar). |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 if (is_loading == is_loading_) | 2508 if (is_loading == is_loading_) |
2485 return; | 2509 return; |
2486 | 2510 |
2487 if (!is_loading) { | 2511 if (!is_loading) { |
2488 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); | 2512 load_state_ = net::LoadStateWithParam(net::LOAD_STATE_IDLE, string16()); |
2489 load_state_host_.clear(); | 2513 load_state_host_.clear(); |
2490 upload_size_ = 0; | 2514 upload_size_ = 0; |
2491 upload_position_ = 0; | 2515 upload_position_ = 0; |
2492 } | 2516 } |
2493 | 2517 |
2494 render_manager_.SetIsLoading(is_loading); | 2518 GetRenderManager()->SetIsLoading(is_loading); |
2495 | 2519 |
2496 is_loading_ = is_loading; | 2520 is_loading_ = is_loading; |
2497 waiting_for_response_ = is_loading; | 2521 waiting_for_response_ = is_loading; |
2498 | 2522 |
2499 if (delegate_) | 2523 if (delegate_) |
2500 delegate_->LoadingStateChanged(this); | 2524 delegate_->LoadingStateChanged(this); |
2501 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | 2525 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); |
2502 | 2526 |
2503 if (is_loading) { | 2527 if (is_loading) { |
2504 TRACE_EVENT_ASYNC_BEGIN0("browser", "WebContentsImpl Loading", this); | 2528 TRACE_EVENT_ASYNC_BEGIN0("browser", "WebContentsImpl Loading", this); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 void WebContentsImpl::NotifyNavigationEntryCommitted( | 2693 void WebContentsImpl::NotifyNavigationEntryCommitted( |
2670 const LoadCommittedDetails& load_details) { | 2694 const LoadCommittedDetails& load_details) { |
2671 FOR_EACH_OBSERVER( | 2695 FOR_EACH_OBSERVER( |
2672 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); | 2696 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); |
2673 } | 2697 } |
2674 | 2698 |
2675 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { | 2699 RenderViewHostDelegateView* WebContentsImpl::GetDelegateView() { |
2676 return render_view_host_delegate_view_; | 2700 return render_view_host_delegate_view_; |
2677 } | 2701 } |
2678 | 2702 |
2679 RenderViewHostDelegate::RendererManagement* | 2703 RenderViewHostManager* WebContentsImpl::GetRenderManager() const { |
2680 WebContentsImpl::GetRendererManagementDelegate() { | 2704 return frame_tree_.root()->render_manager(); |
2681 return &render_manager_; | |
2682 } | 2705 } |
2683 | 2706 |
2684 RendererPreferences WebContentsImpl::GetRendererPrefs( | 2707 RendererPreferences WebContentsImpl::GetRendererPrefs( |
2685 BrowserContext* browser_context) const { | 2708 BrowserContext* browser_context) const { |
2686 return renderer_preferences_; | 2709 return renderer_preferences_; |
2687 } | 2710 } |
2688 | 2711 |
2689 WebContents* WebContentsImpl::GetAsWebContents() { | 2712 WebContents* WebContentsImpl::GetAsWebContents() { |
2690 return this; | 2713 return this; |
2691 } | 2714 } |
(...skipping 19 matching lines...) Expand all Loading... |
2711 if (delegate_) | 2734 if (delegate_) |
2712 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); | 2735 view_->SetOverscrollControllerEnabled(delegate_->CanOverscrollContent()); |
2713 | 2736 |
2714 NotificationService::current()->Notify( | 2737 NotificationService::current()->Notify( |
2715 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 2738 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
2716 Source<WebContents>(this), | 2739 Source<WebContents>(this), |
2717 Details<RenderViewHost>(render_view_host)); | 2740 Details<RenderViewHost>(render_view_host)); |
2718 | 2741 |
2719 // When we're creating views, we're still doing initial setup, so we always | 2742 // When we're creating views, we're still doing initial setup, so we always |
2720 // use the pending Web UI rather than any possibly existing committed one. | 2743 // use the pending Web UI rather than any possibly existing committed one. |
2721 if (render_manager_.pending_web_ui()) | 2744 if (GetRenderManager()->pending_web_ui()) |
2722 render_manager_.pending_web_ui()->RenderViewCreated(render_view_host); | 2745 GetRenderManager()->pending_web_ui()->RenderViewCreated(render_view_host); |
2723 | 2746 |
2724 NavigationEntry* entry = controller_.GetPendingEntry(); | 2747 NavigationEntry* entry = controller_.GetPendingEntry(); |
2725 if (entry && entry->IsViewSourceMode()) { | 2748 if (entry && entry->IsViewSourceMode()) { |
2726 // Put the renderer in view source mode. | 2749 // Put the renderer in view source mode. |
2727 render_view_host->Send( | 2750 render_view_host->Send( |
2728 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); | 2751 new ViewMsg_EnableViewSourceMode(render_view_host->GetRoutingID())); |
2729 } | 2752 } |
2730 | 2753 |
2731 view_->RenderViewCreated(render_view_host); | 2754 view_->RenderViewCreated(render_view_host); |
2732 | 2755 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2775 SetIsCrashed(status, error_code); | 2798 SetIsCrashed(status, error_code); |
2776 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); | 2799 GetView()->OnTabCrashed(GetCrashedStatus(), crashed_error_code_); |
2777 | 2800 |
2778 FOR_EACH_OBSERVER(WebContentsObserver, | 2801 FOR_EACH_OBSERVER(WebContentsObserver, |
2779 observers_, | 2802 observers_, |
2780 RenderProcessGone(GetCrashedStatus())); | 2803 RenderProcessGone(GetCrashedStatus())); |
2781 } | 2804 } |
2782 | 2805 |
2783 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 2806 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
2784 ClearPowerSaveBlockers(rvh); | 2807 ClearPowerSaveBlockers(rvh); |
2785 render_manager_.RenderViewDeleted(rvh); | 2808 GetRenderManager()->RenderViewDeleted(rvh); |
2786 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); | 2809 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); |
2787 } | 2810 } |
2788 | 2811 |
2789 void WebContentsImpl::DidGetResourceResponseStart( | 2812 void WebContentsImpl::DidGetResourceResponseStart( |
2790 const ResourceRequestDetails& details) { | 2813 const ResourceRequestDetails& details) { |
2791 controller_.ssl_manager()->DidStartResourceResponse(details); | 2814 controller_.ssl_manager()->DidStartResourceResponse(details); |
2792 | 2815 |
2793 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2816 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
2794 DidGetResourceResponseStart(details)); | 2817 DidGetResourceResponseStart(details)); |
2795 | 2818 |
(...skipping 13 matching lines...) Expand all Loading... |
2809 | 2832 |
2810 // TODO(avi): Remove. http://crbug.com/170921 | 2833 // TODO(avi): Remove. http://crbug.com/170921 |
2811 NotificationService::current()->Notify( | 2834 NotificationService::current()->Notify( |
2812 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 2835 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
2813 Source<WebContents>(this), | 2836 Source<WebContents>(this), |
2814 Details<const ResourceRedirectDetails>(&details)); | 2837 Details<const ResourceRedirectDetails>(&details)); |
2815 } | 2838 } |
2816 | 2839 |
2817 void WebContentsImpl::DidNavigate( | 2840 void WebContentsImpl::DidNavigate( |
2818 RenderViewHost* rvh, | 2841 RenderViewHost* rvh, |
2819 const ViewHostMsg_FrameNavigate_Params& params) { | 2842 const ViewHostMsg_FrameNavigate_Params& orig_params) { |
2820 if (frame_tree_.IsFirstNavigationAfterSwap()) { | 2843 ViewHostMsg_FrameNavigate_Params params(orig_params); |
| 2844 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
| 2845 if (!rvhi->HasFrameTreeNodeID(params.frame_id)) { |
2821 // First navigation should be a main frame navigation. | 2846 // First navigation should be a main frame navigation. |
2822 DCHECK(PageTransitionIsMainFrame(params.transition)); | 2847 //DCHECK(PageTransitionIsMainFrame(params.transition)); |
2823 frame_tree_.OnFirstNavigationAfterSwap(params.frame_id); | 2848 rvhi->RegisterFrameTreeNodeID(params.frame_id, |
| 2849 frame_tree_.root()->frame_tree_node_id()); |
| 2850 } |
| 2851 |
| 2852 // Look up the FrameTreeNode ID that the renderer-specific frame ID |
| 2853 // corresponds to. |
| 2854 int frame_tree_node_id = rvhi->GetFrameTreeNodeID(params.frame_id); |
| 2855 |
| 2856 // TODO(creis): In the short term, cross-process subframe navigations are |
| 2857 // happening in the pending RenderViewHost's top-level frame. (We need to |
| 2858 // both mirror the frame tree and get the navigation to occur in the correct |
| 2859 // subframe to fix this.) Until then, we should check whether we have a |
| 2860 // pending NavigationEntry with a frame ID and if so, treat the cross-process |
| 2861 // "main frame" navigation as a subframe navigation. |
| 2862 NavigationEntryImpl* pending_entry = NavigationEntryImpl::FromNavigationEntry( |
| 2863 controller_.GetPendingEntry()); |
| 2864 if (pending_entry && pending_entry->frame_tree_node_id() != -1) { |
| 2865 params.transition = PAGE_TRANSITION_AUTO_SUBFRAME; |
| 2866 frame_tree_node_id = pending_entry->frame_tree_node_id(); |
2824 } | 2867 } |
2825 | 2868 |
2826 if (PageTransitionIsMainFrame(params.transition)) { | 2869 if (PageTransitionIsMainFrame(params.transition)) { |
2827 // When overscroll navigation gesture is enabled, a screenshot of the page | 2870 // When overscroll navigation gesture is enabled, a screenshot of the page |
2828 // in its current state is taken so that it can be used during the | 2871 // in its current state is taken so that it can be used during the |
2829 // nav-gesture. It is necessary to take the screenshot here, before calling | 2872 // nav-gesture. It is necessary to take the screenshot here, before calling |
2830 // RenderViewHostManager::DidNavigateMainFrame, because that can change | 2873 // RenderViewHostManager::DidNavigateMainFrame, because that can change |
2831 // WebContents::GetRenderViewHost to return the new host, instead of the one | 2874 // WebContents::GetRenderViewHost to return the new host, instead of the one |
2832 // that may have just been swapped out. | 2875 // that may have just been swapped out. |
2833 if (delegate_ && delegate_->CanOverscrollContent()) | 2876 if (delegate_ && delegate_->CanOverscrollContent()) |
2834 controller_.TakeScreenshot(); | 2877 controller_.TakeScreenshot(); |
| 2878 } |
2835 | 2879 |
2836 render_manager_.DidNavigateMainFrame(rvh); | 2880 FrameTreeNode* frame = frame_tree_.FindByID(frame_tree_node_id); |
| 2881 if (!frame) { |
| 2882 // Just for debugging. We can't trust the renderer to lie about the ID. |
| 2883 NOTREACHED(); |
| 2884 return; |
2837 } | 2885 } |
| 2886 // TODO(creis): Rename to DidNavigateFrame. |
| 2887 frame->render_manager()->DidNavigateMainFrame(rvh); |
2838 | 2888 |
2839 // Update the site of the SiteInstance if it doesn't have one yet, unless | 2889 // Update the site of the SiteInstance if it doesn't have one yet, unless |
2840 // assigning a site is not necessary for this URL. In that case, the | 2890 // assigning a site is not necessary for this URL. In that case, the |
2841 // SiteInstance can still be considered unused until a navigation to a real | 2891 // SiteInstance can still be considered unused until a navigation to a real |
2842 // page. | 2892 // page. |
2843 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && | 2893 if (!static_cast<SiteInstanceImpl*>(GetSiteInstance())->HasSite() && |
2844 ShouldAssignSiteForURL(params.url)) { | 2894 ShouldAssignSiteForURL(params.url)) { |
2845 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); | 2895 static_cast<SiteInstanceImpl*>(GetSiteInstance())->SetSite(params.url); |
2846 } | 2896 } |
2847 | 2897 |
2848 // Need to update MIME type here because it's referred to in | 2898 // Need to update MIME type here because it's referred to in |
2849 // UpdateNavigationCommands() called by RendererDidNavigate() to | 2899 // UpdateNavigationCommands() called by RendererDidNavigate() to |
2850 // determine whether or not to enable the encoding menu. | 2900 // determine whether or not to enable the encoding menu. |
2851 // It's updated only for the main frame. For a subframe, | 2901 // It's updated only for the main frame. For a subframe, |
2852 // RenderView::UpdateURL does not set params.contents_mime_type. | 2902 // RenderView::UpdateURL does not set params.contents_mime_type. |
2853 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) | 2903 // (see http://code.google.com/p/chromium/issues/detail?id=2929 ) |
2854 // TODO(jungshik): Add a test for the encoding menu to avoid | 2904 // TODO(jungshik): Add a test for the encoding menu to avoid |
2855 // regressing it again. | 2905 // regressing it again. |
2856 if (PageTransitionIsMainFrame(params.transition)) | 2906 if (PageTransitionIsMainFrame(params.transition)) |
2857 contents_mime_type_ = params.contents_mime_type; | 2907 contents_mime_type_ = params.contents_mime_type; |
2858 | 2908 |
2859 LoadCommittedDetails details; | 2909 LoadCommittedDetails details; |
2860 bool did_navigate = controller_.RendererDidNavigate(params, &details); | 2910 bool did_navigate = controller_.RendererDidNavigate(params, &details); |
2861 | 2911 |
2862 // For now, keep track of each frame's URL in its FrameTreeNode. This lets | 2912 // For now, keep track of each frame's URL in its FrameTreeNode. This lets |
2863 // us estimate our process count for implementing OOP iframes. | 2913 // us estimate our process count for implementing OOP iframes. |
2864 // TODO(creis): Remove this when we track which pages commit in each frame. | 2914 // TODO(creis): Remove this when we track which pages commit in each frame. |
2865 frame_tree_.SetFrameUrl(params.frame_id, params.url); | 2915 frame_tree_.SetFrameUrl(frame_tree_node_id, params.url); |
2866 | 2916 |
2867 // Send notification about committed provisional loads. This notification is | 2917 // Send notification about committed provisional loads. This notification is |
2868 // different from the NAV_ENTRY_COMMITTED notification which doesn't include | 2918 // different from the NAV_ENTRY_COMMITTED notification which doesn't include |
2869 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. | 2919 // the actual URL navigated to and isn't sent for AUTO_SUBFRAME navigations. |
2870 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { | 2920 if (details.type != NAVIGATION_TYPE_NAV_IGNORE) { |
2871 // For AUTO_SUBFRAME navigations, an event for the main frame is generated | 2921 // For AUTO_SUBFRAME navigations, an event for the main frame is generated |
2872 // that is not recorded in the navigation history. For the purpose of | 2922 // that is not recorded in the navigation history. For the purpose of |
2873 // tracking navigation events, we treat this event as a sub frame navigation | 2923 // tracking navigation events, we treat this event as a sub frame navigation |
2874 // event. | 2924 // event. |
2875 bool is_main_frame = did_navigate ? details.is_main_frame : false; | 2925 bool is_main_frame = did_navigate ? details.is_main_frame : false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2911 } | 2961 } |
2912 } | 2962 } |
2913 DidNavigateAnyFramePostCommit(rvh, details, params); | 2963 DidNavigateAnyFramePostCommit(rvh, details, params); |
2914 } | 2964 } |
2915 | 2965 |
2916 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 2966 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
2917 int32 page_id, | 2967 int32 page_id, |
2918 const PageState& page_state) { | 2968 const PageState& page_state) { |
2919 // Ensure that this state update comes from either the active RVH or one of | 2969 // Ensure that this state update comes from either the active RVH or one of |
2920 // the swapped out RVHs. We don't expect to hear from any other RVHs. | 2970 // the swapped out RVHs. We don't expect to hear from any other RVHs. |
2921 DCHECK(rvh == GetRenderViewHost() || render_manager_.IsOnSwappedOutList(rvh)); | 2971 // TODO(creis): This should go through RenderFrameHost. |
| 2972 //DCHECK(rvh == GetRenderViewHost() || |
| 2973 // GetRenderManager()->IsOnSwappedOutList(rvh)); |
2922 | 2974 |
2923 // We must be prepared to handle state updates for any page, these occur | 2975 // We must be prepared to handle state updates for any page, these occur |
2924 // when the user is scrolling and entering form data, as well as when we're | 2976 // when the user is scrolling and entering form data, as well as when we're |
2925 // leaving a page, in which case our state may have already been moved to | 2977 // leaving a page, in which case our state may have already been moved to |
2926 // the next page. The navigation controller will look up the appropriate | 2978 // the next page. The navigation controller will look up the appropriate |
2927 // NavigationEntry and update it when it is notified via the delegate. | 2979 // NavigationEntry and update it when it is notified via the delegate. |
2928 | 2980 |
2929 int entry_index = controller_.GetEntryIndexWithPageID( | 2981 int entry_index = controller_.GetEntryIndexWithPageID( |
2930 rvh->GetSiteInstance(), page_id); | 2982 rvh->GetSiteInstance(), page_id); |
2931 if (entry_index < 0) | 2983 if (entry_index < 0) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2994 // Ignore this if it comes from a RenderViewHost that we aren't showing. | 3046 // Ignore this if it comes from a RenderViewHost that we aren't showing. |
2995 if (delegate_ && rvh == GetRenderViewHost()) | 3047 if (delegate_ && rvh == GetRenderViewHost()) |
2996 delegate_->CloseContents(this); | 3048 delegate_->CloseContents(this); |
2997 } | 3049 } |
2998 | 3050 |
2999 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { | 3051 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { |
3000 if (delegate_ && rvh == GetRenderViewHost()) | 3052 if (delegate_ && rvh == GetRenderViewHost()) |
3001 delegate_->SwappedOut(this); | 3053 delegate_->SwappedOut(this); |
3002 | 3054 |
3003 // Allow the navigation to proceed. | 3055 // Allow the navigation to proceed. |
3004 render_manager_.SwappedOut(rvh); | 3056 // TODO(creis): We can't make progress until we use the correct RVHM here. |
| 3057 // Otherwise there's no pending_nav_params_ in the subframe RVHM. |
| 3058 GetRenderManager()->SwappedOut(rvh); |
3005 } | 3059 } |
3006 | 3060 |
3007 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { | 3061 void WebContentsImpl::RequestMove(const gfx::Rect& new_bounds) { |
3008 if (delegate_ && delegate_->IsPopupOrPanel(this)) | 3062 if (delegate_ && delegate_->IsPopupOrPanel(this)) |
3009 delegate_->MoveContents(this, new_bounds); | 3063 delegate_->MoveContents(this, new_bounds); |
3010 } | 3064 } |
3011 | 3065 |
3012 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { | 3066 void WebContentsImpl::DidStartLoading(RenderViewHost* render_view_host) { |
3013 SetIsLoading(render_view_host, true, NULL); | 3067 SetIsLoading(render_view_host, true, NULL); |
3014 } | 3068 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3052 if (opener_) { | 3106 if (opener_) { |
3053 // Clear our opener so that future cross-process navigations don't have an | 3107 // Clear our opener so that future cross-process navigations don't have an |
3054 // opener assigned. | 3108 // opener assigned. |
3055 RemoveDestructionObserver(opener_); | 3109 RemoveDestructionObserver(opener_); |
3056 opener_ = NULL; | 3110 opener_ = NULL; |
3057 } | 3111 } |
3058 | 3112 |
3059 // Notify all swapped out RenderViewHosts for this tab. This is important | 3113 // Notify all swapped out RenderViewHosts for this tab. This is important |
3060 // in case we go back to them, or if another window in those processes tries | 3114 // in case we go back to them, or if another window in those processes tries |
3061 // to access window.opener. | 3115 // to access window.opener. |
3062 render_manager_.DidDisownOpener(rvh); | 3116 GetRenderManager()->DidDisownOpener(rvh); |
3063 } | 3117 } |
3064 | 3118 |
3065 void WebContentsImpl::DidAccessInitialDocument() { | 3119 void WebContentsImpl::DidAccessInitialDocument() { |
3066 // Update the URL display. | 3120 // Update the URL display. |
3067 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); | 3121 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL); |
3068 } | 3122 } |
3069 | 3123 |
3070 void WebContentsImpl::DocumentAvailableInMainFrame( | 3124 void WebContentsImpl::DocumentAvailableInMainFrame( |
3071 RenderViewHost* render_view_host) { | 3125 RenderViewHost* render_view_host) { |
3072 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3126 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3119 int64 source_frame_id, | 3173 int64 source_frame_id, |
3120 const GlobalRequestID& old_request_id, | 3174 const GlobalRequestID& old_request_id, |
3121 bool should_replace_current_entry, | 3175 bool should_replace_current_entry, |
3122 bool user_gesture) { | 3176 bool user_gesture) { |
3123 WebContents* new_contents = NULL; | 3177 WebContents* new_contents = NULL; |
3124 GURL dest_url(url); | 3178 GURL dest_url(url); |
3125 if (!GetContentClient()->browser()->ShouldAllowOpenURL( | 3179 if (!GetContentClient()->browser()->ShouldAllowOpenURL( |
3126 GetSiteInstance(), url)) | 3180 GetSiteInstance(), url)) |
3127 dest_url = GURL(kAboutBlankURL); | 3181 dest_url = GURL(kAboutBlankURL); |
3128 | 3182 |
3129 OpenURLParams params(dest_url, referrer, source_frame_id, disposition, | 3183 int64 frame_tree_node_id = -1; |
| 3184 if (source_frame_id != -1) { |
| 3185 frame_tree_node_id = static_cast<RenderViewHostImpl*>( |
| 3186 GetRenderViewHost())->GetFrameTreeNodeID(source_frame_id); |
| 3187 } |
| 3188 OpenURLParams params(dest_url, referrer, source_frame_id, |
| 3189 frame_tree_node_id, disposition, |
3130 page_transition, true /* is_renderer_initiated */); | 3190 page_transition, true /* is_renderer_initiated */); |
3131 if (redirect_chain.size() > 0) | 3191 if (redirect_chain.size() > 0) |
3132 params.redirect_chain = redirect_chain; | 3192 params.redirect_chain = redirect_chain; |
3133 params.transferred_global_request_id = old_request_id; | 3193 params.transferred_global_request_id = old_request_id; |
3134 params.should_replace_current_entry = should_replace_current_entry; | 3194 params.should_replace_current_entry = should_replace_current_entry; |
3135 params.user_gesture = user_gesture; | 3195 params.user_gesture = user_gesture; |
3136 | 3196 |
3137 if (render_manager_.web_ui()) { | 3197 if (GetRenderManager()->web_ui()) { |
3138 // Web UI pages sometimes want to override the page transition type for | 3198 // Web UI pages sometimes want to override the page transition type for |
3139 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for | 3199 // link clicks (e.g., so the new tab page can specify AUTO_BOOKMARK for |
3140 // automatically generated suggestions). We don't override other types | 3200 // automatically generated suggestions). We don't override other types |
3141 // like TYPED because they have different implications (e.g., autocomplete). | 3201 // like TYPED because they have different implications (e.g., autocomplete). |
3142 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) | 3202 if (PageTransitionCoreTypeIs(params.transition, PAGE_TRANSITION_LINK)) |
3143 params.transition = render_manager_.web_ui()->GetLinkTransitionType(); | 3203 params.transition = GetRenderManager()->web_ui()->GetLinkTransitionType(); |
3144 | 3204 |
3145 // Note also that we hide the referrer for Web UI pages. We don't really | 3205 // Note also that we hide the referrer for Web UI pages. We don't really |
3146 // want web sites to see a referrer of "chrome://blah" (and some | 3206 // want web sites to see a referrer of "chrome://blah" (and some |
3147 // chrome: URLs might have search terms or other stuff we don't want to | 3207 // chrome: URLs might have search terms or other stuff we don't want to |
3148 // send to the site), so we send no referrer. | 3208 // send to the site), so we send no referrer. |
3149 params.referrer = Referrer(); | 3209 params.referrer = Referrer(); |
3150 | 3210 |
3151 // Navigations in Web UI pages count as browser-initiated navigations. | 3211 // Navigations in Web UI pages count as browser-initiated navigations. |
3152 params.is_renderer_initiated = false; | 3212 params.is_renderer_initiated = false; |
3153 } | 3213 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3330 } | 3390 } |
3331 | 3391 |
3332 WebPreferences WebContentsImpl::GetWebkitPrefs() { | 3392 WebPreferences WebContentsImpl::GetWebkitPrefs() { |
3333 // We want to base the page config off of the actual URL, rather than the | 3393 // We want to base the page config off of the actual URL, rather than the |
3334 // virtual URL. | 3394 // virtual URL. |
3335 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, | 3395 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, |
3336 // as it is deprecated and can be out of sync with GetRenderViewHost(). | 3396 // as it is deprecated and can be out of sync with GetRenderViewHost(). |
3337 GURL url = controller_.GetActiveEntry() | 3397 GURL url = controller_.GetActiveEntry() |
3338 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3398 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
3339 | 3399 |
3340 return render_manager_.current_host()->GetWebkitPrefs(url); | 3400 return GetRenderManager()->current_host()->GetWebkitPrefs(url); |
3341 } | 3401 } |
3342 | 3402 |
3343 int WebContentsImpl::CreateSwappedOutRenderView( | 3403 int WebContentsImpl::CreateSwappedOutRenderView( |
3344 SiteInstance* instance) { | 3404 SiteInstance* instance) { |
3345 return render_manager_.CreateRenderView(instance, MSG_ROUTING_NONE, | 3405 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, |
3346 true, true); | 3406 true, true); |
3347 } | 3407 } |
3348 | 3408 |
3349 void WebContentsImpl::OnUserGesture() { | 3409 void WebContentsImpl::OnUserGesture() { |
3350 // Notify observers. | 3410 // Notify observers. |
3351 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3411 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
3352 | 3412 |
3353 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3413 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
3354 if (rdh) // NULL in unittests. | 3414 if (rdh) // NULL in unittests. |
3355 rdh->OnUserGesture(this); | 3415 rdh->OnUserGesture(this); |
3356 } | 3416 } |
(...skipping 16 matching lines...) Expand all Loading... |
3373 // since the event may be a result of the renderer sitting on a breakpoint. | 3433 // since the event may be a result of the renderer sitting on a breakpoint. |
3374 // See http://crbug.com/65458 | 3434 // See http://crbug.com/65458 |
3375 if (DevToolsAgentHost::IsDebuggerAttached(this)) | 3435 if (DevToolsAgentHost::IsDebuggerAttached(this)) |
3376 return; | 3436 return; |
3377 | 3437 |
3378 if (is_during_beforeunload || is_during_unload) { | 3438 if (is_during_beforeunload || is_during_unload) { |
3379 // Hang occurred while firing the beforeunload/unload handler. | 3439 // Hang occurred while firing the beforeunload/unload handler. |
3380 // Pretend the handler fired so tab closing continues as if it had. | 3440 // Pretend the handler fired so tab closing continues as if it had. |
3381 rvhi->set_sudden_termination_allowed(true); | 3441 rvhi->set_sudden_termination_allowed(true); |
3382 | 3442 |
3383 if (!render_manager_.ShouldCloseTabOnUnresponsiveRenderer()) | 3443 if (!GetRenderManager()->ShouldCloseTabOnUnresponsiveRenderer()) |
3384 return; | 3444 return; |
3385 | 3445 |
3386 // If the tab hangs in the beforeunload/unload handler there's really | 3446 // If the tab hangs in the beforeunload/unload handler there's really |
3387 // nothing we can do to recover. If the hang is in the beforeunload handler, | 3447 // nothing we can do to recover. If the hang is in the beforeunload handler, |
3388 // pretend the beforeunload listeners have all fired and allow the delegate | 3448 // pretend the beforeunload listeners have all fired and allow the delegate |
3389 // to continue closing; the user will not have the option of cancelling the | 3449 // to continue closing; the user will not have the option of cancelling the |
3390 // close. Otherwise, pretend the unload listeners have all fired and close | 3450 // close. Otherwise, pretend the unload listeners have all fired and close |
3391 // the tab. | 3451 // the tab. |
3392 bool close = true; | 3452 bool close = true; |
3393 if (is_during_beforeunload) { | 3453 if (is_during_beforeunload) { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { | 3550 int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) { |
3491 int opener_route_id = MSG_ROUTING_NONE; | 3551 int opener_route_id = MSG_ROUTING_NONE; |
3492 | 3552 |
3493 // If this tab has an opener, ensure it has a RenderView in the given | 3553 // If this tab has an opener, ensure it has a RenderView in the given |
3494 // SiteInstance as well. | 3554 // SiteInstance as well. |
3495 if (opener_) | 3555 if (opener_) |
3496 opener_route_id = opener_->CreateOpenerRenderViews(instance); | 3556 opener_route_id = opener_->CreateOpenerRenderViews(instance); |
3497 | 3557 |
3498 // If any of the renderers (current, pending, or swapped out) for this | 3558 // If any of the renderers (current, pending, or swapped out) for this |
3499 // WebContents has the same SiteInstance, use it. | 3559 // WebContents has the same SiteInstance, use it. |
3500 if (render_manager_.current_host()->GetSiteInstance() == instance) | 3560 if (GetRenderManager()->current_host()->GetSiteInstance() == instance) |
3501 return render_manager_.current_host()->GetRoutingID(); | 3561 return GetRenderManager()->current_host()->GetRoutingID(); |
3502 | 3562 |
3503 if (render_manager_.pending_render_view_host() && | 3563 if (GetRenderManager()->pending_render_view_host() && |
3504 render_manager_.pending_render_view_host()->GetSiteInstance() == instance) | 3564 GetRenderManager()->pending_render_view_host()->GetSiteInstance() == |
3505 return render_manager_.pending_render_view_host()->GetRoutingID(); | 3565 instance) |
| 3566 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
3506 | 3567 |
3507 RenderViewHostImpl* rvh = render_manager_.GetSwappedOutRenderViewHost( | 3568 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
3508 instance); | 3569 instance); |
3509 if (rvh) | 3570 if (rvh) |
3510 return rvh->GetRoutingID(); | 3571 return rvh->GetRoutingID(); |
3511 | 3572 |
3512 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3573 // Create a swapped out RenderView in the given SiteInstance if none exists, |
3513 // setting its opener to the given route_id. Return the new view's route_id. | 3574 // setting its opener to the given route_id. Return the new view's route_id. |
3514 return render_manager_.CreateRenderView(instance, opener_route_id, | 3575 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, |
3515 true, true); | 3576 true, true); |
3516 } | 3577 } |
3517 | 3578 |
3518 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3579 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
3519 return GetController(); | 3580 return GetController(); |
3520 } | 3581 } |
3521 | 3582 |
3522 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3583 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
3523 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3584 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
3524 } | 3585 } |
3525 | 3586 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3650 } | 3711 } |
3651 | 3712 |
3652 void WebContentsImpl::OnFrameRemoved( | 3713 void WebContentsImpl::OnFrameRemoved( |
3653 RenderViewHostImpl* render_view_host, | 3714 RenderViewHostImpl* render_view_host, |
3654 int64 frame_id) { | 3715 int64 frame_id) { |
3655 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3716 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3656 FrameDetached(render_view_host, frame_id)); | 3717 FrameDetached(render_view_host, frame_id)); |
3657 } | 3718 } |
3658 | 3719 |
3659 } // namespace content | 3720 } // namespace content |
OLD | NEW |