OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_usages_state
.h" | 5 #include "components/content_settings/core/browser/content_settings_usages_state
.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 HostContentSettingsMapFactory::GetForProfile(&profile), | 39 HostContentSettingsMapFactory::GetForProfile(&profile), |
40 type, | 40 type, |
41 prefs::kAcceptLanguages, | 41 prefs::kAcceptLanguages, |
42 profile.GetPrefs()); | 42 profile.GetPrefs()); |
43 GURL url_0("http://www.example.com"); | 43 GURL url_0("http://www.example.com"); |
44 | 44 |
45 ContentSettingsUsagesState::CommittedDetails details = | 45 ContentSettingsUsagesState::CommittedDetails details = |
46 CreateDetailsWithURL(url_0); | 46 CreateDetailsWithURL(url_0); |
47 state.DidNavigate(details); | 47 state.DidNavigate(details); |
48 | 48 |
49 HostContentSettingsMapFactory::GetForProfile(&profile)->SetContentSetting( | 49 HostContentSettingsMapFactory::GetForProfile(&profile) |
50 ContentSettingsPattern::FromURLNoWildcard(url_0), | 50 ->SetContentSettingDefaultScope(url_0, url_0, type, std::string(), |
51 ContentSettingsPattern::FromURLNoWildcard(url_0), | 51 CONTENT_SETTING_ALLOW); |
52 type, | |
53 std::string(), | |
54 CONTENT_SETTING_ALLOW); | |
55 state.OnPermissionSet(url_0, true); | 52 state.OnPermissionSet(url_0, true); |
56 | 53 |
57 GURL url_1("http://www.example1.com"); | 54 GURL url_1("http://www.example1.com"); |
58 HostContentSettingsMapFactory::GetForProfile(&profile)->SetContentSetting( | 55 HostContentSettingsMapFactory::GetForProfile(&profile) |
59 ContentSettingsPattern::FromURLNoWildcard(url_1), | 56 ->SetContentSettingDefaultScope(url_1, url_0, type, std::string(), |
60 ContentSettingsPattern::FromURLNoWildcard(url_0), | 57 CONTENT_SETTING_BLOCK); |
61 type, | |
62 std::string(), | |
63 CONTENT_SETTING_BLOCK); | |
64 state.OnPermissionSet(url_1, false); | 58 state.OnPermissionSet(url_1, false); |
65 | 59 |
66 ContentSettingsUsagesState::StateMap state_map = | 60 ContentSettingsUsagesState::StateMap state_map = |
67 state.state_map(); | 61 state.state_map(); |
68 EXPECT_EQ(2U, state_map.size()); | 62 EXPECT_EQ(2U, state_map.size()); |
69 | 63 |
70 ContentSettingsUsagesState::FormattedHostsPerState formatted_host_per_state; | 64 ContentSettingsUsagesState::FormattedHostsPerState formatted_host_per_state; |
71 unsigned int tab_state_flags = 0; | 65 unsigned int tab_state_flags = 0; |
72 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); | 66 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); |
73 EXPECT_TRUE(tab_state_flags & | 67 EXPECT_TRUE(tab_state_flags & |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 HostContentSettingsMapFactory::GetForProfile(&profile), | 139 HostContentSettingsMapFactory::GetForProfile(&profile), |
146 type, | 140 type, |
147 prefs::kAcceptLanguages, | 141 prefs::kAcceptLanguages, |
148 profile.GetPrefs()); | 142 profile.GetPrefs()); |
149 GURL url_0("http://www.example.com"); | 143 GURL url_0("http://www.example.com"); |
150 | 144 |
151 ContentSettingsUsagesState::CommittedDetails details = | 145 ContentSettingsUsagesState::CommittedDetails details = |
152 CreateDetailsWithURL(url_0); | 146 CreateDetailsWithURL(url_0); |
153 state.DidNavigate(details); | 147 state.DidNavigate(details); |
154 | 148 |
155 HostContentSettingsMapFactory::GetForProfile(&profile)->SetContentSetting( | 149 HostContentSettingsMapFactory::GetForProfile(&profile) |
156 ContentSettingsPattern::FromURLNoWildcard(url_0), | 150 ->SetContentSettingDefaultScope(url_0, url_0, type, std::string(), |
157 ContentSettingsPattern::FromURLNoWildcard(url_0), | 151 CONTENT_SETTING_ALLOW); |
158 type, | |
159 std::string(), | |
160 CONTENT_SETTING_ALLOW); | |
161 state.OnPermissionSet(url_0, true); | 152 state.OnPermissionSet(url_0, true); |
162 | 153 |
163 GURL url_1("https://www.example.com"); | 154 GURL url_1("https://www.example.com"); |
164 HostContentSettingsMapFactory::GetForProfile(&profile)->SetContentSetting( | 155 HostContentSettingsMapFactory::GetForProfile(&profile) |
165 ContentSettingsPattern::FromURLNoWildcard(url_1), | 156 ->SetContentSettingDefaultScope(url_1, url_0, type, std::string(), |
166 ContentSettingsPattern::FromURLNoWildcard(url_0), | 157 CONTENT_SETTING_ALLOW); |
167 type, | |
168 std::string(), | |
169 CONTENT_SETTING_ALLOW); | |
170 state.OnPermissionSet(url_1, true); | 158 state.OnPermissionSet(url_1, true); |
171 | 159 |
172 GURL url_2("http://www.example1.com"); | 160 GURL url_2("http://www.example1.com"); |
173 HostContentSettingsMapFactory::GetForProfile(&profile)->SetContentSetting( | 161 HostContentSettingsMapFactory::GetForProfile(&profile) |
174 ContentSettingsPattern::FromURLNoWildcard(url_2), | 162 ->SetContentSettingDefaultScope(url_2, url_0, type, std::string(), |
175 ContentSettingsPattern::FromURLNoWildcard(url_0), | 163 CONTENT_SETTING_ALLOW); |
176 type, | |
177 std::string(), | |
178 CONTENT_SETTING_ALLOW); | |
179 state.OnPermissionSet(url_2, true); | 164 state.OnPermissionSet(url_2, true); |
180 | 165 |
181 ContentSettingsUsagesState::StateMap state_map = | 166 ContentSettingsUsagesState::StateMap state_map = |
182 state.state_map(); | 167 state.state_map(); |
183 EXPECT_EQ(3U, state_map.size()); | 168 EXPECT_EQ(3U, state_map.size()); |
184 | 169 |
185 ContentSettingsUsagesState::FormattedHostsPerState formatted_host_per_state; | 170 ContentSettingsUsagesState::FormattedHostsPerState formatted_host_per_state; |
186 unsigned int tab_state_flags = 0; | 171 unsigned int tab_state_flags = 0; |
187 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); | 172 state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); |
188 | 173 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 215 |
231 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForGeolocation) { | 216 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForGeolocation) { |
232 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_GEOLOCATION); | 217 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_GEOLOCATION); |
233 } | 218 } |
234 | 219 |
235 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForMidi) { | 220 TEST_F(ContentSettingsUsagesStateTests, ShowPortOnSameHostForMidi) { |
236 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); | 221 ShowPortOnSameHost(CONTENT_SETTINGS_TYPE_MIDI_SYSEX); |
237 } | 222 } |
238 | 223 |
239 } // namespace | 224 } // namespace |
OLD | NEW |