| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chrome/browser/ui/authentication/authentication_flow.h" | 5 #import "ios/chrome/browser/ui/authentication/authentication_flow.h" |
| 6 | 6 |
| 7 #include "base/ios/weak_nsobject.h" | 7 #include "base/ios/weak_nsobject.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/objc_property_releaser.h" | 9 #include "base/mac/objc_release_properties.h" |
| 10 #include "base/mac/scoped_block.h" | 10 #include "base/mac/scoped_block.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 12 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 13 #include "ios/chrome/browser/signin/authentication_service.h" | 13 #include "ios/chrome/browser/signin/authentication_service.h" |
| 14 #include "ios/chrome/browser/signin/authentication_service_factory.h" | 14 #include "ios/chrome/browser/signin/authentication_service_factory.h" |
| 15 #include "ios/chrome/browser/signin/constants.h" | 15 #include "ios/chrome/browser/signin/constants.h" |
| 16 #import "ios/chrome/browser/ui/authentication/authentication_flow_performer.h" | 16 #import "ios/chrome/browser/ui/authentication/authentication_flow_performer.h" |
| 17 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
| 18 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 18 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 19 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" | 19 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 BOOL _shouldStartSync; | 94 BOOL _shouldStartSync; |
| 95 ios::ChromeBrowserState* _browserState; | 95 ios::ChromeBrowserState* _browserState; |
| 96 base::scoped_nsobject<ChromeIdentity> _browserStateIdentity; | 96 base::scoped_nsobject<ChromeIdentity> _browserStateIdentity; |
| 97 base::scoped_nsobject<ChromeIdentity> _identityToSignIn; | 97 base::scoped_nsobject<ChromeIdentity> _identityToSignIn; |
| 98 base::scoped_nsobject<NSString> _identityToSignInHostedDomain; | 98 base::scoped_nsobject<NSString> _identityToSignInHostedDomain; |
| 99 | 99 |
| 100 // This AuthenticationFlow keeps a reference to |self| while a sign-in flow is | 100 // This AuthenticationFlow keeps a reference to |self| while a sign-in flow is |
| 101 // is in progress to ensure it outlives any attempt to destroy it in | 101 // is in progress to ensure it outlives any attempt to destroy it in |
| 102 // |_signInCompletion|. | 102 // |_signInCompletion|. |
| 103 base::scoped_nsobject<AuthenticationFlow> _selfRetainer; | 103 base::scoped_nsobject<AuthenticationFlow> _selfRetainer; |
| 104 | |
| 105 base::mac::ObjCPropertyReleaser _propertyReleaser_AuthenticationFlow; | |
| 106 } | 104 } |
| 107 | 105 |
| 108 @synthesize handlingError = _handlingError; | 106 @synthesize handlingError = _handlingError; |
| 109 | 107 |
| 110 #pragma mark - Public methods | 108 #pragma mark - Public methods |
| 111 | 109 |
| 112 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState | 110 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 113 identity:(ChromeIdentity*)identity | 111 identity:(ChromeIdentity*)identity |
| 114 shouldClearData:(ShouldClearData)shouldClearData | 112 shouldClearData:(ShouldClearData)shouldClearData |
| 115 postSignInAction:(PostSignInAction)postSignInAction | 113 postSignInAction:(PostSignInAction)postSignInAction |
| 116 presentingViewController: | 114 presentingViewController: |
| 117 (UIViewController*)presentingViewController { | 115 (UIViewController*)presentingViewController { |
| 118 if ((self = [super init])) { | 116 if ((self = [super init])) { |
| 119 DCHECK(browserState); | 117 DCHECK(browserState); |
| 120 DCHECK(presentingViewController); | 118 DCHECK(presentingViewController); |
| 121 _browserState = browserState; | 119 _browserState = browserState; |
| 122 _identityToSignIn.reset([identity retain]); | 120 _identityToSignIn.reset([identity retain]); |
| 123 _shouldClearData = shouldClearData; | 121 _shouldClearData = shouldClearData; |
| 124 _postSignInAction = postSignInAction; | 122 _postSignInAction = postSignInAction; |
| 125 _presentingViewController.reset([presentingViewController retain]); | 123 _presentingViewController.reset([presentingViewController retain]); |
| 126 _state = BEGIN; | 124 _state = BEGIN; |
| 127 _propertyReleaser_AuthenticationFlow.Init(self, [AuthenticationFlow class]); | |
| 128 } | 125 } |
| 129 return self; | 126 return self; |
| 130 } | 127 } |
| 131 | 128 |
| 129 - (void)dealloc { |
| 130 base::mac::ReleaseProperties(self); |
| 131 [super dealloc]; |
| 132 } |
| 133 |
| 132 - (void)startSignInWithCompletion:(CompletionCallback)completion { | 134 - (void)startSignInWithCompletion:(CompletionCallback)completion { |
| 133 DCHECK_EQ(BEGIN, _state); | 135 DCHECK_EQ(BEGIN, _state); |
| 134 DCHECK(!_signInCompletion); | 136 DCHECK(!_signInCompletion); |
| 135 DCHECK(completion); | 137 DCHECK(completion); |
| 136 _signInCompletion.reset(completion, base::scoped_policy::RETAIN); | 138 _signInCompletion.reset(completion, base::scoped_policy::RETAIN); |
| 137 _selfRetainer.reset([self retain]); | 139 _selfRetainer.reset([self retain]); |
| 138 // Kick off the state machine. | 140 // Kick off the state machine. |
| 139 if (!_performer) { | 141 if (!_performer) { |
| 140 _performer.reset( | 142 _performer.reset( |
| 141 [[AuthenticationFlowPerformer alloc] initWithDelegate:self]); | 143 [[AuthenticationFlowPerformer alloc] initWithDelegate:self]); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 return _presentingViewController; | 449 return _presentingViewController; |
| 448 } | 450 } |
| 449 | 451 |
| 450 #pragma mark - Used for testing | 452 #pragma mark - Used for testing |
| 451 | 453 |
| 452 - (void)setPerformerForTesting:(AuthenticationFlowPerformer*)performer { | 454 - (void)setPerformerForTesting:(AuthenticationFlowPerformer*)performer { |
| 453 _performer.reset([performer retain]); | 455 _performer.reset([performer retain]); |
| 454 } | 456 } |
| 455 | 457 |
| 456 @end | 458 @end |
| OLD | NEW |