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