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 GetWebStateImpl()->GetNavigationManager()->DiscardNonCommittedItems(); | 87 NavigationManager* nav_manager = GetWebStateImpl()->GetNavigationManager(); |
| 88 nav_manager->DiscardNonCommittedItems(); |
88 | 89 |
89 Hide(); | 90 Hide(); |
90 | 91 |
91 GetDelegate()->OnDontProceed(); | 92 GetDelegate()->OnDontProceed(); |
92 | 93 |
| 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 |
93 delete this; | 100 delete this; |
94 } | 101 } |
95 | 102 |
96 void WebInterstitialImpl::Proceed() { | 103 void WebInterstitialImpl::Proceed() { |
97 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. | 104 // Proceed() and DontProceed() are not re-entrant, as they delete |this|. |
98 if (action_taken_) | 105 if (action_taken_) |
99 return; | 106 return; |
100 action_taken_ = true; | 107 action_taken_ = true; |
101 Hide(); | 108 Hide(); |
102 GetDelegate()->OnProceed(); | 109 GetDelegate()->OnProceed(); |
103 delete this; | 110 delete this; |
104 } | 111 } |
105 | 112 |
106 void WebInterstitialImpl::WebStateDestroyed() { | 113 void WebInterstitialImpl::WebStateDestroyed() { |
107 DontProceed(); | 114 DontProceed(); |
108 } | 115 } |
109 | 116 |
110 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const { | 117 WebStateImpl* WebInterstitialImpl::GetWebStateImpl() const { |
111 return static_cast<web::WebStateImpl*>(web_state()); | 118 return static_cast<web::WebStateImpl*>(web_state()); |
112 } | 119 } |
113 | 120 |
114 } // namespace web | 121 } // namespace web |
OLD | NEW |