summaryrefslogtreecommitdiffstats
path: root/ios/public/provider
diff options
context:
space:
mode:
authormsarda@chromium.org <msarda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 16:39:19 +0000
committermsarda@chromium.org <msarda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-10 16:39:19 +0000
commite72a5906fbef55afa52203a0bc2f7868b4601526 (patch)
tree53740be871251250759ad8940ceb48282b498314 /ios/public/provider
parent1cf6ad926a97716a0a05cdb93398542a615f6322 (diff)
downloadchromium_src-e72a5906fbef55afa52203a0bc2f7868b4601526.zip
chromium_src-e72a5906fbef55afa52203a0bc2f7868b4601526.tar.gz
chromium_src-e72a5906fbef55afa52203a0bc2f7868b4601526.tar.bz2
Upstream iOS implementation of ProfileOAuth2TokenService
This CL adds the iOS implementation of the ProfileOAuth2TokenService. BUG=NONE Review URL: https://codereview.chromium.org/226643012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ios/public/provider')
-rw-r--r--ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h b/ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h
new file mode 100644
index 0000000..d6f5238
--- /dev/null
+++ b/ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h
@@ -0,0 +1,78 @@
+// Copyright 2014 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.
+
+#ifndef IOS_PUBLIC_PROVIDER_COMPONENTS_SIGNIN_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
+#define IOS_PUBLIC_PROVIDER_COMPONENTS_SIGNIN_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
+
+#if defined(__OBJC__)
+@class NSDate;
+@class NSError;
+@class NSString;
+#else
+class NSDate;
+class NSError;
+class NSString;
+#endif // defined(__OBJC__)
+
+#include <set>
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+
+namespace ios {
+
+enum AuthenticationErrorCategory {
+ // Unknown errors.
+ kAuthenticationErrorCategoryUnknownErrors,
+ // Authorization errors.
+ kAuthenticationErrorCategoryAuthorizationErrors,
+ // Authorization errors with HTTP_FORBIDDEN (403) error code.
+ kAuthenticationErrorCategoryAuthorizationForbiddenErrors,
+ // Network server errors includes parsing error and should be treated as
+ // transient/offline errors.
+ kAuthenticationErrorCategoryNetworkServerErrors,
+ // User cancellation errors should be handled by treating them as a no-op.
+ kAuthenticationErrorCategoryUserCancellationErrors,
+ // User identity not found errors.
+ kAuthenticationErrorCategoryUnknownIdentityErrors,
+};
+
+// Interface that provides support for ProfileOAuth2TokenServiceIOS.
+class ProfileOAuth2TokenServiceIOSProvider {
+ public:
+ typedef base::Callback<void(NSString* token,
+ NSDate* expiration,
+ NSError* error)> AccessTokenCallback;
+
+ ProfileOAuth2TokenServiceIOSProvider() {};
+ virtual ~ProfileOAuth2TokenServiceIOSProvider() {};
+
+ // Returns whether authentication is using the shared authentication library.
+ virtual bool IsUsingSharedAuthentication() const = 0;
+
+ // Initializes the shared authentication library. This method should be called
+ // when loading credentials if the user is signed in to Chrome via the shared
+ // authentication library.
+ virtual void InitializeSharedAuthentication() = 0;
+
+ // Returns the ids of all accounts.
+ virtual std::vector<std::string> GetAllAccountIds() = 0;
+
+ // Starts fetching an access token for the account with id |account_id| with
+ // the given |scopes|. Once the token is obtained, |callback| is called.
+ virtual void GetAccessToken(const std::string& account_id,
+ const std::string& client_id,
+ const std::string& client_secret,
+ const std::set<std::string>& scopes,
+ const AccessTokenCallback& callback) = 0;
+
+ // Returns the authentication error category of |error|.
+ virtual AuthenticationErrorCategory GetAuthenticationErrorCategory(
+ NSError* error) const = 0;
+};
+
+} // namespace ios
+
+#endif // IOS_PUBLIC_PROVIDER_COMPONENTS_SIGNIN_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_