| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/web/interstitials/web_interstitial_impl.h" | 5 #import "ios/web/interstitials/web_interstitial_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ios/web/interstitials/web_interstitial_facade_delegate.h" | 8 #include "ios/web/interstitials/web_interstitial_facade_delegate.h" |
| 9 #import "ios/web/navigation/crw_session_controller.h" | 9 #import "ios/web/navigation/crw_session_controller.h" |
| 10 #import "ios/web/navigation/navigation_manager_impl.h" | 10 #import "ios/web/navigation/navigation_manager_impl.h" |
| 11 #import "ios/web/public/interstitials/web_interstitial_delegate.h" | 11 #import "ios/web/public/interstitials/web_interstitial_delegate.h" |
| 12 #import "ios/web/public/navigation_manager.h" | 12 #import "ios/web/public/navigation_manager.h" |
| 13 #include "ios/web/public/reload_type.h" |
| 13 #import "ios/web/web_state/web_state_impl.h" | 14 #import "ios/web/web_state/web_state_impl.h" |
| 14 | 15 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) | 16 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." | 17 #error "This file requires ARC support." |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 namespace web { | 20 namespace web { |
| 20 | 21 |
| 21 // static | 22 // static |
| 22 WebInterstitial* WebInterstitial::GetWebInterstitial(web::WebState* web_state) { | 23 WebInterstitial* WebInterstitial::GetWebInterstitial(web::WebState* web_state) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 NavigationManager* nav_manager = GetWebStateImpl()->GetNavigationManager(); | 87 NavigationManager* nav_manager = GetWebStateImpl()->GetNavigationManager(); |
| 87 nav_manager->DiscardNonCommittedItems(); | 88 nav_manager->DiscardNonCommittedItems(); |
| 88 | 89 |
| 89 Hide(); | 90 Hide(); |
| 90 | 91 |
| 91 GetDelegate()->OnDontProceed(); | 92 GetDelegate()->OnDontProceed(); |
| 92 | 93 |
| 93 NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; | 94 NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; |
| 94 if (![user_defaults boolForKey:@"PendingIndexNavigationDisabled"]) { | 95 if (![user_defaults boolForKey:@"PendingIndexNavigationDisabled"]) { |
| 95 // Reload last committed entry. | 96 // Reload last committed entry. |
| 96 nav_manager->Reload(true /* check_for_repost */); | 97 nav_manager->Reload(ReloadType::NORMAL, true /* check_for_repost */); |
| 97 } | 98 } |
| 98 | 99 |
| 99 delete this; | 100 delete this; |
| 100 } | 101 } |
| 101 | 102 |
| 102 void WebInterstitialImpl::Proceed() { | 103 void WebInterstitialImpl::Proceed() { |
| 103 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. | 104 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. |
| 104 if (action_taken_) | 105 if (action_taken_) |
| 105 return; | 106 return; |
| 106 action_taken_ = true; | 107 action_taken_ = true; |
| 107 Hide(); | 108 Hide(); |
| 108 GetDelegate()->OnProceed(); | 109 GetDelegate()->OnProceed(); |
| 109 delete this; | 110 delete this; |
| 110 } | 111 } |
| 111 | 112 |
| 112 void WebInterstitialImpl::WebStateDestroyed() { | 113 void WebInterstitialImpl::WebStateDestroyed() { |
| 113 DontProceed(); | 114 DontProceed(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const { | 117 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const { |
| 117 return static_cast<web::WebStateImpl*>(web_state()); | 118 return static_cast<web::WebStateImpl*>(web_state()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 } // namespace web | 121 } // namespace web |
| OLD | NEW |