Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: chrome/browser/android/preferences/pref_service_bridge.cc

Issue 902833003: Add a HostContentSettingsMap layer for Supervised Users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_supervised_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 480 }
471 481
472 static jboolean GetCameraMicUserModifiable(JNIEnv* env, jobject obj) { 482 static jboolean GetCameraMicUserModifiable(JNIEnv* env, jobject obj) {
473 PrefService* prefs = GetPrefService(); 483 PrefService* prefs = GetPrefService();
474 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_MEDIASTREAM) && 484 return IsContentSettingUserModifiable(CONTENT_SETTINGS_TYPE_MEDIASTREAM) &&
475 prefs->IsUserModifiablePreference(prefs::kAudioCaptureAllowed) && 485 prefs->IsUserModifiablePreference(prefs::kAudioCaptureAllowed) &&
476 prefs->IsUserModifiablePreference(prefs::kVideoCaptureAllowed); 486 prefs->IsUserModifiablePreference(prefs::kVideoCaptureAllowed);
477 } 487 }
478 488
479 static jboolean GetCameraMicManagedByCustodian(JNIEnv* env, jobject obj) { 489 static jboolean GetCameraMicManagedByCustodian(JNIEnv* env, jobject obj) {
480 PrefService* prefs = GetPrefService(); 490 return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_MEDIASTREAM);
481 if (prefs->IsPreferenceManagedByCustodian(prefs::kVideoCaptureAllowed))
482 return true;
483 if (prefs->IsPreferenceManagedByCustodian(prefs::kAudioCaptureAllowed))
484 return true;
485 return false;
486 } 491 }
487 492
488 static jboolean GetAutologinEnabled(JNIEnv* env, jobject obj) { 493 static jboolean GetAutologinEnabled(JNIEnv* env, jobject obj) {
489 return GetPrefService()->GetBoolean(prefs::kAutologinEnabled); 494 return GetPrefService()->GetBoolean(prefs::kAutologinEnabled);
490 } 495 }
491 496
492 static void SetAutologinEnabled(JNIEnv* env, jobject obj, 497 static void SetAutologinEnabled(JNIEnv* env, jobject obj,
493 jboolean autologinEnabled) { 498 jboolean autologinEnabled) {
494 GetPrefService()->SetBoolean(prefs::kAutologinEnabled, autologinEnabled); 499 GetPrefService()->SetBoolean(prefs::kAutologinEnabled, autologinEnabled);
495 } 500 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 jobject obj) { 731 jobject obj) {
727 return ConvertUTF8ToJavaString( 732 return ConvertUTF8ToJavaString(
728 env, 733 env,
729 GetPrefService()->GetString( 734 GetPrefService()->GetString(
730 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release(); 735 prefs::kSupervisedUserSecondCustodianProfileImageURL)).Release();
731 } 736 }
732 737
733 bool RegisterPrefServiceBridge(JNIEnv* env) { 738 bool RegisterPrefServiceBridge(JNIEnv* env) {
734 return RegisterNativesImpl(env); 739 return RegisterNativesImpl(env);
735 } 740 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_supervised_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698