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

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

Issue 1267843003: Fix reconcilor loop when the primary account is in an auth error state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo 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 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" 5 #include "chrome/browser/signin/oauth2_token_service_delegate_android.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 scope += " "; 124 scope += " ";
125 scope += *it; 125 scope += *it;
126 } 126 }
127 return scope; 127 return scope;
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 bool OAuth2TokenServiceDelegateAndroid::is_testing_profile_ = false; 132 bool OAuth2TokenServiceDelegateAndroid::is_testing_profile_ = false;
133 133
134 OAuth2TokenServiceDelegateAndroid::ErrorInfo::ErrorInfo()
135 : error(GoogleServiceAuthError::NONE) {}
136
137 OAuth2TokenServiceDelegateAndroid::ErrorInfo::ErrorInfo(
138 const GoogleServiceAuthError& error)
139 : error(error) {}
140
134 OAuth2TokenServiceDelegateAndroid::OAuth2TokenServiceDelegateAndroid() { 141 OAuth2TokenServiceDelegateAndroid::OAuth2TokenServiceDelegateAndroid() {
135 DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ctor"; 142 DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::ctor";
136 JNIEnv* env = AttachCurrentThread(); 143 JNIEnv* env = AttachCurrentThread();
137 base::android::ScopedJavaLocalRef<jobject> local_java_ref = 144 base::android::ScopedJavaLocalRef<jobject> local_java_ref =
138 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this)); 145 Java_OAuth2TokenService_create(env, reinterpret_cast<intptr_t>(this));
139 java_ref_.Reset(env, local_java_ref.obj()); 146 java_ref_.Reset(env, local_java_ref.obj());
140 } 147 }
141 148
142 OAuth2TokenServiceDelegateAndroid::~OAuth2TokenServiceDelegateAndroid() { 149 OAuth2TokenServiceDelegateAndroid::~OAuth2TokenServiceDelegateAndroid() {
143 } 150 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const std::string& account_id) const { 182 const std::string& account_id) const {
176 JNIEnv* env = AttachCurrentThread(); 183 JNIEnv* env = AttachCurrentThread();
177 ScopedJavaLocalRef<jstring> j_account_id = 184 ScopedJavaLocalRef<jstring> j_account_id =
178 ConvertUTF8ToJavaString(env, account_id); 185 ConvertUTF8ToJavaString(env, account_id);
179 jboolean refresh_token_is_available = 186 jboolean refresh_token_is_available =
180 Java_OAuth2TokenService_hasOAuth2RefreshToken( 187 Java_OAuth2TokenService_hasOAuth2RefreshToken(
181 env, base::android::GetApplicationContext(), j_account_id.obj()); 188 env, base::android::GetApplicationContext(), j_account_id.obj());
182 return refresh_token_is_available == JNI_TRUE; 189 return refresh_token_is_available == JNI_TRUE;
183 } 190 }
184 191
192 bool OAuth2TokenServiceDelegateAndroid::RefreshTokenHasError(
193 const std::string& account_id) const {
194 auto it = errors_.find(account_id);
195 // TODO(rogerta): should we distinguish between transient and persistent?
196 return it == errors_.end() ? false : IsError(it->second.error);
197 }
198
185 void OAuth2TokenServiceDelegateAndroid::UpdateAuthError( 199 void OAuth2TokenServiceDelegateAndroid::UpdateAuthError(
186 const std::string& account_id, 200 const std::string& account_id,
187 const GoogleServiceAuthError& error) { 201 const GoogleServiceAuthError& error) {
188 // TODO(rogerta): do we need to update anything, or does the system handle it? 202 if (error.state() == GoogleServiceAuthError::NONE) {
203 errors_.erase(account_id);
204 } else {
205 // TODO(rogerta): should we distinguish between transient and persistent?
206 errors_[account_id] = ErrorInfo(error);
207 }
189 } 208 }
190 209
191 std::vector<std::string> OAuth2TokenServiceDelegateAndroid::GetAccounts() { 210 std::vector<std::string> OAuth2TokenServiceDelegateAndroid::GetAccounts() {
192 std::vector<std::string> accounts; 211 std::vector<std::string> accounts;
193 JNIEnv* env = AttachCurrentThread(); 212 JNIEnv* env = AttachCurrentThread();
194 ScopedJavaLocalRef<jobjectArray> j_accounts = 213 ScopedJavaLocalRef<jobjectArray> j_accounts =
195 Java_OAuth2TokenService_getAccounts( 214 Java_OAuth2TokenService_getAccounts(
196 env, base::android::GetApplicationContext()); 215 env, base::android::GetApplicationContext());
197 // TODO(fgorski): We may decide to filter out some of the accounts. 216 // TODO(fgorski): We may decide to filter out some of the accounts.
198 base::android::AppendJavaStringArrayToStringVector(env, j_accounts.obj(), 217 base::android::AppendJavaStringArrayToStringVector(env, j_accounts.obj(),
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 GoogleServiceAuthError err(authToken 467 GoogleServiceAuthError err(authToken
449 ? GoogleServiceAuthError::NONE 468 ? GoogleServiceAuthError::NONE
450 : GoogleServiceAuthError::CONNECTION_FAILED); 469 : GoogleServiceAuthError::CONNECTION_FAILED);
451 heap_callback->Run(err, token, base::Time()); 470 heap_callback->Run(err, token, base::Time());
452 } 471 }
453 472
454 // static 473 // static
455 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) { 474 bool OAuth2TokenServiceDelegateAndroid::Register(JNIEnv* env) {
456 return RegisterNativesImpl(env); 475 return RegisterNativesImpl(env);
457 } 476 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/oauth2_token_service_delegate_android.h ('k') | components/signin/core/browser/account_reconcilor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698