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_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <map> | |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
| 12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 16 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
| 17 #include "google_apis/gaia/oauth2_token_service_delegate.h" | 18 #include "google_apis/gaia/oauth2_token_service_delegate.h" |
| 18 | 19 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 40 | 41 |
| 41 // Called by the TestingProfile class to disable account validation in | 42 // Called by the TestingProfile class to disable account validation in |
| 42 // tests. This prevents the token service from trying to look up system | 43 // tests. This prevents the token service from trying to look up system |
| 43 // accounts which requires special permission. | 44 // accounts which requires special permission. |
| 44 static void set_is_testing_profile() { is_testing_profile_ = true; } | 45 static void set_is_testing_profile() { is_testing_profile_ = true; } |
| 45 | 46 |
| 46 void Initialize(); | 47 void Initialize(); |
| 47 | 48 |
| 48 // OAuth2TokenServiceDelegate overrides: | 49 // OAuth2TokenServiceDelegate overrides: |
| 49 bool RefreshTokenIsAvailable(const std::string& account_id) const override; | 50 bool RefreshTokenIsAvailable(const std::string& account_id) const override; |
| 51 bool RefreshTokenHasError(const std::string& account_id) const override; | |
| 50 void UpdateAuthError(const std::string& account_id, | 52 void UpdateAuthError(const std::string& account_id, |
| 51 const GoogleServiceAuthError& error) override; | 53 const GoogleServiceAuthError& error) override; |
| 52 std::vector<std::string> GetAccounts() override; | 54 std::vector<std::string> GetAccounts() override; |
| 53 | 55 |
| 54 // Lists account at the OS level. | 56 // Lists account at the OS level. |
| 55 std::vector<std::string> GetSystemAccounts(); | 57 std::vector<std::string> GetSystemAccounts(); |
| 56 | 58 |
| 57 void ValidateAccounts(JNIEnv* env, | 59 void ValidateAccounts(JNIEnv* env, |
| 58 jobject obj, | 60 jobject obj, |
| 59 jstring current_account, | 61 jstring current_account, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 103 const std::string& access_token) override; | 105 const std::string& access_token) override; |
| 104 | 106 |
| 105 // Called to notify observers when a refresh token is available. | 107 // Called to notify observers when a refresh token is available. |
| 106 void FireRefreshTokenAvailable(const std::string& account_id) override; | 108 void FireRefreshTokenAvailable(const std::string& account_id) override; |
| 107 // Called to notify observers when a refresh token has been revoked. | 109 // Called to notify observers when a refresh token has been revoked. |
| 108 void FireRefreshTokenRevoked(const std::string& account_id) override; | 110 void FireRefreshTokenRevoked(const std::string& account_id) override; |
| 109 // Called to notify observers when refresh tokans have been loaded. | 111 // Called to notify observers when refresh tokans have been loaded. |
| 110 void FireRefreshTokensLoaded() override; | 112 void FireRefreshTokensLoaded() override; |
| 111 | 113 |
| 112 private: | 114 private: |
| 115 struct ErrorInfo { | |
|
anthonyvd
2015/08/11 15:43:10
Any reason why errors_ doesn't just store the Goog
Roger Tawa OOO till Jul 10th
2015/08/11 16:25:25
GoogleServiceAuthError does not have a no-arg ctor
| |
| 116 ErrorInfo(); | |
| 117 explicit ErrorInfo(const GoogleServiceAuthError& error); | |
| 118 GoogleServiceAuthError error; | |
| 119 }; | |
| 120 | |
| 113 // Return whether |signed_in_account| is valid and we have access | 121 // Return whether |signed_in_account| is valid and we have access |
| 114 // to all the tokens in |curr_account_ids|. If |force_notifications| is true, | 122 // to all the tokens in |curr_account_ids|. If |force_notifications| is true, |
| 115 // TokenAvailable notifications will be sent anyway, even if the account was | 123 // TokenAvailable notifications will be sent anyway, even if the account was |
| 116 // already known. | 124 // already known. |
| 117 bool ValidateAccounts(const std::string& signed_in_account, | 125 bool ValidateAccounts(const std::string& signed_in_account, |
| 118 const std::vector<std::string>& prev_account_ids, | 126 const std::vector<std::string>& prev_account_ids, |
| 119 const std::vector<std::string>& curr_account_ids, | 127 const std::vector<std::string>& curr_account_ids, |
| 120 std::vector<std::string>& refreshed_ids, | 128 std::vector<std::string>& refreshed_ids, |
| 121 std::vector<std::string>& revoked_ids, | 129 std::vector<std::string>& revoked_ids, |
| 122 bool force_notifications); | 130 bool force_notifications); |
| 123 | 131 |
| 124 base::android::ScopedJavaGlobalRef<jobject> java_ref_; | 132 base::android::ScopedJavaGlobalRef<jobject> java_ref_; |
| 125 | 133 |
| 134 // Maps account_id to the last error for that account. | |
| 135 std::map<std::string, ErrorInfo> errors_; | |
| 136 | |
| 126 static bool is_testing_profile_; | 137 static bool is_testing_profile_; |
| 127 | 138 |
| 128 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegateAndroid); | 139 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegateAndroid); |
| 129 }; | 140 }; |
| 130 | 141 |
| 131 #endif // CHROME_BROWSER_SIGNIN_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_ | 142 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ |
| OLD | NEW |