| 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 "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" | 5 #include "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/mac/objc_property_releaser.h" | 9 #include "base/mac/objc_release_properties.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "components/sync_preferences/testing_pref_service_syncable.h" | 12 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 14 #include "ios/chrome/browser/infobars/confirm_infobar_controller.h" | 14 #include "ios/chrome/browser/infobars/confirm_infobar_controller.h" |
| 15 #include "ios/chrome/browser/infobars/infobar.h" | 15 #include "ios/chrome/browser/infobars/infobar.h" |
| 16 #include "ios/chrome/browser/infobars/infobar_utils.h" | 16 #include "ios/chrome/browser/infobars/infobar_utils.h" |
| 17 #include "ios/chrome/browser/signin/authentication_service.h" | 17 #include "ios/chrome/browser/signin/authentication_service.h" |
| 18 #include "ios/chrome/browser/signin/authentication_service_factory.h" | 18 #include "ios/chrome/browser/signin/authentication_service_factory.h" |
| 19 #include "ios/chrome/browser/signin/authentication_service_fake.h" | 19 #include "ios/chrome/browser/signin/authentication_service_fake.h" |
| 20 #include "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 20 #include "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 21 #import "ios/chrome/browser/ui/commands/show_signin_command.h" | 21 #import "ios/chrome/browser/ui/commands/show_signin_command.h" |
| 22 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" | 22 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity.h" |
| 23 #include "ios/web/public/test/test_web_thread_bundle.h" | 23 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 24 #include "testing/gtest_mac.h" | 24 #include "testing/gtest_mac.h" |
| 25 #include "testing/platform_test.h" | 25 #include "testing/platform_test.h" |
| 26 | 26 |
| 27 // View that intercepts and stores chrome commands sent up the responder chain. | 27 // View that intercepts and stores chrome commands sent up the responder chain. |
| 28 @interface CatchExecuteCommandView : UIView { | 28 @interface CatchExecuteCommandView : UIView |
| 29 base::mac::ObjCPropertyReleaser propertyReleaser_CatchExecuteCommandView_; | |
| 30 } | |
| 31 // Command sent up the responder chain and intercepted by this view. | 29 // Command sent up the responder chain and intercepted by this view. |
| 32 @property(nonatomic, retain) id command; | 30 @property(nonatomic, retain) id command; |
| 33 @end | 31 @end |
| 34 | 32 |
| 35 @implementation CatchExecuteCommandView | 33 @implementation CatchExecuteCommandView |
| 36 | 34 |
| 37 @synthesize command = _command; | 35 @synthesize command = _command; |
| 38 | 36 |
| 39 - (instancetype)initWithFrame:(CGRect)frame { | 37 - (void)dealloc { |
| 40 self = [super initWithFrame:frame]; | 38 base::mac::ReleaseProperties(self); |
| 41 if (self) { | 39 [super dealloc]; |
| 42 propertyReleaser_CatchExecuteCommandView_.Init( | |
| 43 self, [CatchExecuteCommandView class]); | |
| 44 } | |
| 45 return self; | |
| 46 } | 40 } |
| 47 | 41 |
| 48 - (void)chromeExecuteCommand:(id)command { | 42 - (void)chromeExecuteCommand:(id)command { |
| 49 DCHECK(command); | 43 DCHECK(command); |
| 50 DCHECK(!self.command); | 44 DCHECK(!self.command); |
| 51 self.command = command; | 45 self.command = command; |
| 52 } | 46 } |
| 53 | 47 |
| 54 @end | 48 @end |
| 55 | 49 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 [view.get() addSubview:infobarIOS->view()]; | 203 [view.get() addSubview:infobarIOS->view()]; |
| 210 | 204 |
| 211 ReSignInInfoBarDelegate* delegate = | 205 ReSignInInfoBarDelegate* delegate = |
| 212 static_cast<ReSignInInfoBarDelegate*>(infobarIOS->delegate()); | 206 static_cast<ReSignInInfoBarDelegate*>(infobarIOS->delegate()); |
| 213 delegate->InfoBarDismissed(); | 207 delegate->InfoBarDismissed(); |
| 214 EXPECT_FALSE(authService->ShouldPromptForSignIn()); | 208 EXPECT_FALSE(authService->ShouldPromptForSignIn()); |
| 215 EXPECT_FALSE([view command]); | 209 EXPECT_FALSE([view command]); |
| 216 } | 210 } |
| 217 | 211 |
| 218 } // namespace | 212 } // namespace |
| OLD | NEW |