summaryrefslogtreecommitdiffstats
path: root/ios
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
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')
-rw-r--r--ios/provider/ios_components.gyp20
-rw-r--r--ios/public/DEPS12
-rw-r--r--ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h78
3 files changed, 98 insertions, 12 deletions
diff --git a/ios/provider/ios_components.gyp b/ios/provider/ios_components.gyp
new file mode 100644
index 0000000..002c43a
--- /dev/null
+++ b/ios/provider/ios_components.gyp
@@ -0,0 +1,20 @@
+# 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.
+{
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'targets': [
+ {
+ 'target_name': 'ios_components',
+ 'type': 'none',
+ 'include_dirs': [
+ '../..',
+ ],
+ 'sources': [
+ '../public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h',
+ ]
+ },
+ ],
+}
diff --git a/ios/public/DEPS b/ios/public/DEPS
deleted file mode 100644
index c04c1d5..0000000
--- a/ios/public/DEPS
+++ /dev/null
@@ -1,12 +0,0 @@
-include_rules = [
- # The public interfaces cannot reference Chromium code, so all allowances
- # that the top-level DEPS file introduces are removed here. This list should
- # be kept in sync with src/DEPS.
- "-base",
- "-build",
- "-library_loaders",
- "-testing",
- "-third_party/icu/source/common/unicode",
- "-third_party/icu/source/i18n/unicode",
- "-url",
-]
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_