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/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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 << "Ignoring call to DisableSync() because sync is already disabled"; | 169 << "Ignoring call to DisableSync() because sync is already disabled"; |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 void ProfileSyncServiceAndroid::SignInSync(JNIEnv* env, jobject) { | 173 void ProfileSyncServiceAndroid::SignInSync(JNIEnv* env, jobject) { |
174 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 174 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
175 // Just return if sync already has everything it needs to start up (sync | 175 // Just return if sync already has everything it needs to start up (sync |
176 // should start up automatically as long as it has credentials). This can | 176 // should start up automatically as long as it has credentials). This can |
177 // happen normally if (for example) the user closes and reopens the sync | 177 // happen normally if (for example) the user closes and reopens the sync |
178 // settings window quickly during initial startup. | 178 // settings window quickly during initial startup. |
179 if (sync_service_->IsSyncEnabledAndLoggedIn() && | 179 if (sync_service_->CanSyncStart() && |
180 sync_service_->IsOAuthRefreshTokenAvailable() && | 180 sync_service_->IsOAuthRefreshTokenAvailable() && |
181 sync_service_->HasSyncSetupCompleted()) { | 181 sync_service_->HasSyncSetupCompleted()) { |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 // Request that sync starts. If we don't have credentials yet, this will | 185 // Request that sync starts. If we don't have credentials yet, this will |
186 // let sync start once credentials arrive. | 186 // let sync start once credentials arrive. |
187 sync_service_->RequestStart(); | 187 sync_service_->RequestStart(); |
188 } | 188 } |
189 | 189 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 ProfileSyncServiceAndroid* profile_sync_service_android = | 576 ProfileSyncServiceAndroid* profile_sync_service_android = |
577 new ProfileSyncServiceAndroid(env, obj); | 577 new ProfileSyncServiceAndroid(env, obj); |
578 profile_sync_service_android->Init(); | 578 profile_sync_service_android->Init(); |
579 return reinterpret_cast<intptr_t>(profile_sync_service_android); | 579 return reinterpret_cast<intptr_t>(profile_sync_service_android); |
580 } | 580 } |
581 | 581 |
582 // static | 582 // static |
583 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { | 583 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { |
584 return RegisterNativesImpl(env); | 584 return RegisterNativesImpl(env); |
585 } | 585 } |
OLD | NEW |