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

Side by Side Diff: chrome/browser/sync/profile_sync_service_android.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add commandline switch to toggle between OAuth2 and ClientLogin token Created 7 years, 6 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/sync/profile_sync_service_android.h" 5 #include "chrome/browser/sync/profile_sync_service_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h" 8 #include "base/android/jni_string.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/i18n/time_formatting.h" 10 #include "base/i18n/time_formatting.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 244 }
245 245
246 void ProfileSyncServiceAndroid::SignInSync( 246 void ProfileSyncServiceAndroid::SignInSync(
247 JNIEnv* env, jobject, jstring username, jstring auth_token) { 247 JNIEnv* env, jobject, jstring username, jstring auth_token) {
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
249 // Just return if sync already has everything it needs to start up (sync 249 // Just return if sync already has everything it needs to start up (sync
250 // should start up automatically as long as it has credentials). This can 250 // should start up automatically as long as it has credentials). This can
251 // happen normally if (for example) the user closes and reopens the sync 251 // happen normally if (for example) the user closes and reopens the sync
252 // settings window quickly during initial startup. 252 // settings window quickly during initial startup.
253 if (sync_service_->IsSyncEnabledAndLoggedIn() && 253 if (sync_service_->IsSyncEnabledAndLoggedIn() &&
254 sync_service_->IsSyncTokenAvailable() && 254 sync_service_->IsOAuthRefreshTokenAvailable() &&
255 sync_service_->HasSyncSetupCompleted()) { 255 sync_service_->HasSyncSetupCompleted()) {
256 return; 256 return;
257 } 257 }
258 258
259 if (!sync_service_->IsSyncEnabledAndLoggedIn() || 259 if (!sync_service_->IsSyncEnabledAndLoggedIn() ||
260 !sync_service_->IsSyncTokenAvailable()) { 260 !sync_service_->IsOAuthRefreshTokenAvailable()) {
261 // Set the currently-signed-in username, fetch an auth token if necessary, 261 // Set the currently-signed-in username, fetch an auth token if necessary,
262 // and enable sync. 262 // and enable sync.
263 std::string name = ConvertJavaStringToUTF8(env, username); 263 std::string name = ConvertJavaStringToUTF8(env, username);
264 // TODO(tim) It should be enough to only call 264 // TODO(tim) It should be enough to only call
265 // SigninManager::SetAuthenticatedUsername here. See 265 // SigninManager::SetAuthenticatedUsername here. See
266 // http://crbug.com/107160. 266 // http://crbug.com/107160.
267 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, name); 267 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, name);
268 SigninManagerFactory::GetForProfile(profile_)-> 268 SigninManagerFactory::GetForProfile(profile_)->
269 SetAuthenticatedUsername(name); 269 SetAuthenticatedUsername(name);
270 std::string token = ConvertJavaStringToUTF8(env, auth_token); 270 std::string token = ConvertJavaStringToUTF8(env, auth_token);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 ProfileSyncServiceAndroid* profile_sync_service_android = 631 ProfileSyncServiceAndroid* profile_sync_service_android =
632 new ProfileSyncServiceAndroid(env, obj); 632 new ProfileSyncServiceAndroid(env, obj);
633 profile_sync_service_android->Init(); 633 profile_sync_service_android->Init();
634 return reinterpret_cast<jint>(profile_sync_service_android); 634 return reinterpret_cast<jint>(profile_sync_service_android);
635 } 635 }
636 636
637 // static 637 // static
638 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { 638 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) {
639 return RegisterNativesImpl(env); 639 return RegisterNativesImpl(env);
640 } 640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698