| 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 26 matching lines...) Expand all Loading... |
| 37 JNIEnv* env, jclass clazz, jobject j_profile_android); | 37 JNIEnv* env, jclass clazz, jobject j_profile_android); |
| 38 | 38 |
| 39 // Called by the TestingProfile class to disable account validation in | 39 // Called by the TestingProfile class to disable account validation in |
| 40 // tests. This prevents the token service from trying to look up system | 40 // tests. This prevents the token service from trying to look up system |
| 41 // accounts which requires special permission. | 41 // accounts which requires special permission. |
| 42 static void set_is_testing_profile() { | 42 static void set_is_testing_profile() { |
| 43 is_testing_profile_ = true; | 43 is_testing_profile_ = true; |
| 44 } | 44 } |
| 45 | 45 |
| 46 // ProfileOAuth2TokenService overrides: | 46 // ProfileOAuth2TokenService overrides: |
| 47 virtual void Initialize(SigninClient* client) OVERRIDE; | 47 virtual void Initialize(SigninClient* client) override; |
| 48 virtual bool RefreshTokenIsAvailable( | 48 virtual bool RefreshTokenIsAvailable( |
| 49 const std::string& account_id) const OVERRIDE; | 49 const std::string& account_id) const override; |
| 50 virtual void UpdateAuthError( | 50 virtual void UpdateAuthError( |
| 51 const std::string& account_id, | 51 const std::string& account_id, |
| 52 const GoogleServiceAuthError& error) OVERRIDE; | 52 const GoogleServiceAuthError& error) override; |
| 53 virtual std::vector<std::string> GetAccounts() OVERRIDE; | 53 virtual std::vector<std::string> GetAccounts() override; |
| 54 | 54 |
| 55 // Lists account at the OS level. | 55 // Lists account at the OS level. |
| 56 std::vector<std::string> GetSystemAccounts(); | 56 std::vector<std::string> GetSystemAccounts(); |
| 57 | 57 |
| 58 void ValidateAccounts(JNIEnv* env, | 58 void ValidateAccounts(JNIEnv* env, |
| 59 jobject obj, | 59 jobject obj, |
| 60 jstring current_account, | 60 jstring current_account, |
| 61 jboolean force_notifications); | 61 jboolean force_notifications); |
| 62 | 62 |
| 63 // Takes a the signed in sync account as well as all the other | 63 // Takes a the signed in sync account as well as all the other |
| (...skipping 13 matching lines...) Expand all Loading... |
| 77 // refresh token is now available. | 77 // refresh token is now available. |
| 78 virtual void FireRefreshTokenRevokedFromJava(JNIEnv* env, | 78 virtual void FireRefreshTokenRevokedFromJava(JNIEnv* env, |
| 79 jobject obj, | 79 jobject obj, |
| 80 const jstring account_name); | 80 const jstring account_name); |
| 81 // Triggers a notification to all observers of the OAuth2TokenService that all | 81 // Triggers a notification to all observers of the OAuth2TokenService that all |
| 82 // refresh tokens have now been loaded. | 82 // refresh tokens have now been loaded. |
| 83 virtual void FireRefreshTokensLoadedFromJava(JNIEnv* env, jobject obj); | 83 virtual void FireRefreshTokensLoadedFromJava(JNIEnv* env, jobject obj); |
| 84 | 84 |
| 85 // Overridden from OAuth2TokenService to complete signout of all | 85 // Overridden from OAuth2TokenService to complete signout of all |
| 86 // OA2TService aware accounts. | 86 // OA2TService aware accounts. |
| 87 virtual void RevokeAllCredentials() OVERRIDE; | 87 virtual void RevokeAllCredentials() override; |
| 88 | 88 |
| 89 protected: | 89 protected: |
| 90 friend class ProfileOAuth2TokenServiceFactory; | 90 friend class ProfileOAuth2TokenServiceFactory; |
| 91 AndroidProfileOAuth2TokenService(); | 91 AndroidProfileOAuth2TokenService(); |
| 92 virtual ~AndroidProfileOAuth2TokenService(); | 92 virtual ~AndroidProfileOAuth2TokenService(); |
| 93 | 93 |
| 94 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( | 94 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
| 95 const std::string& account_id, | 95 const std::string& account_id, |
| 96 net::URLRequestContextGetter* getter, | 96 net::URLRequestContextGetter* getter, |
| 97 OAuth2AccessTokenConsumer* consumer) OVERRIDE; | 97 OAuth2AccessTokenConsumer* consumer) override; |
| 98 | 98 |
| 99 // Overridden from OAuth2TokenService to intercept token fetch requests and | 99 // Overridden from OAuth2TokenService to intercept token fetch requests and |
| 100 // redirect them to the Account Manager. | 100 // redirect them to the Account Manager. |
| 101 virtual void InvalidateOAuth2Token(const std::string& account_id, | 101 virtual void InvalidateOAuth2Token(const std::string& account_id, |
| 102 const std::string& client_id, | 102 const std::string& client_id, |
| 103 const ScopeSet& scopes, | 103 const ScopeSet& scopes, |
| 104 const std::string& access_token) OVERRIDE; | 104 const std::string& access_token) override; |
| 105 | 105 |
| 106 // Called to notify observers when a refresh token is available. | 106 // Called to notify observers when a refresh token is available. |
| 107 virtual void FireRefreshTokenAvailable( | 107 virtual void FireRefreshTokenAvailable( |
| 108 const std::string& account_id) OVERRIDE; | 108 const std::string& account_id) override; |
| 109 // Called to notify observers when a refresh token has been revoked. | 109 // Called to notify observers when a refresh token has been revoked. |
| 110 virtual void FireRefreshTokenRevoked(const std::string& account_id) OVERRIDE; | 110 virtual void FireRefreshTokenRevoked(const std::string& account_id) override; |
| 111 // Called to notify observers when refresh tokans have been loaded. | 111 // Called to notify observers when refresh tokans have been loaded. |
| 112 virtual void FireRefreshTokensLoaded() OVERRIDE; | 112 virtual void FireRefreshTokensLoaded() override; |
| 113 | 113 |
| 114 // Return whether |signed_in_account| is valid and we have access | 114 // Return whether |signed_in_account| is valid and we have access |
| 115 // to all the tokens in |curr_account_ids|. If |force_notifications| is true, | 115 // to all the tokens in |curr_account_ids|. If |force_notifications| is true, |
| 116 // TokenAvailable notifications will be sent anyway, even if the account was | 116 // TokenAvailable notifications will be sent anyway, even if the account was |
| 117 // already known. | 117 // already known. |
| 118 bool ValidateAccounts(const std::string& signed_in_account, | 118 bool ValidateAccounts(const std::string& signed_in_account, |
| 119 const std::vector<std::string>& prev_account_ids, | 119 const std::vector<std::string>& prev_account_ids, |
| 120 const std::vector<std::string>& curr_account_ids, | 120 const std::vector<std::string>& curr_account_ids, |
| 121 std::vector<std::string>& refreshed_ids, | 121 std::vector<std::string>& refreshed_ids, |
| 122 std::vector<std::string>& revoked_ids, | 122 std::vector<std::string>& revoked_ids, |
| 123 bool force_notifications); | 123 bool force_notifications); |
| 124 | 124 |
| 125 private: | 125 private: |
| 126 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 126 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 127 | 127 |
| 128 static bool is_testing_profile_; | 128 static bool is_testing_profile_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(AndroidProfileOAuth2TokenService); | 130 DISALLOW_COPY_AND_ASSIGN(AndroidProfileOAuth2TokenService); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 #endif // CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 133 #endif // CHROME_BROWSER_SIGNIN_ANDROID_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |