diff options
author | bzanotti <bzanotti@chromium.org> | 2016-03-24 09:25:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-24 16:26:53 +0000 |
commit | 3a7634e6366c5af07940573c0a08f2fab832670d (patch) | |
tree | 837b626713871738a8dd8af15dcad07b1c0a7ac5 | |
parent | 291662056088696015887723c6c29f72c2ad08f4 (diff) | |
download | chromium_src-3a7634e6366c5af07940573c0a08f2fab832670d.zip chromium_src-3a7634e6366c5af07940573c0a08f2fab832670d.tar.gz chromium_src-3a7634e6366c5af07940573c0a08f2fab832670d.tar.bz2 |
Add GetAuthenticationErrorCategory method with gaia_id.
Also add a default implementation of ProfileOAuth2TokenServiceProvider.
Provider should not have pure virtual methods, as this breaks
compilation for the provider implementations when changing a method.
BUG=520908
Review URL: https://codereview.chromium.org/1826183002
Cr-Commit-Position: refs/heads/master@{#383075}
5 files changed, 59 insertions, 8 deletions
diff --git a/components/signin.gypi b/components/signin.gypi index c953738..77a27dd 100644 --- a/components/signin.gypi +++ b/components/signin.gypi @@ -235,6 +235,7 @@ 'signin/ios/browser/profile_oauth2_token_service_ios_delegate.h', 'signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm', 'signin/ios/browser/profile_oauth2_token_service_ios_provider.h', + 'signin/ios/browser/profile_oauth2_token_service_ios_provider.mm', ], }, { diff --git a/components/signin/ios/browser/BUILD.gn b/components/signin/ios/browser/BUILD.gn index d11349b..9d1572b 100644 --- a/components/signin/ios/browser/BUILD.gn +++ b/components/signin/ios/browser/BUILD.gn @@ -14,6 +14,7 @@ source_set("browser") { "profile_oauth2_token_service_ios_delegate.h", "profile_oauth2_token_service_ios_delegate.mm", "profile_oauth2_token_service_ios_provider.h", + "profile_oauth2_token_service_ios_provider.mm", ] deps = [ diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm index 80c9ae0..379e216 100644 --- a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm +++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm @@ -33,12 +33,13 @@ namespace { // google_apis/gaia/oauth2_access_token_fetcher.cc: GoogleServiceAuthError GetGoogleServiceAuthErrorFromNSError( ProfileOAuth2TokenServiceIOSProvider* provider, + const std::string& gaia_id, NSError* error) { if (!error) return GoogleServiceAuthError::AuthErrorNone(); AuthenticationErrorCategory errorCategory = - provider->GetAuthenticationErrorCategory(error); + provider->GetAuthenticationErrorCategory(gaia_id, error); switch (errorCategory) { case kAuthenticationErrorCategoryUnknownErrors: // Treat all unknown error as unexpected service response errors. @@ -129,7 +130,7 @@ void SSOAccessTokenFetcher::OnAccessTokenResponse(NSString* token, return; } GoogleServiceAuthError auth_error = - GetGoogleServiceAuthErrorFromNSError(provider_, error); + GetGoogleServiceAuthErrorFromNSError(provider_, account_.gaia, error); if (auth_error.state() == GoogleServiceAuthError::NONE) { base::Time expiration_date = base::Time::FromDoubleT([expiration timeIntervalSince1970]); diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h b/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h index b9c8da9..0262019 100644 --- a/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h +++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h @@ -54,16 +54,15 @@ class ProfileOAuth2TokenServiceIOSProvider { virtual ~ProfileOAuth2TokenServiceIOSProvider() {} // Returns the ids of all accounts. - virtual std::vector<AccountInfo> GetAllAccounts() const = 0; + virtual std::vector<AccountInfo> GetAllAccounts() const; // Returns the account info composed of a GAIA id and email corresponding to // email |email|. - virtual AccountInfo GetAccountInfoForEmail( - const std::string& email) const = 0; + virtual AccountInfo GetAccountInfoForEmail(const std::string& email) const; // Returns the account info composed of a GAIA id and email corresponding to // GAIA id |gaia|. - virtual AccountInfo GetAccountInfoForGaia(const std::string& gaia) const = 0; + virtual AccountInfo GetAccountInfoForGaia(const std::string& gaia) const; // Starts fetching an access token for the account with id |gaia_id| with // the given |scopes|. Once the token is obtained, |callback| is called. @@ -71,11 +70,17 @@ class ProfileOAuth2TokenServiceIOSProvider { const std::string& client_id, const std::string& client_secret, const std::set<std::string>& scopes, - const AccessTokenCallback& callback) = 0; + const AccessTokenCallback& callback); + + // Returns the authentication error category of |error| associated with the + // account with id |gaia_id|. + virtual AuthenticationErrorCategory GetAuthenticationErrorCategory( + const std::string& gaia_id, + NSError* error) const; // Returns the authentication error category of |error|. virtual AuthenticationErrorCategory GetAuthenticationErrorCategory( - NSError* error) const = 0; + NSError* error) const; }; #endif // COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_ diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.mm b/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.mm new file mode 100644 index 0000000..15a6637 --- /dev/null +++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.mm @@ -0,0 +1,43 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h" + +std::vector<ProfileOAuth2TokenServiceIOSProvider::AccountInfo> +ProfileOAuth2TokenServiceIOSProvider::GetAllAccounts() const { + return std::vector<ProfileOAuth2TokenServiceIOSProvider::AccountInfo>(); +} + +ProfileOAuth2TokenServiceIOSProvider::AccountInfo +ProfileOAuth2TokenServiceIOSProvider::GetAccountInfoForEmail( + const std::string& email) const { + return ProfileOAuth2TokenServiceIOSProvider::AccountInfo(); +} + +ProfileOAuth2TokenServiceIOSProvider::AccountInfo +ProfileOAuth2TokenServiceIOSProvider::GetAccountInfoForGaia( + const std::string& gaia) const { + return ProfileOAuth2TokenServiceIOSProvider::AccountInfo(); +} + +void ProfileOAuth2TokenServiceIOSProvider::GetAccessToken( + const std::string& gaia_id, + const std::string& client_id, + const std::string& client_secret, + const std::set<std::string>& scopes, + const AccessTokenCallback& callback) {} + +AuthenticationErrorCategory +ProfileOAuth2TokenServiceIOSProvider::GetAuthenticationErrorCategory( + const std::string& gaia_id, + NSError* error) const { + return GetAuthenticationErrorCategory(error); +} + +AuthenticationErrorCategory +ProfileOAuth2TokenServiceIOSProvider::GetAuthenticationErrorCategory( + NSError* error) const { + return kAuthenticationErrorCategoryUnknownErrors; +} + |