Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: chrome/browser/signin/oauth2_token_service_delegate_android.h

Issue 1256283002: GAIA ID migration for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simple version Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_
6 #define CHROME_BROWSER_SIGNIN_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_ 6 #define CHROME_BROWSER_SIGNIN_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 10
11 #include "base/android/jni_weak_ref.h" 11 #include "base/android/jni_weak_ref.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/signin/core/browser/account_tracker_service.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
19 // A specialization of OAuth2TokenServiceDelegate that will be returned by 20 // A specialization of OAuth2TokenServiceDelegate that will be returned by
20 // OAuth2TokenServiceDelegateFactory for OS_ANDROID. This instance uses 21 // OAuth2TokenServiceDelegateFactory for OS_ANDROID. This instance uses
21 // native Android features to lookup OAuth2 tokens. 22 // native Android features to lookup OAuth2 tokens.
22 // 23 //
23 // See |OAuth2TokenServiceDelegate| for usage details. 24 // See |OAuth2TokenServiceDelegate| for usage details.
24 // 25 //
(...skipping 11 matching lines...) Expand all
36 // Returns a reference to the Java instance of this service. 37 // Returns a reference to the Java instance of this service.
37 static jobject GetForProfile(JNIEnv* env, 38 static jobject GetForProfile(JNIEnv* env,
38 jclass clazz, 39 jclass clazz,
39 jobject j_profile_android); 40 jobject j_profile_android);
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(AccountTrackerService* account_tracker_service);
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;
50 void UpdateAuthError(const std::string& account_id, 51 void UpdateAuthError(const std::string& account_id,
51 const GoogleServiceAuthError& error) override; 52 const GoogleServiceAuthError& error) override;
52 std::vector<std::string> GetAccounts() override; 53 std::vector<std::string> GetAccounts() override;
53 54
54 // Lists account at the OS level. 55 // Lists account at the OS level.
55 std::vector<std::string> GetSystemAccounts(); 56 std::vector<std::string> GetSystemAccounts();
56 57
(...skipping 21 matching lines...) Expand all
78 jobject obj, 79 jobject obj,
79 const jstring account_name); 80 const jstring account_name);
80 // Triggers a notification to all observers of the OAuth2TokenService that all 81 // Triggers a notification to all observers of the OAuth2TokenService that all
81 // refresh tokens have now been loaded. 82 // refresh tokens have now been loaded.
82 virtual void FireRefreshTokensLoadedFromJava(JNIEnv* env, jobject obj); 83 virtual void FireRefreshTokensLoadedFromJava(JNIEnv* env, jobject obj);
83 84
84 // Overridden from OAuth2TokenService to complete signout of all 85 // Overridden from OAuth2TokenService to complete signout of all
85 // OA2TService aware accounts. 86 // OA2TService aware accounts.
86 void RevokeAllCredentials() override; 87 void RevokeAllCredentials() override;
87 88
89 void SeedAccountsInfo(JNIEnv* env,
90 jobject obj,
91 jobjectArray gaiaids,
92 jobjectArray usernames);
93
88 protected: 94 protected:
89 friend class ProfileOAuth2TokenServiceFactory; 95 friend class ProfileOAuth2TokenServiceFactory;
90 OAuth2TokenServiceDelegateAndroid(); 96 OAuth2TokenServiceDelegateAndroid();
91 ~OAuth2TokenServiceDelegateAndroid() override; 97 ~OAuth2TokenServiceDelegateAndroid() override;
92 98
93 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( 99 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher(
94 const std::string& account_id, 100 const std::string& account_id,
95 net::URLRequestContextGetter* getter, 101 net::URLRequestContextGetter* getter,
96 OAuth2AccessTokenConsumer* consumer) override; 102 OAuth2AccessTokenConsumer* consumer) override;
97 103
98 // Overridden from OAuth2TokenService to intercept token fetch requests and 104 // Overridden from OAuth2TokenService to intercept token fetch requests and
99 // redirect them to the Account Manager. 105 // redirect them to the Account Manager.
100 void InvalidateAccessToken(const std::string& account_id, 106 void InvalidateAccessToken(const std::string& account_id,
101 const std::string& client_id, 107 const std::string& client_id,
102 const OAuth2TokenService::ScopeSet& scopes, 108 const OAuth2TokenService::ScopeSet& scopes,
103 const std::string& access_token) override; 109 const std::string& access_token) override;
104 110
105 // Called to notify observers when a refresh token is available. 111 // Called to notify observers when a refresh token is available.
106 void FireRefreshTokenAvailable(const std::string& account_id) override; 112 void FireRefreshTokenAvailable(const std::string& account_id) override;
107 // Called to notify observers when a refresh token has been revoked. 113 // Called to notify observers when a refresh token has been revoked.
108 void FireRefreshTokenRevoked(const std::string& account_id) override; 114 void FireRefreshTokenRevoked(const std::string& account_id) override;
109 // Called to notify observers when refresh tokans have been loaded. 115 // Called to notify observers when refresh tokans have been loaded.
110 void FireRefreshTokensLoaded() override; 116 void FireRefreshTokensLoaded() override;
111 117
112 private: 118 private:
119 std::vector<std::string> GetPersistentAccounts();
120 void ValidateAccountsWithOsTypeIds(const std::string& signed_in_account,
121 bool force_notifications);
122 std::string MapUserAccountIdToOs(const std::string& user_account_id) const;
123 std::string MapOsAccountIdToUser(const std::string& os_account_id) const;
124
113 // Return whether |signed_in_account| is valid and we have access 125 // 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, 126 // 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 127 // TokenAvailable notifications will be sent anyway, even if the account was
116 // already known. 128 // already known.
117 bool ValidateAccounts(const std::string& signed_in_account, 129 bool ValidateAccounts(const std::string& signed_in_account,
118 const std::vector<std::string>& prev_account_ids, 130 const std::vector<std::string>& prev_account_ids,
119 const std::vector<std::string>& curr_account_ids, 131 const std::vector<std::string>& curr_account_ids,
120 std::vector<std::string>& refreshed_ids, 132 std::vector<std::string>& refreshed_ids,
121 std::vector<std::string>& revoked_ids, 133 std::vector<std::string>& revoked_ids,
122 bool force_notifications); 134 bool force_notifications);
123 135
124 base::android::ScopedJavaGlobalRef<jobject> java_ref_; 136 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
125 137
138 AccountTrackerService* account_tracker_service_;
126 static bool is_testing_profile_; 139 static bool is_testing_profile_;
127 140
128 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegateAndroid); 141 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegateAndroid);
129 }; 142 };
130 143
131 #endif // CHROME_BROWSER_SIGNIN_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_ 144 #endif // CHROME_BROWSER_SIGNIN_DELEGATE_ANDROID_OAUTH2_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698