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/signin/signin_util.h" | 5 #include "ios/chrome/browser/signin/signin_util.h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "google_apis/gaia/gaia_auth_util.h" | 8 #include "google_apis/gaia/gaia_auth_util.h" |
9 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" | |
10 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" | 9 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" |
11 #include "ios/public/provider/chrome/browser/signin/signin_error_provider.h" | 10 #include "ios/public/provider/chrome/browser/signin/signin_error_provider.h" |
12 | 11 |
13 NSArray* GetScopeArray(const std::set<std::string>& scopes) { | 12 NSArray* GetScopeArray(const std::set<std::string>& scopes) { |
14 NSMutableArray* scopes_array = [[[NSMutableArray alloc] init] autorelease]; | 13 NSMutableArray* scopes_array = [[[NSMutableArray alloc] init] autorelease]; |
15 for (const auto& scope : scopes) { | 14 for (const auto& scope : scopes) { |
16 [scopes_array addObject:base::SysUTF8ToNSString(scope)]; | 15 [scopes_array addObject:base::SysUTF8ToNSString(scope)]; |
17 } | 16 } |
18 return scopes_array; | 17 return scopes_array; |
19 } | 18 } |
20 | 19 |
21 std::string GetCanonicalizedEmailForIdentity(ChromeIdentity* identity) { | 20 std::string GetCanonicalizedEmailForIdentity(ChromeIdentity* identity) { |
22 NSString* nsEmail = [identity userEmail]; | 21 NSString* nsEmail = [identity userEmail]; |
23 if (!nsEmail) | 22 if (!nsEmail) |
24 return std::string(); | 23 return std::string(); |
25 std::string email = base::SysNSStringToUTF8(nsEmail); | 24 std::string email = base::SysNSStringToUTF8(nsEmail); |
26 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email)); | 25 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email)); |
27 } | 26 } |
28 | 27 |
29 bool ShouldHandleSigninError(NSError* error) { | 28 bool ShouldHandleSigninError(NSError* error) { |
30 ios::SigninErrorProvider* provider = | 29 ios::SigninErrorProvider* provider = ios::GetSigninErrorProvider(); |
31 ios::GetChromeBrowserProvider()->GetSigninErrorProvider(); | |
32 return ![provider->GetSigninErrorDomain() isEqualToString:error.domain] || | 30 return ![provider->GetSigninErrorDomain() isEqualToString:error.domain] || |
33 (error.code != provider->GetCode(ios::SigninError::CANCELED) && | 31 (error.code != provider->GetCode(ios::SigninError::CANCELED) && |
34 error.code != | 32 error.code != |
35 provider->GetCode(ios::SigninError::HANDLED_INTERNALLY)); | 33 provider->GetCode(ios::SigninError::HANDLED_INTERNALLY)); |
36 } | 34 } |
OLD | NEW |