OLD | NEW |
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, this, this, |
163 static_cast<WebContentsImpl*>(web_contents)), | 163 static_cast<WebContentsImpl*>(web_contents)), |
164 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), | 164 original_child_id_(web_contents->GetRenderProcessHost()->GetID()), |
165 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), | 165 original_rvh_id_(web_contents->GetRenderViewHost()->GetRoutingID()), |
166 should_revert_web_contents_title_(false), | 166 should_revert_web_contents_title_(false), |
| 167 web_contents_was_loading_(false), |
167 resource_dispatcher_host_notified_(false), | 168 resource_dispatcher_host_notified_(false), |
168 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), | 169 rvh_delegate_view_(new InterstitialPageRVHDelegateView(this)), |
169 create_view_(true), | 170 create_view_(true), |
170 delegate_(delegate), | 171 delegate_(delegate), |
171 weak_ptr_factory_(this) { | 172 weak_ptr_factory_(this) { |
172 InitInterstitialPageMap(); | 173 InitInterstitialPageMap(); |
173 } | 174 } |
174 | 175 |
175 InterstitialPageImpl::~InterstitialPageImpl() { | 176 InterstitialPageImpl::~InterstitialPageImpl() { |
176 } | 177 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 511 |
511 // The RenderViewHost may already have crashed before we even get here. | 512 // The RenderViewHost may already have crashed before we even get here. |
512 if (rwh_view) { | 513 if (rwh_view) { |
513 // If the page has focus, focus the interstitial. | 514 // If the page has focus, focus the interstitial. |
514 if (rwh_view->HasFocus()) | 515 if (rwh_view->HasFocus()) |
515 Focus(); | 516 Focus(); |
516 | 517 |
517 // Hide the original RVH since we're showing the interstitial instead. | 518 // Hide the original RVH since we're showing the interstitial instead. |
518 rwh_view->Hide(); | 519 rwh_view->Hide(); |
519 } | 520 } |
| 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); |
520 } | 529 } |
521 | 530 |
522 RendererPreferences InterstitialPageImpl::GetRendererPrefs( | 531 RendererPreferences InterstitialPageImpl::GetRendererPrefs( |
523 BrowserContext* browser_context) const { | 532 BrowserContext* browser_context) const { |
524 delegate_->OverrideRendererPrefs(&renderer_preferences_); | 533 delegate_->OverrideRendererPrefs(&renderer_preferences_); |
525 return renderer_preferences_; | 534 return renderer_preferences_; |
526 } | 535 } |
527 | 536 |
528 void InterstitialPageImpl::RenderWidgetDeleted( | 537 void InterstitialPageImpl::RenderWidgetDeleted( |
529 RenderWidgetHostImpl* render_widget_host) { | 538 RenderWidgetHostImpl* render_widget_host) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 if (!render_view_host_) | 627 if (!render_view_host_) |
619 return; | 628 return; |
620 | 629 |
621 if (action_taken_ != NO_ACTION) { | 630 if (action_taken_ != NO_ACTION) { |
622 NOTREACHED(); | 631 NOTREACHED(); |
623 return; | 632 return; |
624 } | 633 } |
625 Disable(); | 634 Disable(); |
626 action_taken_ = PROCEED_ACTION; | 635 action_taken_ = PROCEED_ACTION; |
627 | 636 |
628 controller_->delegate()->DidProceedOnInterstitial(); | 637 // Resumes the throbber, if applicable. |
| 638 if (web_contents_was_loading_) |
| 639 controller_->delegate()->SetIsLoading(true, true, NULL); |
629 | 640 |
630 // If this is a new navigation, the old page is going away, so we cancel any | 641 // If this is a new navigation, the old page is going away, so we cancel any |
631 // blocked requests for it. If it is not a new navigation, then it means the | 642 // blocked requests for it. If it is not a new navigation, then it means the |
632 // interstitial was shown as a result of a resource loading in the page. | 643 // interstitial was shown as a result of a resource loading in the page. |
633 // Since the user wants to proceed, we'll let any blocked request go through. | 644 // Since the user wants to proceed, we'll let any blocked request go through. |
634 if (new_navigation_) | 645 if (new_navigation_) |
635 TakeActionOnResourceDispatcher(CANCEL); | 646 TakeActionOnResourceDispatcher(CANCEL); |
636 else | 647 else |
637 TakeActionOnResourceDispatcher(RESUME); | 648 TakeActionOnResourceDispatcher(RESUME); |
638 | 649 |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( | 938 void InterstitialPageImpl::UnderlyingContentObserver::NavigationEntryCommitted( |
928 const LoadCommittedDetails& load_details) { | 939 const LoadCommittedDetails& load_details) { |
929 interstitial_->OnNavigatingAwayOrTabClosing(); | 940 interstitial_->OnNavigatingAwayOrTabClosing(); |
930 } | 941 } |
931 | 942 |
932 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { | 943 void InterstitialPageImpl::UnderlyingContentObserver::WebContentsDestroyed() { |
933 interstitial_->OnNavigatingAwayOrTabClosing(); | 944 interstitial_->OnNavigatingAwayOrTabClosing(); |
934 } | 945 } |
935 | 946 |
936 } // namespace content | 947 } // namespace content |
OLD | NEW |