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