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