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

Side by Side Diff: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc

Issue 1865803002: [Policy Experimental] Add policies to allow Cookies and Pop-ups exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync; compile fix in PolicyProvider::GetUserExceptionsUsageSettingForType(). Created 4 years, 8 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/host_content_settings_map_unittest.cc » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "components/content_settings/core/browser/content_settings_policy_provi der.h" 5 #include "components/content_settings/core/browser/content_settings_policy_provi der.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 247
248 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType()); 248 ASSERT_EQ(base::Value::TYPE_DICTIONARY, cert_filter->GetType());
249 base::DictionaryValue* dict_value = 249 base::DictionaryValue* dict_value =
250 static_cast<base::DictionaryValue*>(cert_filter.get()); 250 static_cast<base::DictionaryValue*>(cert_filter.get());
251 std::string actual_common_name; 251 std::string actual_common_name;
252 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name)); 252 ASSERT_TRUE(dict_value->GetString("ISSUER.CN", &actual_common_name));
253 EXPECT_EQ("issuer name", actual_common_name); 253 EXPECT_EQ("issuer name", actual_common_name);
254 provider.ShutdownOnUIThread(); 254 provider.ShutdownOnUIThread();
255 } 255 }
256 256
257 TEST_F(PolicyProviderTest, GetUserExceptionsUsageSettingForType) {
258 struct {
259 ContentSettingsType content_type;
260 const char* pref_exception_setting;
261 } kTypeInfos[] = {
262 {CONTENT_SETTINGS_TYPE_COOKIES, prefs::kUserCookiesExceptionsUsage},
263 {CONTENT_SETTINGS_TYPE_POPUPS, prefs::kUserPopupsExceptionsUsage},
264 };
265
266 TestingProfile profile;
267 syncable_prefs::TestingPrefServiceSyncable* prefs =
268 profile.GetTestingPrefService();
269 PolicyProvider provider(prefs);
270
271 for (const auto& type_info : kTypeInfos) {
272 // Initially not set.
273 EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
274 provider.GetUserExceptionsUsageSettingForType(
275 type_info.content_type));
276
277 // Set value.
278 prefs->SetManagedPref(type_info.pref_exception_setting,
279 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
280 EXPECT_EQ(USER_EXCEPTIONS_ALLOW,
281 provider.GetUserExceptionsUsageSettingForType(
282 type_info.content_type));
283
284 // Clear value.
285 prefs->RemoveManagedPref(type_info.pref_exception_setting);
286 EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
287 provider.GetUserExceptionsUsageSettingForType(
288 type_info.content_type));
289
290 // Try to set as user pref: Should have no effect.
291 prefs->SetUserPref(type_info.pref_exception_setting,
292 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
293 EXPECT_EQ(USER_EXCEPTIONS_DEFAULT,
294 provider.GetUserExceptionsUsageSettingForType(
295 type_info.content_type));
296
297 // Set value again and leave it lingering around.
298 prefs->SetManagedPref(type_info.pref_exception_setting,
299 new base::FundamentalValue(CONTENT_SETTING_ALLOW));
300 EXPECT_EQ(USER_EXCEPTIONS_ALLOW,
301 provider.GetUserExceptionsUsageSettingForType(
302 type_info.content_type));
303 }
304
305 provider.ShutdownOnUIThread();
306 }
307
257 } // namespace content_settings 308 } // namespace content_settings
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/host_content_settings_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698