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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 incognito_pref == IncognitoModePrefs::DISABLED) << | 266 incognito_pref == IncognitoModePrefs::DISABLED) << |
267 "Unsupported incognito mode preference: " << incognito_pref; | 267 "Unsupported incognito mode preference: " << incognito_pref; |
268 return incognito_pref != IncognitoModePrefs::DISABLED; | 268 return incognito_pref != IncognitoModePrefs::DISABLED; |
269 } | 269 } |
270 | 270 |
271 static jboolean GetIncognitoModeManaged(JNIEnv* env, jobject obj) { | 271 static jboolean GetIncognitoModeManaged(JNIEnv* env, jobject obj) { |
272 return GetPrefService()->IsManagedPreference( | 272 return GetPrefService()->IsManagedPreference( |
273 prefs::kIncognitoModeAvailability); | 273 prefs::kIncognitoModeAvailability); |
274 } | 274 } |
275 | 275 |
| 276 static jboolean GetFullscreenManaged(JNIEnv* env, jobject obj) { |
| 277 return IsContentSettingManaged(CONTENT_SETTINGS_TYPE_FULLSCREEN); |
| 278 } |
| 279 |
| 280 static jboolean GetFullscreenAllowed(JNIEnv* env, jobject obj) { |
| 281 HostContentSettingsMap* content_settings = |
| 282 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 283 return content_settings->GetDefaultContentSetting( |
| 284 CONTENT_SETTINGS_TYPE_FULLSCREEN, NULL) == CONTENT_SETTING_ALLOW; |
| 285 } |
| 286 |
276 namespace { | 287 namespace { |
277 | 288 |
278 // Redirects a BrowsingDataRemover completion callback back into Java. | 289 // Redirects a BrowsingDataRemover completion callback back into Java. |
279 class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer { | 290 class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer { |
280 public: | 291 public: |
281 // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a | 292 // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a |
282 // ChromePreference. | 293 // ChromePreference. |
283 ClearBrowsingDataObserver(JNIEnv* env, jobject obj) | 294 ClearBrowsingDataObserver(JNIEnv* env, jobject obj) |
284 : weak_chrome_native_preferences_(env, obj) { | 295 : weak_chrome_native_preferences_(env, obj) { |
285 } | 296 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 373 } |
363 | 374 |
364 static void SetCameraMicEnabled(JNIEnv* env, jobject obj, jboolean allow) { | 375 static void SetCameraMicEnabled(JNIEnv* env, jobject obj, jboolean allow) { |
365 HostContentSettingsMap* host_content_settings_map = | 376 HostContentSettingsMap* host_content_settings_map = |
366 GetOriginalProfile()->GetHostContentSettingsMap(); | 377 GetOriginalProfile()->GetHostContentSettingsMap(); |
367 host_content_settings_map->SetDefaultContentSetting( | 378 host_content_settings_map->SetDefaultContentSetting( |
368 CONTENT_SETTINGS_TYPE_MEDIASTREAM, | 379 CONTENT_SETTINGS_TYPE_MEDIASTREAM, |
369 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 380 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
370 } | 381 } |
371 | 382 |
| 383 static void SetFullscreenAllowed(JNIEnv* env, jobject obj, jboolean allow) { |
| 384 HostContentSettingsMap* host_content_settings_map = |
| 385 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 386 host_content_settings_map->SetDefaultContentSetting( |
| 387 CONTENT_SETTINGS_TYPE_FULLSCREEN, |
| 388 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_ASK); |
| 389 } |
| 390 |
372 static void SetPushNotificationsEnabled(JNIEnv* env, | 391 static void SetPushNotificationsEnabled(JNIEnv* env, |
373 jobject obj, | 392 jobject obj, |
374 jboolean allow) { | 393 jboolean allow) { |
375 HostContentSettingsMap* host_content_settings_map = | 394 HostContentSettingsMap* host_content_settings_map = |
376 GetOriginalProfile()->GetHostContentSettingsMap(); | 395 GetOriginalProfile()->GetHostContentSettingsMap(); |
377 host_content_settings_map->SetDefaultContentSetting( | 396 host_content_settings_map->SetDefaultContentSetting( |
378 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 397 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
379 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); | 398 allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); |
380 } | 399 } |
381 | 400 |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 jobject obj) { | 745 jobject obj) { |
727 return ConvertUTF8ToJavaString( | 746 return ConvertUTF8ToJavaString( |
728 env, | 747 env, |
729 GetPrefService()->GetString( | 748 GetPrefService()->GetString( |
730 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); | 749 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); |
731 } | 750 } |
732 | 751 |
733 bool RegisterPrefServiceBridge(JNIEnv* env) { | 752 bool RegisterPrefServiceBridge(JNIEnv* env) { |
734 return RegisterNativesImpl(env); | 753 return RegisterNativesImpl(env); |
735 } | 754 } |
OLD | NEW |