Chromium Code Reviews| 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; |
|
Roger Tawa OOO till Jul 10th
2013/09/13 14:53:56
I think this function needs an |account_id| arg.
fgorski
2013/09/13 22:06:46
Done. Changed to implement the virtual protected I
| |
| 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 |
| 41 // Lists account IDs of all accounts with a refresh token. | |
| 42 virtual std::vector<std::string> GetAccounts() OVERRIDE; | |
| 43 | |
| 47 protected: | 44 protected: |
| 48 friend class ProfileOAuth2TokenServiceFactory; | 45 friend class ProfileOAuth2TokenServiceFactory; |
| 49 AndroidProfileOAuth2TokenService(); | 46 AndroidProfileOAuth2TokenService(); |
| 50 virtual ~AndroidProfileOAuth2TokenService(); | 47 virtual ~AndroidProfileOAuth2TokenService(); |
| 51 | 48 |
| 52 // Overridden from OAuth2TokenService to intercept token fetch requests and | 49 // Overridden from OAuth2TokenService to intercept token fetch requests and |
| 53 // redirect them to the Account Manager. | 50 // redirect them to the Account Manager. |
| 54 virtual void FetchOAuth2Token(RequestImpl* request, | 51 virtual void FetchOAuth2Token(RequestImpl* request, |
| 52 const std::string& account_id, | |
| 55 net::URLRequestContextGetter* getter, | 53 net::URLRequestContextGetter* getter, |
| 56 const std::string& client_id, | 54 const std::string& client_id, |
| 57 const std::string& client_secret, | 55 const std::string& client_secret, |
| 58 const ScopeSet& scopes) OVERRIDE; | 56 const ScopeSet& scopes) OVERRIDE; |
| 59 | 57 |
| 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: | 58 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(AndroidProfileOAuth2TokenService); | 59 DISALLOW_COPY_AND_ASSIGN(AndroidProfileOAuth2TokenService); |
| 69 }; | 60 }; |
| 70 | 61 |
| 71 #endif // CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 62 #endif // CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |