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

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: Rebase 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 246
247 void ProfileSyncServiceAndroid::SignInSync( 247 void ProfileSyncServiceAndroid::SignInSync(
248 JNIEnv* env, jobject, jstring username, jstring auth_token) { 248 JNIEnv* env, jobject, jstring username, jstring auth_token) {
249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 249 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
250 // Just return if sync already has everything it needs to start up (sync 250 // Just return if sync already has everything it needs to start up (sync
251 // should start up automatically as long as it has credentials). This can 251 // should start up automatically as long as it has credentials). This can
252 // happen normally if (for example) the user closes and reopens the sync 252 // happen normally if (for example) the user closes and reopens the sync
253 // settings window quickly during initial startup. 253 // settings window quickly during initial startup.
254 if (sync_service_->IsSyncEnabledAndLoggedIn() && 254 if (sync_service_->IsSyncEnabledAndLoggedIn() &&
255 sync_service_->IsSyncTokenAvailable() && 255 sync_service_->IsOAuthRefreshTokenAvailable() &&
256 sync_service_->HasSyncSetupCompleted()) { 256 sync_service_->HasSyncSetupCompleted()) {
257 return; 257 return;
258 } 258 }
259 259
260 if (!sync_service_->IsSyncEnabledAndLoggedIn() || 260 if (!sync_service_->IsSyncEnabledAndLoggedIn() ||
261 !sync_service_->IsSyncTokenAvailable()) { 261 !sync_service_->IsOAuthRefreshTokenAvailable()) {
262 // Set the currently-signed-in username, fetch an auth token if necessary, 262 // Set the currently-signed-in username, fetch an auth token if necessary,
263 // and enable sync. 263 // and enable sync.
264 std::string name = ConvertJavaStringToUTF8(env, username); 264 std::string name = ConvertJavaStringToUTF8(env, username);
265 // TODO(tim) It should be enough to only call 265 // TODO(tim) It should be enough to only call
266 // SigninManager::SetAuthenticatedUsername here. See 266 // SigninManager::SetAuthenticatedUsername here. See
267 // http://crbug.com/107160. 267 // http://crbug.com/107160.
268 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, name); 268 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, name);
269 SigninManagerFactory::GetForProfile(profile_)-> 269 SigninManagerFactory::GetForProfile(profile_)->
270 SetAuthenticatedUsername(name); 270 SetAuthenticatedUsername(name);
271 std::string token = ConvertJavaStringToUTF8(env, auth_token); 271 std::string token = ConvertJavaStringToUTF8(env, auth_token);
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 ProfileSyncServiceAndroid* profile_sync_service_android = 638 ProfileSyncServiceAndroid* profile_sync_service_android =
639 new ProfileSyncServiceAndroid(env, obj); 639 new ProfileSyncServiceAndroid(env, obj);
640 profile_sync_service_android->Init(); 640 profile_sync_service_android->Init();
641 return reinterpret_cast<jint>(profile_sync_service_android); 641 return reinterpret_cast<jint>(profile_sync_service_android);
642 } 642 }
643 643
644 // static 644 // static
645 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { 645 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) {
646 return RegisterNativesImpl(env); 646 return RegisterNativesImpl(env);
647 } 647 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_autofill_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698