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

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

Issue 440423003: Clean content_settings_pattern_parser.* from unnecessary dependencies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed the clients Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "base/prefs/scoped_user_pref_update.h" 11 #include "base/prefs/scoped_user_pref_update.h"
12 #include "chrome/browser/content_settings/content_settings_details.h" 12 #include "chrome/browser/content_settings/content_settings_details.h"
13 #include "chrome/browser/content_settings/cookie_settings.h" 13 #include "chrome/browser/content_settings/cookie_settings.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h" 14 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/content_settings/mock_settings_observer.h" 15 #include "chrome/browser/content_settings/mock_settings_observer.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "chrome/test/base/testing_pref_service_syncable.h" 19 #include "chrome/test/base/testing_pref_service_syncable.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "content/public/test/test_browser_thread.h" 21 #include "content/public/test/test_browser_thread.h"
22 #include "extensions/common/constants.h"
22 #include "net/base/static_cookie_policy.h" 23 #include "net/base/static_cookie_policy.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 using content::BrowserThread; 27 using content::BrowserThread;
27 28
28 using ::testing::_; 29 using ::testing::_;
29 30
30 class HostContentSettingsMapTest : public testing::Test { 31 class HostContentSettingsMapTest : public testing::Test {
31 public: 32 public:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 72 }
72 73
73 TEST_F(HostContentSettingsMapTest, IndividualSettings) { 74 TEST_F(HostContentSettingsMapTest, IndividualSettings) {
74 TestingProfile profile; 75 TestingProfile profile;
75 HostContentSettingsMap* host_content_settings_map = 76 HostContentSettingsMap* host_content_settings_map =
76 profile.GetHostContentSettingsMap(); 77 profile.GetHostContentSettingsMap();
77 78
78 // Check returning individual settings. 79 // Check returning individual settings.
79 GURL host("http://example.com/"); 80 GURL host("http://example.com/");
80 ContentSettingsPattern pattern = 81 ContentSettingsPattern pattern =
81 ContentSettingsPattern::FromString("[*.]example.com"); 82 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
83 "[*.]example.com");
82 EXPECT_EQ(CONTENT_SETTING_ALLOW, 84 EXPECT_EQ(CONTENT_SETTING_ALLOW,
83 host_content_settings_map->GetContentSetting( 85 host_content_settings_map->GetContentSetting(
84 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 86 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
85 host_content_settings_map->SetContentSetting( 87 host_content_settings_map->SetContentSetting(
86 pattern, 88 pattern,
87 ContentSettingsPattern::Wildcard(), 89 ContentSettingsPattern::Wildcard(),
88 CONTENT_SETTINGS_TYPE_IMAGES, 90 CONTENT_SETTINGS_TYPE_IMAGES,
89 std::string(), 91 std::string(),
90 CONTENT_SETTING_DEFAULT); 92 CONTENT_SETTING_DEFAULT);
91 EXPECT_EQ(CONTENT_SETTING_ALLOW, 93 EXPECT_EQ(CONTENT_SETTING_ALLOW,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); 146 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string()));
145 EXPECT_EQ(CONTENT_SETTING_ASK, 147 EXPECT_EQ(CONTENT_SETTING_ASK,
146 host_content_settings_map->GetContentSetting( 148 host_content_settings_map->GetContentSetting(
147 host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string())); 149 host, host, CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string()));
148 EXPECT_EQ(CONTENT_SETTING_ASK, 150 EXPECT_EQ(CONTENT_SETTING_ASK,
149 host_content_settings_map->GetContentSetting( 151 host_content_settings_map->GetContentSetting(
150 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string())); 152 host, host, CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string()));
151 153
152 // Check returning all hosts for a setting. 154 // Check returning all hosts for a setting.
153 ContentSettingsPattern pattern2 = 155 ContentSettingsPattern pattern2 =
154 ContentSettingsPattern::FromString("[*.]example.org"); 156 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
157 "[*.]example.org");
155 host_content_settings_map->SetContentSetting( 158 host_content_settings_map->SetContentSetting(
156 pattern2, 159 pattern2,
157 ContentSettingsPattern::Wildcard(), 160 ContentSettingsPattern::Wildcard(),
158 CONTENT_SETTINGS_TYPE_IMAGES, 161 CONTENT_SETTINGS_TYPE_IMAGES,
159 std::string(), 162 std::string(),
160 CONTENT_SETTING_BLOCK); 163 CONTENT_SETTING_BLOCK);
161 host_content_settings_map->SetContentSetting( 164 host_content_settings_map->SetContentSetting(
162 pattern2, 165 pattern2,
163 ContentSettingsPattern::Wildcard(), 166 ContentSettingsPattern::Wildcard(),
164 CONTENT_SETTINGS_TYPE_PLUGINS, 167 CONTENT_SETTINGS_TYPE_PLUGINS,
(...skipping 14 matching lines...) Expand all
179 EXPECT_EQ(1U, host_settings.size()); 182 EXPECT_EQ(1U, host_settings.size());
180 } 183 }
181 184
182 TEST_F(HostContentSettingsMapTest, Clear) { 185 TEST_F(HostContentSettingsMapTest, Clear) {
183 TestingProfile profile; 186 TestingProfile profile;
184 HostContentSettingsMap* host_content_settings_map = 187 HostContentSettingsMap* host_content_settings_map =
185 profile.GetHostContentSettingsMap(); 188 profile.GetHostContentSettingsMap();
186 189
187 // Check clearing one type. 190 // Check clearing one type.
188 ContentSettingsPattern pattern = 191 ContentSettingsPattern pattern =
189 ContentSettingsPattern::FromString("[*.]example.org"); 192 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
193 "[*.]example.org");
190 ContentSettingsPattern pattern2 = 194 ContentSettingsPattern pattern2 =
191 ContentSettingsPattern::FromString("[*.]example.net"); 195 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
196 "[*.]example.net");
192 host_content_settings_map->SetContentSetting( 197 host_content_settings_map->SetContentSetting(
193 pattern2, 198 pattern2,
194 ContentSettingsPattern::Wildcard(), 199 ContentSettingsPattern::Wildcard(),
195 CONTENT_SETTINGS_TYPE_IMAGES, 200 CONTENT_SETTINGS_TYPE_IMAGES,
196 std::string(), 201 std::string(),
197 CONTENT_SETTING_BLOCK); 202 CONTENT_SETTING_BLOCK);
198 host_content_settings_map->SetContentSetting( 203 host_content_settings_map->SetContentSetting(
199 pattern, 204 pattern,
200 ContentSettingsPattern::Wildcard(), 205 ContentSettingsPattern::Wildcard(),
201 CONTENT_SETTINGS_TYPE_IMAGES, 206 CONTENT_SETTINGS_TYPE_IMAGES,
(...skipping 26 matching lines...) Expand all
228 233
229 TEST_F(HostContentSettingsMapTest, Patterns) { 234 TEST_F(HostContentSettingsMapTest, Patterns) {
230 TestingProfile profile; 235 TestingProfile profile;
231 HostContentSettingsMap* host_content_settings_map = 236 HostContentSettingsMap* host_content_settings_map =
232 profile.GetHostContentSettingsMap(); 237 profile.GetHostContentSettingsMap();
233 238
234 GURL host1("http://example.com/"); 239 GURL host1("http://example.com/");
235 GURL host2("http://www.example.com/"); 240 GURL host2("http://www.example.com/");
236 GURL host3("http://example.org/"); 241 GURL host3("http://example.org/");
237 ContentSettingsPattern pattern1 = 242 ContentSettingsPattern pattern1 =
238 ContentSettingsPattern::FromString("[*.]example.com"); 243 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
244 "[*.]example.com");
239 ContentSettingsPattern pattern2 = 245 ContentSettingsPattern pattern2 =
240 ContentSettingsPattern::FromString("example.org"); 246 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
247 "example.org");
241 EXPECT_EQ(CONTENT_SETTING_ALLOW, 248 EXPECT_EQ(CONTENT_SETTING_ALLOW,
242 host_content_settings_map->GetContentSetting( 249 host_content_settings_map->GetContentSetting(
243 host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 250 host1, host1, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
244 host_content_settings_map->SetContentSetting( 251 host_content_settings_map->SetContentSetting(
245 pattern1, 252 pattern1,
246 ContentSettingsPattern::Wildcard(), 253 ContentSettingsPattern::Wildcard(),
247 CONTENT_SETTINGS_TYPE_IMAGES, 254 CONTENT_SETTINGS_TYPE_IMAGES,
248 std::string(), 255 std::string(),
249 CONTENT_SETTING_BLOCK); 256 CONTENT_SETTING_BLOCK);
250 EXPECT_EQ(CONTENT_SETTING_BLOCK, 257 EXPECT_EQ(CONTENT_SETTING_BLOCK,
(...skipping 16 matching lines...) Expand all
267 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 274 host3, host3, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
268 } 275 }
269 276
270 TEST_F(HostContentSettingsMapTest, Observer) { 277 TEST_F(HostContentSettingsMapTest, Observer) {
271 TestingProfile profile; 278 TestingProfile profile;
272 HostContentSettingsMap* host_content_settings_map = 279 HostContentSettingsMap* host_content_settings_map =
273 profile.GetHostContentSettingsMap(); 280 profile.GetHostContentSettingsMap();
274 MockSettingsObserver observer; 281 MockSettingsObserver observer;
275 282
276 ContentSettingsPattern primary_pattern = 283 ContentSettingsPattern primary_pattern =
277 ContentSettingsPattern::FromString("[*.]example.com"); 284 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
285 "[*.]example.com");
278 ContentSettingsPattern secondary_pattern = 286 ContentSettingsPattern secondary_pattern =
279 ContentSettingsPattern::Wildcard(); 287 ContentSettingsPattern::Wildcard();
280 EXPECT_CALL(observer, 288 EXPECT_CALL(observer,
281 OnContentSettingsChanged(host_content_settings_map, 289 OnContentSettingsChanged(host_content_settings_map,
282 CONTENT_SETTINGS_TYPE_IMAGES, 290 CONTENT_SETTINGS_TYPE_IMAGES,
283 false, 291 false,
284 primary_pattern, 292 primary_pattern,
285 secondary_pattern, 293 secondary_pattern,
286 false)); 294 false));
287 host_content_settings_map->SetContentSetting( 295 host_content_settings_map->SetContentSetting(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 HostContentSettingsMap* host_content_settings_map = 357 HostContentSettingsMap* host_content_settings_map =
350 profile.GetHostContentSettingsMap(); 358 profile.GetHostContentSettingsMap();
351 359
352 PrefService* prefs = profile.GetPrefs(); 360 PrefService* prefs = profile.GetPrefs();
353 361
354 // Make a copy of the default pref value so we can reset it later. 362 // Make a copy of the default pref value so we can reset it later.
355 scoped_ptr<base::Value> default_value(prefs->FindPreference( 363 scoped_ptr<base::Value> default_value(prefs->FindPreference(
356 prefs::kContentSettingsPatternPairs)->GetValue()->DeepCopy()); 364 prefs::kContentSettingsPatternPairs)->GetValue()->DeepCopy());
357 365
358 ContentSettingsPattern pattern = 366 ContentSettingsPattern pattern =
359 ContentSettingsPattern::FromString("[*.]example.com"); 367 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
368 "[*.]example.com");
360 GURL host("http://example.com"); 369 GURL host("http://example.com");
361 370
362 EXPECT_EQ(CONTENT_SETTING_ALLOW, 371 EXPECT_EQ(CONTENT_SETTING_ALLOW,
363 host_content_settings_map->GetContentSetting( 372 host_content_settings_map->GetContentSetting(
364 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 373 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
365 374
366 host_content_settings_map->SetContentSetting( 375 host_content_settings_map->SetContentSetting(
367 pattern, 376 pattern,
368 ContentSettingsPattern::Wildcard(), 377 ContentSettingsPattern::Wildcard(),
369 CONTENT_SETTINGS_TYPE_IMAGES, 378 CONTENT_SETTINGS_TYPE_IMAGES,
(...skipping 21 matching lines...) Expand all
391 } 400 }
392 401
393 TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { 402 TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) {
394 TestingProfile profile; 403 TestingProfile profile;
395 HostContentSettingsMap* host_content_settings_map = 404 HostContentSettingsMap* host_content_settings_map =
396 profile.GetHostContentSettingsMap(); 405 profile.GetHostContentSettingsMap();
397 CookieSettings* cookie_settings = 406 CookieSettings* cookie_settings =
398 CookieSettings::Factory::GetForProfile(&profile).get(); 407 CookieSettings::Factory::GetForProfile(&profile).get();
399 408
400 ContentSettingsPattern pattern = 409 ContentSettingsPattern pattern =
401 ContentSettingsPattern::FromString("[*.]example.com"); 410 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
411 "[*.]example.com");
402 GURL host_ending_with_dot("http://example.com./"); 412 GURL host_ending_with_dot("http://example.com./");
403 413
404 EXPECT_EQ(CONTENT_SETTING_ALLOW, 414 EXPECT_EQ(CONTENT_SETTING_ALLOW,
405 host_content_settings_map->GetContentSetting( 415 host_content_settings_map->GetContentSetting(
406 host_ending_with_dot, 416 host_ending_with_dot,
407 host_ending_with_dot, 417 host_ending_with_dot,
408 CONTENT_SETTINGS_TYPE_IMAGES, 418 CONTENT_SETTINGS_TYPE_IMAGES,
409 std::string())); 419 std::string()));
410 host_content_settings_map->SetContentSetting( 420 host_content_settings_map->SetContentSetting(
411 pattern, 421 pattern,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 std::string())); 555 std::string()));
546 } 556 }
547 557
548 TEST_F(HostContentSettingsMapTest, NestedSettings) { 558 TEST_F(HostContentSettingsMapTest, NestedSettings) {
549 TestingProfile profile; 559 TestingProfile profile;
550 HostContentSettingsMap* host_content_settings_map = 560 HostContentSettingsMap* host_content_settings_map =
551 profile.GetHostContentSettingsMap(); 561 profile.GetHostContentSettingsMap();
552 562
553 GURL host("http://a.b.example.com/"); 563 GURL host("http://a.b.example.com/");
554 ContentSettingsPattern pattern1 = 564 ContentSettingsPattern pattern1 =
555 ContentSettingsPattern::FromString("[*.]example.com"); 565 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
566 "[*.]example.com");
556 ContentSettingsPattern pattern2 = 567 ContentSettingsPattern pattern2 =
557 ContentSettingsPattern::FromString("[*.]b.example.com"); 568 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
569 "[*.]b.example.com");
558 ContentSettingsPattern pattern3 = 570 ContentSettingsPattern pattern3 =
559 ContentSettingsPattern::FromString("a.b.example.com"); 571 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
572 "a.b.example.com");
560 573
561 host_content_settings_map->SetContentSetting( 574 host_content_settings_map->SetContentSetting(
562 pattern1, 575 pattern1,
563 ContentSettingsPattern::Wildcard(), 576 ContentSettingsPattern::Wildcard(),
564 CONTENT_SETTINGS_TYPE_IMAGES, 577 CONTENT_SETTINGS_TYPE_IMAGES,
565 std::string(), 578 std::string(),
566 CONTENT_SETTING_BLOCK); 579 CONTENT_SETTING_BLOCK);
567 580
568 host_content_settings_map->SetContentSetting( 581 host_content_settings_map->SetContentSetting(
569 pattern2, 582 pattern2,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 TEST_F(HostContentSettingsMapTest, OffTheRecord) { 627 TEST_F(HostContentSettingsMapTest, OffTheRecord) {
615 TestingProfile profile; 628 TestingProfile profile;
616 HostContentSettingsMap* host_content_settings_map = 629 HostContentSettingsMap* host_content_settings_map =
617 profile.GetHostContentSettingsMap(); 630 profile.GetHostContentSettingsMap();
618 scoped_refptr<HostContentSettingsMap> otr_map( 631 scoped_refptr<HostContentSettingsMap> otr_map(
619 new HostContentSettingsMap(profile.GetPrefs(), 632 new HostContentSettingsMap(profile.GetPrefs(),
620 true)); 633 true));
621 634
622 GURL host("http://example.com/"); 635 GURL host("http://example.com/");
623 ContentSettingsPattern pattern = 636 ContentSettingsPattern pattern =
624 ContentSettingsPattern::FromString("[*.]example.com"); 637 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
638 "[*.]example.com");
625 639
626 EXPECT_EQ(CONTENT_SETTING_ALLOW, 640 EXPECT_EQ(CONTENT_SETTING_ALLOW,
627 host_content_settings_map->GetContentSetting( 641 host_content_settings_map->GetContentSetting(
628 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 642 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
629 EXPECT_EQ(CONTENT_SETTING_ALLOW, 643 EXPECT_EQ(CONTENT_SETTING_ALLOW,
630 otr_map->GetContentSetting( 644 otr_map->GetContentSetting(
631 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 645 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
632 646
633 // Changing content settings on the main map should also affect the 647 // Changing content settings on the main map should also affect the
634 // incognito map. 648 // incognito map.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 770
757 TEST_F(HostContentSettingsMapTest, 771 TEST_F(HostContentSettingsMapTest,
758 GetNonDefaultContentSettingsIfTypeManaged) { 772 GetNonDefaultContentSettingsIfTypeManaged) {
759 TestingProfile profile; 773 TestingProfile profile;
760 HostContentSettingsMap* host_content_settings_map = 774 HostContentSettingsMap* host_content_settings_map =
761 profile.GetHostContentSettingsMap(); 775 profile.GetHostContentSettingsMap();
762 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 776 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
763 777
764 // Set pattern for JavaScript setting. 778 // Set pattern for JavaScript setting.
765 ContentSettingsPattern pattern = 779 ContentSettingsPattern pattern =
766 ContentSettingsPattern::FromString("[*.]example.com"); 780 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
781 "[*.]example.com");
767 host_content_settings_map->SetContentSetting( 782 host_content_settings_map->SetContentSetting(
768 pattern, 783 pattern,
769 ContentSettingsPattern::Wildcard(), 784 ContentSettingsPattern::Wildcard(),
770 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 785 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
771 std::string(), 786 std::string(),
772 CONTENT_SETTING_BLOCK); 787 CONTENT_SETTING_BLOCK);
773 788
774 EXPECT_EQ(CONTENT_SETTING_ALLOW, 789 EXPECT_EQ(CONTENT_SETTING_ALLOW,
775 host_content_settings_map->GetDefaultContentSetting( 790 host_content_settings_map->GetDefaultContentSetting(
776 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); 791 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL));
(...skipping 19 matching lines...) Expand all
796 HostContentSettingsMap* host_content_settings_map = 811 HostContentSettingsMap* host_content_settings_map =
797 profile.GetHostContentSettingsMap(); 812 profile.GetHostContentSettingsMap();
798 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService(); 813 TestingPrefServiceSyncable* prefs = profile.GetTestingPrefService();
799 814
800 // Block all JavaScript. 815 // Block all JavaScript.
801 host_content_settings_map->SetDefaultContentSetting( 816 host_content_settings_map->SetDefaultContentSetting(
802 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); 817 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
803 818
804 // Set an exception to allow "[*.]example.com" 819 // Set an exception to allow "[*.]example.com"
805 ContentSettingsPattern pattern = 820 ContentSettingsPattern pattern =
806 ContentSettingsPattern::FromString("[*.]example.com"); 821 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
822 "[*.]example.com");
807 823
808 host_content_settings_map->SetContentSetting( 824 host_content_settings_map->SetContentSetting(
809 pattern, 825 pattern,
810 ContentSettingsPattern::Wildcard(), 826 ContentSettingsPattern::Wildcard(),
811 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 827 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
812 std::string(), 828 std::string(),
813 CONTENT_SETTING_ALLOW); 829 CONTENT_SETTING_ALLOW);
814 830
815 EXPECT_EQ(CONTENT_SETTING_BLOCK, 831 EXPECT_EQ(CONTENT_SETTING_BLOCK,
816 host_content_settings_map->GetDefaultContentSetting( 832 host_content_settings_map->GetDefaultContentSetting(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 } 907 }
892 908
893 TEST_F(HostContentSettingsMapTest, GetContentSetting) { 909 TEST_F(HostContentSettingsMapTest, GetContentSetting) {
894 TestingProfile profile; 910 TestingProfile profile;
895 HostContentSettingsMap* host_content_settings_map = 911 HostContentSettingsMap* host_content_settings_map =
896 profile.GetHostContentSettingsMap(); 912 profile.GetHostContentSettingsMap();
897 913
898 GURL host("http://example.com/"); 914 GURL host("http://example.com/");
899 GURL embedder("chrome://foo"); 915 GURL embedder("chrome://foo");
900 ContentSettingsPattern pattern = 916 ContentSettingsPattern pattern =
901 ContentSettingsPattern::FromString("[*.]example.com"); 917 ContentSettingsPattern::FromString(extensions::kExtensionScheme,
918 "[*.]example.com");
902 host_content_settings_map->SetContentSetting( 919 host_content_settings_map->SetContentSetting(
903 pattern, 920 pattern,
904 ContentSettingsPattern::Wildcard(), 921 ContentSettingsPattern::Wildcard(),
905 CONTENT_SETTINGS_TYPE_IMAGES, 922 CONTENT_SETTINGS_TYPE_IMAGES,
906 std::string(), 923 std::string(),
907 CONTENT_SETTING_BLOCK); 924 CONTENT_SETTING_BLOCK);
908 EXPECT_EQ(CONTENT_SETTING_BLOCK, 925 EXPECT_EQ(CONTENT_SETTING_BLOCK,
909 host_content_settings_map->GetContentSetting( 926 host_content_settings_map->GetContentSetting(
910 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); 927 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string()));
911 EXPECT_EQ(CONTENT_SETTING_ALLOW, 928 EXPECT_EQ(CONTENT_SETTING_ALLOW,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 GURL("http://other.com"), 992 GURL("http://other.com"),
976 CONTENT_SETTINGS_TYPE_COOKIES, 993 CONTENT_SETTINGS_TYPE_COOKIES,
977 std::string())); 994 std::string()));
978 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, 995 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY,
979 host_content_settings_map->GetContentSetting( 996 host_content_settings_map->GetContentSetting(
980 GURL("http://third.com"), 997 GURL("http://third.com"),
981 GURL("http://third.com"), 998 GURL("http://third.com"),
982 CONTENT_SETTINGS_TYPE_COOKIES, 999 CONTENT_SETTINGS_TYPE_COOKIES,
983 std::string())); 1000 std::string()));
984 } 1001 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698