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_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ |
6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_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 <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
13 #include "base/android/scoped_java_ref.h" | |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
16 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 17 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
17 #include "google_apis/gaia/google_service_auth_error.h" | 18 #include "google_apis/gaia/google_service_auth_error.h" |
18 #include "google_apis/gaia/oauth2_token_service_delegate.h" | 19 #include "google_apis/gaia/oauth2_token_service_delegate.h" |
19 | 20 |
20 // A specialization of OAuth2TokenServiceDelegate that will be returned by | 21 // A specialization of OAuth2TokenServiceDelegate that will be returned by |
21 // OAuth2TokenServiceDelegateFactory for OS_ANDROID. This instance uses | 22 // OAuth2TokenServiceDelegateFactory for OS_ANDROID. This instance uses |
22 // native Android features to lookup OAuth2 tokens. | 23 // native Android features to lookup OAuth2 tokens. |
23 // | 24 // |
24 // See |OAuth2TokenServiceDelegate| for usage details. | 25 // See |OAuth2TokenServiceDelegate| for usage details. |
25 // | 26 // |
26 // 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 |
27 // request from other thread, please use OAuth2TokenServiceRequest. | 28 // request from other thread, please use OAuth2TokenServiceRequest. |
28 class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate { | 29 class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate { |
29 public: | 30 public: |
30 // Registers the OAuth2TokenServiceDelegateAndroid's native methods through | 31 // Registers the OAuth2TokenServiceDelegateAndroid's native methods through |
31 // JNI. | 32 // JNI. |
32 static bool Register(JNIEnv* env); | 33 static bool Register(JNIEnv* env); |
33 | 34 |
34 // Creates a new instance of the OAuth2TokenServiceDelegateAndroid. | 35 // Creates a new instance of the OAuth2TokenServiceDelegateAndroid. |
35 static OAuth2TokenServiceDelegateAndroid* Create(); | 36 static OAuth2TokenServiceDelegateAndroid* Create(); |
36 | 37 |
37 // Returns a reference to the Java instance of this service. | 38 // Returns a reference to the Java instance of this service. |
38 static jobject GetForProfile(JNIEnv* env, | 39 static base::android::ScopedJavaLocalRef<jobject> |
39 jclass clazz, | 40 GetForProfile(JNIEnv* env, jclass clazz, jobject j_profile_android); |
Mike Lerman
2015/08/18 14:17:39
nit: indent
| |
40 jobject j_profile_android); | |
41 | 41 |
42 // Called by the TestingProfile class to disable account validation in | 42 // Called by the TestingProfile class to disable account validation in |
43 // 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 |
44 // accounts which requires special permission. | 44 // accounts which requires special permission. |
45 static void set_is_testing_profile() { is_testing_profile_ = true; } | 45 static void set_is_testing_profile() { is_testing_profile_ = true; } |
46 | 46 |
47 void Initialize(); | 47 void Initialize(); |
48 | 48 |
49 // OAuth2TokenServiceDelegate overrides: | 49 // OAuth2TokenServiceDelegate overrides: |
50 bool RefreshTokenIsAvailable(const std::string& account_id) const override; | 50 bool RefreshTokenIsAvailable(const std::string& account_id) const override; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 133 |
134 // Maps account_id to the last error for that account. | 134 // Maps account_id to the last error for that account. |
135 std::map<std::string, ErrorInfo> errors_; | 135 std::map<std::string, ErrorInfo> errors_; |
136 | 136 |
137 static bool is_testing_profile_; | 137 static bool is_testing_profile_; |
138 | 138 |
139 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegateAndroid); | 139 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegateAndroid); |
140 }; | 140 }; |
141 | 141 |
142 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ | 142 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_DELEGATE_ANDROID_H_ |
OLD | NEW |