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 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 std::vector<std::string> account_ids; | 164 std::vector<std::string> account_ids; |
| 165 base::android::AppendJavaStringArrayToStringVector(env, | 165 base::android::AppendJavaStringArrayToStringVector(env, |
| 166 accounts, | 166 accounts, |
| 167 &account_ids); | 167 &account_ids); |
| 168 std::string signed_in_account = ConvertJavaStringToUTF8(env, j_current_acc); | 168 std::string signed_in_account = ConvertJavaStringToUTF8(env, j_current_acc); |
| 169 ValidateAccounts(signed_in_account, account_ids); | 169 ValidateAccounts(signed_in_account, account_ids); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void AndroidProfileOAuth2TokenService::ValidateAccounts( | 172 void AndroidProfileOAuth2TokenService::ValidateAccounts( |
| 173 const std::string& signed_in_account, | 173 const std::string& signed_in_account, |
| 174 const std::vector<std::string>& account_ids) { | 174 const std::vector<std::string>& account_ids) { |
|
Roger Tawa OOO till Jul 10th
2014/03/27 15:46:45
This function is called when the user signs in and
acleung1
2014/03/27 21:09:54
Yes. Good point. I was under the impression that S
Roger Tawa OOO till Jul 10th
2014/03/28 13:21:59
SigninManager already calls RevokeAllCredentials()
Roger Tawa OOO till Jul 10th
2014/04/02 14:45:58
I don't think we need to change AccountReconcilor
acleung1
2014/04/08 02:01:02
Yes, you are correct. My reply was oudated and was
| |
| 175 if (signed_in_account.empty()) | 175 if (signed_in_account.empty()) |
| 176 return; | 176 return; |
| 177 | 177 |
| 178 if (std::find(account_ids.begin(), | 178 if (std::find(account_ids.begin(), |
| 179 account_ids.end(), | 179 account_ids.end(), |
| 180 signed_in_account) != account_ids.end()) { | 180 signed_in_account) != account_ids.end()) { |
| 181 // Currently signed in account still exists among accounts on system. | 181 // Currently signed in account still exists among accounts on system. |
| 182 std::vector<std::string> ids = GetAccounts(); | 182 std::vector<std::string> ids = GetAccounts(); |
|
Roger Tawa OOO till Jul 10th
2014/03/27 15:46:45
In what cases is |ids| going to be different from
acleung1
2014/03/27 21:09:54
Good catch. It's a mistake from previous CL. Was g
| |
| 183 | 183 |
| 184 // Test to see if we an account is removed from the Android AccountManager. | |
|
Roger Tawa OOO till Jul 10th
2014/03/27 15:46:45
Remove "if we" ?
acleung1
2014/03/27 21:09:54
Done.
| |
| 185 // If so, invoke FireRefreshTokenRevoked to notify the reconcilor. | |
| 186 for (std::vector<std::string>::iterator it = current_accounts_.begin(); | |
| 187 it != current_accounts_.end(); it++) { | |
|
Roger Tawa OOO till Jul 10th
2014/03/27 15:46:45
Indent one more.
acleung1
2014/03/27 21:09:54
Done.
| |
| 188 if (*it == signed_in_account) | |
| 189 continue; | |
| 190 | |
| 191 if (std::find(account_ids.begin(), | |
| 192 account_ids.end(), | |
| 193 *it) == account_ids.end()) { | |
| 194 FireRefreshTokenRevoked(*it); | |
| 195 } | |
| 196 } | |
| 197 | |
| 198 current_accounts_.clear(); | |
| 199 current_accounts_.push_back(signed_in_account); | |
| 200 | |
| 184 // Always fire the primary signed in account first. | 201 // Always fire the primary signed in account first. |
| 185 FireRefreshTokenAvailable(signed_in_account); | 202 FireRefreshTokenAvailable(signed_in_account); |
| 186 | 203 |
| 187 for (std::vector<std::string>::iterator it = ids.begin(); | 204 for (std::vector<std::string>::iterator it = ids.begin(); |
| 188 it != ids.end(); it++) { | 205 it != ids.end(); it++) { |
| 189 if (*it != signed_in_account) { | 206 if (*it != signed_in_account) { |
| 190 FireRefreshTokenAvailable(*it); | 207 FireRefreshTokenAvailable(*it); |
| 208 current_accounts_.push_back(*it); | |
| 191 } | 209 } |
| 192 } | 210 } |
| 193 } else { | 211 } else { |
| 194 // Currently signed in account does not any longer exist among accounts on | 212 // Currently signed in account does not any longer exist among accounts on |
| 195 // system. | 213 // system. |
| 196 FireRefreshTokenRevoked(signed_in_account); | 214 FireRefreshTokenRevoked(signed_in_account); |
| 197 } | 215 } |
| 198 } | 216 } |
| 199 | 217 |
| 200 void AndroidProfileOAuth2TokenService::FireRefreshTokenAvailableFromJava( | 218 void AndroidProfileOAuth2TokenService::FireRefreshTokenAvailableFromJava( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 266 GoogleServiceAuthError err(result ? | 284 GoogleServiceAuthError err(result ? |
| 267 GoogleServiceAuthError::NONE : | 285 GoogleServiceAuthError::NONE : |
| 268 GoogleServiceAuthError::CONNECTION_FAILED); | 286 GoogleServiceAuthError::CONNECTION_FAILED); |
| 269 heap_callback->Run(err, token, base::Time()); | 287 heap_callback->Run(err, token, base::Time()); |
| 270 } | 288 } |
| 271 | 289 |
| 272 // static | 290 // static |
| 273 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { | 291 bool AndroidProfileOAuth2TokenService::Register(JNIEnv* env) { |
| 274 return RegisterNativesImpl(env); | 292 return RegisterNativesImpl(env); |
| 275 } | 293 } |
| OLD | NEW |