| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // A specialization of ProfileOAuth2TokenService that will be returned by | 21 // A specialization of ProfileOAuth2TokenService that will be returned by |
| 22 // ProfileOAuth2TokenServiceFactory for OS_ANDROID. This instance uses | 22 // ProfileOAuth2TokenServiceFactory for OS_ANDROID. This instance uses |
| 23 // native Android features to lookup OAuth2 tokens. | 23 // native Android features to lookup OAuth2 tokens. |
| 24 // | 24 // |
| 25 // See |ProfileOAuth2TokenService| for usage details. | 25 // See |ProfileOAuth2TokenService| for usage details. |
| 26 // | 26 // |
| 27 // Note: requests should be started from the UI thread. To start a | 27 // Note: requests should be started from the UI thread. To start a |
| 28 // request from other thread, please use ProfileOAuth2TokenServiceRequest. | 28 // request from other thread, please use ProfileOAuth2TokenServiceRequest. |
| 29 class AndroidProfileOAuth2TokenService : public ProfileOAuth2TokenService { | 29 class AndroidProfileOAuth2TokenService : public ProfileOAuth2TokenService { |
| 30 public: | 30 public: |
| 31 // StartRequest() fetches a token for the currently signed-in account; this | 31 virtual bool RefreshTokenIsAvailable( |
| 32 // version uses the account corresponding to |username|. This allows fetching | 32 const std::string& account_id) OVERRIDE; |
| 33 // tokens before a user is signed-in (e.g. during the sign-in flow). | |
| 34 scoped_ptr<OAuth2TokenService::Request> StartRequestForUsername( | |
| 35 const std::string& username, | |
| 36 const OAuth2TokenService::ScopeSet& scopes, | |
| 37 OAuth2TokenService::Consumer* consumer); | |
| 38 | 33 |
| 39 virtual bool RefreshTokenIsAvailable() OVERRIDE; | |
| 40 virtual void InvalidateToken(const ScopeSet& scopes, | 34 virtual void InvalidateToken(const ScopeSet& scopes, |
| 41 const std::string& invalid_token) OVERRIDE; | 35 const std::string& invalid_token) OVERRIDE; |
| 42 | 36 |
| 43 // Registers the AndroidProfileOAuth2TokenService's native methods through | 37 // Registers the AndroidProfileOAuth2TokenService's native methods through |
| 44 // JNI. | 38 // JNI. |
| 45 static bool Register(JNIEnv* env); | 39 static bool Register(JNIEnv* env); |
| 46 | 40 |
| 47 protected: | 41 protected: |
| 48 friend class ProfileOAuth2TokenServiceFactory; | 42 friend class ProfileOAuth2TokenServiceFactory; |
| 49 AndroidProfileOAuth2TokenService(); | 43 AndroidProfileOAuth2TokenService(); |
| 50 virtual ~AndroidProfileOAuth2TokenService(); | 44 virtual ~AndroidProfileOAuth2TokenService(); |
| 51 | 45 |
| 52 // Overridden from OAuth2TokenService to intercept token fetch requests and | 46 // Overridden from OAuth2TokenService to intercept token fetch requests and |
| 53 // redirect them to the Account Manager. | 47 // redirect them to the Account Manager. |
| 54 virtual void FetchOAuth2Token(RequestImpl* request, | 48 virtual void FetchOAuth2Token(RequestImpl* request, |
| 49 const std::string& account_id, |
| 55 net::URLRequestContextGetter* getter, | 50 net::URLRequestContextGetter* getter, |
| 56 const std::string& client_id, | 51 const std::string& client_id, |
| 57 const std::string& client_secret, | 52 const std::string& client_secret, |
| 58 const ScopeSet& scopes) OVERRIDE; | 53 const ScopeSet& scopes) OVERRIDE; |
| 59 | 54 |
| 60 // Low-level helper function used by both FetchOAuth2Token and | |
| 61 // StartRequestForUsername to fetch tokens. virtual to enable mocks. | |
| 62 virtual void FetchOAuth2TokenWithUsername( | |
| 63 RequestImpl* request, | |
| 64 const std::string& username, | |
| 65 const ScopeSet& scope); | |
| 66 | |
| 67 private: | 55 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(AndroidProfileOAuth2TokenService); | 56 DISALLOW_COPY_AND_ASSIGN(AndroidProfileOAuth2TokenService); |
| 69 }; | 57 }; |
| 70 | 58 |
| 71 #endif // CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 59 #endif // CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |