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

Side by Side Diff: content/browser/frame_host/interstitial_page_impl.cc

Issue 1693353002: Reland #2 Remove the is_loading_ field from WebContentsImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/interstitial_page_impl.h" 5 #include "content/browser/frame_host/interstitial_page_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 enabled_(true), 152 enabled_(true),
153 action_taken_(NO_ACTION), 153 action_taken_(NO_ACTION),
154 render_view_host_(NULL), 154 render_view_host_(NULL),
155 // TODO(nasko): The InterstitialPageImpl will need to provide its own 155 // TODO(nasko): The InterstitialPageImpl will need to provide its own
156 // NavigationControllerImpl to the Navigator, which is separate from 156 // NavigationControllerImpl to the Navigator, which is separate from
157 // the WebContents one, so we can enforce no navigation policy here. 157 // the WebContents one, so we can enforce no navigation policy here.
158 // While we get the code to a point to do this, pass NULL for it. 158 // While we get the code to a point to do this, pass NULL for it.
159 // TODO(creis): We will also need to pass delegates for the RVHM as we 159 // TODO(creis): We will also need to pass delegates for the RVHM as we
160 // start to use it. 160 // start to use it.
161 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_), 161 frame_tree_(new InterstitialPageNavigatorImpl(this, controller_),
162 this, this, this, 162 this,
163 this,
164 this,
Charlie Reis 2016/02/19 05:24:54 Curious, is this a git cl format thing? In genera
clamy 2016/02/19 12:02:05 Yes it's a git cl format change: maybe it's differ
163 static_cast<WebContentsImpl*>(web_contents)), 165 static_cast<WebContentsImpl*>(web_contents)),
164 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), 166 original_child_id_(web_contents->GetRenderProcessHost()->GetID()),
165 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), 167 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()),
166 should_revert_web_contents_title_(false), 168 should_revert_web_contents_title_(false),
167 web_contents_was_loading_(false),
168 resource_dispatcher_host_notified_(false), 169 resource_dispatcher_host_notified_(false),
169 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), 170 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)),
170 create_view_(true), 171 create_view_(true),
172 pause_throbber_(false),
171 delegate_(delegate), 173 delegate_(delegate),
172 weak_ptr_factory_(this) { 174 weak_ptr_factory_(this) {
173 InitInterstitialPageMap(); 175 InitInterstitialPageMap();
174 } 176 }
175 177
176 InterstitialPageImpl::~InterstitialPageImpl() { 178 InterstitialPageImpl::~InterstitialPageImpl() {
177 } 179 }
178 180
179 void InterstitialPageImpl::Show() { 181 void InterstitialPageImpl::Show() {
180 if (!enabled()) 182 if (!enabled())
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 if (!enabled()) { 496 if (!enabled()) {
495 DontProceed(); 497 DontProceed();
496 return; 498 return;
497 } 499 }
498 if (ui::PageTransitionCoreTypeIs(params.transition, 500 if (ui::PageTransitionCoreTypeIs(params.transition,
499 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { 501 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) {
500 // No need to handle navigate message from iframe in the interstitial page. 502 // No need to handle navigate message from iframe in the interstitial page.
501 return; 503 return;
502 } 504 }
503 505
506 // The interstitial is not loading anymore so stop the throbber.
507 pause_throbber_ = true;
508
504 // The RenderViewHost has loaded its contents, we can show it now. 509 // The RenderViewHost has loaded its contents, we can show it now.
505 if (!controller_->delegate()->IsHidden()) 510 if (!controller_->delegate()->IsHidden())
506 render_view_host_->GetWidget()->GetView()->Show(); 511 render_view_host_->GetWidget()->GetView()->Show();
507 controller_->delegate()->AttachInterstitialPage(this); 512 controller_->delegate()->AttachInterstitialPage(this);
508 513
509 RenderWidgetHostView* rwh_view = 514 RenderWidgetHostView* rwh_view =
510 controller_->delegate()->GetRenderViewHost()->GetWidget()->GetView(); 515 controller_->delegate()->GetRenderViewHost()->GetWidget()->GetView();
511 516
512 // The RenderViewHost may already have crashed before we even get here. 517 // The RenderViewHost may already have crashed before we even get here.
513 if (rwh_view) { 518 if (rwh_view) {
514 // If the page has focus, focus the interstitial. 519 // If the page has focus, focus the interstitial.
515 if (rwh_view->HasFocus()) 520 if (rwh_view->HasFocus())
516 Focus(); 521 Focus();
517 522
518 // Hide the original RVH since we're showing the interstitial instead. 523 // Hide the original RVH since we're showing the interstitial instead.
519 rwh_view->Hide(); 524 rwh_view->Hide();
520 } 525 }
521
522 // Notify the tab we are not loading so the throbber is stopped. It also
523 // causes a WebContentsObserver::DidStopLoading callback that the
524 // AutomationProvider (used by the UI tests) expects to consider a navigation
525 // as complete. Without this, navigating in a UI test to a URL that triggers
526 // an interstitial would hang.
527 web_contents_was_loading_ = controller_->delegate()->IsLoading();
528 controller_->delegate()->SetIsLoading(false, true, NULL);
529 } 526 }
530 527
531 RendererPreferences InterstitialPageImpl::GetRendererPrefs( 528 RendererPreferences InterstitialPageImpl::GetRendererPrefs(
532 BrowserContext* browser_context) const { 529 BrowserContext* browser_context) const {
533 delegate_->OverrideRendererPrefs(&renderer_preferences_); 530 delegate_->OverrideRendererPrefs(&renderer_preferences_);
534 return renderer_preferences_; 531 return renderer_preferences_;
535 } 532 }
536 533
537 void InterstitialPageImpl::RenderWidgetDeleted( 534 void InterstitialPageImpl::RenderWidgetDeleted(
538 RenderWidgetHostImpl* render_widget_host) { 535 RenderWidgetHostImpl* render_widget_host) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 return; 625 return;
629 626
630 if (action_taken_ != NO_ACTION) { 627 if (action_taken_ != NO_ACTION) {
631 NOTREACHED(); 628 NOTREACHED();
632 return; 629 return;
633 } 630 }
634 Disable(); 631 Disable();
635 action_taken_ = PROCEED_ACTION; 632 action_taken_ = PROCEED_ACTION;
636 633
637 // Resumes the throbber, if applicable. 634 // Resumes the throbber, if applicable.
638 if (web_contents_was_loading_) 635 pause_throbber_ = false;
639 controller_->delegate()->SetIsLoading(true, true, NULL); 636 controller_->delegate()->DidProceedOnInterstitial();
640 637
641 // If this is a new navigation, the old page is going away, so we cancel any 638 // If this is a new navigation, the old page is going away, so we cancel any
642 // blocked requests for it. If it is not a new navigation, then it means the 639 // blocked requests for it. If it is not a new navigation, then it means the
643 // interstitial was shown as a result of a resource loading in the page. 640 // interstitial was shown as a result of a resource loading in the page.
644 // Since the user wants to proceed, we'll let any blocked request go through. 641 // Since the user wants to proceed, we'll let any blocked request go through.
645 if (new_navigation_) 642 if (new_navigation_)
646 TakeActionOnResourceDispatcher(CANCEL); 643 TakeActionOnResourceDispatcher(CANCEL);
647 else 644 else
648 TakeActionOnResourceDispatcher(RESUME); 645 TakeActionOnResourceDispatcher(RESUME);
649 646
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( 935 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted(
939 const LoadCommittedDetails& load_details) { 936 const LoadCommittedDetails& load_details) {
940 interstitial_->OnNavigatingAwayOrTabClosing(); 937 interstitial_->OnNavigatingAwayOrTabClosing();
941 } 938 }
942 939
943 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { 940 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() {
944 interstitial_->OnNavigatingAwayOrTabClosing(); 941 interstitial_->OnNavigatingAwayOrTabClosing();
945 } 942 }
946 943
947 } // namespace content 944 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698