Chromium Code Reviews| Index: chrome/browser/android/preferences/pref_service_bridge.cc |
| diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc |
| index 5b5f4b54ac3b2e812c18acfc28a2a45e8f9c3d3a..62b6f63f2e3aaa14f3a538d74f3ad7b79ba7515a 100644 |
| --- a/chrome/browser/android/preferences/pref_service_bridge.cc |
| +++ b/chrome/browser/android/preferences/pref_service_bridge.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/android/jni_android.h" |
| #include "base/android/jni_string.h" |
| #include "base/android/jni_weak_ref.h" |
| +#include "base/base64.h" |
| #include "base/files/file_path.h" |
| #include "base/files/file_util.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -36,6 +37,7 @@ |
| #include "components/signin/core/common/signin_pref_names.h" |
| #include "components/translate/core/browser/translate_prefs.h" |
| #include "components/translate/core/common/translate_pref_names.h" |
| +#include "components/variations/pref_names.h" |
| #include "components/version_info/version_info.h" |
| #include "components/web_resource/web_resource_pref_names.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -47,6 +49,7 @@ using base::android::AttachCurrentThread; |
| using base::android::CheckException; |
| using base::android::ConvertJavaStringToUTF8; |
| using base::android::ConvertUTF8ToJavaString; |
| +using base::android::GetApplicationContext; |
| using base::android::ScopedJavaLocalRef; |
| using base::android::ScopedJavaGlobalRef; |
| using content::BrowserThread; |
| @@ -948,3 +951,30 @@ std::string PrefServiceBridge::GetAndroidPermissionForContentSetting( |
| return ConvertJavaStringToUTF8(android_permission); |
| } |
| + |
| +//static |
|
Bernhard Bauer
2015/10/30 09:56:08
Space after //
Alexander Agulenko
2015/11/02 22:55:33
Done.
|
| +void PrefServiceBridge::GetVariationsFirstRunSeed( |
| + std::string* seed_data, |
| + std::string* seed_signature, |
| + std::string* seed_country) { |
| + JNIEnv* env = AttachCurrentThread(); |
| + ScopedJavaLocalRef<jbyteArray> j_seed_data = |
| + Java_PrefServiceBridge_getVariationsFirstRunSeedData( |
| + env, GetApplicationContext()); |
| + ScopedJavaLocalRef<jstring> j_seed_signature = |
| + Java_PrefServiceBridge_getVariationsFirstRunSeedSignature( |
| + env, GetApplicationContext()); |
| + ScopedJavaLocalRef<jstring> j_seed_country = |
| + Java_PrefServiceBridge_getVariationsFirstRunSeedCountry( |
| + env, GetApplicationContext()); |
| + std::string seed; |
| + if (!j_seed_data.is_null()) { |
| + int array_length = env->GetArrayLength(j_seed_data.obj()); |
| + seed.resize(array_length); |
| + env->GetByteArrayRegion(j_seed_data.obj(), 0, array_length, |
| + reinterpret_cast<jbyte*>(&(seed[0]))); |
|
Alexei Svitkine (slow)
2015/10/29 15:04:12
Can you make a helper similar to https://code.goog
Alexander Agulenko
2015/11/02 22:55:33
Done.
|
| + } |
| + seed_data->swap(seed); |
| + *seed_signature = ConvertJavaStringToUTF8(j_seed_signature); |
| + *seed_country = ConvertJavaStringToUTF8(j_seed_country); |
| +} |