Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: ios/chrome/browser/ui/authentication/signin_interaction_controller.mm

Issue 2940063004: Revert of Removes usage of signin APIs that return scoped_nsobjects. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/signin_interaction_controller.h" 5 #import "ios/chrome/browser/ui/authentication/signin_interaction_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "components/prefs/pref_service.h" 9 #include "components/prefs/pref_service.h"
10 #include "components/signin/core/browser/signin_manager.h" 10 #include "components/signin/core/browser/signin_manager.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 ios::GetChromeBrowserProvider()->GetChromeIdentityService(); 108 ios::GetChromeBrowserProvider()->GetChromeIdentityService();
109 if (identity) { 109 if (identity) {
110 DCHECK(identityService->IsValidIdentity(identity)); 110 DCHECK(identityService->IsValidIdentity(identity));
111 DCHECK(!signinViewController_); 111 DCHECK(!signinViewController_);
112 [self showSigninViewControllerWithIdentity:identity identityAdded:NO]; 112 [self showSigninViewControllerWithIdentity:identity identityAdded:NO];
113 } else if (identityService->HasIdentities()) { 113 } else if (identityService->HasIdentities()) {
114 DCHECK(!signinViewController_); 114 DCHECK(!signinViewController_);
115 [self showSigninViewControllerWithIdentity:nil identityAdded:NO]; 115 [self showSigninViewControllerWithIdentity:nil identityAdded:NO];
116 } else { 116 } else {
117 identityInteractionManager_ = 117 identityInteractionManager_ =
118 identityService->CreateChromeIdentityInteractionManager(browserState_, 118 identityService->NewChromeIdentityInteractionManager(browserState_,
119 self); 119 self);
120 if (!identityInteractionManager_) { 120 if (!identityInteractionManager_) {
121 // Abort sign-in if the ChromeIdentityInteractionManager returned is 121 // Abort sign-in if the ChromeIdentityInteractionManager returned is
122 // nil (this can happen when the iOS internal provider is not used). 122 // nil (this can happen when the iOS internal provider is not used).
123 [self runCompletionCallbackWithSuccess:NO executeCommand:nil]; 123 [self runCompletionCallbackWithSuccess:NO executeCommand:nil];
124 return; 124 return;
125 } 125 }
126 126
127 __weak SigninInteractionController* weakSelf = self; 127 __weak SigninInteractionController* weakSelf = self;
128 [identityInteractionManager_ 128 [identityInteractionManager_
129 addAccountWithCompletion:^(ChromeIdentity* identity, NSError* error) { 129 addAccountWithCompletion:^(ChromeIdentity* identity, NSError* error) {
(...skipping 25 matching lines...) Expand all
155 emailToReauthenticate = browserState_->GetPrefs()->GetString( 155 emailToReauthenticate = browserState_->GetPrefs()->GetString(
156 prefs::kGoogleServicesLastUsername); 156 prefs::kGoogleServicesLastUsername);
157 idToReauthenticate = browserState_->GetPrefs()->GetString( 157 idToReauthenticate = browserState_->GetPrefs()->GetString(
158 prefs::kGoogleServicesLastAccountId); 158 prefs::kGoogleServicesLastAccountId);
159 } 159 }
160 DCHECK(!emailToReauthenticate.empty()); 160 DCHECK(!emailToReauthenticate.empty());
161 DCHECK(!idToReauthenticate.empty()); 161 DCHECK(!idToReauthenticate.empty());
162 identityInteractionManager_ = 162 identityInteractionManager_ =
163 ios::GetChromeBrowserProvider() 163 ios::GetChromeBrowserProvider()
164 ->GetChromeIdentityService() 164 ->GetChromeIdentityService()
165 ->CreateChromeIdentityInteractionManager(browserState_, self); 165 ->NewChromeIdentityInteractionManager(browserState_, self);
166 __weak SigninInteractionController* weakSelf = self; 166 __weak SigninInteractionController* weakSelf = self;
167 [identityInteractionManager_ 167 [identityInteractionManager_
168 reauthenticateUserWithID:base::SysUTF8ToNSString(idToReauthenticate) 168 reauthenticateUserWithID:base::SysUTF8ToNSString(idToReauthenticate)
169 email:base::SysUTF8ToNSString(emailToReauthenticate) 169 email:base::SysUTF8ToNSString(emailToReauthenticate)
170 completion:^(ChromeIdentity* identity, NSError* error) { 170 completion:^(ChromeIdentity* identity, NSError* error) {
171 [weakSelf handleIdentityAdded:identity 171 [weakSelf handleIdentityAdded:identity
172 error:error 172 error:error
173 shouldSignIn:YES 173 shouldSignIn:YES
174 viewController:viewController]; 174 viewController:viewController];
175 }]; 175 }];
176 } 176 }
177 177
178 - (void)addAccountWithCompletion:(CompletionCallback)completion 178 - (void)addAccountWithCompletion:(CompletionCallback)completion
179 viewController:(UIViewController*)viewController { 179 viewController:(UIViewController*)viewController {
180 completionCallback_ = [completion copy]; 180 completionCallback_ = [completion copy];
181 identityInteractionManager_ = 181 identityInteractionManager_ =
182 ios::GetChromeBrowserProvider() 182 ios::GetChromeBrowserProvider()
183 ->GetChromeIdentityService() 183 ->GetChromeIdentityService()
184 ->CreateChromeIdentityInteractionManager(browserState_, self); 184 ->NewChromeIdentityInteractionManager(browserState_, self);
185 __weak SigninInteractionController* weakSelf = self; 185 __weak SigninInteractionController* weakSelf = self;
186 [identityInteractionManager_ 186 [identityInteractionManager_
187 addAccountWithCompletion:^(ChromeIdentity* identity, NSError* error) { 187 addAccountWithCompletion:^(ChromeIdentity* identity, NSError* error) {
188 [weakSelf handleIdentityAdded:identity 188 [weakSelf handleIdentityAdded:identity
189 error:error 189 error:error
190 shouldSignIn:NO 190 shouldSignIn:NO
191 viewController:viewController]; 191 viewController:viewController];
192 }]; 192 }];
193 } 193 }
194 194
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 completionCallback_(success); 386 completionCallback_(success);
387 completionCallback_ = nil; 387 completionCallback_ = nil;
388 } 388 }
389 strongSelf = nil; 389 strongSelf = nil;
390 if (command) { 390 if (command) {
391 [presentingViewController chromeExecuteCommand:command]; 391 [presentingViewController chromeExecuteCommand:command];
392 } 392 }
393 } 393 }
394 394
395 @end 395 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698