OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1009 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
1010 host_content_settings_map->GetContentSetting( | 1010 host_content_settings_map->GetContentSetting( |
1011 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1011 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
1012 host_content_settings_map->SetContentSetting( | 1012 host_content_settings_map->SetContentSetting( |
1013 pattern, | 1013 pattern, |
1014 ContentSettingsPattern::Wildcard(), | 1014 ContentSettingsPattern::Wildcard(), |
1015 CONTENT_SETTINGS_TYPE_IMAGES, | 1015 CONTENT_SETTINGS_TYPE_IMAGES, |
1016 std::string(), | 1016 std::string(), |
1017 CONTENT_SETTING_DEFAULT); | 1017 CONTENT_SETTING_DEFAULT); |
1018 } | 1018 } |
| 1019 |
| 1020 TEST_F(HostContentSettingsMapTest, OverrideAllowedWebsiteSetting) { |
| 1021 TestingProfile profile; |
| 1022 HostContentSettingsMap* host_content_settings_map = |
| 1023 profile.GetHostContentSettingsMap(); |
| 1024 GURL host("http://example.com/"); |
| 1025 ContentSettingsPattern pattern = |
| 1026 ContentSettingsPattern::FromString("[*.]example.com"); |
| 1027 host_content_settings_map->SetContentSetting( |
| 1028 pattern, |
| 1029 ContentSettingsPattern::Wildcard(), |
| 1030 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 1031 std::string(), |
| 1032 CONTENT_SETTING_ALLOW); |
| 1033 |
| 1034 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1035 host_content_settings_map->GetContentSetting( |
| 1036 host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
| 1037 |
| 1038 // Disabling should override an allowed exception. |
| 1039 host_content_settings_map->SetContentSettingOverride( |
| 1040 CONTENT_SETTINGS_TYPE_GEOLOCATION, false); |
| 1041 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1042 host_content_settings_map->GetContentSetting( |
| 1043 host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
| 1044 |
| 1045 host_content_settings_map->SetContentSettingOverride( |
| 1046 CONTENT_SETTINGS_TYPE_GEOLOCATION, true); |
| 1047 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1048 host_content_settings_map->GetContentSetting( |
| 1049 host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
| 1050 } |
| 1051 |
| 1052 TEST_F(HostContentSettingsMapTest, OverrideAllowedDefaultSetting) { |
| 1053 TestingProfile profile; |
| 1054 HostContentSettingsMap* host_content_settings_map = |
| 1055 profile.GetHostContentSettingsMap(); |
| 1056 |
| 1057 // Check setting defaults. |
| 1058 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1059 host_content_settings_map->GetDefaultContentSetting( |
| 1060 CONTENT_SETTINGS_TYPE_IMAGES, NULL)); |
| 1061 |
| 1062 GURL host("http://example.com/"); |
| 1063 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1064 host_content_settings_map->GetContentSetting( |
| 1065 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 1066 |
| 1067 // Disabling should override an allowed default setting. |
| 1068 host_content_settings_map->SetContentSettingOverride( |
| 1069 CONTENT_SETTINGS_TYPE_IMAGES, false); |
| 1070 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1071 host_content_settings_map->GetContentSetting( |
| 1072 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 1073 |
| 1074 // Enabling shouldn't override positively. |
| 1075 host_content_settings_map->SetContentSettingOverride( |
| 1076 CONTENT_SETTINGS_TYPE_IMAGES, true); |
| 1077 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1078 host_content_settings_map->GetContentSetting( |
| 1079 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 1080 host_content_settings_map->SetDefaultContentSetting( |
| 1081 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
| 1082 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 1083 host_content_settings_map->GetContentSetting( |
| 1084 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 1085 } |
OLD | NEW |