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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 bool IsContentSettingManaged(ContentSettingsType content_settings_type) { | 97 bool IsContentSettingManaged(ContentSettingsType content_settings_type) { |
98 std::string source; | 98 std::string source; |
99 HostContentSettingsMap* content_settings = | 99 HostContentSettingsMap* content_settings = |
100 GetOriginalProfile()->GetHostContentSettingsMap(); | 100 GetOriginalProfile()->GetHostContentSettingsMap(); |
101 content_settings->GetDefaultContentSetting(content_settings_type, &source); | 101 content_settings->GetDefaultContentSetting(content_settings_type, &source); |
102 HostContentSettingsMap::ProviderType provider = | 102 HostContentSettingsMap::ProviderType provider = |
103 content_settings->GetProviderTypeFromSource(source); | 103 content_settings->GetProviderTypeFromSource(source); |
104 return provider == HostContentSettingsMap::POLICY_PROVIDER; | 104 return provider == HostContentSettingsMap::POLICY_PROVIDER; |
105 } | 105 } |
106 | 106 |
| 107 bool IsContentSettingManagedByCustodian( |
| 108 ContentSettingsType content_settings_type) { |
| 109 std::string source; |
| 110 HostContentSettingsMap* content_settings = |
| 111 GetOriginalProfile()->GetHostContentSettingsMap(); |
| 112 content_settings->GetDefaultContentSetting(content_settings_type, &source); |
| 113 HostContentSettingsMap::ProviderType provider = |
| 114 content_settings->GetProviderTypeFromSource(source); |
| 115 return provider == HostContentSettingsMap::SUPERVISED_PROVIDER; |
| 116 } |
| 117 |
107 bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { | 118 bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { |
108 std::string source; | 119 std::string source; |
109 HostContentSettingsMap* content_settings = | 120 HostContentSettingsMap* content_settings = |
110 GetOriginalProfile()->GetHostContentSettingsMap(); | 121 GetOriginalProfile()->GetHostContentSettingsMap(); |
111 content_settings->GetDefaultContentSetting(content_settings_type, &source); | 122 content_settings->GetDefaultContentSetting(content_settings_type, &source); |
112 HostContentSettingsMap::ProviderType provider = | 123 HostContentSettingsMap::ProviderType provider = |
113 content_settings->GetProviderTypeFromSource(source); | 124 content_settings->GetProviderTypeFromSource(source); |
114 return provider >= HostContentSettingsMap::PREF_PROVIDER; | 125 return provider >= HostContentSettingsMap::PREF_PROVIDER; |
115 } | 126 } |
116 | 127 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 GetPrefService()->GetBoolean(prefs::kGeolocationEnabled); | 234 GetPrefService()->GetBoolean(prefs::kGeolocationEnabled); |
224 } | 235 } |
225 | 236 |
226 static jboolean GetAllowLocationUserModifiable(JNIEnv* env, jobject obj) { | 237 static jboolean GetAllowLocationUserModifiable(JNIEnv* env, jobject obj) { |
227 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_GEOLOCATION) && | 238 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_GEOLOCATION) && |
228 GetPrefService()->IsUserModifiablePreference( | 239 GetPrefService()->IsUserModifiablePreference( |
229 prefs::kGeolocationEnabled); | 240 prefs::kGeolocationEnabled); |
230 } | 241 } |
231 | 242 |
232 static jboolean GetAllowLocationManagedByCustodian(JNIEnv* env, jobject obj) { | 243 static jboolean GetAllowLocationManagedByCustodian(JNIEnv* env, jobject obj) { |
233 return GetPrefService()->IsPreferenceManagedByCustodian( | 244 return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
234 prefs::kGeolocationEnabled); | |
235 } | 245 } |
236 | 246 |
237 static jboolean GetResolveNavigationErrorEnabled(JNIEnv* env, jobject obj) { | 247 static jboolean GetResolveNavigationErrorEnabled(JNIEnv* env, jobject obj) { |
238 return GetPrefService()->GetBoolean(prefs::kAlternateErrorPagesEnabled); | 248 return GetPrefService()->GetBoolean(prefs::kAlternateErrorPagesEnabled); |
239 } | 249 } |
240 | 250 |
241 static jboolean GetResolveNavigationErrorManaged(JNIEnv* env, jobject obj) { | 251 static jboolean GetResolveNavigationErrorManaged(JNIEnv* env, jobject obj) { |
242 return GetPrefService()->IsManagedPreference( | 252 return GetPrefService()->IsManagedPreference( |
243 prefs::kAlternateErrorPagesEnabled); | 253 prefs::kAlternateErrorPagesEnabled); |
244 } | 254 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 } | 470 } |
461 | 471 |
462 static jboolean GetCameraMicUserModifiable(JNIEnv* env, jobject obj) { | 472 static jboolean GetCameraMicUserModifiable(JNIEnv* env, jobject obj) { |
463 PrefService* prefs = GetPrefService(); | 473 PrefService* prefs = GetPrefService(); |
464 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_MEDIASTREAM) && | 474 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_MEDIASTREAM) && |
465 prefs->IsUserModifiablePreference(prefs::kAudioCaptureAllowed) && | 475 prefs->IsUserModifiablePreference(prefs::kAudioCaptureAllowed) && |
466 prefs->IsUserModifiablePreference(prefs::kVideoCaptureAllowed); | 476 prefs->IsUserModifiablePreference(prefs::kVideoCaptureAllowed); |
467 } | 477 } |
468 | 478 |
469 static jboolean GetCameraMicManagedByCustodian(JNIEnv* env, jobject obj) { | 479 static jboolean GetCameraMicManagedByCustodian(JNIEnv* env, jobject obj) { |
470 PrefService* prefs = GetPrefService(); | 480 return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_MEDIASTREAM); |
471 if (prefs->IsPreferenceManagedByCustodian(prefs::kVideoCaptureAllowed)) | |
472 return true; | |
473 if (prefs->IsPreferenceManagedByCustodian(prefs::kAudioCaptureAllowed)) | |
474 return true; | |
475 return false; | |
476 } | 481 } |
477 | 482 |
478 static jboolean GetAutologinEnabled(JNIEnv* env, jobject obj) { | 483 static jboolean GetAutologinEnabled(JNIEnv* env, jobject obj) { |
479 return GetPrefService()->GetBoolean(prefs::kAutologinEnabled); | 484 return GetPrefService()->GetBoolean(prefs::kAutologinEnabled); |
480 } | 485 } |
481 | 486 |
482 static void SetAutologinEnabled(JNIEnv* env, jobject obj, | 487 static void SetAutologinEnabled(JNIEnv* env, jobject obj, |
483 jboolean autologinEnabled) { | 488 jboolean autologinEnabled) { |
484 GetPrefService()->SetBoolean(prefs::kAutologinEnabled, autologinEnabled); | 489 GetPrefService()->SetBoolean(prefs::kAutologinEnabled, autologinEnabled); |
485 } | 490 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 jobject obj) { | 703 jobject obj) { |
699 return ConvertUTF8ToJavaString( | 704 return ConvertUTF8ToJavaString( |
700 env, | 705 env, |
701 GetPrefService()->GetString( | 706 GetPrefService()->GetString( |
702 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); | 707 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); |
703 } | 708 } |
704 | 709 |
705 bool RegisterPrefServiceBridge(JNIEnv* env) { | 710 bool RegisterPrefServiceBridge(JNIEnv* env) { |
706 return RegisterNativesImpl(env); | 711 return RegisterNativesImpl(env); |
707 } | 712 } |
OLD | NEW |