OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/android/preferences/pref_service_bridge.h" | 5 #include "chrome/browser/android/preferences/pref_service_bridge.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/android/jni_weak_ref.h" | 12 #include "base/android/jni_weak_ref.h" |
13 #include "base/base64.h" | |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 21 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
21 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 22 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
22 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
23 #include "chrome/browser/net/prediction_options.h" | 24 #include "chrome/browser/net/prediction_options.h" |
24 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 25 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/browser/translate/chrome_translate_client.h" | 27 #include "chrome/browser/translate/chrome_translate_client.h" |
27 #include "chrome/browser/ui/android/android_about_app_info.h" | 28 #include "chrome/browser/ui/android/android_about_app_info.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 #include "chrome/grit/locale_settings.h" | 30 #include "chrome/grit/locale_settings.h" |
30 #include "components/content_settings/core/browser/host_content_settings_map.h" | 31 #include "components/content_settings/core/browser/host_content_settings_map.h" |
31 #include "components/content_settings/core/common/content_settings.h" | 32 #include "components/content_settings/core/common/content_settings.h" |
32 #include "components/content_settings/core/common/content_settings_pattern.h" | 33 #include "components/content_settings/core/common/content_settings_pattern.h" |
33 #include "components/content_settings/core/common/pref_names.h" | 34 #include "components/content_settings/core/common/pref_names.h" |
34 #include "components/metrics/metrics_pref_names.h" | 35 #include "components/metrics/metrics_pref_names.h" |
35 #include "components/password_manager/core/common/password_manager_pref_names.h" | 36 #include "components/password_manager/core/common/password_manager_pref_names.h" |
36 #include "components/signin/core/common/signin_pref_names.h" | 37 #include "components/signin/core/common/signin_pref_names.h" |
37 #include "components/translate/core/browser/translate_prefs.h" | 38 #include "components/translate/core/browser/translate_prefs.h" |
38 #include "components/translate/core/common/translate_pref_names.h" | 39 #include "components/translate/core/common/translate_pref_names.h" |
40 #include "components/variations/pref_names.h" | |
39 #include "components/version_info/version_info.h" | 41 #include "components/version_info/version_info.h" |
40 #include "components/web_resource/web_resource_pref_names.h" | 42 #include "components/web_resource/web_resource_pref_names.h" |
41 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
43 #include "jni/PrefServiceBridge_jni.h" | 45 #include "jni/PrefServiceBridge_jni.h" |
44 #include "ui/base/l10n/l10n_util.h" | 46 #include "ui/base/l10n/l10n_util.h" |
45 | 47 |
46 using base::android::AttachCurrentThread; | 48 using base::android::AttachCurrentThread; |
47 using base::android::CheckException; | 49 using base::android::CheckException; |
48 using base::android::ConvertJavaStringToUTF8; | 50 using base::android::ConvertJavaStringToUTF8; |
49 using base::android::ConvertUTF8ToJavaString; | 51 using base::android::ConvertUTF8ToJavaString; |
52 using base::android::GetApplicationContext; | |
50 using base::android::ScopedJavaLocalRef; | 53 using base::android::ScopedJavaLocalRef; |
51 using base::android::ScopedJavaGlobalRef; | 54 using base::android::ScopedJavaGlobalRef; |
52 using content::BrowserThread; | 55 using content::BrowserThread; |
53 | 56 |
54 namespace { | 57 namespace { |
55 | 58 |
56 enum NetworkPredictionOptions { | 59 enum NetworkPredictionOptions { |
57 NETWORK_PREDICTION_ALWAYS, | 60 NETWORK_PREDICTION_ALWAYS, |
58 NETWORK_PREDICTION_WIFI_ONLY, | 61 NETWORK_PREDICTION_WIFI_ONLY, |
59 NETWORK_PREDICTION_NEVER, | 62 NETWORK_PREDICTION_NEVER, |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
941 ContentSettingsType content_type) { | 944 ContentSettingsType content_type) { |
942 JNIEnv* env = AttachCurrentThread(); | 945 JNIEnv* env = AttachCurrentThread(); |
943 base::android::ScopedJavaLocalRef<jstring> android_permission = | 946 base::android::ScopedJavaLocalRef<jstring> android_permission = |
944 Java_PrefServiceBridge_getAndroidPermissionForContentSetting( | 947 Java_PrefServiceBridge_getAndroidPermissionForContentSetting( |
945 env, content_type); | 948 env, content_type); |
946 if (android_permission.is_null()) | 949 if (android_permission.is_null()) |
947 return std::string(); | 950 return std::string(); |
948 | 951 |
949 return ConvertJavaStringToUTF8(android_permission); | 952 return ConvertJavaStringToUTF8(android_permission); |
950 } | 953 } |
954 | |
955 //static | |
Bernhard Bauer
2015/10/30 09:56:08
Space after //
Alexander Agulenko
2015/11/02 22:55:33
Done.
| |
956 void PrefServiceBridge::GetVariationsFirstRunSeed( | |
957 std::string* seed_data, | |
958 std::string* seed_signature, | |
959 std::string* seed_country) { | |
960 JNIEnv* env = AttachCurrentThread(); | |
961 ScopedJavaLocalRef<jbyteArray> j_seed_data = | |
962 Java_PrefServiceBridge_getVariationsFirstRunSeedData( | |
963 env, GetApplicationContext()); | |
964 ScopedJavaLocalRef<jstring> j_seed_signature = | |
965 Java_PrefServiceBridge_getVariationsFirstRunSeedSignature( | |
966 env, GetApplicationContext()); | |
967 ScopedJavaLocalRef<jstring> j_seed_country = | |
968 Java_PrefServiceBridge_getVariationsFirstRunSeedCountry( | |
969 env, GetApplicationContext()); | |
970 std::string seed; | |
971 if (!j_seed_data.is_null()) { | |
972 int array_length = env->GetArrayLength(j_seed_data.obj()); | |
973 seed.resize(array_length); | |
974 env->GetByteArrayRegion(j_seed_data.obj(), 0, array_length, | |
975 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.
| |
976 } | |
977 seed_data->swap(seed); | |
978 *seed_signature = ConvertJavaStringToUTF8(j_seed_signature); | |
979 *seed_country = ConvertJavaStringToUTF8(j_seed_country); | |
980 } | |
OLD | NEW |