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 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 return IsContentSettingManaged( | 136 return IsContentSettingManaged( |
137 static_cast<ContentSettingsType>(content_settings_type)); | 137 static_cast<ContentSettingsType>(content_settings_type)); |
138 } | 138 } |
139 | 139 |
140 static jboolean IsContentSettingEnabled(JNIEnv* env, | 140 static jboolean IsContentSettingEnabled(JNIEnv* env, |
141 const JavaParamRef<jobject>& obj, | 141 const JavaParamRef<jobject>& obj, |
142 int content_settings_type) { | 142 int content_settings_type) { |
143 // Before we migrate functions over to this central function, we must verify | 143 // Before we migrate functions over to this central function, we must verify |
144 // that the functionality provided below is correct. | 144 // that the functionality provided below is correct. |
145 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 145 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
146 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); | 146 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS || |
| 147 content_settings_type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER); |
147 ContentSettingsType type = | 148 ContentSettingsType type = |
148 static_cast<ContentSettingsType>(content_settings_type); | 149 static_cast<ContentSettingsType>(content_settings_type); |
149 return GetBooleanForContentSetting(type); | 150 return GetBooleanForContentSetting(type); |
150 } | 151 } |
151 | 152 |
152 static void SetContentSettingEnabled(JNIEnv* env, | 153 static void SetContentSettingEnabled(JNIEnv* env, |
153 const JavaParamRef<jobject>& obj, | 154 const JavaParamRef<jobject>& obj, |
154 int content_settings_type, | 155 int content_settings_type, |
155 jboolean allow) { | 156 jboolean allow) { |
156 // Before we migrate functions over to this central function, we must verify | 157 // Before we migrate functions over to this central function, we must verify |
157 // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. | 158 // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. |
158 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 159 DCHECK(content_settings_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
159 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS); | 160 content_settings_type == CONTENT_SETTINGS_TYPE_POPUPS || |
| 161 content_settings_type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER); |
160 | 162 |
161 HostContentSettingsMap* host_content_settings_map = | 163 HostContentSettingsMap* host_content_settings_map = |
162 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); | 164 HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); |
163 host_content_settings_map->SetDefaultContentSetting( | 165 host_content_settings_map->SetDefaultContentSetting( |
164 static_cast<ContentSettingsType>(content_settings_type), | 166 static_cast<ContentSettingsType>(content_settings_type), |
165 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 167 allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
166 } | 168 } |
167 | 169 |
168 static void SetContentSettingForPattern(JNIEnv* env, | 170 static void SetContentSettingForPattern(JNIEnv* env, |
169 const JavaParamRef<jobject>& obj, | 171 const JavaParamRef<jobject>& obj, |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 .obj(), | 1012 .obj(), |
1011 out); | 1013 out); |
1012 } | 1014 } |
1013 | 1015 |
1014 static void SetSupervisedUserId(JNIEnv* env, | 1016 static void SetSupervisedUserId(JNIEnv* env, |
1015 const JavaParamRef<jobject>& obj, | 1017 const JavaParamRef<jobject>& obj, |
1016 const JavaParamRef<jstring>& pref) { | 1018 const JavaParamRef<jstring>& pref) { |
1017 GetPrefService()->SetString(prefs::kSupervisedUserId, | 1019 GetPrefService()->SetString(prefs::kSupervisedUserId, |
1018 ConvertJavaStringToUTF8(env, pref)); | 1020 ConvertJavaStringToUTF8(env, pref)); |
1019 } | 1021 } |
OLD | NEW |