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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
465 | 465 |
466 scoped_ptr<DictionaryValue> about_info = | 466 scoped_ptr<DictionaryValue> about_info = |
467 sync_ui_util::ConstructAboutInformation(sync_service_); | 467 sync_ui_util::ConstructAboutInformation(sync_service_); |
468 std::string about_info_json; | 468 std::string about_info_json; |
469 base::JSONWriter::Write(about_info.get(), &about_info_json); | 469 base::JSONWriter::Write(about_info.get(), &about_info_json); |
470 | 470 |
471 return ConvertUTF8ToJavaString(env, about_info_json); | 471 return ConvertUTF8ToJavaString(env, about_info_json); |
472 } | 472 } |
473 | 473 |
| 474 jlong ProfileSyncServiceAndroid::GetLastSyncedTimeForTest( |
| 475 JNIEnv* env, jobject obj) { |
| 476 // Use profile preferences here instead of SyncPrefs to avoid an extra |
| 477 // conversion, since SyncPrefs::GetLastSyncedTime() converts the stored value |
| 478 // to to base::Time. |
| 479 return static_cast<jlong>( |
| 480 profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); |
| 481 } |
| 482 |
474 void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env, | 483 void ProfileSyncServiceAndroid::NudgeSyncer(JNIEnv* env, |
475 jobject obj, | 484 jobject obj, |
476 jstring objectId, | 485 jstring objectId, |
477 jlong version, | 486 jlong version, |
478 jstring state) { | 487 jstring state) { |
479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
480 SendNudgeNotification(ConvertJavaStringToUTF8(env, objectId), version, | 489 SendNudgeNotification(ConvertJavaStringToUTF8(env, objectId), version, |
481 ConvertJavaStringToUTF8(env, state)); | 490 ConvertJavaStringToUTF8(env, state)); |
482 } | 491 } |
483 | 492 |
(...skipping 20 matching lines...) Expand all Loading... |
504 ProfileSyncServiceAndroid* profile_sync_service_android = | 513 ProfileSyncServiceAndroid* profile_sync_service_android = |
505 new ProfileSyncServiceAndroid(env, obj); | 514 new ProfileSyncServiceAndroid(env, obj); |
506 profile_sync_service_android->Init(); | 515 profile_sync_service_android->Init(); |
507 return reinterpret_cast<jint>(profile_sync_service_android); | 516 return reinterpret_cast<jint>(profile_sync_service_android); |
508 } | 517 } |
509 | 518 |
510 // static | 519 // static |
511 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { | 520 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { |
512 return RegisterNativesImpl(env); | 521 return RegisterNativesImpl(env); |
513 } | 522 } |
OLD | NEW |