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
3 // found in the LICENSE file.
5 #include "base/auto_reset.h"
6 #include "base/command_line.h"
7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/prefs/scoped_user_pref_update.h"
12 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
13 #include "chrome/browser/content_settings/cookie_settings_factory.h"
14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
15 #include "chrome/browser/content_settings/mock_settings_observer.h"
16 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/testing_profile.h"
19 #include "components/content_settings/core/browser/content_settings_details.h"
20 #include "components/content_settings/core/browser/cookie_settings.h"
21 #include "components/content_settings/core/browser/host_content_settings_map.h"
22 #include "components/content_settings/core/browser/website_settings_info.h"
23 #include "components/content_settings/core/browser/website_settings_registry.h"
24 #include "components/syncable_prefs/testing_pref_service_syncable.h"
25 #include "content/public/test/test_browser_thread.h"
26 #include "net/base/static_cookie_policy.h"
27 #include "testing/gtest/include/gtest/gtest.h"
30 using content::BrowserThread
;
34 class HostContentSettingsMapTest
: public testing::Test
{
36 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI
, &message_loop_
) {
40 const std::string
& GetPrefName(ContentSettingsType type
) {
41 return content_settings::WebsiteSettingsRegistry::GetInstance()
46 base::MessageLoop message_loop_
;
47 content::TestBrowserThread ui_thread_
;
50 TEST_F(HostContentSettingsMapTest
, DefaultValues
) {
51 TestingProfile profile
;
52 HostContentSettingsMap
* host_content_settings_map
=
53 HostContentSettingsMapFactory::GetForProfile(&profile
);
55 // Check setting defaults.
56 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
57 host_content_settings_map
->GetDefaultContentSetting(
58 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
59 host_content_settings_map
->SetDefaultContentSetting(
60 CONTENT_SETTINGS_TYPE_IMAGES
, CONTENT_SETTING_BLOCK
);
61 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
62 host_content_settings_map
->GetDefaultContentSetting(
63 CONTENT_SETTINGS_TYPE_IMAGES
, NULL
));
64 EXPECT_EQ(CONTENT_SETTING_ALLOW
, host_content_settings_map
->GetContentSetting(
65 GURL(chrome::kChromeUINewTabURL
),
66 GURL(chrome::kChromeUINewTabURL
),
67 CONTENT_SETTINGS_TYPE_IMAGES
,
70 #if defined(ENABLE_PLUGINS)
71 host_content_settings_map
->SetDefaultContentSetting(
72 CONTENT_SETTINGS_TYPE_PLUGINS
, CONTENT_SETTING_ALLOW
);
73 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
74 host_content_settings_map
->GetDefaultContentSetting(
75 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
76 host_content_settings_map
->SetDefaultContentSetting(
77 CONTENT_SETTINGS_TYPE_PLUGINS
, CONTENT_SETTING_BLOCK
);
78 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
79 host_content_settings_map
->GetDefaultContentSetting(
80 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
81 host_content_settings_map
->SetDefaultContentSetting(
82 CONTENT_SETTINGS_TYPE_PLUGINS
, CONTENT_SETTING_DETECT_IMPORTANT_CONTENT
);
83 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT
,
84 host_content_settings_map
->GetDefaultContentSetting(
85 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
88 host_content_settings_map
->SetDefaultContentSetting(
89 CONTENT_SETTINGS_TYPE_POPUPS
, CONTENT_SETTING_ALLOW
);
90 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
91 host_content_settings_map
->GetDefaultContentSetting(
92 CONTENT_SETTINGS_TYPE_POPUPS
, NULL
));
95 TEST_F(HostContentSettingsMapTest
, IndividualSettings
) {
96 TestingProfile profile
;
97 HostContentSettingsMap
* host_content_settings_map
=
98 HostContentSettingsMapFactory::GetForProfile(&profile
);
100 // Check returning individual settings.
101 GURL
host("http://example.com/");
102 ContentSettingsPattern pattern
=
103 ContentSettingsPattern::FromString("[*.]example.com");
104 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
105 host_content_settings_map
->GetContentSetting(
106 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
107 host_content_settings_map
->SetContentSetting(
109 ContentSettingsPattern::Wildcard(),
110 CONTENT_SETTINGS_TYPE_IMAGES
,
112 CONTENT_SETTING_DEFAULT
);
113 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
114 host_content_settings_map
->GetContentSetting(
115 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
116 host_content_settings_map
->SetContentSetting(
118 ContentSettingsPattern::Wildcard(),
119 CONTENT_SETTINGS_TYPE_IMAGES
,
121 CONTENT_SETTING_BLOCK
);
122 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
123 host_content_settings_map
->GetContentSetting(
124 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
125 #if defined(ENABLE_PLUGINS)
126 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
127 host_content_settings_map
->GetContentSetting(
128 host
, host
, CONTENT_SETTINGS_TYPE_PLUGINS
, std::string()));
131 // Check returning all settings for a host.
132 host_content_settings_map
->SetContentSetting(
134 ContentSettingsPattern::Wildcard(),
135 CONTENT_SETTINGS_TYPE_IMAGES
,
137 CONTENT_SETTING_DEFAULT
);
138 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
139 host_content_settings_map
->GetContentSetting(
140 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
141 host_content_settings_map
->SetContentSetting(
143 ContentSettingsPattern::Wildcard(),
144 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
146 CONTENT_SETTING_BLOCK
);
147 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
148 host_content_settings_map
->GetContentSetting(
149 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
150 #if defined(ENABLE_PLUGINS)
151 host_content_settings_map
->SetContentSetting(
153 ContentSettingsPattern::Wildcard(),
154 CONTENT_SETTINGS_TYPE_PLUGINS
,
156 CONTENT_SETTING_ALLOW
);
157 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
158 host_content_settings_map
->GetContentSetting(
159 host
, host
, CONTENT_SETTINGS_TYPE_PLUGINS
, std::string()));
161 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
162 host_content_settings_map
->GetContentSetting(
163 host
, host
, CONTENT_SETTINGS_TYPE_POPUPS
, std::string()));
164 EXPECT_EQ(CONTENT_SETTING_ASK
,
165 host_content_settings_map
->GetContentSetting(
166 host
, host
, CONTENT_SETTINGS_TYPE_GEOLOCATION
, std::string()));
169 host_content_settings_map
->GetContentSetting(
170 host
, host
, CONTENT_SETTINGS_TYPE_NOTIFICATIONS
, std::string()));
171 EXPECT_EQ(CONTENT_SETTING_ASK
,
172 host_content_settings_map
->GetContentSetting(
173 host
, host
, CONTENT_SETTINGS_TYPE_FULLSCREEN
, std::string()));
174 EXPECT_EQ(CONTENT_SETTING_ASK
,
175 host_content_settings_map
->GetContentSetting(
176 host
, host
, CONTENT_SETTINGS_TYPE_MOUSELOCK
, std::string()));
178 // Check returning all hosts for a setting.
179 ContentSettingsPattern pattern2
=
180 ContentSettingsPattern::FromString("[*.]example.org");
181 host_content_settings_map
->SetContentSetting(
183 ContentSettingsPattern::Wildcard(),
184 CONTENT_SETTINGS_TYPE_IMAGES
,
186 CONTENT_SETTING_BLOCK
);
187 #if defined(ENABLE_PLUGINS)
188 host_content_settings_map
->SetContentSetting(
190 ContentSettingsPattern::Wildcard(),
191 CONTENT_SETTINGS_TYPE_PLUGINS
,
193 CONTENT_SETTING_BLOCK
);
195 ContentSettingsForOneType host_settings
;
196 host_content_settings_map
->GetSettingsForOneType(
197 CONTENT_SETTINGS_TYPE_IMAGES
, std::string(), &host_settings
);
198 // |host_settings| contains the default setting and an exception.
199 EXPECT_EQ(2U, host_settings
.size());
200 #if defined(ENABLE_PLUGINS)
201 host_content_settings_map
->GetSettingsForOneType(
202 CONTENT_SETTINGS_TYPE_PLUGINS
, std::string(), &host_settings
);
203 // |host_settings| contains the default setting and 2 exceptions.
204 EXPECT_EQ(3U, host_settings
.size());
206 host_content_settings_map
->GetSettingsForOneType(
207 CONTENT_SETTINGS_TYPE_POPUPS
, std::string(), &host_settings
);
208 // |host_settings| contains only the default setting.
209 EXPECT_EQ(1U, host_settings
.size());
212 TEST_F(HostContentSettingsMapTest
, Clear
) {
213 TestingProfile profile
;
214 HostContentSettingsMap
* host_content_settings_map
=
215 HostContentSettingsMapFactory::GetForProfile(&profile
);
217 // Check clearing one type.
218 ContentSettingsPattern pattern
=
219 ContentSettingsPattern::FromString("[*.]example.org");
220 ContentSettingsPattern pattern2
=
221 ContentSettingsPattern::FromString("[*.]example.net");
222 host_content_settings_map
->SetContentSetting(
224 ContentSettingsPattern::Wildcard(),
225 CONTENT_SETTINGS_TYPE_IMAGES
,
227 CONTENT_SETTING_BLOCK
);
228 host_content_settings_map
->SetContentSetting(
230 ContentSettingsPattern::Wildcard(),
231 CONTENT_SETTINGS_TYPE_IMAGES
,
233 CONTENT_SETTING_BLOCK
);
234 #if defined(ENABLE_PLUGINS)
235 host_content_settings_map
->SetContentSetting(
237 ContentSettingsPattern::Wildcard(),
238 CONTENT_SETTINGS_TYPE_PLUGINS
,
240 CONTENT_SETTING_BLOCK
);
242 host_content_settings_map
->SetContentSetting(
244 ContentSettingsPattern::Wildcard(),
245 CONTENT_SETTINGS_TYPE_IMAGES
,
247 CONTENT_SETTING_BLOCK
);
248 host_content_settings_map
->ClearSettingsForOneType(
249 CONTENT_SETTINGS_TYPE_IMAGES
);
250 ContentSettingsForOneType host_settings
;
251 host_content_settings_map
->GetSettingsForOneType(
252 CONTENT_SETTINGS_TYPE_IMAGES
, std::string(), &host_settings
);
253 // |host_settings| contains only the default setting.
254 EXPECT_EQ(1U, host_settings
.size());
255 #if defined(ENABLE_PLUGINS)
256 host_content_settings_map
->GetSettingsForOneType(
257 CONTENT_SETTINGS_TYPE_PLUGINS
, std::string(), &host_settings
);
258 // |host_settings| contains the default setting and an exception.
259 EXPECT_EQ(2U, host_settings
.size());
263 TEST_F(HostContentSettingsMapTest
, Patterns
) {
264 TestingProfile profile
;
265 HostContentSettingsMap
* host_content_settings_map
=
266 HostContentSettingsMapFactory::GetForProfile(&profile
);
268 GURL
host1("http://example.com/");
269 GURL
host2("http://www.example.com/");
270 GURL
host3("http://example.org/");
271 ContentSettingsPattern pattern1
=
272 ContentSettingsPattern::FromString("[*.]example.com");
273 ContentSettingsPattern pattern2
=
274 ContentSettingsPattern::FromString("example.org");
275 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
276 host_content_settings_map
->GetContentSetting(
277 host1
, host1
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
278 host_content_settings_map
->SetContentSetting(
280 ContentSettingsPattern::Wildcard(),
281 CONTENT_SETTINGS_TYPE_IMAGES
,
283 CONTENT_SETTING_BLOCK
);
284 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
285 host_content_settings_map
->GetContentSetting(
286 host1
, host1
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
287 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
288 host_content_settings_map
->GetContentSetting(
289 host2
, host2
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
290 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
291 host_content_settings_map
->GetContentSetting(
292 host3
, host3
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
293 host_content_settings_map
->SetContentSetting(
295 ContentSettingsPattern::Wildcard(),
296 CONTENT_SETTINGS_TYPE_IMAGES
,
298 CONTENT_SETTING_BLOCK
);
299 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
300 host_content_settings_map
->GetContentSetting(
301 host3
, host3
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
304 TEST_F(HostContentSettingsMapTest
, Observer
) {
305 TestingProfile profile
;
306 HostContentSettingsMap
* host_content_settings_map
=
307 HostContentSettingsMapFactory::GetForProfile(&profile
);
308 MockSettingsObserver
observer(host_content_settings_map
);
310 ContentSettingsPattern primary_pattern
=
311 ContentSettingsPattern::FromString("[*.]example.com");
312 ContentSettingsPattern secondary_pattern
=
313 ContentSettingsPattern::Wildcard();
314 EXPECT_CALL(observer
,
315 OnContentSettingsChanged(host_content_settings_map
,
316 CONTENT_SETTINGS_TYPE_IMAGES
,
321 host_content_settings_map
->SetContentSetting(
324 CONTENT_SETTINGS_TYPE_IMAGES
,
326 CONTENT_SETTING_ALLOW
);
327 ::testing::Mock::VerifyAndClearExpectations(&observer
);
329 EXPECT_CALL(observer
,
330 OnContentSettingsChanged(host_content_settings_map
,
331 CONTENT_SETTINGS_TYPE_IMAGES
, false,
333 host_content_settings_map
->ClearSettingsForOneType(
334 CONTENT_SETTINGS_TYPE_IMAGES
);
335 ::testing::Mock::VerifyAndClearExpectations(&observer
);
337 EXPECT_CALL(observer
,
338 OnContentSettingsChanged(host_content_settings_map
,
339 CONTENT_SETTINGS_TYPE_IMAGES
, false,
341 host_content_settings_map
->SetDefaultContentSetting(
342 CONTENT_SETTINGS_TYPE_IMAGES
, CONTENT_SETTING_BLOCK
);
345 TEST_F(HostContentSettingsMapTest
, ObserveDefaultPref
) {
346 TestingProfile profile
;
347 HostContentSettingsMap
* host_content_settings_map
=
348 HostContentSettingsMapFactory::GetForProfile(&profile
);
350 PrefService
* prefs
= profile
.GetPrefs();
351 GURL
host("http://example.com");
353 host_content_settings_map
->SetDefaultContentSetting(
354 CONTENT_SETTINGS_TYPE_IMAGES
, CONTENT_SETTING_BLOCK
);
355 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
356 host_content_settings_map
->GetContentSetting(
357 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
359 const content_settings::WebsiteSettingsInfo
* info
=
360 content_settings::WebsiteSettingsRegistry::GetInstance()->Get(
361 CONTENT_SETTINGS_TYPE_IMAGES
);
362 // Clearing the backing pref should also clear the internal cache.
363 prefs
->ClearPref(info
->default_value_pref_name());
364 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
365 host_content_settings_map
->GetContentSetting(
366 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
368 // Reseting the pref to its previous value should update the cache.
369 prefs
->SetInteger(info
->default_value_pref_name(), CONTENT_SETTING_BLOCK
);
370 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
371 host_content_settings_map
->GetContentSetting(
372 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
375 TEST_F(HostContentSettingsMapTest
, ObserveExceptionPref
) {
376 TestingProfile profile
;
377 HostContentSettingsMap
* host_content_settings_map
=
378 HostContentSettingsMapFactory::GetForProfile(&profile
);
380 PrefService
* prefs
= profile
.GetPrefs();
382 // Make a copy of the default pref value so we can reset it later.
383 scoped_ptr
<base::Value
> default_value(
384 prefs
->FindPreference(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES
))
388 ContentSettingsPattern pattern
=
389 ContentSettingsPattern::FromString("[*.]example.com");
390 GURL
host("http://example.com");
392 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
393 host_content_settings_map
->GetContentSetting(
394 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
396 host_content_settings_map
->SetContentSetting(
398 ContentSettingsPattern::Wildcard(),
399 CONTENT_SETTINGS_TYPE_IMAGES
,
401 CONTENT_SETTING_BLOCK
);
402 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
403 host_content_settings_map
->GetContentSetting(
404 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
406 // Make a copy of the pref's new value so we can reset it later.
407 scoped_ptr
<base::Value
> new_value(
408 prefs
->FindPreference(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES
))
412 // Clearing the backing pref should also clear the internal cache.
413 prefs
->Set(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES
), *default_value
);
414 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
415 host_content_settings_map
->GetContentSetting(
416 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
418 // Reseting the pref to its previous value should update the cache.
419 prefs
->Set(GetPrefName(CONTENT_SETTINGS_TYPE_IMAGES
), *new_value
);
420 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
421 host_content_settings_map
->GetContentSetting(
422 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
425 TEST_F(HostContentSettingsMapTest
, HostTrimEndingDotCheck
) {
426 TestingProfile profile
;
427 HostContentSettingsMap
* host_content_settings_map
=
428 HostContentSettingsMapFactory::GetForProfile(&profile
);
429 content_settings::CookieSettings
* cookie_settings
=
430 CookieSettingsFactory::GetForProfile(&profile
).get();
432 ContentSettingsPattern pattern
=
433 ContentSettingsPattern::FromString("[*.]example.com");
434 GURL
host_ending_with_dot("http://example.com./");
436 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
437 host_content_settings_map
->GetContentSetting(
438 host_ending_with_dot
,
439 host_ending_with_dot
,
440 CONTENT_SETTINGS_TYPE_IMAGES
,
442 host_content_settings_map
->SetContentSetting(
444 ContentSettingsPattern::Wildcard(),
445 CONTENT_SETTINGS_TYPE_IMAGES
,
447 CONTENT_SETTING_DEFAULT
);
449 CONTENT_SETTING_ALLOW
,
450 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
451 host_ending_with_dot
,
452 CONTENT_SETTINGS_TYPE_IMAGES
,
454 host_content_settings_map
->SetContentSetting(
456 ContentSettingsPattern::Wildcard(),
457 CONTENT_SETTINGS_TYPE_IMAGES
,
459 CONTENT_SETTING_BLOCK
);
461 CONTENT_SETTING_BLOCK
,
462 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
463 host_ending_with_dot
,
464 CONTENT_SETTINGS_TYPE_IMAGES
,
467 EXPECT_TRUE(cookie_settings
->IsSettingCookieAllowed(
468 host_ending_with_dot
, host_ending_with_dot
));
469 host_content_settings_map
->SetContentSetting(
471 ContentSettingsPattern::Wildcard(),
472 CONTENT_SETTINGS_TYPE_COOKIES
,
474 CONTENT_SETTING_DEFAULT
);
475 EXPECT_TRUE(cookie_settings
->IsSettingCookieAllowed(
476 host_ending_with_dot
, host_ending_with_dot
));
477 host_content_settings_map
->SetContentSetting(
479 ContentSettingsPattern::Wildcard(),
480 CONTENT_SETTINGS_TYPE_COOKIES
,
482 CONTENT_SETTING_BLOCK
);
483 EXPECT_FALSE(cookie_settings
->IsSettingCookieAllowed(
484 host_ending_with_dot
, host_ending_with_dot
));
486 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
487 host_content_settings_map
->GetContentSetting(
488 host_ending_with_dot
,
489 host_ending_with_dot
,
490 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
492 host_content_settings_map
->SetContentSetting(
494 ContentSettingsPattern::Wildcard(),
495 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
497 CONTENT_SETTING_DEFAULT
);
498 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
499 host_content_settings_map
->GetContentSetting(
500 host_ending_with_dot
,
501 host_ending_with_dot
,
502 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
504 host_content_settings_map
->SetContentSetting(
506 ContentSettingsPattern::Wildcard(),
507 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
509 CONTENT_SETTING_BLOCK
);
510 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
511 host_content_settings_map
->GetContentSetting(
512 host_ending_with_dot
,
513 host_ending_with_dot
,
514 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
517 #if defined(ENABLE_PLUGINS)
518 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
519 host_content_settings_map
->GetContentSetting(
520 host_ending_with_dot
,
521 host_ending_with_dot
,
522 CONTENT_SETTINGS_TYPE_PLUGINS
,
524 host_content_settings_map
->SetContentSetting(
526 ContentSettingsPattern::Wildcard(),
527 CONTENT_SETTINGS_TYPE_PLUGINS
,
529 CONTENT_SETTING_DEFAULT
);
530 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
531 host_content_settings_map
->GetContentSetting(
532 host_ending_with_dot
,
533 host_ending_with_dot
,
534 CONTENT_SETTINGS_TYPE_PLUGINS
,
536 host_content_settings_map
->SetContentSetting(
538 ContentSettingsPattern::Wildcard(),
539 CONTENT_SETTINGS_TYPE_PLUGINS
,
541 CONTENT_SETTING_BLOCK
);
542 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
543 host_content_settings_map
->GetContentSetting(
544 host_ending_with_dot
,
545 host_ending_with_dot
,
546 CONTENT_SETTINGS_TYPE_PLUGINS
,
551 CONTENT_SETTING_BLOCK
,
552 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
553 host_ending_with_dot
,
554 CONTENT_SETTINGS_TYPE_POPUPS
,
556 host_content_settings_map
->SetContentSetting(
558 ContentSettingsPattern::Wildcard(),
559 CONTENT_SETTINGS_TYPE_POPUPS
,
561 CONTENT_SETTING_DEFAULT
);
563 CONTENT_SETTING_BLOCK
,
564 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
565 host_ending_with_dot
,
566 CONTENT_SETTINGS_TYPE_POPUPS
,
568 host_content_settings_map
->SetContentSetting(
570 ContentSettingsPattern::Wildcard(),
571 CONTENT_SETTINGS_TYPE_POPUPS
,
573 CONTENT_SETTING_ALLOW
);
575 CONTENT_SETTING_ALLOW
,
576 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
577 host_ending_with_dot
,
578 CONTENT_SETTINGS_TYPE_POPUPS
,
582 TEST_F(HostContentSettingsMapTest
, NestedSettings
) {
583 TestingProfile profile
;
584 HostContentSettingsMap
* host_content_settings_map
=
585 HostContentSettingsMapFactory::GetForProfile(&profile
);
587 GURL
host("http://a.b.example.com/");
588 ContentSettingsPattern pattern1
=
589 ContentSettingsPattern::FromString("[*.]example.com");
590 ContentSettingsPattern pattern2
=
591 ContentSettingsPattern::FromString("[*.]b.example.com");
592 ContentSettingsPattern pattern3
=
593 ContentSettingsPattern::FromString("a.b.example.com");
595 host_content_settings_map
->SetContentSetting(
597 ContentSettingsPattern::Wildcard(),
598 CONTENT_SETTINGS_TYPE_IMAGES
,
600 CONTENT_SETTING_BLOCK
);
602 host_content_settings_map
->SetContentSetting(
604 ContentSettingsPattern::Wildcard(),
605 CONTENT_SETTINGS_TYPE_COOKIES
,
607 CONTENT_SETTING_BLOCK
);
609 host_content_settings_map
->SetContentSetting(
611 ContentSettingsPattern::Wildcard(),
612 CONTENT_SETTINGS_TYPE_PLUGINS
,
614 CONTENT_SETTING_BLOCK
);
615 host_content_settings_map
->SetDefaultContentSetting(
616 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, CONTENT_SETTING_BLOCK
);
618 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
619 host_content_settings_map
->GetContentSetting(
620 host
, host
, CONTENT_SETTINGS_TYPE_COOKIES
, std::string()));
621 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
622 host_content_settings_map
->GetContentSetting(
623 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
624 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
625 host_content_settings_map
->GetContentSetting(
626 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
627 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
628 host_content_settings_map
->GetContentSetting(
629 host
, host
, CONTENT_SETTINGS_TYPE_PLUGINS
, std::string()));
630 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
631 host_content_settings_map
->GetContentSetting(
632 host
, host
, CONTENT_SETTINGS_TYPE_POPUPS
, std::string()));
633 EXPECT_EQ(CONTENT_SETTING_ASK
,
634 host_content_settings_map
->GetContentSetting(
635 host
, host
, CONTENT_SETTINGS_TYPE_GEOLOCATION
, std::string()));
638 host_content_settings_map
->GetContentSetting(
639 host
, host
, CONTENT_SETTINGS_TYPE_NOTIFICATIONS
, std::string()));
640 EXPECT_EQ(CONTENT_SETTING_ASK
,
641 host_content_settings_map
->GetContentSetting(
642 host
, host
, CONTENT_SETTINGS_TYPE_FULLSCREEN
, std::string()));
643 EXPECT_EQ(CONTENT_SETTING_ASK
,
644 host_content_settings_map
->GetContentSetting(
645 host
, host
, CONTENT_SETTINGS_TYPE_MOUSELOCK
, std::string()));
648 TEST_F(HostContentSettingsMapTest
, OffTheRecord
) {
649 TestingProfile profile
;
650 HostContentSettingsMap
* host_content_settings_map
=
651 HostContentSettingsMapFactory::GetForProfile(&profile
);
652 scoped_refptr
<HostContentSettingsMap
> otr_map(
653 new HostContentSettingsMap(profile
.GetPrefs(),
656 GURL
host("http://example.com/");
657 ContentSettingsPattern pattern
=
658 ContentSettingsPattern::FromString("[*.]example.com");
660 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
661 host_content_settings_map
->GetContentSetting(
662 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
663 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
664 otr_map
->GetContentSetting(
665 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
667 // Changing content settings on the main map should also affect the
669 host_content_settings_map
->SetContentSetting(
671 ContentSettingsPattern::Wildcard(),
672 CONTENT_SETTINGS_TYPE_IMAGES
,
674 CONTENT_SETTING_BLOCK
);
675 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
676 host_content_settings_map
->GetContentSetting(
677 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
678 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
679 otr_map
->GetContentSetting(
680 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
682 // Changing content settings on the incognito map should NOT affect the
684 otr_map
->SetContentSetting(pattern
,
685 ContentSettingsPattern::Wildcard(),
686 CONTENT_SETTINGS_TYPE_IMAGES
,
688 CONTENT_SETTING_ALLOW
);
689 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
690 host_content_settings_map
->GetContentSetting(
691 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
692 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
693 otr_map
->GetContentSetting(
694 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
696 otr_map
->ShutdownOnUIThread();
699 // For a single Unicode encoded pattern, check if it gets converted to punycode
700 // and old pattern gets deleted.
701 TEST_F(HostContentSettingsMapTest
, CanonicalizeExceptionsUnicodeOnly
) {
702 TestingProfile profile
;
703 PrefService
* prefs
= profile
.GetPrefs();
707 DictionaryPrefUpdate
update(prefs
,
708 GetPrefName(CONTENT_SETTINGS_TYPE_PLUGINS
));
709 base::DictionaryValue
* all_settings_dictionary
= update
.Get();
710 ASSERT_TRUE(NULL
!= all_settings_dictionary
);
712 base::DictionaryValue
* dummy_payload
= new base::DictionaryValue
;
713 dummy_payload
->SetInteger("setting", CONTENT_SETTING_ALLOW
);
714 all_settings_dictionary
->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*",
718 HostContentSettingsMapFactory::GetForProfile(&profile
);
720 const base::DictionaryValue
* all_settings_dictionary
=
721 prefs
->GetDictionary(GetPrefName(CONTENT_SETTINGS_TYPE_PLUGINS
));
722 const base::DictionaryValue
* result
= NULL
;
723 EXPECT_FALSE(all_settings_dictionary
->GetDictionaryWithoutPathExpansion(
724 "[*.]\xC4\x87ira.com,*", &result
));
725 EXPECT_TRUE(all_settings_dictionary
->GetDictionaryWithoutPathExpansion(
726 "[*.]xn--ira-ppa.com,*", &result
));
729 // If both Unicode and its punycode pattern exist, make sure we don't touch the
730 // settings for the punycode, and that Unicode pattern gets deleted.
731 TEST_F(HostContentSettingsMapTest
, CanonicalizeExceptionsUnicodeAndPunycode
) {
732 TestingProfile profile
;
734 scoped_ptr
<base::Value
> value
=
735 base::JSONReader::Read("{\"[*.]\\xC4\\x87ira.com,*\":{\"setting\":1}}");
736 profile
.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES
), *value
);
738 // Set punycode equivalent, with different setting.
739 scoped_ptr
<base::Value
> puny_value
=
740 base::JSONReader::Read("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}");
741 profile
.GetPrefs()->Set(GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES
),
744 // Initialize the content map.
745 HostContentSettingsMapFactory::GetForProfile(&profile
);
747 const base::DictionaryValue
& content_setting_prefs
=
748 *profile
.GetPrefs()->GetDictionary(
749 GetPrefName(CONTENT_SETTINGS_TYPE_COOKIES
));
750 std::string prefs_as_json
;
751 base::JSONWriter::Write(content_setting_prefs
, &prefs_as_json
);
752 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}",
753 prefs_as_json
.c_str());
756 // If a default-content-setting is managed, the managed value should be used
757 // instead of the default value.
758 TEST_F(HostContentSettingsMapTest
, ManagedDefaultContentSetting
) {
759 TestingProfile profile
;
760 HostContentSettingsMap
* host_content_settings_map
=
761 HostContentSettingsMapFactory::GetForProfile(&profile
);
762 syncable_prefs::TestingPrefServiceSyncable
* prefs
=
763 profile
.GetTestingPrefService();
765 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
766 host_content_settings_map
->GetDefaultContentSetting(
767 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
769 // Set managed-default-content-setting through the coresponding preferences.
770 prefs
->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting
,
771 new base::FundamentalValue(CONTENT_SETTING_BLOCK
));
772 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
773 host_content_settings_map
->GetDefaultContentSetting(
774 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
776 // Remove managed-default-content-settings-preferences.
777 prefs
->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting
);
778 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
779 host_content_settings_map
->GetDefaultContentSetting(
780 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
782 // Set preference to manage the default-content-setting for Plugins.
783 prefs
->SetManagedPref(prefs::kManagedDefaultPluginsSetting
,
784 new base::FundamentalValue(CONTENT_SETTING_BLOCK
));
785 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
786 host_content_settings_map
->GetDefaultContentSetting(
787 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
789 #if defined(ENABLE_PLUGINS)
790 // Remove the preference to manage the default-content-setting for Plugins.
791 prefs
->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting
);
792 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
793 host_content_settings_map
->GetDefaultContentSetting(
794 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
798 TEST_F(HostContentSettingsMapTest
,
799 GetNonDefaultContentSettingsIfTypeManaged
) {
800 TestingProfile profile
;
801 HostContentSettingsMap
* host_content_settings_map
=
802 HostContentSettingsMapFactory::GetForProfile(&profile
);
803 syncable_prefs::TestingPrefServiceSyncable
* prefs
=
804 profile
.GetTestingPrefService();
806 // Set pattern for JavaScript setting.
807 ContentSettingsPattern pattern
=
808 ContentSettingsPattern::FromString("[*.]example.com");
809 host_content_settings_map
->SetContentSetting(
811 ContentSettingsPattern::Wildcard(),
812 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
814 CONTENT_SETTING_BLOCK
);
816 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
817 host_content_settings_map
->GetDefaultContentSetting(
818 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
820 GURL
host("http://example.com/");
821 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
822 host_content_settings_map
->GetContentSetting(
823 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
825 // Set managed-default-content-setting for content-settings-type JavaScript.
826 prefs
->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting
,
827 new base::FundamentalValue(CONTENT_SETTING_ALLOW
));
828 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
829 host_content_settings_map
->GetContentSetting(
830 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
833 // Managed default content setting should have higher priority
834 // than user defined patterns.
835 TEST_F(HostContentSettingsMapTest
,
836 ManagedDefaultContentSettingIgnoreUserPattern
) {
837 TestingProfile profile
;
838 HostContentSettingsMap
* host_content_settings_map
=
839 HostContentSettingsMapFactory::GetForProfile(&profile
);
840 syncable_prefs::TestingPrefServiceSyncable
* prefs
=
841 profile
.GetTestingPrefService();
843 // Block all JavaScript.
844 host_content_settings_map
->SetDefaultContentSetting(
845 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, CONTENT_SETTING_BLOCK
);
847 // Set an exception to allow "[*.]example.com"
848 ContentSettingsPattern pattern
=
849 ContentSettingsPattern::FromString("[*.]example.com");
851 host_content_settings_map
->SetContentSetting(
853 ContentSettingsPattern::Wildcard(),
854 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
856 CONTENT_SETTING_ALLOW
);
858 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
859 host_content_settings_map
->GetDefaultContentSetting(
860 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
861 GURL
host("http://example.com/");
862 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
863 host_content_settings_map
->GetContentSetting(
864 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
866 // Set managed-default-content-settings-preferences.
867 prefs
->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting
,
868 new base::FundamentalValue(CONTENT_SETTING_BLOCK
));
869 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
870 host_content_settings_map
->GetContentSetting(
871 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
873 // Remove managed-default-content-settings-preferences.
874 prefs
->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting
);
875 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
876 host_content_settings_map
->GetContentSetting(
877 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
880 // If a default-content-setting is set to managed setting, the user defined
881 // setting should be preserved.
882 TEST_F(HostContentSettingsMapTest
, OverwrittenDefaultContentSetting
) {
883 TestingProfile profile
;
884 HostContentSettingsMap
* host_content_settings_map
=
885 HostContentSettingsMapFactory::GetForProfile(&profile
);
886 syncable_prefs::TestingPrefServiceSyncable
* prefs
=
887 profile
.GetTestingPrefService();
889 // Set user defined default-content-setting for Cookies.
890 host_content_settings_map
->SetDefaultContentSetting(
891 CONTENT_SETTINGS_TYPE_COOKIES
, CONTENT_SETTING_BLOCK
);
892 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
893 host_content_settings_map
->GetDefaultContentSetting(
894 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
896 // Set preference to manage the default-content-setting for Cookies.
897 prefs
->SetManagedPref(prefs::kManagedDefaultCookiesSetting
,
898 new base::FundamentalValue(CONTENT_SETTING_ALLOW
));
899 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
900 host_content_settings_map
->GetDefaultContentSetting(
901 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
903 // Remove the preference to manage the default-content-setting for Cookies.
904 prefs
->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting
);
905 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
906 host_content_settings_map
->GetDefaultContentSetting(
907 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
910 // If a setting for a default-content-setting-type is set while the type is
911 // managed, then the new setting should be preserved and used after the
912 // default-content-setting-type is not managed anymore.
913 TEST_F(HostContentSettingsMapTest
, SettingDefaultContentSettingsWhenManaged
) {
914 TestingProfile profile
;
915 HostContentSettingsMap
* host_content_settings_map
=
916 HostContentSettingsMapFactory::GetForProfile(&profile
);
917 syncable_prefs::TestingPrefServiceSyncable
* prefs
=
918 profile
.GetTestingPrefService();
920 prefs
->SetManagedPref(prefs::kManagedDefaultPluginsSetting
,
921 new base::FundamentalValue(CONTENT_SETTING_ALLOW
));
922 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
923 host_content_settings_map
->GetDefaultContentSetting(
924 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
926 host_content_settings_map
->SetDefaultContentSetting(
927 CONTENT_SETTINGS_TYPE_PLUGINS
, CONTENT_SETTING_BLOCK
);
928 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
929 host_content_settings_map
->GetDefaultContentSetting(
930 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
932 prefs
->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting
);
933 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
934 host_content_settings_map
->GetDefaultContentSetting(
935 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
938 TEST_F(HostContentSettingsMapTest
, GetContentSetting
) {
939 TestingProfile profile
;
940 HostContentSettingsMap
* host_content_settings_map
=
941 HostContentSettingsMapFactory::GetForProfile(&profile
);
943 GURL
host("http://example.com/");
944 GURL
embedder("chrome://foo");
945 ContentSettingsPattern pattern
=
946 ContentSettingsPattern::FromString("[*.]example.com");
947 host_content_settings_map
->SetContentSetting(
949 ContentSettingsPattern::Wildcard(),
950 CONTENT_SETTINGS_TYPE_IMAGES
,
952 CONTENT_SETTING_BLOCK
);
953 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
954 host_content_settings_map
->GetContentSetting(
955 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
956 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
957 host_content_settings_map
->GetContentSetting(
958 embedder
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
961 TEST_F(HostContentSettingsMapTest
, IsSettingAllowedForType
) {
962 TestingProfile profile
;
963 PrefService
* prefs
= profile
.GetPrefs();
965 EXPECT_TRUE(HostContentSettingsMap::IsSettingAllowedForType(
966 prefs
, CONTENT_SETTING_ASK
,
967 CONTENT_SETTINGS_TYPE_FULLSCREEN
));
969 // The mediastream setting is deprecated.
970 EXPECT_FALSE(HostContentSettingsMap::IsSettingAllowedForType(
971 prefs
, CONTENT_SETTING_ALLOW
,
972 CONTENT_SETTINGS_TYPE_MEDIASTREAM
));
973 EXPECT_FALSE(HostContentSettingsMap::IsSettingAllowedForType(
974 prefs
, CONTENT_SETTING_ASK
,
975 CONTENT_SETTINGS_TYPE_MEDIASTREAM
));
976 EXPECT_FALSE(HostContentSettingsMap::IsSettingAllowedForType(
977 prefs
, CONTENT_SETTING_BLOCK
,
978 CONTENT_SETTINGS_TYPE_MEDIASTREAM
));
980 // We support the ALLOW value for media permission exceptions,
981 // but not as the default setting.
982 EXPECT_TRUE(HostContentSettingsMap::IsSettingAllowedForType(
983 prefs
, CONTENT_SETTING_ALLOW
,
984 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
));
985 EXPECT_TRUE(HostContentSettingsMap::IsSettingAllowedForType(
986 prefs
, CONTENT_SETTING_ALLOW
,
987 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA
));
988 EXPECT_FALSE(HostContentSettingsMap::IsDefaultSettingAllowedForType(
989 prefs
, CONTENT_SETTING_ALLOW
,
990 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
));
991 EXPECT_FALSE(HostContentSettingsMap::IsDefaultSettingAllowedForType(
992 prefs
, CONTENT_SETTING_ALLOW
,
993 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA
));
995 // TODO(msramek): Add more checks for setting type - setting pairs where
996 // it is not obvious whether or not they are allowed.
999 TEST_F(HostContentSettingsMapTest
, AddContentSettingsObserver
) {
1000 TestingProfile profile
;
1001 HostContentSettingsMap
* host_content_settings_map
=
1002 HostContentSettingsMapFactory::GetForProfile(&profile
);
1003 content_settings::MockObserver mock_observer
;
1005 GURL
host("http://example.com/");
1006 ContentSettingsPattern pattern
=
1007 ContentSettingsPattern::FromString("[*.]example.com");
1008 EXPECT_CALL(mock_observer
,
1009 OnContentSettingChanged(pattern
,
1010 ContentSettingsPattern::Wildcard(),
1011 CONTENT_SETTINGS_TYPE_IMAGES
,
1014 host_content_settings_map
->AddObserver(&mock_observer
);
1016 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
1017 host_content_settings_map
->GetContentSetting(
1018 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
1019 host_content_settings_map
->SetContentSetting(
1021 ContentSettingsPattern::Wildcard(),
1022 CONTENT_SETTINGS_TYPE_IMAGES
,
1024 CONTENT_SETTING_DEFAULT
);