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_details.h"
13 #include "chrome/browser/content_settings/content_settings_mock_observer.h"
14 #include "chrome/browser/content_settings/cookie_settings.h"
15 #include "chrome/browser/content_settings/host_content_settings_map.h"
16 #include "chrome/browser/content_settings/mock_settings_observer.h"
17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h"
19 #include "chrome/common/url_constants.h"
20 #include "chrome/test/base/testing_pref_service_syncable.h"
21 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/test/test_browser_thread.h"
23 #include "net/base/static_cookie_policy.h"
24 #include "testing/gtest/include/gtest/gtest.h"
27 using content::BrowserThread
;
31 class HostContentSettingsMapTest
: public testing::Test
{
33 HostContentSettingsMapTest() : ui_thread_(BrowserThread::UI
, &message_loop_
) {
37 base::MessageLoop message_loop_
;
38 content::TestBrowserThread ui_thread_
;
41 TEST_F(HostContentSettingsMapTest
, DefaultValues
) {
42 TestingProfile profile
;
43 HostContentSettingsMap
* host_content_settings_map
=
44 profile
.GetHostContentSettingsMap();
46 // Check setting defaults.
47 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
48 host_content_settings_map
->GetDefaultContentSetting(
49 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
50 host_content_settings_map
->SetDefaultContentSetting(
51 CONTENT_SETTINGS_TYPE_IMAGES
, CONTENT_SETTING_BLOCK
);
52 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
53 host_content_settings_map
->GetDefaultContentSetting(
54 CONTENT_SETTINGS_TYPE_IMAGES
, NULL
));
55 EXPECT_EQ(CONTENT_SETTING_ALLOW
, host_content_settings_map
->GetContentSetting(
56 GURL(chrome::kChromeUINewTabURL
),
57 GURL(chrome::kChromeUINewTabURL
),
58 CONTENT_SETTINGS_TYPE_IMAGES
,
61 host_content_settings_map
->SetDefaultContentSetting(
62 CONTENT_SETTINGS_TYPE_PLUGINS
, CONTENT_SETTING_ASK
);
63 EXPECT_EQ(CONTENT_SETTING_ASK
,
64 host_content_settings_map
->GetDefaultContentSetting(
65 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
67 host_content_settings_map
->SetDefaultContentSetting(
68 CONTENT_SETTINGS_TYPE_POPUPS
, CONTENT_SETTING_ALLOW
);
69 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
70 host_content_settings_map
->GetDefaultContentSetting(
71 CONTENT_SETTINGS_TYPE_POPUPS
, NULL
));
74 TEST_F(HostContentSettingsMapTest
, IndividualSettings
) {
75 TestingProfile profile
;
76 HostContentSettingsMap
* host_content_settings_map
=
77 profile
.GetHostContentSettingsMap();
79 // Check returning individual settings.
80 GURL
host("http://example.com/");
81 ContentSettingsPattern pattern
=
82 ContentSettingsPattern::FromString("[*.]example.com");
83 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
84 host_content_settings_map
->GetContentSetting(
85 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
86 host_content_settings_map
->SetContentSetting(
88 ContentSettingsPattern::Wildcard(),
89 CONTENT_SETTINGS_TYPE_IMAGES
,
91 CONTENT_SETTING_DEFAULT
);
92 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
93 host_content_settings_map
->GetContentSetting(
94 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
95 host_content_settings_map
->SetContentSetting(
97 ContentSettingsPattern::Wildcard(),
98 CONTENT_SETTINGS_TYPE_IMAGES
,
100 CONTENT_SETTING_BLOCK
);
101 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
102 host_content_settings_map
->GetContentSetting(
103 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
104 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
105 host_content_settings_map
->GetContentSetting(
106 host
, host
, CONTENT_SETTINGS_TYPE_PLUGINS
, std::string()));
108 // Check returning all settings for a host.
109 host_content_settings_map
->SetContentSetting(
111 ContentSettingsPattern::Wildcard(),
112 CONTENT_SETTINGS_TYPE_IMAGES
,
114 CONTENT_SETTING_DEFAULT
);
115 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
116 host_content_settings_map
->GetContentSetting(
117 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
118 host_content_settings_map
->SetContentSetting(
120 ContentSettingsPattern::Wildcard(),
121 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
123 CONTENT_SETTING_BLOCK
);
124 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
125 host_content_settings_map
->GetContentSetting(
126 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
127 host_content_settings_map
->SetContentSetting(
129 ContentSettingsPattern::Wildcard(),
130 CONTENT_SETTINGS_TYPE_PLUGINS
,
132 CONTENT_SETTING_ALLOW
);
133 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
134 host_content_settings_map
->GetContentSetting(
135 host
, host
, CONTENT_SETTINGS_TYPE_PLUGINS
, std::string()));
136 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
137 host_content_settings_map
->GetContentSetting(
138 host
, host
, CONTENT_SETTINGS_TYPE_POPUPS
, std::string()));
139 EXPECT_EQ(CONTENT_SETTING_ASK
,
140 host_content_settings_map
->GetContentSetting(
141 host
, host
, CONTENT_SETTINGS_TYPE_GEOLOCATION
, std::string()));
144 host_content_settings_map
->GetContentSetting(
145 host
, host
, CONTENT_SETTINGS_TYPE_NOTIFICATIONS
, std::string()));
146 EXPECT_EQ(CONTENT_SETTING_ASK
,
147 host_content_settings_map
->GetContentSetting(
148 host
, host
, CONTENT_SETTINGS_TYPE_FULLSCREEN
, std::string()));
149 EXPECT_EQ(CONTENT_SETTING_ASK
,
150 host_content_settings_map
->GetContentSetting(
151 host
, host
, CONTENT_SETTINGS_TYPE_MOUSELOCK
, std::string()));
153 // Check returning all hosts for a setting.
154 ContentSettingsPattern pattern2
=
155 ContentSettingsPattern::FromString("[*.]example.org");
156 host_content_settings_map
->SetContentSetting(
158 ContentSettingsPattern::Wildcard(),
159 CONTENT_SETTINGS_TYPE_IMAGES
,
161 CONTENT_SETTING_BLOCK
);
162 host_content_settings_map
->SetContentSetting(
164 ContentSettingsPattern::Wildcard(),
165 CONTENT_SETTINGS_TYPE_PLUGINS
,
167 CONTENT_SETTING_BLOCK
);
168 ContentSettingsForOneType host_settings
;
169 host_content_settings_map
->GetSettingsForOneType(
170 CONTENT_SETTINGS_TYPE_IMAGES
, std::string(), &host_settings
);
171 // |host_settings| contains the default setting and an exception.
172 EXPECT_EQ(2U, host_settings
.size());
173 host_content_settings_map
->GetSettingsForOneType(
174 CONTENT_SETTINGS_TYPE_PLUGINS
, std::string(), &host_settings
);
175 // |host_settings| contains the default setting and 2 exceptions.
176 EXPECT_EQ(3U, host_settings
.size());
177 host_content_settings_map
->GetSettingsForOneType(
178 CONTENT_SETTINGS_TYPE_POPUPS
, std::string(), &host_settings
);
179 // |host_settings| contains only the default setting.
180 EXPECT_EQ(1U, host_settings
.size());
183 TEST_F(HostContentSettingsMapTest
, Clear
) {
184 TestingProfile profile
;
185 HostContentSettingsMap
* host_content_settings_map
=
186 profile
.GetHostContentSettingsMap();
188 // Check clearing one type.
189 ContentSettingsPattern pattern
=
190 ContentSettingsPattern::FromString("[*.]example.org");
191 ContentSettingsPattern pattern2
=
192 ContentSettingsPattern::FromString("[*.]example.net");
193 host_content_settings_map
->SetContentSetting(
195 ContentSettingsPattern::Wildcard(),
196 CONTENT_SETTINGS_TYPE_IMAGES
,
198 CONTENT_SETTING_BLOCK
);
199 host_content_settings_map
->SetContentSetting(
201 ContentSettingsPattern::Wildcard(),
202 CONTENT_SETTINGS_TYPE_IMAGES
,
204 CONTENT_SETTING_BLOCK
);
205 host_content_settings_map
->SetContentSetting(
207 ContentSettingsPattern::Wildcard(),
208 CONTENT_SETTINGS_TYPE_PLUGINS
,
210 CONTENT_SETTING_BLOCK
);
211 host_content_settings_map
->SetContentSetting(
213 ContentSettingsPattern::Wildcard(),
214 CONTENT_SETTINGS_TYPE_IMAGES
,
216 CONTENT_SETTING_BLOCK
);
217 host_content_settings_map
->ClearSettingsForOneType(
218 CONTENT_SETTINGS_TYPE_IMAGES
);
219 ContentSettingsForOneType host_settings
;
220 host_content_settings_map
->GetSettingsForOneType(
221 CONTENT_SETTINGS_TYPE_IMAGES
, std::string(), &host_settings
);
222 // |host_settings| contains only the default setting.
223 EXPECT_EQ(1U, host_settings
.size());
224 host_content_settings_map
->GetSettingsForOneType(
225 CONTENT_SETTINGS_TYPE_PLUGINS
, std::string(), &host_settings
);
226 // |host_settings| contains the default setting and an exception.
227 EXPECT_EQ(2U, host_settings
.size());
230 TEST_F(HostContentSettingsMapTest
, Patterns
) {
231 TestingProfile profile
;
232 HostContentSettingsMap
* host_content_settings_map
=
233 profile
.GetHostContentSettingsMap();
235 GURL
host1("http://example.com/");
236 GURL
host2("http://www.example.com/");
237 GURL
host3("http://example.org/");
238 ContentSettingsPattern pattern1
=
239 ContentSettingsPattern::FromString("[*.]example.com");
240 ContentSettingsPattern pattern2
=
241 ContentSettingsPattern::FromString("example.org");
242 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
243 host_content_settings_map
->GetContentSetting(
244 host1
, host1
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
245 host_content_settings_map
->SetContentSetting(
247 ContentSettingsPattern::Wildcard(),
248 CONTENT_SETTINGS_TYPE_IMAGES
,
250 CONTENT_SETTING_BLOCK
);
251 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
252 host_content_settings_map
->GetContentSetting(
253 host1
, host1
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
254 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
255 host_content_settings_map
->GetContentSetting(
256 host2
, host2
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
257 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
258 host_content_settings_map
->GetContentSetting(
259 host3
, host3
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
260 host_content_settings_map
->SetContentSetting(
262 ContentSettingsPattern::Wildcard(),
263 CONTENT_SETTINGS_TYPE_IMAGES
,
265 CONTENT_SETTING_BLOCK
);
266 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
267 host_content_settings_map
->GetContentSetting(
268 host3
, host3
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
271 TEST_F(HostContentSettingsMapTest
, Observer
) {
272 TestingProfile profile
;
273 HostContentSettingsMap
* host_content_settings_map
=
274 profile
.GetHostContentSettingsMap();
275 MockSettingsObserver
observer(host_content_settings_map
);
277 ContentSettingsPattern primary_pattern
=
278 ContentSettingsPattern::FromString("[*.]example.com");
279 ContentSettingsPattern secondary_pattern
=
280 ContentSettingsPattern::Wildcard();
281 EXPECT_CALL(observer
,
282 OnContentSettingsChanged(host_content_settings_map
,
283 CONTENT_SETTINGS_TYPE_IMAGES
,
288 host_content_settings_map
->SetContentSetting(
291 CONTENT_SETTINGS_TYPE_IMAGES
,
293 CONTENT_SETTING_ALLOW
);
294 ::testing::Mock::VerifyAndClearExpectations(&observer
);
296 EXPECT_CALL(observer
,
297 OnContentSettingsChanged(host_content_settings_map
,
298 CONTENT_SETTINGS_TYPE_IMAGES
, false,
300 host_content_settings_map
->ClearSettingsForOneType(
301 CONTENT_SETTINGS_TYPE_IMAGES
);
302 ::testing::Mock::VerifyAndClearExpectations(&observer
);
304 EXPECT_CALL(observer
,
305 OnContentSettingsChanged(host_content_settings_map
,
306 CONTENT_SETTINGS_TYPE_IMAGES
, false,
308 host_content_settings_map
->SetDefaultContentSetting(
309 CONTENT_SETTINGS_TYPE_IMAGES
, CONTENT_SETTING_BLOCK
);
312 TEST_F(HostContentSettingsMapTest
, ObserveDefaultPref
) {
313 TestingProfile profile
;
314 HostContentSettingsMap
* host_content_settings_map
=
315 profile
.GetHostContentSettingsMap();
317 PrefService
* prefs
= profile
.GetPrefs();
319 // Make a copy of the default pref value so we can reset it later.
320 scoped_ptr
<base::Value
> default_value(prefs
->FindPreference(
321 prefs::kDefaultContentSettings
)->GetValue()->DeepCopy());
323 GURL
host("http://example.com");
325 host_content_settings_map
->SetDefaultContentSetting(
326 CONTENT_SETTINGS_TYPE_IMAGES
, CONTENT_SETTING_BLOCK
);
327 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
328 host_content_settings_map
->GetContentSetting(
329 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
331 // Make a copy of the pref's new value so we can reset it later.
332 scoped_ptr
<base::Value
> new_value(prefs
->FindPreference(
333 prefs::kDefaultContentSettings
)->GetValue()->DeepCopy());
335 // Clearing the backing pref should also clear the internal cache.
336 prefs
->Set(prefs::kDefaultContentSettings
, *default_value
);
337 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
338 host_content_settings_map
->GetContentSetting(
339 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
341 // Reseting the pref to its previous value should update the cache.
342 prefs
->Set(prefs::kDefaultContentSettings
, *new_value
);
343 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
344 host_content_settings_map
->GetContentSetting(
345 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
348 TEST_F(HostContentSettingsMapTest
, ObserveExceptionPref
) {
349 TestingProfile profile
;
350 HostContentSettingsMap
* host_content_settings_map
=
351 profile
.GetHostContentSettingsMap();
353 PrefService
* prefs
= profile
.GetPrefs();
355 // Make a copy of the default pref value so we can reset it later.
356 scoped_ptr
<base::Value
> default_value(prefs
->FindPreference(
357 prefs::kContentSettingsPatternPairs
)->GetValue()->DeepCopy());
359 ContentSettingsPattern pattern
=
360 ContentSettingsPattern::FromString("[*.]example.com");
361 GURL
host("http://example.com");
363 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
364 host_content_settings_map
->GetContentSetting(
365 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
367 host_content_settings_map
->SetContentSetting(
369 ContentSettingsPattern::Wildcard(),
370 CONTENT_SETTINGS_TYPE_IMAGES
,
372 CONTENT_SETTING_BLOCK
);
373 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
374 host_content_settings_map
->GetContentSetting(
375 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
377 // Make a copy of the pref's new value so we can reset it later.
378 scoped_ptr
<base::Value
> new_value(prefs
->FindPreference(
379 prefs::kContentSettingsPatternPairs
)->GetValue()->DeepCopy());
381 // Clearing the backing pref should also clear the internal cache.
382 prefs
->Set(prefs::kContentSettingsPatternPairs
, *default_value
);
383 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
384 host_content_settings_map
->GetContentSetting(
385 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
387 // Reseting the pref to its previous value should update the cache.
388 prefs
->Set(prefs::kContentSettingsPatternPairs
, *new_value
);
389 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
390 host_content_settings_map
->GetContentSetting(
391 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
394 TEST_F(HostContentSettingsMapTest
, HostTrimEndingDotCheck
) {
395 TestingProfile profile
;
396 HostContentSettingsMap
* host_content_settings_map
=
397 profile
.GetHostContentSettingsMap();
398 CookieSettings
* cookie_settings
=
399 CookieSettings::Factory::GetForProfile(&profile
).get();
401 ContentSettingsPattern pattern
=
402 ContentSettingsPattern::FromString("[*.]example.com");
403 GURL
host_ending_with_dot("http://example.com./");
405 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
406 host_content_settings_map
->GetContentSetting(
407 host_ending_with_dot
,
408 host_ending_with_dot
,
409 CONTENT_SETTINGS_TYPE_IMAGES
,
411 host_content_settings_map
->SetContentSetting(
413 ContentSettingsPattern::Wildcard(),
414 CONTENT_SETTINGS_TYPE_IMAGES
,
416 CONTENT_SETTING_DEFAULT
);
418 CONTENT_SETTING_ALLOW
,
419 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
420 host_ending_with_dot
,
421 CONTENT_SETTINGS_TYPE_IMAGES
,
423 host_content_settings_map
->SetContentSetting(
425 ContentSettingsPattern::Wildcard(),
426 CONTENT_SETTINGS_TYPE_IMAGES
,
428 CONTENT_SETTING_BLOCK
);
430 CONTENT_SETTING_BLOCK
,
431 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
432 host_ending_with_dot
,
433 CONTENT_SETTINGS_TYPE_IMAGES
,
436 EXPECT_TRUE(cookie_settings
->IsSettingCookieAllowed(
437 host_ending_with_dot
, host_ending_with_dot
));
438 host_content_settings_map
->SetContentSetting(
440 ContentSettingsPattern::Wildcard(),
441 CONTENT_SETTINGS_TYPE_COOKIES
,
443 CONTENT_SETTING_DEFAULT
);
444 EXPECT_TRUE(cookie_settings
->IsSettingCookieAllowed(
445 host_ending_with_dot
, host_ending_with_dot
));
446 host_content_settings_map
->SetContentSetting(
448 ContentSettingsPattern::Wildcard(),
449 CONTENT_SETTINGS_TYPE_COOKIES
,
451 CONTENT_SETTING_BLOCK
);
452 EXPECT_FALSE(cookie_settings
->IsSettingCookieAllowed(
453 host_ending_with_dot
, host_ending_with_dot
));
455 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
456 host_content_settings_map
->GetContentSetting(
457 host_ending_with_dot
,
458 host_ending_with_dot
,
459 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
461 host_content_settings_map
->SetContentSetting(
463 ContentSettingsPattern::Wildcard(),
464 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
466 CONTENT_SETTING_DEFAULT
);
467 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
468 host_content_settings_map
->GetContentSetting(
469 host_ending_with_dot
,
470 host_ending_with_dot
,
471 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
473 host_content_settings_map
->SetContentSetting(
475 ContentSettingsPattern::Wildcard(),
476 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
478 CONTENT_SETTING_BLOCK
);
479 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
480 host_content_settings_map
->GetContentSetting(
481 host_ending_with_dot
,
482 host_ending_with_dot
,
483 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
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_PLUGINS
,
492 host_content_settings_map
->SetContentSetting(
494 ContentSettingsPattern::Wildcard(),
495 CONTENT_SETTINGS_TYPE_PLUGINS
,
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_PLUGINS
,
504 host_content_settings_map
->SetContentSetting(
506 ContentSettingsPattern::Wildcard(),
507 CONTENT_SETTINGS_TYPE_PLUGINS
,
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_PLUGINS
,
518 CONTENT_SETTING_BLOCK
,
519 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
520 host_ending_with_dot
,
521 CONTENT_SETTINGS_TYPE_POPUPS
,
523 host_content_settings_map
->SetContentSetting(
525 ContentSettingsPattern::Wildcard(),
526 CONTENT_SETTINGS_TYPE_POPUPS
,
528 CONTENT_SETTING_DEFAULT
);
530 CONTENT_SETTING_BLOCK
,
531 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
532 host_ending_with_dot
,
533 CONTENT_SETTINGS_TYPE_POPUPS
,
535 host_content_settings_map
->SetContentSetting(
537 ContentSettingsPattern::Wildcard(),
538 CONTENT_SETTINGS_TYPE_POPUPS
,
540 CONTENT_SETTING_ALLOW
);
542 CONTENT_SETTING_ALLOW
,
543 host_content_settings_map
->GetContentSetting(host_ending_with_dot
,
544 host_ending_with_dot
,
545 CONTENT_SETTINGS_TYPE_POPUPS
,
549 TEST_F(HostContentSettingsMapTest
, NestedSettings
) {
550 TestingProfile profile
;
551 HostContentSettingsMap
* host_content_settings_map
=
552 profile
.GetHostContentSettingsMap();
554 GURL
host("http://a.b.example.com/");
555 ContentSettingsPattern pattern1
=
556 ContentSettingsPattern::FromString("[*.]example.com");
557 ContentSettingsPattern pattern2
=
558 ContentSettingsPattern::FromString("[*.]b.example.com");
559 ContentSettingsPattern pattern3
=
560 ContentSettingsPattern::FromString("a.b.example.com");
562 host_content_settings_map
->SetContentSetting(
564 ContentSettingsPattern::Wildcard(),
565 CONTENT_SETTINGS_TYPE_IMAGES
,
567 CONTENT_SETTING_BLOCK
);
569 host_content_settings_map
->SetContentSetting(
571 ContentSettingsPattern::Wildcard(),
572 CONTENT_SETTINGS_TYPE_COOKIES
,
574 CONTENT_SETTING_BLOCK
);
576 host_content_settings_map
->SetContentSetting(
578 ContentSettingsPattern::Wildcard(),
579 CONTENT_SETTINGS_TYPE_PLUGINS
,
581 CONTENT_SETTING_BLOCK
);
582 host_content_settings_map
->SetDefaultContentSetting(
583 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, CONTENT_SETTING_BLOCK
);
585 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
586 host_content_settings_map
->GetContentSetting(
587 host
, host
, CONTENT_SETTINGS_TYPE_COOKIES
, std::string()));
588 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
589 host_content_settings_map
->GetContentSetting(
590 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
591 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
592 host_content_settings_map
->GetContentSetting(
593 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
594 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
595 host_content_settings_map
->GetContentSetting(
596 host
, host
, CONTENT_SETTINGS_TYPE_PLUGINS
, std::string()));
597 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
598 host_content_settings_map
->GetContentSetting(
599 host
, host
, CONTENT_SETTINGS_TYPE_POPUPS
, std::string()));
600 EXPECT_EQ(CONTENT_SETTING_ASK
,
601 host_content_settings_map
->GetContentSetting(
602 host
, host
, CONTENT_SETTINGS_TYPE_GEOLOCATION
, std::string()));
605 host_content_settings_map
->GetContentSetting(
606 host
, host
, CONTENT_SETTINGS_TYPE_NOTIFICATIONS
, std::string()));
607 EXPECT_EQ(CONTENT_SETTING_ASK
,
608 host_content_settings_map
->GetContentSetting(
609 host
, host
, CONTENT_SETTINGS_TYPE_FULLSCREEN
, std::string()));
610 EXPECT_EQ(CONTENT_SETTING_ASK
,
611 host_content_settings_map
->GetContentSetting(
612 host
, host
, CONTENT_SETTINGS_TYPE_MOUSELOCK
, std::string()));
615 TEST_F(HostContentSettingsMapTest
, OffTheRecord
) {
616 TestingProfile profile
;
617 HostContentSettingsMap
* host_content_settings_map
=
618 profile
.GetHostContentSettingsMap();
619 scoped_refptr
<HostContentSettingsMap
> otr_map(
620 new HostContentSettingsMap(profile
.GetPrefs(),
623 GURL
host("http://example.com/");
624 ContentSettingsPattern pattern
=
625 ContentSettingsPattern::FromString("[*.]example.com");
627 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
628 host_content_settings_map
->GetContentSetting(
629 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
630 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
631 otr_map
->GetContentSetting(
632 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
634 // Changing content settings on the main map should also affect the
636 host_content_settings_map
->SetContentSetting(
638 ContentSettingsPattern::Wildcard(),
639 CONTENT_SETTINGS_TYPE_IMAGES
,
641 CONTENT_SETTING_BLOCK
);
642 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
643 host_content_settings_map
->GetContentSetting(
644 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
645 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
646 otr_map
->GetContentSetting(
647 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
649 // Changing content settings on the incognito map should NOT affect the
651 otr_map
->SetContentSetting(pattern
,
652 ContentSettingsPattern::Wildcard(),
653 CONTENT_SETTINGS_TYPE_IMAGES
,
655 CONTENT_SETTING_ALLOW
);
656 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
657 host_content_settings_map
->GetContentSetting(
658 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
659 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
660 otr_map
->GetContentSetting(
661 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
663 otr_map
->ShutdownOnUIThread();
666 // For a single Unicode encoded pattern, check if it gets converted to punycode
667 // and old pattern gets deleted.
668 TEST_F(HostContentSettingsMapTest
, CanonicalizeExceptionsUnicodeOnly
) {
669 TestingProfile profile
;
670 PrefService
* prefs
= profile
.GetPrefs();
674 DictionaryPrefUpdate
update(prefs
, prefs::kContentSettingsPatternPairs
);
675 base::DictionaryValue
* all_settings_dictionary
= update
.Get();
676 ASSERT_TRUE(NULL
!= all_settings_dictionary
);
678 base::DictionaryValue
* dummy_payload
= new base::DictionaryValue
;
679 dummy_payload
->SetInteger("images", CONTENT_SETTING_ALLOW
);
680 all_settings_dictionary
->SetWithoutPathExpansion("[*.]\xC4\x87ira.com,*",
683 profile
.GetHostContentSettingsMap();
685 const base::DictionaryValue
* all_settings_dictionary
=
686 prefs
->GetDictionary(prefs::kContentSettingsPatternPairs
);
687 const base::DictionaryValue
* result
= NULL
;
688 EXPECT_FALSE(all_settings_dictionary
->GetDictionaryWithoutPathExpansion(
689 "[*.]\xC4\x87ira.com,*", &result
));
690 EXPECT_TRUE(all_settings_dictionary
->GetDictionaryWithoutPathExpansion(
691 "[*.]xn--ira-ppa.com,*", &result
));
694 // If both Unicode and its punycode pattern exist, make sure we don't touch the
695 // settings for the punycode, and that Unicode pattern gets deleted.
696 TEST_F(HostContentSettingsMapTest
, CanonicalizeExceptionsUnicodeAndPunycode
) {
697 TestingProfile profile
;
699 scoped_ptr
<base::Value
> value(base::JSONReader::Read(
700 "{\"[*.]\\xC4\\x87ira.com,*\":{\"images\":1}}"));
701 profile
.GetPrefs()->Set(prefs::kContentSettingsPatternPairs
, *value
);
703 // Set punycode equivalent, with different setting.
704 scoped_ptr
<base::Value
> puny_value(base::JSONReader::Read(
705 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}"));
706 profile
.GetPrefs()->Set(prefs::kContentSettingsPatternPairs
, *puny_value
);
708 // Initialize the content map.
709 profile
.GetHostContentSettingsMap();
711 const base::DictionaryValue
* content_setting_prefs
=
712 profile
.GetPrefs()->GetDictionary(prefs::kContentSettingsPatternPairs
);
713 std::string prefs_as_json
;
714 base::JSONWriter::Write(content_setting_prefs
, &prefs_as_json
);
715 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}",
716 prefs_as_json
.c_str());
719 // If a default-content-setting is managed, the managed value should be used
720 // instead of the default value.
721 TEST_F(HostContentSettingsMapTest
, ManagedDefaultContentSetting
) {
722 TestingProfile profile
;
723 HostContentSettingsMap
* host_content_settings_map
=
724 profile
.GetHostContentSettingsMap();
725 TestingPrefServiceSyncable
* prefs
= profile
.GetTestingPrefService();
727 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
728 host_content_settings_map
->GetDefaultContentSetting(
729 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
731 // Set managed-default-content-setting through the coresponding preferences.
732 prefs
->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting
,
733 new base::FundamentalValue(CONTENT_SETTING_BLOCK
));
734 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
735 host_content_settings_map
->GetDefaultContentSetting(
736 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
738 // Remove managed-default-content-settings-preferences.
739 prefs
->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting
);
740 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
741 host_content_settings_map
->GetDefaultContentSetting(
742 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
744 // Set preference to manage the default-content-setting for Plugins.
745 prefs
->SetManagedPref(prefs::kManagedDefaultPluginsSetting
,
746 new base::FundamentalValue(CONTENT_SETTING_BLOCK
));
747 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
748 host_content_settings_map
->GetDefaultContentSetting(
749 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
751 // Remove the preference to manage the default-content-setting for Plugins.
752 prefs
->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting
);
753 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
754 host_content_settings_map
->GetDefaultContentSetting(
755 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
758 TEST_F(HostContentSettingsMapTest
,
759 GetNonDefaultContentSettingsIfTypeManaged
) {
760 TestingProfile profile
;
761 HostContentSettingsMap
* host_content_settings_map
=
762 profile
.GetHostContentSettingsMap();
763 TestingPrefServiceSyncable
* prefs
= profile
.GetTestingPrefService();
765 // Set pattern for JavaScript setting.
766 ContentSettingsPattern pattern
=
767 ContentSettingsPattern::FromString("[*.]example.com");
768 host_content_settings_map
->SetContentSetting(
770 ContentSettingsPattern::Wildcard(),
771 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
773 CONTENT_SETTING_BLOCK
);
775 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
776 host_content_settings_map
->GetDefaultContentSetting(
777 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
779 GURL
host("http://example.com/");
780 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
781 host_content_settings_map
->GetContentSetting(
782 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
784 // Set managed-default-content-setting for content-settings-type JavaScript.
785 prefs
->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting
,
786 new base::FundamentalValue(CONTENT_SETTING_ALLOW
));
787 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
788 host_content_settings_map
->GetContentSetting(
789 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
792 // Managed default content setting should have higher priority
793 // than user defined patterns.
794 TEST_F(HostContentSettingsMapTest
,
795 ManagedDefaultContentSettingIgnoreUserPattern
) {
796 TestingProfile profile
;
797 HostContentSettingsMap
* host_content_settings_map
=
798 profile
.GetHostContentSettingsMap();
799 TestingPrefServiceSyncable
* prefs
= profile
.GetTestingPrefService();
801 // Block all JavaScript.
802 host_content_settings_map
->SetDefaultContentSetting(
803 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, CONTENT_SETTING_BLOCK
);
805 // Set an exception to allow "[*.]example.com"
806 ContentSettingsPattern pattern
=
807 ContentSettingsPattern::FromString("[*.]example.com");
809 host_content_settings_map
->SetContentSetting(
811 ContentSettingsPattern::Wildcard(),
812 CONTENT_SETTINGS_TYPE_JAVASCRIPT
,
814 CONTENT_SETTING_ALLOW
);
816 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
817 host_content_settings_map
->GetDefaultContentSetting(
818 CONTENT_SETTINGS_TYPE_JAVASCRIPT
, NULL
));
819 GURL
host("http://example.com/");
820 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
821 host_content_settings_map
->GetContentSetting(
822 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
824 // Set managed-default-content-settings-preferences.
825 prefs
->SetManagedPref(prefs::kManagedDefaultJavaScriptSetting
,
826 new base::FundamentalValue(CONTENT_SETTING_BLOCK
));
827 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
828 host_content_settings_map
->GetContentSetting(
829 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
831 // Remove managed-default-content-settings-preferences.
832 prefs
->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting
);
833 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
834 host_content_settings_map
->GetContentSetting(
835 host
, host
, CONTENT_SETTINGS_TYPE_JAVASCRIPT
, std::string()));
838 // If a default-content-setting is set to managed setting, the user defined
839 // setting should be preserved.
840 TEST_F(HostContentSettingsMapTest
, OverwrittenDefaultContentSetting
) {
841 TestingProfile profile
;
842 HostContentSettingsMap
* host_content_settings_map
=
843 profile
.GetHostContentSettingsMap();
844 TestingPrefServiceSyncable
* prefs
= profile
.GetTestingPrefService();
846 // Set user defined default-content-setting for Cookies.
847 host_content_settings_map
->SetDefaultContentSetting(
848 CONTENT_SETTINGS_TYPE_COOKIES
, CONTENT_SETTING_BLOCK
);
849 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
850 host_content_settings_map
->GetDefaultContentSetting(
851 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
853 // Set preference to manage the default-content-setting for Cookies.
854 prefs
->SetManagedPref(prefs::kManagedDefaultCookiesSetting
,
855 new base::FundamentalValue(CONTENT_SETTING_ALLOW
));
856 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
857 host_content_settings_map
->GetDefaultContentSetting(
858 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
860 // Remove the preference to manage the default-content-setting for Cookies.
861 prefs
->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting
);
862 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
863 host_content_settings_map
->GetDefaultContentSetting(
864 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
867 // If a setting for a default-content-setting-type is set while the type is
868 // managed, then the new setting should be preserved and used after the
869 // default-content-setting-type is not managed anymore.
870 TEST_F(HostContentSettingsMapTest
, SettingDefaultContentSettingsWhenManaged
) {
871 TestingProfile profile
;
872 HostContentSettingsMap
* host_content_settings_map
=
873 profile
.GetHostContentSettingsMap();
874 TestingPrefServiceSyncable
* prefs
= profile
.GetTestingPrefService();
876 prefs
->SetManagedPref(prefs::kManagedDefaultPluginsSetting
,
877 new base::FundamentalValue(CONTENT_SETTING_ALLOW
));
878 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
879 host_content_settings_map
->GetDefaultContentSetting(
880 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
882 host_content_settings_map
->SetDefaultContentSetting(
883 CONTENT_SETTINGS_TYPE_PLUGINS
, CONTENT_SETTING_BLOCK
);
884 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
885 host_content_settings_map
->GetDefaultContentSetting(
886 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
888 prefs
->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting
);
889 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
890 host_content_settings_map
->GetDefaultContentSetting(
891 CONTENT_SETTINGS_TYPE_PLUGINS
, NULL
));
894 TEST_F(HostContentSettingsMapTest
, GetContentSetting
) {
895 TestingProfile profile
;
896 HostContentSettingsMap
* host_content_settings_map
=
897 profile
.GetHostContentSettingsMap();
899 GURL
host("http://example.com/");
900 GURL
embedder("chrome://foo");
901 ContentSettingsPattern pattern
=
902 ContentSettingsPattern::FromString("[*.]example.com");
903 host_content_settings_map
->SetContentSetting(
905 ContentSettingsPattern::Wildcard(),
906 CONTENT_SETTINGS_TYPE_IMAGES
,
908 CONTENT_SETTING_BLOCK
);
909 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
910 host_content_settings_map
->GetContentSetting(
911 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
912 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
913 host_content_settings_map
->GetContentSetting(
914 embedder
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
917 TEST_F(HostContentSettingsMapTest
, ShouldAllowAllContent
) {
918 TestingProfile profile
;
919 HostContentSettingsMap
* host_content_settings_map
=
920 profile
.GetHostContentSettingsMap();
922 GURL
http_host("http://example.com/");
923 GURL
https_host("https://example.com/");
924 GURL
embedder("chrome://foo");
925 GURL
extension("chrome-extension://foo");
926 EXPECT_FALSE(host_content_settings_map
->ShouldAllowAllContent(
927 http_host
, embedder
, CONTENT_SETTINGS_TYPE_NOTIFICATIONS
));
928 EXPECT_FALSE(host_content_settings_map
->ShouldAllowAllContent(
929 http_host
, embedder
, CONTENT_SETTINGS_TYPE_GEOLOCATION
));
930 EXPECT_FALSE(host_content_settings_map
->ShouldAllowAllContent(
931 http_host
, embedder
, CONTENT_SETTINGS_TYPE_COOKIES
));
932 EXPECT_TRUE(host_content_settings_map
->ShouldAllowAllContent(
933 https_host
, embedder
, CONTENT_SETTINGS_TYPE_COOKIES
));
934 EXPECT_TRUE(host_content_settings_map
->ShouldAllowAllContent(
935 https_host
, embedder
, CONTENT_SETTINGS_TYPE_COOKIES
));
936 EXPECT_TRUE(host_content_settings_map
->ShouldAllowAllContent(
937 embedder
, http_host
, CONTENT_SETTINGS_TYPE_COOKIES
));
938 EXPECT_TRUE(host_content_settings_map
->ShouldAllowAllContent(
939 extension
, extension
, CONTENT_SETTINGS_TYPE_COOKIES
));
940 EXPECT_FALSE(host_content_settings_map
->ShouldAllowAllContent(
941 extension
, extension
, CONTENT_SETTINGS_TYPE_PLUGINS
));
942 EXPECT_FALSE(host_content_settings_map
->ShouldAllowAllContent(
943 extension
, http_host
, CONTENT_SETTINGS_TYPE_COOKIES
));
946 TEST_F(HostContentSettingsMapTest
, MigrateClearOnExit
) {
947 TestingProfile profile
;
948 TestingPrefServiceSyncable
* prefs
= profile
.GetTestingPrefService();
950 prefs
->SetBoolean(prefs::kClearSiteDataOnExit
, true);
952 scoped_ptr
<base::Value
> patterns(base::JSONReader::Read(
953 "{\"[*.]example.com,*\":{\"cookies\": 1},"
954 " \"[*.]other.com,*\":{\"cookies\": 2},"
955 " \"[*.]third.com,*\":{\"cookies\": 4}}"));
956 profile
.GetPrefs()->Set(prefs::kContentSettingsPatternPairs
, *patterns
);
958 scoped_ptr
<base::Value
> defaults(base::JSONReader::Read("{\"cookies\": 1}"));
959 profile
.GetPrefs()->Set(prefs::kDefaultContentSettings
, *defaults
);
961 HostContentSettingsMap
* host_content_settings_map
=
962 profile
.GetHostContentSettingsMap();
964 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY
,
965 host_content_settings_map
->GetDefaultContentSetting(
966 CONTENT_SETTINGS_TYPE_COOKIES
, NULL
));
967 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY
,
968 host_content_settings_map
->GetContentSetting(
969 GURL("http://example.com"),
970 GURL("http://example.com"),
971 CONTENT_SETTINGS_TYPE_COOKIES
,
973 EXPECT_EQ(CONTENT_SETTING_BLOCK
,
974 host_content_settings_map
->GetContentSetting(
975 GURL("http://other.com"),
976 GURL("http://other.com"),
977 CONTENT_SETTINGS_TYPE_COOKIES
,
979 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY
,
980 host_content_settings_map
->GetContentSetting(
981 GURL("http://third.com"),
982 GURL("http://third.com"),
983 CONTENT_SETTINGS_TYPE_COOKIES
,
987 TEST_F(HostContentSettingsMapTest
, AddContentSettingsObserver
) {
988 TestingProfile profile
;
989 HostContentSettingsMap
* host_content_settings_map
=
990 profile
.GetHostContentSettingsMap();
991 content_settings::MockObserver mock_observer
;
993 GURL
host("http://example.com/");
994 ContentSettingsPattern pattern
=
995 ContentSettingsPattern::FromString("[*.]example.com");
996 EXPECT_CALL(mock_observer
,
997 OnContentSettingChanged(pattern
,
998 ContentSettingsPattern::Wildcard(),
999 CONTENT_SETTINGS_TYPE_IMAGES
,
1002 host_content_settings_map
->AddObserver(&mock_observer
);
1004 EXPECT_EQ(CONTENT_SETTING_ALLOW
,
1005 host_content_settings_map
->GetContentSetting(
1006 host
, host
, CONTENT_SETTINGS_TYPE_IMAGES
, std::string()));
1007 host_content_settings_map
->SetContentSetting(
1009 ContentSettingsPattern::Wildcard(),
1010 CONTENT_SETTINGS_TYPE_IMAGES
,
1012 CONTENT_SETTING_DEFAULT
);