| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 incognito_pref == IncognitoModePrefs::DISABLED) << | 288 incognito_pref == IncognitoModePrefs::DISABLED) << |
| 289 "Unsupported incognito mode preference: " << incognito_pref; | 289 "Unsupported incognito mode preference: " << incognito_pref; |
| 290 return incognito_pref != IncognitoModePrefs::DISABLED; | 290 return incognito_pref != IncognitoModePrefs::DISABLED; |
| 291 } | 291 } |
| 292 | 292 |
| 293 static jboolean GetIncognitoModeManaged(JNIEnv* env, jobject obj) { | 293 static jboolean GetIncognitoModeManaged(JNIEnv* env, jobject obj) { |
| 294 return GetPrefService()->IsManagedPreference( | 294 return GetPrefService()->IsManagedPreference( |
| 295 prefs::kIncognitoModeAvailability); | 295 prefs::kIncognitoModeAvailability); |
| 296 } | 296 } |
| 297 | 297 |
| 298 static jboolean GetFullscreenManaged(JNIEnv* env, jobject obj) { |
| 299 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); |
| 300 } |
| 301 |
| 302 static jboolean GetFullscreenAllowed(JNIEnv* env, jobject obj) { |
| 303 HostContentSettingsMap* content_settings = |
| 304 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 305 return content_settings->GetDefaultContentSetting( |
| 306 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; |
| 307 } |
| 308 |
| 298 namespace { | 309 namespace { |
| 299 | 310 |
| 300 // Redirects a BrowsingDataRemover completion callback back into Java. | 311 // Redirects a BrowsingDataRemover completion callback back into Java. |
| 301 class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer { | 312 class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer { |
| 302 public: | 313 public: |
| 303 // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a | 314 // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a |
| 304 // ChromePreference. | 315 // ChromePreference. |
| 305 ClearBrowsingDataObserver(JNIEnv* env, jobject obj) | 316 ClearBrowsingDataObserver(JNIEnv* env, jobject obj) |
| 306 : weak_chrome_native_preferences_(env, obj) { | 317 : weak_chrome_native_preferences_(env, obj) { |
| 307 } | 318 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 408 } |
| 398 | 409 |
| 399 static void SetCameraMicEnabled(JNIEnv* env, jobject obj, jboolean allow) { | 410 static void SetCameraMicEnabled(JNIEnv* env, jobject obj, jboolean allow) { |
| 400 HostContentSettingsMap* host_content_settings_map = | 411 HostContentSettingsMap* host_content_settings_map = |
| 401 GetOriginalProfile()->GetHostContentSettingsMap(); | 412 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 402 host_content_settings_map->SetDefaultContentSetting( | 413 host_content_settings_map->SetDefaultContentSetting( |
| 403 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 414 CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
| 404 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 415 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 405 } | 416 } |
| 406 | 417 |
| 418 static void SetFullscreenAllowed(JNIEnv* env, jobject obj, jboolean allow) { |
| 419 HostContentSettingsMap* host_content_settings_map = |
| 420 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 421 host_content_settings_map->SetDefaultContentSetting( |
| 422 CONTENT_SETTINGS_TYPE_FULLSCREEN, |
| 423 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_ASK); |
| 424 } |
| 425 |
| 407 static void SetPushNotificationsEnabled(JNIEnv* env, | 426 static void SetPushNotificationsEnabled(JNIEnv* env, |
| 408 jobject obj, | 427 jobject obj, |
| 409 jboolean allow) { | 428 jboolean allow) { |
| 410 HostContentSettingsMap* host_content_settings_map = | 429 HostContentSettingsMap* host_content_settings_map = |
| 411 GetOriginalProfile()->GetHostContentSettingsMap(); | 430 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 412 host_content_settings_map->SetDefaultContentSetting( | 431 host_content_settings_map->SetDefaultContentSetting( |
| 413 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 432 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 414 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 433 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
| 415 } | 434 } |
| 416 | 435 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 jobject obj) { | 769 jobject obj) { |
| 751 return ConvertUTF8ToJavaString( | 770 return ConvertUTF8ToJavaString( |
| 752 env, | 771 env, |
| 753 GetPrefService()->GetString( | 772 GetPrefService()->GetString( |
| 754 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); | 773 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); |
| 755 } | 774 } |
| 756 | 775 |
| 757 bool RegisterPrefServiceBridge(JNIEnv* env) { | 776 bool RegisterPrefServiceBridge(JNIEnv* env) { |
| 758 return RegisterNativesImpl(env); | 777 return RegisterNativesImpl(env); |
| 759 } | 778 } |
| OLD | NEW |