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..79366d0befb7deca54e7f7ccd74fe6fd31d40b8a 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,40 @@ std::string PrefServiceBridge::GetAndroidPermissionForContentSetting( |
| return ConvertJavaStringToUTF8(android_permission); |
| } |
| + |
| +// static |
| +std::string PrefServiceBridge::PullVariationsSeedPref( |
|
Alexei Svitkine (slow)
2015/10/28 15:16:38
Instead of being able to pass arbitrary pref names
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
| + const std::string& prefName) { |
| + if (prefName == variations::prefs::kVariationsSeed) { |
|
Alexei Svitkine (slow)
2015/10/28 15:16:38
Nit: No {}'s
Alexander Agulenko
2015/10/28 23:05:09
Done.
|
| + return PullRawVariationsSeed(); |
| + } |
| + JNIEnv* env = AttachCurrentThread(); |
| + ScopedJavaLocalRef<jstring> j_pref_name = ConvertUTF8ToJavaString(env, |
| + prefName); |
| + base::android::ScopedJavaLocalRef<jstring> pref_data = |
| + Java_PrefServiceBridge_getVariationsSeedPref(env, GetApplicationContext(), |
| + j_pref_name.obj()); |
| + return ConvertJavaStringToUTF8(pref_data); |
| +} |
| + |
| +// static |
| +std::string PrefServiceBridge::PullRawVariationsSeed() { |
| + JNIEnv* env = AttachCurrentThread(); |
| + ScopedJavaLocalRef<jbyteArray> array = |
| + Java_PrefServiceBridge_getRawVariationsSeed(env, GetApplicationContext()); |
| + if (array.is_null()) { |
| + return std::string(); |
| + } |
| + int array_length = env->GetArrayLength(array.obj()); |
| + /* std::string seed; |
|
Steven Holte
2015/10/28 01:00:18
Looks like unfinished code?
Alexander Agulenko
2015/10/28 23:05:09
Done.
Alexander Agulenko
2015/10/28 23:05:09
Yes, this piece of code has been changed in Patch
|
| + seed.resize(array_length); |
| + env->GetByteArrayRegion(array.obj(), 0, array_length, |
| + reinterpret_cast<jbyte*>(&(seed[0]))); |
| + return seed; */ |
| + char* buf = new char[array_length]; |
| + env->GetByteArrayRegion(array.obj(), 0, array_length, |
| + reinterpret_cast<jbyte*>(buf)); |
| + std::string seed(buf, buf + array_length); |
| + delete[] buf; |
| + return seed; |
| +} |