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 (std::set<std::string>::iterator it = scopes.begin(); it != scopes.end(); | |
sdefresne
2015/08/04 08:46:17
nit: use c++11 for loop
for (const auto& scope :
| |
15 ++it) { | |
16 [scopes_array addObject:base::SysUTF8ToNSString(*it)]; | |
17 } | |
18 return scopes_array; | |
19 } | |
20 | |
21 std::string GetCanonicalizedEmailForIdentity(ChromeIdentity* identity) { | |
22 NSString* nsEmail = [identity userEmail]; | |
23 if (!nsEmail) | |
24 return ""; | |
sdefresne
2015/08/04 08:46:17
return std::string();
| |
25 std::string email = base::SysNSStringToUTF8(nsEmail); | |
26 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email)); | |
27 } | |
28 | |
29 bool ShouldHandleSigninError(NSError* error) { | |
30 ios::SigninErrorProvider* provider = ios::GetSigninErrorProvider(); | |
31 return ![provider->GetSigninErrorDomain() isEqualToString:error.domain] || | |
32 (error.code != provider->GetCode(ios::SigninError::CANCELED) && | |
33 error.code != | |
34 provider->GetCode(ios::SigninError::HANDLED_INTERNALLY)); | |
35 } | |
OLD | NEW |