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_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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 234 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
235 return sync_service_->IsPassphraseRequiredForDecryption(); | 235 return sync_service_->IsPassphraseRequiredForDecryption(); |
236 } | 236 } |
237 | 237 |
238 jboolean ProfileSyncServiceAndroid::IsUsingSecondaryPassphrase( | 238 jboolean ProfileSyncServiceAndroid::IsUsingSecondaryPassphrase( |
239 JNIEnv* env, jobject) { | 239 JNIEnv* env, jobject) { |
240 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 240 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
241 return sync_service_->IsUsingSecondaryPassphrase(); | 241 return sync_service_->IsUsingSecondaryPassphrase(); |
242 } | 242 } |
243 | 243 |
| 244 ScopedJavaLocalRef<jbyteArray> |
| 245 ProfileSyncServiceAndroid::GetCustomPassphraseKey(JNIEnv* env, jobject obj) { |
| 246 std::string key = sync_service_->GetCustomPassphraseKey(); |
| 247 return base::android::ToJavaByteArray( |
| 248 env, reinterpret_cast<const uint8_t*>(key.data()), key.size()); |
| 249 } |
| 250 |
244 jint ProfileSyncServiceAndroid::GetPassphraseType(JNIEnv* env, jobject) { | 251 jint ProfileSyncServiceAndroid::GetPassphraseType(JNIEnv* env, jobject) { |
245 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 252 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
246 return sync_service_->GetPassphraseType(); | 253 return sync_service_->GetPassphraseType(); |
247 } | 254 } |
248 | 255 |
249 void ProfileSyncServiceAndroid::SetEncryptionPassphrase( | 256 void ProfileSyncServiceAndroid::SetEncryptionPassphrase( |
250 JNIEnv* env, jobject obj, jstring passphrase) { | 257 JNIEnv* env, jobject obj, jstring passphrase) { |
251 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 258 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
252 std::string key = ConvertJavaStringToUTF8(env, passphrase); | 259 std::string key = ConvertJavaStringToUTF8(env, passphrase); |
253 sync_service_->SetEncryptionPassphrase(key, ProfileSyncService::EXPLICIT); | 260 sync_service_->SetEncryptionPassphrase(key, ProfileSyncService::EXPLICIT); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { | 438 bool ProfileSyncServiceAndroid::Register(JNIEnv* env) { |
432 return RegisterNativesImpl(env); | 439 return RegisterNativesImpl(env); |
433 } | 440 } |
434 | 441 |
435 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 442 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
436 ProfileSyncServiceAndroid* profile_sync_service_android = | 443 ProfileSyncServiceAndroid* profile_sync_service_android = |
437 new ProfileSyncServiceAndroid(env, obj); | 444 new ProfileSyncServiceAndroid(env, obj); |
438 profile_sync_service_android->Init(); | 445 profile_sync_service_android->Init(); |
439 return reinterpret_cast<intptr_t>(profile_sync_service_android); | 446 return reinterpret_cast<intptr_t>(profile_sync_service_android); |
440 } | 447 } |
OLD | NEW |