| 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" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 void WebInterstitialImpl::DontProceed() { | 79 void WebInterstitialImpl::DontProceed() { |
| 80 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. | 80 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. |
| 81 if (action_taken_) | 81 if (action_taken_) |
| 82 return; | 82 return; |
| 83 action_taken_ = true; | 83 action_taken_ = true; |
| 84 | 84 |
| 85 // Clear the pending entry, since that's the page that's not being | 85 // Clear the pending entry, since that's the page that's not being |
| 86 // proceeded to. | 86 // proceeded to. |
| 87 NavigationManager* nav_manager = GetWebStateImpl()->GetNavigationManager(); | 87 GetWebStateImpl()->GetNavigationManager()->DiscardNonCommittedItems(); |
| 88 nav_manager->DiscardNonCommittedItems(); | |
| 89 | 88 |
| 90 Hide(); | 89 Hide(); |
| 91 | 90 |
| 92 GetDelegate()->OnDontProceed(); | 91 GetDelegate()->OnDontProceed(); |
| 93 | 92 |
| 94 NSUserDefaults* user_defaults = [NSUserDefaults standardUserDefaults]; | |
| 95 if (![user_defaults boolForKey:@"PendingIndexNavigationDisabled"]) { | |
| 96 // Reload last committed entry. | |
| 97 nav_manager->Reload(ReloadType::NORMAL, true /* check_for_repost */); | |
| 98 } | |
| 99 | |
| 100 delete this; | 93 delete this; |
| 101 } | 94 } |
| 102 | 95 |
| 103 void WebInterstitialImpl::Proceed() { | 96 void WebInterstitialImpl::Proceed() { |
| 104 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. | 97 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. |
| 105 if (action_taken_) | 98 if (action_taken_) |
| 106 return; | 99 return; |
| 107 action_taken_ = true; | 100 action_taken_ = true; |
| 108 Hide(); | 101 Hide(); |
| 109 GetDelegate()->OnProceed(); | 102 GetDelegate()->OnProceed(); |
| 110 delete this; | 103 delete this; |
| 111 } | 104 } |
| 112 | 105 |
| 113 void WebInterstitialImpl::WebStateDestroyed() { | 106 void WebInterstitialImpl::WebStateDestroyed() { |
| 114 DontProceed(); | 107 DontProceed(); |
| 115 } | 108 } |
| 116 | 109 |
| 117 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const { | 110 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const { |
| 118 return static_cast<web::WebStateImpl*>(web_state()); | 111 return static_cast<web::WebStateImpl*>(web_state()); |
| 119 } | 112 } |
| 120 | 113 |
| 121 } // namespace web | 114 } // namespace web |
| OLD | NEW |