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