| 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 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 const JavaParamRef<jobject>& obj) { | 361 const JavaParamRef<jobject>& obj) { |
| 362 return GetBooleanForContentSetting( | 362 return GetBooleanForContentSetting( |
| 363 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); | 363 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); |
| 364 } | 364 } |
| 365 | 365 |
| 366 static jboolean GetNotificationsEnabled(JNIEnv* env, | 366 static jboolean GetNotificationsEnabled(JNIEnv* env, |
| 367 const JavaParamRef<jobject>& obj) { | 367 const JavaParamRef<jobject>& obj) { |
| 368 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 368 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 369 } | 369 } |
| 370 | 370 |
| 371 static jboolean GetNotificationsVibrateEnabled( |
| 372 JNIEnv* env, |
| 373 const JavaParamRef<jobject>& obj) { |
| 374 return GetPrefService()->GetBoolean(prefs::kNotificationsVibrateEnabled); |
| 375 } |
| 376 |
| 371 static jboolean GetAllowLocationEnabled(JNIEnv* env, | 377 static jboolean GetAllowLocationEnabled(JNIEnv* env, |
| 372 const JavaParamRef<jobject>& obj) { | 378 const JavaParamRef<jobject>& obj) { |
| 373 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 379 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 374 } | 380 } |
| 375 | 381 |
| 376 static jboolean GetLocationAllowedByPolicy(JNIEnv* env, | 382 static jboolean GetLocationAllowedByPolicy(JNIEnv* env, |
| 377 const JavaParamRef<jobject>& obj) { | 383 const JavaParamRef<jobject>& obj) { |
| 378 if (!IsContentSettingManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)) | 384 if (!IsContentSettingManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)) |
| 379 return false; | 385 return false; |
| 380 HostContentSettingsMap* content_settings = | 386 HostContentSettingsMap* content_settings = |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 static void SetNotificationsEnabled(JNIEnv* env, | 821 static void SetNotificationsEnabled(JNIEnv* env, |
| 816 const JavaParamRef<jobject>& obj, | 822 const JavaParamRef<jobject>& obj, |
| 817 jboolean allow) { | 823 jboolean allow) { |
| 818 HostContentSettingsMap* host_content_settings_map = | 824 HostContentSettingsMap* host_content_settings_map = |
| 819 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); | 825 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
| 820 host_content_settings_map->SetDefaultContentSetting( | 826 host_content_settings_map->SetDefaultContentSetting( |
| 821 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 827 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 822 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 828 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 823 } | 829 } |
| 824 | 830 |
| 831 static void SetNotificationsVibrateEnabled(JNIEnv* env, |
| 832 const JavaParamRef<jobject>& obj, |
| 833 jboolean enabled) { |
| 834 GetPrefService()->SetBoolean(prefs::kNotificationsVibrateEnabled, enabled); |
| 835 } |
| 836 |
| 825 static void SetCrashReportingEnabled(JNIEnv* env, | 837 static void SetCrashReportingEnabled(JNIEnv* env, |
| 826 const JavaParamRef<jobject>& obj, | 838 const JavaParamRef<jobject>& obj, |
| 827 jboolean reporting) { | 839 jboolean reporting) { |
| 828 PrefService* local_state = g_browser_process->local_state(); | 840 PrefService* local_state = g_browser_process->local_state(); |
| 829 local_state->SetBoolean(prefs::kCrashReportingEnabled, reporting); | 841 local_state->SetBoolean(prefs::kCrashReportingEnabled, reporting); |
| 830 } | 842 } |
| 831 | 843 |
| 832 static jboolean IsCrashReportingEnabled(JNIEnv* env, | 844 static jboolean IsCrashReportingEnabled(JNIEnv* env, |
| 833 const JavaParamRef<jobject>& obj) { | 845 const JavaParamRef<jobject>& obj) { |
| 834 PrefService* local_state = g_browser_process->local_state(); | 846 PrefService* local_state = g_browser_process->local_state(); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 | 1155 |
| 1144 return ConvertJavaStringToUTF8(android_permission); | 1156 return ConvertJavaStringToUTF8(android_permission); |
| 1145 } | 1157 } |
| 1146 | 1158 |
| 1147 static void SetSupervisedUserId(JNIEnv* env, | 1159 static void SetSupervisedUserId(JNIEnv* env, |
| 1148 const JavaParamRef<jobject>& obj, | 1160 const JavaParamRef<jobject>& obj, |
| 1149 const JavaParamRef<jstring>& pref) { | 1161 const JavaParamRef<jstring>& pref) { |
| 1150 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1162 GetPrefService()->SetString(prefs::kSupervisedUserId, |
| 1151 ConvertJavaStringToUTF8(env, pref)); | 1163 ConvertJavaStringToUTF8(env, pref)); |
| 1152 } | 1164 } |
| OLD | NEW |