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..bbe975b3bacb5b153eef607166a301259c538f32 100644 |
| --- a/chrome/browser/android/preferences/pref_service_bridge.cc |
| +++ b/chrome/browser/android/preferences/pref_service_bridge.cc |
| @@ -5,11 +5,14 @@ |
| #include "chrome/browser/android/preferences/pref_service_bridge.h" |
| #include <jni.h> |
| +#include <vector> |
| #include "base/android/build_info.h" |
| #include "base/android/jni_android.h" |
| +#include "base/android/jni_array.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 +39,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 +51,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; |
| @@ -111,6 +116,20 @@ PrefService* GetPrefService() { |
| return GetOriginalProfile()->GetPrefs(); |
| } |
| +void JavaByteArrayToString(JNIEnv* env, |
| + jbyteArray byte_array, |
| + std::string* out) { |
|
Alexei Svitkine (slow)
2015/11/03 18:34:03
I suggest just making this return the std::string(
Alexander Agulenko
2015/11/04 08:00:58
Removed this function at all.
Done.
|
| + DCHECK(out); |
| + if (!byte_array) { |
| + out->clear(); |
| + return; |
| + } |
| + std::vector<uint8> array_data; |
| + base::android::JavaByteArrayToByteVector(env, byte_array, &array_data); |
| + std::string temp(array_data.begin(), array_data.end()); |
| + out->swap(temp); |
| +} |
| + |
| } // namespace |
| // ---------------------------------------------------------------------------- |
| @@ -948,3 +967,23 @@ std::string PrefServiceBridge::GetAndroidPermissionForContentSetting( |
| return ConvertJavaStringToUTF8(android_permission); |
| } |
| + |
| +// static |
| +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( |
|
Alexei Svitkine (slow)
2015/11/03 18:34:03
Nit: Run "git cl format", since you have the wrong
Alexander Agulenko
2015/11/04 08:00:58
Done.
|
| + env, GetApplicationContext()); |
| + ScopedJavaLocalRef<jstring> j_seed_signature = |
| + Java_PrefServiceBridge_getVariationsFirstRunSeedSignature( |
| + env, GetApplicationContext()); |
| + ScopedJavaLocalRef<jstring> j_seed_country = |
| + Java_PrefServiceBridge_getVariationsFirstRunSeedCountry( |
| + env, GetApplicationContext()); |
| + JavaByteArrayToString(env, j_seed_data.obj(), seed_data); |
| + *seed_signature = ConvertJavaStringToUTF8(j_seed_signature); |
| + *seed_country = ConvertJavaStringToUTF8(j_seed_country); |
| +} |