1 // Copyright 2014 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.
5 #ifndef COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
6 #define COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
16 #endif // defined(__OBJC__)
22 #include "base/callback.h"
24 enum AuthenticationErrorCategory
{
26 kAuthenticationErrorCategoryUnknownErrors
,
27 // Authorization errors.
28 kAuthenticationErrorCategoryAuthorizationErrors
,
29 // Authorization errors with HTTP_FORBIDDEN (403) error code.
30 kAuthenticationErrorCategoryAuthorizationForbiddenErrors
,
31 // Network server errors includes parsing error and should be treated as
32 // transient/offline errors.
33 kAuthenticationErrorCategoryNetworkServerErrors
,
34 // User cancellation errors should be handled by treating them as a no-op.
35 kAuthenticationErrorCategoryUserCancellationErrors
,
36 // User identity not found errors.
37 kAuthenticationErrorCategoryUnknownIdentityErrors
,
40 // Interface that provides support for ProfileOAuth2TokenServiceIOS.
41 class ProfileOAuth2TokenServiceIOSProvider
{
43 // Account information.
49 typedef base::Callback
<void(NSString
* token
,
51 NSError
* error
)> AccessTokenCallback
;
53 ProfileOAuth2TokenServiceIOSProvider() {}
54 virtual ~ProfileOAuth2TokenServiceIOSProvider() {}
56 // Returns the ids of all accounts.
57 virtual std::vector
<AccountInfo
> GetAllAccounts() const = 0;
59 // Returns the account info composed of a GAIA id and email corresponding to
61 virtual AccountInfo
GetAccountInfoForEmail(
62 const std::string
& email
) const = 0;
64 // Returns the account info composed of a GAIA id and email corresponding to
66 virtual AccountInfo
GetAccountInfoForGaia(const std::string
& gaia
) const = 0;
68 // Starts fetching an access token for the account with id |gaia_id| with
69 // the given |scopes|. Once the token is obtained, |callback| is called.
70 virtual void GetAccessToken(const std::string
& gaia_id
,
71 const std::string
& client_id
,
72 const std::string
& client_secret
,
73 const std::set
<std::string
>& scopes
,
74 const AccessTokenCallback
& callback
) = 0;
76 // Returns the authentication error category of |error|.
77 virtual AuthenticationErrorCategory
GetAuthenticationErrorCategory(
78 NSError
* error
) const = 0;
81 #endif // COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_