| 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" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 PrefService* GetPrefService() { | 129 PrefService* GetPrefService() { |
| 130 return GetOriginalProfile()->GetPrefs(); | 130 return GetOriginalProfile()->GetPrefs(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 } // namespace | 133 } // namespace |
| 134 | 134 |
| 135 // ---------------------------------------------------------------------------- | 135 // ---------------------------------------------------------------------------- |
| 136 // Native JNI methods | 136 // Native JNI methods |
| 137 // ---------------------------------------------------------------------------- | 137 // ---------------------------------------------------------------------------- |
| 138 | 138 |
| 139 static jboolean IsContentSettingManaged(JNIEnv* env, jobject obj, | 139 static jboolean IsContentSettingManaged(JNIEnv* env, |
| 140 int content_settings_type) { | 140 const JavaParamRef<jobject>& obj, |
| 141 int content_settings_type) { |
| 141 return IsContentSettingManaged( | 142 return IsContentSettingManaged( |
| 142 static_cast<ContentSettingsType>(content_settings_type)); | 143 static_cast<ContentSettingsType>(content_settings_type)); |
| 143 } | 144 } |
| 144 | 145 |
| 145 static jboolean IsContentSettingEnabled(JNIEnv* env, jobject obj, | 146 static jboolean IsContentSettingEnabled(JNIEnv* env, |
| 146 int content_settings_type) { | 147 const JavaParamRef<jobject>& obj, |
| 148 int content_settings_type) { |
| 147 // Before we migrate functions over to this central function, we must verify | 149 // Before we migrate functions over to this central function, we must verify |
| 148 // that the functionality provided below is correct. | 150 // that the functionality provided below is correct. |
| 149 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 151 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 150 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || | 152 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 151 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); | 153 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); |
| 152 ContentSettingsType type = | 154 ContentSettingsType type = |
| 153 static_cast<ContentSettingsType>(content_settings_type); | 155 static_cast<ContentSettingsType>(content_settings_type); |
| 154 if (type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 156 if (type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 155 type == CONTENT_SETTINGS_TYPE_POPUPS) | 157 type == CONTENT_SETTINGS_TYPE_POPUPS) |
| 156 return GetBooleanForContentSetting(type); | 158 return GetBooleanForContentSetting(type); |
| 157 | 159 |
| 158 HostContentSettingsMap* content_settings = | 160 HostContentSettingsMap* content_settings = |
| 159 GetOriginalProfile()->GetHostContentSettingsMap(); | 161 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 160 return content_settings->GetDefaultContentSetting( | 162 return content_settings->GetDefaultContentSetting( |
| 161 type, nullptr) == CONTENT_SETTING_ALLOW; | 163 type, nullptr) == CONTENT_SETTING_ALLOW; |
| 162 } | 164 } |
| 163 | 165 |
| 164 static void SetContentSettingEnabled(JNIEnv* env, jobject obj, | 166 static void SetContentSettingEnabled(JNIEnv* env, |
| 165 int content_settings_type, jboolean allow) { | 167 const JavaParamRef<jobject>& obj, |
| 168 int content_settings_type, |
| 169 jboolean allow) { |
| 166 // Before we migrate functions over to this central function, we must verify | 170 // Before we migrate functions over to this central function, we must verify |
| 167 // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. | 171 // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. |
| 168 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 172 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 169 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || | 173 content_settings_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 170 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); | 174 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); |
| 171 HostContentSettingsMap* host_content_settings_map = | 175 HostContentSettingsMap* host_content_settings_map = |
| 172 GetOriginalProfile()->GetHostContentSettingsMap(); | 176 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 173 host_content_settings_map->SetDefaultContentSetting( | 177 host_content_settings_map->SetDefaultContentSetting( |
| 174 static_cast<ContentSettingsType>(content_settings_type), | 178 static_cast<ContentSettingsType>(content_settings_type), |
| 175 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 179 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 176 } | 180 } |
| 177 | 181 |
| 178 static void SetContentSettingForPattern(JNIEnv* env, jobject obj, | 182 static void SetContentSettingForPattern(JNIEnv* env, |
| 179 int content_settings_type, jstring pattern, int setting) { | 183 const JavaParamRef<jobject>& obj, |
| 184 int content_settings_type, |
| 185 const JavaParamRef<jstring>& pattern, |
| 186 int setting) { |
| 180 HostContentSettingsMap* host_content_settings_map = | 187 HostContentSettingsMap* host_content_settings_map = |
| 181 GetOriginalProfile()->GetHostContentSettingsMap(); | 188 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 182 host_content_settings_map->SetContentSetting( | 189 host_content_settings_map->SetContentSetting( |
| 183 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), | 190 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), |
| 184 ContentSettingsPattern::Wildcard(), | 191 ContentSettingsPattern::Wildcard(), |
| 185 static_cast<ContentSettingsType>(content_settings_type), | 192 static_cast<ContentSettingsType>(content_settings_type), |
| 186 "", | 193 "", |
| 187 static_cast<ContentSetting>(setting)); | 194 static_cast<ContentSetting>(setting)); |
| 188 } | 195 } |
| 189 | 196 |
| 190 static void GetContentSettingsExceptions(JNIEnv* env, jobject obj, | 197 static void GetContentSettingsExceptions(JNIEnv* env, |
| 191 int content_settings_type, jobject list) { | 198 const JavaParamRef<jobject>& obj, |
| 199 int content_settings_type, |
| 200 const JavaParamRef<jobject>& list) { |
| 192 HostContentSettingsMap* host_content_settings_map = | 201 HostContentSettingsMap* host_content_settings_map = |
| 193 GetOriginalProfile()->GetHostContentSettingsMap(); | 202 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 194 ContentSettingsForOneType entries; | 203 ContentSettingsForOneType entries; |
| 195 host_content_settings_map->GetSettingsForOneType( | 204 host_content_settings_map->GetSettingsForOneType( |
| 196 static_cast<ContentSettingsType>(content_settings_type), "", &entries); | 205 static_cast<ContentSettingsType>(content_settings_type), "", &entries); |
| 197 for (size_t i = 0; i < entries.size(); ++i) { | 206 for (size_t i = 0; i < entries.size(); ++i) { |
| 198 Java_PrefServiceBridge_addContentSettingExceptionToList( | 207 Java_PrefServiceBridge_addContentSettingExceptionToList( |
| 199 env, list, | 208 env, list, |
| 200 content_settings_type, | 209 content_settings_type, |
| 201 ConvertUTF8ToJavaString( | 210 ConvertUTF8ToJavaString( |
| 202 env, entries[i].primary_pattern.ToString()).obj(), | 211 env, entries[i].primary_pattern.ToString()).obj(), |
| 203 ConvertUTF8ToJavaString( | 212 ConvertUTF8ToJavaString( |
| 204 env, GetStringForContentSettingsType(entries[i].setting)).obj(), | 213 env, GetStringForContentSettingsType(entries[i].setting)).obj(), |
| 205 ConvertUTF8ToJavaString(env, entries[i].source).obj()); | 214 ConvertUTF8ToJavaString(env, entries[i].source).obj()); |
| 206 } | 215 } |
| 207 } | 216 } |
| 208 | 217 |
| 209 static jboolean GetAcceptCookiesEnabled(JNIEnv* env, jobject obj) { | 218 static jboolean GetAcceptCookiesEnabled(JNIEnv* env, |
| 219 const JavaParamRef<jobject>& obj) { |
| 210 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_COOKIES); | 220 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_COOKIES); |
| 211 } | 221 } |
| 212 | 222 |
| 213 static jboolean GetAcceptCookiesManaged(JNIEnv* env, jobject obj) { | 223 static jboolean GetAcceptCookiesManaged(JNIEnv* env, |
| 224 const JavaParamRef<jobject>& obj) { |
| 214 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_COOKIES); | 225 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_COOKIES); |
| 215 } | 226 } |
| 216 | 227 |
| 217 static jboolean GetBlockThirdPartyCookiesEnabled(JNIEnv* env, jobject obj) { | 228 static jboolean GetBlockThirdPartyCookiesEnabled( |
| 229 JNIEnv* env, |
| 230 const JavaParamRef<jobject>& obj) { |
| 218 return GetPrefService()->GetBoolean(prefs::kBlockThirdPartyCookies); | 231 return GetPrefService()->GetBoolean(prefs::kBlockThirdPartyCookies); |
| 219 } | 232 } |
| 220 | 233 |
| 221 static jboolean GetBlockThirdPartyCookiesManaged(JNIEnv* env, jobject obj) { | 234 static jboolean GetBlockThirdPartyCookiesManaged( |
| 235 JNIEnv* env, |
| 236 const JavaParamRef<jobject>& obj) { |
| 222 return GetPrefService()->IsManagedPreference(prefs::kBlockThirdPartyCookies); | 237 return GetPrefService()->IsManagedPreference(prefs::kBlockThirdPartyCookies); |
| 223 } | 238 } |
| 224 | 239 |
| 225 static jboolean GetRememberPasswordsEnabled(JNIEnv* env, jobject obj) { | 240 static jboolean GetRememberPasswordsEnabled(JNIEnv* env, |
| 241 const JavaParamRef<jobject>& obj) { |
| 226 return GetPrefService()->GetBoolean( | 242 return GetPrefService()->GetBoolean( |
| 227 password_manager::prefs::kPasswordManagerSavingEnabled); | 243 password_manager::prefs::kPasswordManagerSavingEnabled); |
| 228 } | 244 } |
| 229 | 245 |
| 230 static jboolean GetPasswordManagerAutoSigninEnabled(JNIEnv* env, jobject obj) { | 246 static jboolean GetPasswordManagerAutoSigninEnabled( |
| 247 JNIEnv* env, |
| 248 const JavaParamRef<jobject>& obj) { |
| 231 return GetPrefService()->GetBoolean( | 249 return GetPrefService()->GetBoolean( |
| 232 password_manager::prefs::kPasswordManagerAutoSignin); | 250 password_manager::prefs::kPasswordManagerAutoSignin); |
| 233 } | 251 } |
| 234 | 252 |
| 235 static jboolean GetRememberPasswordsManaged(JNIEnv* env, jobject obj) { | 253 static jboolean GetRememberPasswordsManaged(JNIEnv* env, |
| 254 const JavaParamRef<jobject>& obj) { |
| 236 return GetPrefService()->IsManagedPreference( | 255 return GetPrefService()->IsManagedPreference( |
| 237 password_manager::prefs::kPasswordManagerSavingEnabled); | 256 password_manager::prefs::kPasswordManagerSavingEnabled); |
| 238 } | 257 } |
| 239 | 258 |
| 240 static jboolean GetPasswordManagerAutoSigninManaged(JNIEnv* env, jobject obj) { | 259 static jboolean GetPasswordManagerAutoSigninManaged( |
| 260 JNIEnv* env, |
| 261 const JavaParamRef<jobject>& obj) { |
| 241 return GetPrefService()->IsManagedPreference( | 262 return GetPrefService()->IsManagedPreference( |
| 242 password_manager::prefs::kPasswordManagerAutoSignin); | 263 password_manager::prefs::kPasswordManagerAutoSignin); |
| 243 } | 264 } |
| 244 | 265 |
| 245 static jboolean GetDoNotTrackEnabled(JNIEnv* env, jobject obj) { | 266 static jboolean GetDoNotTrackEnabled(JNIEnv* env, |
| 267 const JavaParamRef<jobject>& obj) { |
| 246 return GetPrefService()->GetBoolean(prefs::kEnableDoNotTrack); | 268 return GetPrefService()->GetBoolean(prefs::kEnableDoNotTrack); |
| 247 } | 269 } |
| 248 | 270 |
| 249 static jint GetNetworkPredictionOptions(JNIEnv* env, jobject obj) { | 271 static jint GetNetworkPredictionOptions(JNIEnv* env, |
| 272 const JavaParamRef<jobject>& obj) { |
| 250 return GetPrefService()->GetInteger(prefs::kNetworkPredictionOptions); | 273 return GetPrefService()->GetInteger(prefs::kNetworkPredictionOptions); |
| 251 } | 274 } |
| 252 | 275 |
| 253 static jboolean GetNetworkPredictionManaged(JNIEnv* env, jobject obj) { | 276 static jboolean GetNetworkPredictionManaged(JNIEnv* env, |
| 277 const JavaParamRef<jobject>& obj) { |
| 254 return GetPrefService()->IsManagedPreference( | 278 return GetPrefService()->IsManagedPreference( |
| 255 prefs::kNetworkPredictionOptions); | 279 prefs::kNetworkPredictionOptions); |
| 256 } | 280 } |
| 257 | 281 |
| 258 static jboolean GetPasswordEchoEnabled(JNIEnv* env, jobject obj) { | 282 static jboolean GetPasswordEchoEnabled(JNIEnv* env, |
| 283 const JavaParamRef<jobject>& obj) { |
| 259 return GetPrefService()->GetBoolean(prefs::kWebKitPasswordEchoEnabled); | 284 return GetPrefService()->GetBoolean(prefs::kWebKitPasswordEchoEnabled); |
| 260 } | 285 } |
| 261 | 286 |
| 262 static jboolean GetPrintingEnabled(JNIEnv* env, jobject obj) { | 287 static jboolean GetPrintingEnabled(JNIEnv* env, |
| 288 const JavaParamRef<jobject>& obj) { |
| 263 return GetPrefService()->GetBoolean(prefs::kPrintingEnabled); | 289 return GetPrefService()->GetBoolean(prefs::kPrintingEnabled); |
| 264 } | 290 } |
| 265 | 291 |
| 266 static jboolean GetPrintingManaged(JNIEnv* env, jobject obj) { | 292 static jboolean GetPrintingManaged(JNIEnv* env, |
| 293 const JavaParamRef<jobject>& obj) { |
| 267 return GetPrefService()->IsManagedPreference(prefs::kPrintingEnabled); | 294 return GetPrefService()->IsManagedPreference(prefs::kPrintingEnabled); |
| 268 } | 295 } |
| 269 | 296 |
| 270 static jboolean GetTranslateEnabled(JNIEnv* env, jobject obj) { | 297 static jboolean GetTranslateEnabled(JNIEnv* env, |
| 298 const JavaParamRef<jobject>& obj) { |
| 271 return GetPrefService()->GetBoolean(prefs::kEnableTranslate); | 299 return GetPrefService()->GetBoolean(prefs::kEnableTranslate); |
| 272 } | 300 } |
| 273 | 301 |
| 274 static jboolean GetTranslateManaged(JNIEnv* env, jobject obj) { | 302 static jboolean GetTranslateManaged(JNIEnv* env, |
| 303 const JavaParamRef<jobject>& obj) { |
| 275 return GetPrefService()->IsManagedPreference(prefs::kEnableTranslate); | 304 return GetPrefService()->IsManagedPreference(prefs::kEnableTranslate); |
| 276 } | 305 } |
| 277 | 306 |
| 278 static jboolean GetAutoDetectEncodingEnabled(JNIEnv* env, jobject obj) { | 307 static jboolean GetAutoDetectEncodingEnabled(JNIEnv* env, |
| 308 const JavaParamRef<jobject>& obj) { |
| 279 return GetPrefService()->GetBoolean(prefs::kWebKitUsesUniversalDetector); | 309 return GetPrefService()->GetBoolean(prefs::kWebKitUsesUniversalDetector); |
| 280 } | 310 } |
| 281 | 311 |
| 282 static jboolean GetSearchSuggestEnabled(JNIEnv* env, jobject obj) { | 312 static jboolean GetSearchSuggestEnabled(JNIEnv* env, |
| 313 const JavaParamRef<jobject>& obj) { |
| 283 return GetPrefService()->GetBoolean(prefs::kSearchSuggestEnabled); | 314 return GetPrefService()->GetBoolean(prefs::kSearchSuggestEnabled); |
| 284 } | 315 } |
| 285 | 316 |
| 286 static jboolean GetSearchSuggestManaged(JNIEnv* env, jobject obj) { | 317 static jboolean GetSearchSuggestManaged(JNIEnv* env, |
| 318 const JavaParamRef<jobject>& obj) { |
| 287 return GetPrefService()->IsManagedPreference(prefs::kSearchSuggestEnabled); | 319 return GetPrefService()->IsManagedPreference(prefs::kSearchSuggestEnabled); |
| 288 } | 320 } |
| 289 | 321 |
| 290 static jboolean GetSafeBrowsingExtendedReportingEnabled(JNIEnv* env, | 322 static jboolean GetSafeBrowsingExtendedReportingEnabled( |
| 291 jobject obj) { | 323 JNIEnv* env, |
| 324 const JavaParamRef<jobject>& obj) { |
| 292 return GetPrefService()->GetBoolean( | 325 return GetPrefService()->GetBoolean( |
| 293 prefs::kSafeBrowsingExtendedReportingEnabled); | 326 prefs::kSafeBrowsingExtendedReportingEnabled); |
| 294 } | 327 } |
| 295 | 328 |
| 296 static void SetSafeBrowsingExtendedReportingEnabled(JNIEnv* env, | 329 static void SetSafeBrowsingExtendedReportingEnabled( |
| 297 jobject obj, | 330 JNIEnv* env, |
| 298 jboolean enabled) { | 331 const JavaParamRef<jobject>& obj, |
| 332 jboolean enabled) { |
| 299 GetPrefService()->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, | 333 GetPrefService()->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, |
| 300 enabled); | 334 enabled); |
| 301 } | 335 } |
| 302 | 336 |
| 303 static jboolean GetSafeBrowsingExtendedReportingManaged(JNIEnv* env, | 337 static jboolean GetSafeBrowsingExtendedReportingManaged( |
| 304 jobject obj) { | 338 JNIEnv* env, |
| 339 const JavaParamRef<jobject>& obj) { |
| 305 return GetPrefService()->IsManagedPreference( | 340 return GetPrefService()->IsManagedPreference( |
| 306 prefs::kSafeBrowsingExtendedReportingEnabled); | 341 prefs::kSafeBrowsingExtendedReportingEnabled); |
| 307 } | 342 } |
| 308 | 343 |
| 309 static jboolean GetSafeBrowsingEnabled(JNIEnv* env, jobject obj) { | 344 static jboolean GetSafeBrowsingEnabled(JNIEnv* env, |
| 345 const JavaParamRef<jobject>& obj) { |
| 310 return GetPrefService()->GetBoolean(prefs::kSafeBrowsingEnabled); | 346 return GetPrefService()->GetBoolean(prefs::kSafeBrowsingEnabled); |
| 311 } | 347 } |
| 312 | 348 |
| 313 static void SetSafeBrowsingEnabled(JNIEnv* env, jobject obj, jboolean enabled) { | 349 static void SetSafeBrowsingEnabled(JNIEnv* env, |
| 350 const JavaParamRef<jobject>& obj, |
| 351 jboolean enabled) { |
| 314 GetPrefService()->SetBoolean(prefs::kSafeBrowsingEnabled, enabled); | 352 GetPrefService()->SetBoolean(prefs::kSafeBrowsingEnabled, enabled); |
| 315 } | 353 } |
| 316 | 354 |
| 317 static jboolean GetSafeBrowsingManaged(JNIEnv* env, jobject obj) { | 355 static jboolean GetSafeBrowsingManaged(JNIEnv* env, |
| 356 const JavaParamRef<jobject>& obj) { |
| 318 return GetPrefService()->IsManagedPreference(prefs::kSafeBrowsingEnabled); | 357 return GetPrefService()->IsManagedPreference(prefs::kSafeBrowsingEnabled); |
| 319 } | 358 } |
| 320 | 359 |
| 321 static jboolean GetProtectedMediaIdentifierEnabled(JNIEnv* env, jobject obj) { | 360 static jboolean GetProtectedMediaIdentifierEnabled( |
| 361 JNIEnv* env, |
| 362 const JavaParamRef<jobject>& obj) { |
| 322 return GetBooleanForContentSetting( | 363 return GetBooleanForContentSetting( |
| 323 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); | 364 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER); |
| 324 } | 365 } |
| 325 | 366 |
| 326 static jboolean GetPushNotificationsEnabled(JNIEnv* env, jobject obj) { | 367 static jboolean GetPushNotificationsEnabled(JNIEnv* env, |
| 368 const JavaParamRef<jobject>& obj) { |
| 327 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 369 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 328 } | 370 } |
| 329 | 371 |
| 330 static jboolean GetAllowLocationEnabled(JNIEnv* env, jobject obj) { | 372 static jboolean GetAllowLocationEnabled(JNIEnv* env, |
| 373 const JavaParamRef<jobject>& obj) { |
| 331 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 374 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 332 } | 375 } |
| 333 | 376 |
| 334 static jboolean GetLocationAllowedByPolicy(JNIEnv* env, jobject obj) { | 377 static jboolean GetLocationAllowedByPolicy(JNIEnv* env, |
| 378 const JavaParamRef<jobject>& obj) { |
| 335 if (!IsContentSettingManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)) | 379 if (!IsContentSettingManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)) |
| 336 return false; | 380 return false; |
| 337 HostContentSettingsMap* content_settings = | 381 HostContentSettingsMap* content_settings = |
| 338 GetOriginalProfile()->GetHostContentSettingsMap(); | 382 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 339 return content_settings->GetDefaultContentSetting( | 383 return content_settings->GetDefaultContentSetting( |
| 340 CONTENT_SETTINGS_TYPE_GEOLOCATION, nullptr) == | 384 CONTENT_SETTINGS_TYPE_GEOLOCATION, nullptr) == |
| 341 CONTENT_SETTING_ALLOW; | 385 CONTENT_SETTING_ALLOW; |
| 342 } | 386 } |
| 343 | 387 |
| 344 static jboolean GetAllowLocationUserModifiable(JNIEnv* env, jobject obj) { | 388 static jboolean GetAllowLocationUserModifiable( |
| 389 JNIEnv* env, |
| 390 const JavaParamRef<jobject>& obj) { |
| 345 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 391 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 346 } | 392 } |
| 347 | 393 |
| 348 static jboolean GetAllowLocationManagedByCustodian(JNIEnv* env, jobject obj) { | 394 static jboolean GetAllowLocationManagedByCustodian( |
| 395 JNIEnv* env, |
| 396 const JavaParamRef<jobject>& obj) { |
| 349 return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 397 return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 350 } | 398 } |
| 351 | 399 |
| 352 static jboolean GetResolveNavigationErrorEnabled(JNIEnv* env, jobject obj) { | 400 static jboolean GetResolveNavigationErrorEnabled( |
| 401 JNIEnv* env, |
| 402 const JavaParamRef<jobject>& obj) { |
| 353 return GetPrefService()->GetBoolean(prefs::kAlternateErrorPagesEnabled); | 403 return GetPrefService()->GetBoolean(prefs::kAlternateErrorPagesEnabled); |
| 354 } | 404 } |
| 355 | 405 |
| 356 static jboolean GetResolveNavigationErrorManaged(JNIEnv* env, jobject obj) { | 406 static jboolean GetResolveNavigationErrorManaged( |
| 407 JNIEnv* env, |
| 408 const JavaParamRef<jobject>& obj) { |
| 357 return GetPrefService()->IsManagedPreference( | 409 return GetPrefService()->IsManagedPreference( |
| 358 prefs::kAlternateErrorPagesEnabled); | 410 prefs::kAlternateErrorPagesEnabled); |
| 359 } | 411 } |
| 360 | 412 |
| 361 static jboolean GetCrashReportManaged(JNIEnv* env, jobject obj) { | 413 static jboolean GetCrashReportManaged(JNIEnv* env, |
| 414 const JavaParamRef<jobject>& obj) { |
| 362 return GetPrefService()->IsManagedPreference( | 415 return GetPrefService()->IsManagedPreference( |
| 363 prefs::kCrashReportingEnabled); | 416 prefs::kCrashReportingEnabled); |
| 364 } | 417 } |
| 365 | 418 |
| 366 static jboolean GetForceGoogleSafeSearch(JNIEnv* env, jobject obj) { | 419 static jboolean GetForceGoogleSafeSearch(JNIEnv* env, |
| 420 const JavaParamRef<jobject>& obj) { |
| 367 return GetPrefService()->GetBoolean(prefs::kForceGoogleSafeSearch); | 421 return GetPrefService()->GetBoolean(prefs::kForceGoogleSafeSearch); |
| 368 } | 422 } |
| 369 | 423 |
| 370 static jint GetDefaultSupervisedUserFilteringBehavior(JNIEnv* env, | 424 static jint GetDefaultSupervisedUserFilteringBehavior( |
| 371 jobject obj) { | 425 JNIEnv* env, |
| 426 const JavaParamRef<jobject>& obj) { |
| 372 return GetPrefService()->GetInteger( | 427 return GetPrefService()->GetInteger( |
| 373 prefs::kDefaultSupervisedUserFilteringBehavior); | 428 prefs::kDefaultSupervisedUserFilteringBehavior); |
| 374 } | 429 } |
| 375 | 430 |
| 376 static jboolean GetIncognitoModeEnabled(JNIEnv* env, jobject obj) { | 431 static jboolean GetIncognitoModeEnabled(JNIEnv* env, |
| 432 const JavaParamRef<jobject>& obj) { |
| 377 PrefService* prefs = GetPrefService(); | 433 PrefService* prefs = GetPrefService(); |
| 378 IncognitoModePrefs::Availability incognito_pref = | 434 IncognitoModePrefs::Availability incognito_pref = |
| 379 IncognitoModePrefs::GetAvailability(prefs); | 435 IncognitoModePrefs::GetAvailability(prefs); |
| 380 DCHECK(incognito_pref == IncognitoModePrefs::ENABLED || | 436 DCHECK(incognito_pref == IncognitoModePrefs::ENABLED || |
| 381 incognito_pref == IncognitoModePrefs::DISABLED) << | 437 incognito_pref == IncognitoModePrefs::DISABLED) << |
| 382 "Unsupported incognito mode preference: " << incognito_pref; | 438 "Unsupported incognito mode preference: " << incognito_pref; |
| 383 return incognito_pref != IncognitoModePrefs::DISABLED; | 439 return incognito_pref != IncognitoModePrefs::DISABLED; |
| 384 } | 440 } |
| 385 | 441 |
| 386 static jboolean GetIncognitoModeManaged(JNIEnv* env, jobject obj) { | 442 static jboolean GetIncognitoModeManaged(JNIEnv* env, |
| 443 const JavaParamRef<jobject>& obj) { |
| 387 return GetPrefService()->IsManagedPreference( | 444 return GetPrefService()->IsManagedPreference( |
| 388 prefs::kIncognitoModeAvailability); | 445 prefs::kIncognitoModeAvailability); |
| 389 } | 446 } |
| 390 | 447 |
| 391 static jboolean GetFullscreenManaged(JNIEnv* env, jobject obj) { | 448 static jboolean GetFullscreenManaged(JNIEnv* env, |
| 449 const JavaParamRef<jobject>& obj) { |
| 392 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); | 450 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); |
| 393 } | 451 } |
| 394 | 452 |
| 395 static jboolean GetFullscreenAllowed(JNIEnv* env, jobject obj) { | 453 static jboolean GetFullscreenAllowed(JNIEnv* env, |
| 454 const JavaParamRef<jobject>& obj) { |
| 396 HostContentSettingsMap* content_settings = | 455 HostContentSettingsMap* content_settings = |
| 397 GetOriginalProfile()->GetHostContentSettingsMap(); | 456 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 398 return content_settings->GetDefaultContentSetting( | 457 return content_settings->GetDefaultContentSetting( |
| 399 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; | 458 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; |
| 400 } | 459 } |
| 401 | 460 |
| 402 static jboolean GetMetricsReportingEnabled(JNIEnv* env, jobject obj) { | 461 static jboolean GetMetricsReportingEnabled(JNIEnv* env, |
| 462 const JavaParamRef<jobject>& obj) { |
| 403 PrefService* local_state = g_browser_process->local_state(); | 463 PrefService* local_state = g_browser_process->local_state(); |
| 404 return local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 464 return local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
| 405 } | 465 } |
| 406 | 466 |
| 407 static void SetMetricsReportingEnabled(JNIEnv* env, | 467 static void SetMetricsReportingEnabled(JNIEnv* env, |
| 408 jobject obj, | 468 const JavaParamRef<jobject>& obj, |
| 409 jboolean enabled) { | 469 jboolean enabled) { |
| 410 PrefService* local_state = g_browser_process->local_state(); | 470 PrefService* local_state = g_browser_process->local_state(); |
| 411 local_state->SetBoolean(prefs::kMetricsReportingEnabled, enabled); | 471 local_state->SetBoolean(prefs::kMetricsReportingEnabled, enabled); |
| 412 } | 472 } |
| 413 | 473 |
| 414 static jboolean HasSetMetricsReporting(JNIEnv* env, jobject obj) { | 474 static jboolean HasSetMetricsReporting(JNIEnv* env, |
| 475 const JavaParamRef<jobject>& obj) { |
| 415 PrefService* local_state = g_browser_process->local_state(); | 476 PrefService* local_state = g_browser_process->local_state(); |
| 416 return local_state->HasPrefPath(prefs::kMetricsReportingEnabled); | 477 return local_state->HasPrefPath(prefs::kMetricsReportingEnabled); |
| 417 } | 478 } |
| 418 | 479 |
| 419 namespace { | 480 namespace { |
| 420 | 481 |
| 421 // Redirects a BrowsingDataRemover completion callback back into Java. | 482 // Redirects a BrowsingDataRemover completion callback back into Java. |
| 422 class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer { | 483 class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer { |
| 423 public: | 484 public: |
| 424 // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a | 485 // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a |
| (...skipping 14 matching lines...) Expand all Loading... |
| 439 | 500 |
| 440 Java_PrefServiceBridge_browsingDataCleared( | 501 Java_PrefServiceBridge_browsingDataCleared( |
| 441 env, weak_chrome_native_preferences_.get(env).obj()); | 502 env, weak_chrome_native_preferences_.get(env).obj()); |
| 442 } | 503 } |
| 443 | 504 |
| 444 private: | 505 private: |
| 445 JavaObjectWeakGlobalRef weak_chrome_native_preferences_; | 506 JavaObjectWeakGlobalRef weak_chrome_native_preferences_; |
| 446 }; | 507 }; |
| 447 } // namespace | 508 } // namespace |
| 448 | 509 |
| 449 static void ClearBrowsingData(JNIEnv* env, jobject obj, jboolean history, | 510 static void ClearBrowsingData(JNIEnv* env, |
| 450 jboolean cache, jboolean cookies_and_site_data, jboolean passwords, | 511 const JavaParamRef<jobject>& obj, |
| 451 jboolean form_data) { | 512 jboolean history, |
| 513 jboolean cache, |
| 514 jboolean cookies_and_site_data, |
| 515 jboolean passwords, |
| 516 jboolean form_data) { |
| 452 // BrowsingDataRemover deletes itself. | 517 // BrowsingDataRemover deletes itself. |
| 453 BrowsingDataRemover* browsing_data_remover = | 518 BrowsingDataRemover* browsing_data_remover = |
| 454 BrowsingDataRemover::CreateForPeriod( | 519 BrowsingDataRemover::CreateForPeriod( |
| 455 GetOriginalProfile(), | 520 GetOriginalProfile(), |
| 456 static_cast<BrowsingDataRemover::TimePeriod>( | 521 static_cast<BrowsingDataRemover::TimePeriod>( |
| 457 BrowsingDataRemover::EVERYTHING)); | 522 BrowsingDataRemover::EVERYTHING)); |
| 458 browsing_data_remover->AddObserver(new ClearBrowsingDataObserver(env, obj)); | 523 browsing_data_remover->AddObserver(new ClearBrowsingDataObserver(env, obj)); |
| 459 | 524 |
| 460 int remove_mask = 0; | 525 int remove_mask = 0; |
| 461 if (history) | 526 if (history) |
| 462 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; | 527 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; |
| 463 if (cache) | 528 if (cache) |
| 464 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; | 529 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
| 465 if (cookies_and_site_data) { | 530 if (cookies_and_site_data) { |
| 466 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; | 531 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; |
| 467 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA; | 532 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA; |
| 468 } | 533 } |
| 469 if (passwords) | 534 if (passwords) |
| 470 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 535 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 471 if (form_data) | 536 if (form_data) |
| 472 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 537 remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 473 browsing_data_remover->Remove(remove_mask, | 538 browsing_data_remover->Remove(remove_mask, |
| 474 BrowsingDataHelper::UNPROTECTED_WEB); | 539 BrowsingDataHelper::UNPROTECTED_WEB); |
| 475 } | 540 } |
| 476 | 541 |
| 477 static jboolean CanDeleteBrowsingHistory(JNIEnv* env, jobject obj) { | 542 static jboolean CanDeleteBrowsingHistory(JNIEnv* env, |
| 543 const JavaParamRef<jobject>& obj) { |
| 478 return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 544 return GetPrefService()->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
| 479 } | 545 } |
| 480 | 546 |
| 481 static void SetAllowCookiesEnabled(JNIEnv* env, jobject obj, jboolean allow) { | 547 static void SetAllowCookiesEnabled(JNIEnv* env, |
| 548 const JavaParamRef<jobject>& obj, |
| 549 jboolean allow) { |
| 482 HostContentSettingsMap* host_content_settings_map = | 550 HostContentSettingsMap* host_content_settings_map = |
| 483 GetOriginalProfile()->GetHostContentSettingsMap(); | 551 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 484 host_content_settings_map->SetDefaultContentSetting( | 552 host_content_settings_map->SetDefaultContentSetting( |
| 485 CONTENT_SETTINGS_TYPE_COOKIES, | 553 CONTENT_SETTINGS_TYPE_COOKIES, |
| 486 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 554 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 487 } | 555 } |
| 488 | 556 |
| 489 static void SetBlockThirdPartyCookiesEnabled(JNIEnv* env, jobject obj, | 557 static void SetBlockThirdPartyCookiesEnabled(JNIEnv* env, |
| 558 const JavaParamRef<jobject>& obj, |
| 490 jboolean enabled) { | 559 jboolean enabled) { |
| 491 GetPrefService()->SetBoolean(prefs::kBlockThirdPartyCookies, enabled); | 560 GetPrefService()->SetBoolean(prefs::kBlockThirdPartyCookies, enabled); |
| 492 } | 561 } |
| 493 | 562 |
| 494 static void SetRememberPasswordsEnabled(JNIEnv* env, jobject obj, | 563 static void SetRememberPasswordsEnabled(JNIEnv* env, |
| 564 const JavaParamRef<jobject>& obj, |
| 495 jboolean allow) { | 565 jboolean allow) { |
| 496 GetPrefService()->SetBoolean( | 566 GetPrefService()->SetBoolean( |
| 497 password_manager::prefs::kPasswordManagerSavingEnabled, allow); | 567 password_manager::prefs::kPasswordManagerSavingEnabled, allow); |
| 498 } | 568 } |
| 499 | 569 |
| 500 static void SetPasswordManagerAutoSigninEnabled(JNIEnv* env, | 570 static void SetPasswordManagerAutoSigninEnabled( |
| 501 jobject obj, | 571 JNIEnv* env, |
| 502 jboolean enabled) { | 572 const JavaParamRef<jobject>& obj, |
| 573 jboolean enabled) { |
| 503 GetPrefService()->SetBoolean( | 574 GetPrefService()->SetBoolean( |
| 504 password_manager::prefs::kPasswordManagerAutoSignin, enabled); | 575 password_manager::prefs::kPasswordManagerAutoSignin, enabled); |
| 505 } | 576 } |
| 506 | 577 |
| 507 static void SetProtectedMediaIdentifierEnabled(JNIEnv* env, | 578 static void SetProtectedMediaIdentifierEnabled(JNIEnv* env, |
| 508 jobject obj, | 579 const JavaParamRef<jobject>& obj, |
| 509 jboolean is_enabled) { | 580 jboolean is_enabled) { |
| 510 HostContentSettingsMap* host_content_settings_map = | 581 HostContentSettingsMap* host_content_settings_map = |
| 511 GetOriginalProfile()->GetHostContentSettingsMap(); | 582 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 512 host_content_settings_map->SetDefaultContentSetting( | 583 host_content_settings_map->SetDefaultContentSetting( |
| 513 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, | 584 CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
| 514 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 585 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 515 } | 586 } |
| 516 | 587 |
| 517 static void SetAllowLocationEnabled(JNIEnv* env, | 588 static void SetAllowLocationEnabled(JNIEnv* env, |
| 518 jobject obj, | 589 const JavaParamRef<jobject>& obj, |
| 519 jboolean is_enabled) { | 590 jboolean is_enabled) { |
| 520 HostContentSettingsMap* host_content_settings_map = | 591 HostContentSettingsMap* host_content_settings_map = |
| 521 GetOriginalProfile()->GetHostContentSettingsMap(); | 592 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 522 host_content_settings_map->SetDefaultContentSetting( | 593 host_content_settings_map->SetDefaultContentSetting( |
| 523 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 594 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 524 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 595 is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 525 } | 596 } |
| 526 | 597 |
| 527 static void SetCameraEnabled(JNIEnv* env, jobject obj, jboolean allow) { | 598 static void SetCameraEnabled(JNIEnv* env, |
| 599 const JavaParamRef<jobject>& obj, |
| 600 jboolean allow) { |
| 528 HostContentSettingsMap* host_content_settings_map = | 601 HostContentSettingsMap* host_content_settings_map = |
| 529 GetOriginalProfile()->GetHostContentSettingsMap(); | 602 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 530 host_content_settings_map->SetDefaultContentSetting( | 603 host_content_settings_map->SetDefaultContentSetting( |
| 531 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, | 604 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, |
| 532 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 605 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 533 } | 606 } |
| 534 | 607 |
| 535 static void SetMicEnabled(JNIEnv* env, jobject obj, jboolean allow) { | 608 static void SetMicEnabled(JNIEnv* env, |
| 609 const JavaParamRef<jobject>& obj, |
| 610 jboolean allow) { |
| 536 HostContentSettingsMap* host_content_settings_map = | 611 HostContentSettingsMap* host_content_settings_map = |
| 537 GetOriginalProfile()->GetHostContentSettingsMap(); | 612 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 538 host_content_settings_map->SetDefaultContentSetting( | 613 host_content_settings_map->SetDefaultContentSetting( |
| 539 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, | 614 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, |
| 540 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 615 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 541 } | 616 } |
| 542 | 617 |
| 543 static void SetFullscreenAllowed(JNIEnv* env, jobject obj, jboolean allow) { | 618 static void SetFullscreenAllowed(JNIEnv* env, |
| 619 const JavaParamRef<jobject>& obj, |
| 620 jboolean allow) { |
| 544 HostContentSettingsMap* host_content_settings_map = | 621 HostContentSettingsMap* host_content_settings_map = |
| 545 GetOriginalProfile()->GetHostContentSettingsMap(); | 622 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 546 host_content_settings_map->SetDefaultContentSetting( | 623 host_content_settings_map->SetDefaultContentSetting( |
| 547 CONTENT_SETTINGS_TYPE_FULLSCREEN, | 624 CONTENT_SETTINGS_TYPE_FULLSCREEN, |
| 548 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_ASK); | 625 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_ASK); |
| 549 } | 626 } |
| 550 | 627 |
| 551 static void SetPushNotificationsEnabled(JNIEnv* env, | 628 static void SetPushNotificationsEnabled(JNIEnv* env, |
| 552 jobject obj, | 629 const JavaParamRef<jobject>& obj, |
| 553 jboolean allow) { | 630 jboolean allow) { |
| 554 HostContentSettingsMap* host_content_settings_map = | 631 HostContentSettingsMap* host_content_settings_map = |
| 555 GetOriginalProfile()->GetHostContentSettingsMap(); | 632 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 556 host_content_settings_map->SetDefaultContentSetting( | 633 host_content_settings_map->SetDefaultContentSetting( |
| 557 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 634 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 558 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 635 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 559 } | 636 } |
| 560 | 637 |
| 561 static void SetCrashReporting(JNIEnv* env, jobject obj, jboolean reporting) { | 638 static void SetCrashReporting(JNIEnv* env, |
| 639 const JavaParamRef<jobject>& obj, |
| 640 jboolean reporting) { |
| 562 PrefService* local_state = g_browser_process->local_state(); | 641 PrefService* local_state = g_browser_process->local_state(); |
| 563 local_state->SetBoolean(prefs::kCrashReportingEnabled, reporting); | 642 local_state->SetBoolean(prefs::kCrashReportingEnabled, reporting); |
| 564 } | 643 } |
| 565 | 644 |
| 566 static jboolean CanPredictNetworkActions(JNIEnv* env, jobject obj) { | 645 static jboolean CanPredictNetworkActions(JNIEnv* env, |
| 646 const JavaParamRef<jobject>& obj) { |
| 567 return chrome_browser_net::CanPrefetchAndPrerenderUI(GetPrefService()); | 647 return chrome_browser_net::CanPrefetchAndPrerenderUI(GetPrefService()); |
| 568 } | 648 } |
| 569 | 649 |
| 570 static void SetDoNotTrackEnabled(JNIEnv* env, jobject obj, jboolean allow) { | 650 static void SetDoNotTrackEnabled(JNIEnv* env, |
| 651 const JavaParamRef<jobject>& obj, |
| 652 jboolean allow) { |
| 571 GetPrefService()->SetBoolean(prefs::kEnableDoNotTrack, allow); | 653 GetPrefService()->SetBoolean(prefs::kEnableDoNotTrack, allow); |
| 572 } | 654 } |
| 573 | 655 |
| 574 static ScopedJavaLocalRef<jstring> GetSyncLastAccountName(JNIEnv* env, | 656 static ScopedJavaLocalRef<jstring> GetSyncLastAccountName( |
| 575 jobject obj) { | 657 JNIEnv* env, |
| 658 const JavaParamRef<jobject>& obj) { |
| 576 return ConvertUTF8ToJavaString( | 659 return ConvertUTF8ToJavaString( |
| 577 env, GetPrefService()->GetString(prefs::kGoogleServicesLastUsername)); | 660 env, GetPrefService()->GetString(prefs::kGoogleServicesLastUsername)); |
| 578 } | 661 } |
| 579 | 662 |
| 580 static void SetTranslateEnabled(JNIEnv* env, jobject obj, jboolean enabled) { | 663 static void SetTranslateEnabled(JNIEnv* env, |
| 664 const JavaParamRef<jobject>& obj, |
| 665 jboolean enabled) { |
| 581 GetPrefService()->SetBoolean(prefs::kEnableTranslate, enabled); | 666 GetPrefService()->SetBoolean(prefs::kEnableTranslate, enabled); |
| 582 } | 667 } |
| 583 | 668 |
| 584 static void SetAutoDetectEncodingEnabled(JNIEnv* env, jobject obj, | 669 static void SetAutoDetectEncodingEnabled(JNIEnv* env, |
| 670 const JavaParamRef<jobject>& obj, |
| 585 jboolean enabled) { | 671 jboolean enabled) { |
| 586 content::RecordAction(base::UserMetricsAction("AutoDetectChange")); | 672 content::RecordAction(base::UserMetricsAction("AutoDetectChange")); |
| 587 GetPrefService()->SetBoolean(prefs::kWebKitUsesUniversalDetector, enabled); | 673 GetPrefService()->SetBoolean(prefs::kWebKitUsesUniversalDetector, enabled); |
| 588 } | 674 } |
| 589 | 675 |
| 590 static void ResetTranslateDefaults(JNIEnv* env, jobject obj) { | 676 static void ResetTranslateDefaults(JNIEnv* env, |
| 677 const JavaParamRef<jobject>& obj) { |
| 591 scoped_ptr<translate::TranslatePrefs> translate_prefs = | 678 scoped_ptr<translate::TranslatePrefs> translate_prefs = |
| 592 ChromeTranslateClient::CreateTranslatePrefs(GetPrefService()); | 679 ChromeTranslateClient::CreateTranslatePrefs(GetPrefService()); |
| 593 translate_prefs->ResetToDefaults(); | 680 translate_prefs->ResetToDefaults(); |
| 594 } | 681 } |
| 595 | 682 |
| 596 static void MigrateJavascriptPreference(JNIEnv* env, jobject obj) { | 683 static void MigrateJavascriptPreference(JNIEnv* env, |
| 684 const JavaParamRef<jobject>& obj) { |
| 597 const PrefService::Preference* javascript_pref = | 685 const PrefService::Preference* javascript_pref = |
| 598 GetPrefService()->FindPreference(prefs::kWebKitJavascriptEnabled); | 686 GetPrefService()->FindPreference(prefs::kWebKitJavascriptEnabled); |
| 599 DCHECK(javascript_pref); | 687 DCHECK(javascript_pref); |
| 600 | 688 |
| 601 if (!javascript_pref->HasUserSetting()) | 689 if (!javascript_pref->HasUserSetting()) |
| 602 return; | 690 return; |
| 603 | 691 |
| 604 bool javascript_enabled = false; | 692 bool javascript_enabled = false; |
| 605 bool retval = javascript_pref->GetValue()->GetAsBoolean(&javascript_enabled); | 693 bool retval = javascript_pref->GetValue()->GetAsBoolean(&javascript_enabled); |
| 606 DCHECK(retval); | 694 DCHECK(retval); |
| 607 SetContentSettingEnabled(env, obj, | 695 SetContentSettingEnabled(env, obj, |
| 608 CONTENT_SETTINGS_TYPE_JAVASCRIPT, javascript_enabled); | 696 CONTENT_SETTINGS_TYPE_JAVASCRIPT, javascript_enabled); |
| 609 GetPrefService()->ClearPref(prefs::kWebKitJavascriptEnabled); | 697 GetPrefService()->ClearPref(prefs::kWebKitJavascriptEnabled); |
| 610 } | 698 } |
| 611 | 699 |
| 612 static void MigrateLocationPreference(JNIEnv* env, jobject obj) { | 700 static void MigrateLocationPreference(JNIEnv* env, |
| 701 const JavaParamRef<jobject>& obj) { |
| 613 const PrefService::Preference* pref = | 702 const PrefService::Preference* pref = |
| 614 GetPrefService()->FindPreference(prefs::kGeolocationEnabled); | 703 GetPrefService()->FindPreference(prefs::kGeolocationEnabled); |
| 615 if (!pref || !pref->HasUserSetting()) | 704 if (!pref || !pref->HasUserSetting()) |
| 616 return; | 705 return; |
| 617 bool location_enabled = false; | 706 bool location_enabled = false; |
| 618 bool retval = pref->GetValue()->GetAsBoolean(&location_enabled); | 707 bool retval = pref->GetValue()->GetAsBoolean(&location_enabled); |
| 619 DCHECK(retval); | 708 DCHECK(retval); |
| 620 // Do a restrictive migration. GetAllowLocationEnabled could be | 709 // Do a restrictive migration. GetAllowLocationEnabled could be |
| 621 // non-usermodifiable and we don't want to migrate that. | 710 // non-usermodifiable and we don't want to migrate that. |
| 622 if (!location_enabled) | 711 if (!location_enabled) |
| 623 SetAllowLocationEnabled(env, obj, false); | 712 SetAllowLocationEnabled(env, obj, false); |
| 624 GetPrefService()->ClearPref(prefs::kGeolocationEnabled); | 713 GetPrefService()->ClearPref(prefs::kGeolocationEnabled); |
| 625 } | 714 } |
| 626 | 715 |
| 627 static void MigrateProtectedMediaPreference(JNIEnv* env, jobject obj) { | 716 static void MigrateProtectedMediaPreference(JNIEnv* env, |
| 717 const JavaParamRef<jobject>& obj) { |
| 628 const PrefService::Preference* pref = | 718 const PrefService::Preference* pref = |
| 629 GetPrefService()->FindPreference(prefs::kProtectedMediaIdentifierEnabled); | 719 GetPrefService()->FindPreference(prefs::kProtectedMediaIdentifierEnabled); |
| 630 if (!pref || !pref->HasUserSetting()) | 720 if (!pref || !pref->HasUserSetting()) |
| 631 return; | 721 return; |
| 632 bool pmi_enabled = false; | 722 bool pmi_enabled = false; |
| 633 bool retval = pref->GetValue()->GetAsBoolean(&pmi_enabled); | 723 bool retval = pref->GetValue()->GetAsBoolean(&pmi_enabled); |
| 634 DCHECK(retval); | 724 DCHECK(retval); |
| 635 // Do a restrictive migration if values disagree. | 725 // Do a restrictive migration if values disagree. |
| 636 if (!pmi_enabled) | 726 if (!pmi_enabled) |
| 637 SetProtectedMediaIdentifierEnabled(env, obj, false); | 727 SetProtectedMediaIdentifierEnabled(env, obj, false); |
| 638 GetPrefService()->ClearPref(prefs::kProtectedMediaIdentifierEnabled); | 728 GetPrefService()->ClearPref(prefs::kProtectedMediaIdentifierEnabled); |
| 639 } | 729 } |
| 640 | 730 |
| 641 static void SetPasswordEchoEnabled(JNIEnv* env, | 731 static void SetPasswordEchoEnabled(JNIEnv* env, |
| 642 jobject obj, | 732 const JavaParamRef<jobject>& obj, |
| 643 jboolean passwordEchoEnabled) { | 733 jboolean passwordEchoEnabled) { |
| 644 GetPrefService()->SetBoolean(prefs::kWebKitPasswordEchoEnabled, | 734 GetPrefService()->SetBoolean(prefs::kWebKitPasswordEchoEnabled, |
| 645 passwordEchoEnabled); | 735 passwordEchoEnabled); |
| 646 } | 736 } |
| 647 | 737 |
| 648 static jboolean GetCameraEnabled(JNIEnv* env, jobject obj) { | 738 static jboolean GetCameraEnabled(JNIEnv* env, |
| 739 const JavaParamRef<jobject>& obj) { |
| 649 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 740 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 650 } | 741 } |
| 651 | 742 |
| 652 static jboolean GetCameraUserModifiable(JNIEnv* env, jobject obj) { | 743 static jboolean GetCameraUserModifiable(JNIEnv* env, |
| 744 const JavaParamRef<jobject>& obj) { |
| 653 return IsContentSettingUserModifiable( | 745 return IsContentSettingUserModifiable( |
| 654 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 746 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 655 } | 747 } |
| 656 | 748 |
| 657 static jboolean GetCameraManagedByCustodian(JNIEnv* env, jobject obj) { | 749 static jboolean GetCameraManagedByCustodian(JNIEnv* env, |
| 750 const JavaParamRef<jobject>& obj) { |
| 658 return IsContentSettingManagedByCustodian( | 751 return IsContentSettingManagedByCustodian( |
| 659 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 752 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 660 } | 753 } |
| 661 | 754 |
| 662 static jboolean GetMicEnabled(JNIEnv* env, jobject obj) { | 755 static jboolean GetMicEnabled(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 663 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 756 return GetBooleanForContentSetting(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 664 } | 757 } |
| 665 | 758 |
| 666 static jboolean GetMicUserModifiable(JNIEnv* env, jobject obj) { | 759 static jboolean GetMicUserModifiable(JNIEnv* env, |
| 760 const JavaParamRef<jobject>& obj) { |
| 667 return IsContentSettingUserModifiable( | 761 return IsContentSettingUserModifiable( |
| 668 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 762 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 669 } | 763 } |
| 670 | 764 |
| 671 static jboolean GetMicManagedByCustodian(JNIEnv* env, jobject obj) { | 765 static jboolean GetMicManagedByCustodian(JNIEnv* env, |
| 766 const JavaParamRef<jobject>& obj) { |
| 672 return IsContentSettingManagedByCustodian( | 767 return IsContentSettingManagedByCustodian( |
| 673 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 768 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 674 } | 769 } |
| 675 | 770 |
| 676 static void SetJavaScriptAllowed(JNIEnv* env, jobject obj, jstring pattern, | 771 static void SetJavaScriptAllowed(JNIEnv* env, |
| 772 const JavaParamRef<jobject>& obj, |
| 773 const JavaParamRef<jstring>& pattern, |
| 677 int setting) { | 774 int setting) { |
| 678 HostContentSettingsMap* host_content_settings_map = | 775 HostContentSettingsMap* host_content_settings_map = |
| 679 GetOriginalProfile()->GetHostContentSettingsMap(); | 776 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 680 host_content_settings_map->SetContentSetting( | 777 host_content_settings_map->SetContentSetting( |
| 681 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), | 778 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), |
| 682 ContentSettingsPattern::Wildcard(), | 779 ContentSettingsPattern::Wildcard(), |
| 683 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 780 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 684 "", | 781 "", |
| 685 static_cast<ContentSetting>(setting)); | 782 static_cast<ContentSetting>(setting)); |
| 686 } | 783 } |
| 687 | 784 |
| 688 static void SetPopupException(JNIEnv* env, jobject obj, jstring pattern, | 785 static void SetPopupException(JNIEnv* env, |
| 786 const JavaParamRef<jobject>& obj, |
| 787 const JavaParamRef<jstring>& pattern, |
| 689 int setting) { | 788 int setting) { |
| 690 HostContentSettingsMap* host_content_settings_map = | 789 HostContentSettingsMap* host_content_settings_map = |
| 691 GetOriginalProfile()->GetHostContentSettingsMap(); | 790 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 692 host_content_settings_map->SetContentSetting( | 791 host_content_settings_map->SetContentSetting( |
| 693 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), | 792 ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), |
| 694 ContentSettingsPattern::Wildcard(), | 793 ContentSettingsPattern::Wildcard(), |
| 695 CONTENT_SETTINGS_TYPE_POPUPS, | 794 CONTENT_SETTINGS_TYPE_POPUPS, |
| 696 "", | 795 "", |
| 697 static_cast<ContentSetting>(setting)); | 796 static_cast<ContentSetting>(setting)); |
| 698 } | 797 } |
| 699 | 798 |
| 700 static void SetSearchSuggestEnabled(JNIEnv* env, jobject obj, | 799 static void SetSearchSuggestEnabled(JNIEnv* env, |
| 800 const JavaParamRef<jobject>& obj, |
| 701 jboolean enabled) { | 801 jboolean enabled) { |
| 702 GetPrefService()->SetBoolean(prefs::kSearchSuggestEnabled, enabled); | 802 GetPrefService()->SetBoolean(prefs::kSearchSuggestEnabled, enabled); |
| 703 } | 803 } |
| 704 | 804 |
| 705 static ScopedJavaLocalRef<jstring> GetContextualSearchPreference(JNIEnv* env, | 805 static ScopedJavaLocalRef<jstring> GetContextualSearchPreference( |
| 706 jobject obj) { | 806 JNIEnv* env, |
| 807 const JavaParamRef<jobject>& obj) { |
| 707 return ConvertUTF8ToJavaString( | 808 return ConvertUTF8ToJavaString( |
| 708 env, GetPrefService()->GetString(prefs::kContextualSearchEnabled)); | 809 env, GetPrefService()->GetString(prefs::kContextualSearchEnabled)); |
| 709 } | 810 } |
| 710 | 811 |
| 711 static jboolean GetContextualSearchPreferenceIsManaged(JNIEnv* env, | 812 static jboolean GetContextualSearchPreferenceIsManaged( |
| 712 jobject obj) { | 813 JNIEnv* env, |
| 814 const JavaParamRef<jobject>& obj) { |
| 713 return GetPrefService()->IsManagedPreference(prefs::kContextualSearchEnabled); | 815 return GetPrefService()->IsManagedPreference(prefs::kContextualSearchEnabled); |
| 714 } | 816 } |
| 715 | 817 |
| 716 static void SetContextualSearchPreference(JNIEnv* env, jobject obj, | 818 static void SetContextualSearchPreference(JNIEnv* env, |
| 717 jstring pref) { | 819 const JavaParamRef<jobject>& obj, |
| 820 const JavaParamRef<jstring>& pref) { |
| 718 GetPrefService()->SetString(prefs::kContextualSearchEnabled, | 821 GetPrefService()->SetString(prefs::kContextualSearchEnabled, |
| 719 ConvertJavaStringToUTF8(env, pref)); | 822 ConvertJavaStringToUTF8(env, pref)); |
| 720 } | 823 } |
| 721 | 824 |
| 722 static void SetNetworkPredictionOptions(JNIEnv* env, jobject obj, int option) { | 825 static void SetNetworkPredictionOptions(JNIEnv* env, |
| 826 const JavaParamRef<jobject>& obj, |
| 827 int option) { |
| 723 GetPrefService()->SetInteger(prefs::kNetworkPredictionOptions, option); | 828 GetPrefService()->SetInteger(prefs::kNetworkPredictionOptions, option); |
| 724 } | 829 } |
| 725 | 830 |
| 726 static void SetResolveNavigationErrorEnabled(JNIEnv* env, jobject obj, | 831 static void SetResolveNavigationErrorEnabled(JNIEnv* env, |
| 832 const JavaParamRef<jobject>& obj, |
| 727 jboolean enabled) { | 833 jboolean enabled) { |
| 728 GetPrefService()->SetBoolean(prefs::kAlternateErrorPagesEnabled, enabled); | 834 GetPrefService()->SetBoolean(prefs::kAlternateErrorPagesEnabled, enabled); |
| 729 } | 835 } |
| 730 | 836 |
| 731 static jboolean GetFirstRunEulaAccepted(JNIEnv* env, jobject obj) { | 837 static jboolean GetFirstRunEulaAccepted(JNIEnv* env, |
| 838 const JavaParamRef<jobject>& obj) { |
| 732 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 839 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
| 733 } | 840 } |
| 734 | 841 |
| 735 static void SetEulaAccepted(JNIEnv* env, jobject obj) { | 842 static void SetEulaAccepted(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 736 g_browser_process->local_state()->SetBoolean(prefs::kEulaAccepted, true); | 843 g_browser_process->local_state()->SetBoolean(prefs::kEulaAccepted, true); |
| 737 } | 844 } |
| 738 | 845 |
| 739 static void ResetAcceptLanguages(JNIEnv* env, | 846 static void ResetAcceptLanguages(JNIEnv* env, |
| 740 jobject obj, | 847 const JavaParamRef<jobject>& obj, |
| 741 jstring default_locale) { | 848 const JavaParamRef<jstring>& default_locale) { |
| 742 std::string accept_languages(l10n_util::GetStringUTF8(IDS_ACCEPT_LANGUAGES)); | 849 std::string accept_languages(l10n_util::GetStringUTF8(IDS_ACCEPT_LANGUAGES)); |
| 743 std::string locale_string(ConvertJavaStringToUTF8(env, default_locale)); | 850 std::string locale_string(ConvertJavaStringToUTF8(env, default_locale)); |
| 744 | 851 |
| 745 PrefServiceBridge::PrependToAcceptLanguagesIfNecessary(locale_string, | 852 PrefServiceBridge::PrependToAcceptLanguagesIfNecessary(locale_string, |
| 746 &accept_languages); | 853 &accept_languages); |
| 747 GetPrefService()->SetString(prefs::kAcceptLanguages, accept_languages); | 854 GetPrefService()->SetString(prefs::kAcceptLanguages, accept_languages); |
| 748 } | 855 } |
| 749 | 856 |
| 750 // Sends all information about the different versions to Java. | 857 // Sends all information about the different versions to Java. |
| 751 // From browser_about_handler.cc | 858 // From browser_about_handler.cc |
| 752 static ScopedJavaLocalRef<jobject> GetAboutVersionStrings(JNIEnv* env, | 859 static ScopedJavaLocalRef<jobject> GetAboutVersionStrings( |
| 753 jobject obj) { | 860 JNIEnv* env, |
| 861 const JavaParamRef<jobject>& obj) { |
| 754 std::string os_version = version_info::GetOSType(); | 862 std::string os_version = version_info::GetOSType(); |
| 755 os_version += " " + AndroidAboutAppInfo::GetOsInfo(); | 863 os_version += " " + AndroidAboutAppInfo::GetOsInfo(); |
| 756 | 864 |
| 757 base::android::BuildInfo* android_build_info = | 865 base::android::BuildInfo* android_build_info = |
| 758 base::android::BuildInfo::GetInstance(); | 866 base::android::BuildInfo::GetInstance(); |
| 759 std::string application(android_build_info->package_label()); | 867 std::string application(android_build_info->package_label()); |
| 760 application.append(" "); | 868 application.append(" "); |
| 761 application.append(version_info::GetVersionNumber()); | 869 application.append(version_info::GetVersionNumber()); |
| 762 | 870 |
| 763 return Java_PrefServiceBridge_createAboutVersionStrings( | 871 return Java_PrefServiceBridge_createAboutVersionStrings( |
| 764 env, ConvertUTF8ToJavaString(env, application).obj(), | 872 env, ConvertUTF8ToJavaString(env, application).obj(), |
| 765 ConvertUTF8ToJavaString(env, os_version).obj()); | 873 ConvertUTF8ToJavaString(env, os_version).obj()); |
| 766 } | 874 } |
| 767 | 875 |
| 768 static ScopedJavaLocalRef<jstring> GetSupervisedUserCustodianName(JNIEnv* env, | 876 static ScopedJavaLocalRef<jstring> GetSupervisedUserCustodianName( |
| 769 jobject obj) { | 877 JNIEnv* env, |
| 878 const JavaParamRef<jobject>& obj) { |
| 770 return ConvertUTF8ToJavaString( | 879 return ConvertUTF8ToJavaString( |
| 771 env, GetPrefService()->GetString(prefs::kSupervisedUserCustodianName)); | 880 env, GetPrefService()->GetString(prefs::kSupervisedUserCustodianName)); |
| 772 } | 881 } |
| 773 | 882 |
| 774 static ScopedJavaLocalRef<jstring> GetSupervisedUserCustodianEmail( | 883 static ScopedJavaLocalRef<jstring> GetSupervisedUserCustodianEmail( |
| 775 JNIEnv* env, | 884 JNIEnv* env, |
| 776 jobject obj) { | 885 const JavaParamRef<jobject>& obj) { |
| 777 return ConvertUTF8ToJavaString( | 886 return ConvertUTF8ToJavaString( |
| 778 env, GetPrefService()->GetString(prefs::kSupervisedUserCustodianEmail)); | 887 env, GetPrefService()->GetString(prefs::kSupervisedUserCustodianEmail)); |
| 779 } | 888 } |
| 780 | 889 |
| 781 static ScopedJavaLocalRef<jstring> GetSupervisedUserCustodianProfileImageURL( | 890 static ScopedJavaLocalRef<jstring> GetSupervisedUserCustodianProfileImageURL( |
| 782 JNIEnv* env, | 891 JNIEnv* env, |
| 783 jobject obj) { | 892 const JavaParamRef<jobject>& obj) { |
| 784 return ConvertUTF8ToJavaString( | 893 return ConvertUTF8ToJavaString( |
| 785 env, GetPrefService()->GetString( | 894 env, GetPrefService()->GetString( |
| 786 prefs::kSupervisedUserCustodianProfileImageURL)); | 895 prefs::kSupervisedUserCustodianProfileImageURL)); |
| 787 } | 896 } |
| 788 | 897 |
| 789 static ScopedJavaLocalRef<jstring> GetSupervisedUserSecondCustodianName( | 898 static ScopedJavaLocalRef<jstring> GetSupervisedUserSecondCustodianName( |
| 790 JNIEnv* env, | 899 JNIEnv* env, |
| 791 jobject obj) { | 900 const JavaParamRef<jobject>& obj) { |
| 792 return ConvertUTF8ToJavaString( | 901 return ConvertUTF8ToJavaString( |
| 793 env, | 902 env, |
| 794 GetPrefService()->GetString(prefs::kSupervisedUserSecondCustodianName)); | 903 GetPrefService()->GetString(prefs::kSupervisedUserSecondCustodianName)); |
| 795 } | 904 } |
| 796 | 905 |
| 797 static ScopedJavaLocalRef<jstring> GetSupervisedUserSecondCustodianEmail( | 906 static ScopedJavaLocalRef<jstring> GetSupervisedUserSecondCustodianEmail( |
| 798 JNIEnv* env, | 907 JNIEnv* env, |
| 799 jobject obj) { | 908 const JavaParamRef<jobject>& obj) { |
| 800 return ConvertUTF8ToJavaString( | 909 return ConvertUTF8ToJavaString( |
| 801 env, | 910 env, |
| 802 GetPrefService()->GetString(prefs::kSupervisedUserSecondCustodianEmail)); | 911 GetPrefService()->GetString(prefs::kSupervisedUserSecondCustodianEmail)); |
| 803 } | 912 } |
| 804 | 913 |
| 805 static ScopedJavaLocalRef<jstring> | 914 static ScopedJavaLocalRef<jstring> |
| 806 GetSupervisedUserSecondCustodianProfileImageURL(JNIEnv* env, jobject obj) { | 915 GetSupervisedUserSecondCustodianProfileImageURL( |
| 916 JNIEnv* env, |
| 917 const JavaParamRef<jobject>& obj) { |
| 807 return ConvertUTF8ToJavaString( | 918 return ConvertUTF8ToJavaString( |
| 808 env, GetPrefService()->GetString( | 919 env, GetPrefService()->GetString( |
| 809 prefs::kSupervisedUserSecondCustodianProfileImageURL)); | 920 prefs::kSupervisedUserSecondCustodianProfileImageURL)); |
| 810 } | 921 } |
| 811 | 922 |
| 812 // static | 923 // static |
| 813 bool PrefServiceBridge::RegisterPrefServiceBridge(JNIEnv* env) { | 924 bool PrefServiceBridge::RegisterPrefServiceBridge(JNIEnv* env) { |
| 814 return RegisterNativesImpl(env); | 925 return RegisterNativesImpl(env); |
| 815 } | 926 } |
| 816 | 927 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 ContentSettingsType content_type) { | 966 ContentSettingsType content_type) { |
| 856 JNIEnv* env = AttachCurrentThread(); | 967 JNIEnv* env = AttachCurrentThread(); |
| 857 base::android::ScopedJavaLocalRef<jstring> android_permission = | 968 base::android::ScopedJavaLocalRef<jstring> android_permission = |
| 858 Java_PrefServiceBridge_getAndroidPermissionForContentSetting( | 969 Java_PrefServiceBridge_getAndroidPermissionForContentSetting( |
| 859 env, content_type); | 970 env, content_type); |
| 860 if (android_permission.is_null()) | 971 if (android_permission.is_null()) |
| 861 return std::string(); | 972 return std::string(); |
| 862 | 973 |
| 863 return ConvertJavaStringToUTF8(android_permission); | 974 return ConvertJavaStringToUTF8(android_permission); |
| 864 } | 975 } |
| OLD | NEW |