OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 | 49 |
50 TEST_F(HostContentSettingsMapTest, DefaultValues) { | 50 TEST_F(HostContentSettingsMapTest, DefaultValues) { |
51 TestingProfile profile; | 51 TestingProfile profile; |
52 HostContentSettingsMap* host_content_settings_map = | 52 HostContentSettingsMap* host_content_settings_map = |
53 HostContentSettingsMapFactory::GetForProfile(&profile); | 53 HostContentSettingsMapFactory::GetForProfile(&profile); |
54 | 54 |
55 // Check setting defaults. | 55 // Check setting defaults. |
56 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 56 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
57 host_content_settings_map->GetDefaultContentSetting( | 57 host_content_settings_map->GetDefaultContentSetting( |
58 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); | 58 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); |
59 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
msramek
2015/11/05 17:07:09
nit: Please keep the same ordering as in ContentSe
svaldez
2015/11/05 17:37:51
Done.
| |
60 host_content_settings_map->GetDefaultContentSetting( | |
61 CONTENT_SETTINGS_TYPE_KEYGEN, NULL)); | |
59 host_content_settings_map->SetDefaultContentSetting( | 62 host_content_settings_map->SetDefaultContentSetting( |
60 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 63 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
61 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 64 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
62 host_content_settings_map->GetDefaultContentSetting( | 65 host_content_settings_map->GetDefaultContentSetting( |
63 CONTENT_SETTINGS_TYPE_IMAGES, NULL)); | 66 CONTENT_SETTINGS_TYPE_IMAGES, NULL)); |
64 EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( | 67 EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( |
65 GURL(chrome::kChromeUINewTabURL), | 68 GURL(chrome::kChromeUINewTabURL), |
66 GURL(chrome::kChromeUINewTabURL), | 69 GURL(chrome::kChromeUINewTabURL), |
67 CONTENT_SETTINGS_TYPE_IMAGES, | 70 CONTENT_SETTINGS_TYPE_IMAGES, |
68 std::string())); | 71 std::string())); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 143 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
141 host_content_settings_map->SetContentSetting( | 144 host_content_settings_map->SetContentSetting( |
142 pattern, | 145 pattern, |
143 ContentSettingsPattern::Wildcard(), | 146 ContentSettingsPattern::Wildcard(), |
144 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 147 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
145 std::string(), | 148 std::string(), |
146 CONTENT_SETTING_BLOCK); | 149 CONTENT_SETTING_BLOCK); |
147 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 150 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
148 host_content_settings_map->GetContentSetting( | 151 host_content_settings_map->GetContentSetting( |
149 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 152 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
153 host_content_settings_map->SetContentSetting( | |
154 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_KEYGEN, | |
155 std::string(), CONTENT_SETTING_BLOCK); | |
156 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
157 host_content_settings_map->GetContentSetting( | |
158 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | |
150 #if defined(ENABLE_PLUGINS) | 159 #if defined(ENABLE_PLUGINS) |
151 host_content_settings_map->SetContentSetting( | 160 host_content_settings_map->SetContentSetting( |
152 pattern, | 161 pattern, |
153 ContentSettingsPattern::Wildcard(), | 162 ContentSettingsPattern::Wildcard(), |
154 CONTENT_SETTINGS_TYPE_PLUGINS, | 163 CONTENT_SETTINGS_TYPE_PLUGINS, |
155 std::string(), | 164 std::string(), |
156 CONTENT_SETTING_ALLOW); | 165 CONTENT_SETTING_ALLOW); |
157 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 166 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
158 host_content_settings_map->GetContentSetting( | 167 host_content_settings_map->GetContentSetting( |
159 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); | 168 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 516 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
508 std::string(), | 517 std::string(), |
509 CONTENT_SETTING_BLOCK); | 518 CONTENT_SETTING_BLOCK); |
510 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 519 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
511 host_content_settings_map->GetContentSetting( | 520 host_content_settings_map->GetContentSetting( |
512 host_ending_with_dot, | 521 host_ending_with_dot, |
513 host_ending_with_dot, | 522 host_ending_with_dot, |
514 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 523 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
515 std::string())); | 524 std::string())); |
516 | 525 |
526 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
527 host_content_settings_map->GetContentSetting( | |
528 host_ending_with_dot, host_ending_with_dot, | |
529 CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | |
530 host_content_settings_map->SetContentSetting( | |
531 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_KEYGEN, | |
532 std::string(), CONTENT_SETTING_DEFAULT); | |
533 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
534 host_content_settings_map->GetContentSetting( | |
535 host_ending_with_dot, host_ending_with_dot, | |
536 CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | |
537 host_content_settings_map->SetContentSetting( | |
538 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_KEYGEN, | |
539 std::string(), CONTENT_SETTING_BLOCK); | |
540 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
541 host_content_settings_map->GetContentSetting( | |
542 host_ending_with_dot, host_ending_with_dot, | |
543 CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | |
544 | |
517 #if defined(ENABLE_PLUGINS) | 545 #if defined(ENABLE_PLUGINS) |
518 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, | 546 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, |
519 host_content_settings_map->GetContentSetting( | 547 host_content_settings_map->GetContentSetting( |
520 host_ending_with_dot, | 548 host_ending_with_dot, |
521 host_ending_with_dot, | 549 host_ending_with_dot, |
522 CONTENT_SETTINGS_TYPE_PLUGINS, | 550 CONTENT_SETTINGS_TYPE_PLUGINS, |
523 std::string())); | 551 std::string())); |
524 host_content_settings_map->SetContentSetting( | 552 host_content_settings_map->SetContentSetting( |
525 pattern, | 553 pattern, |
526 ContentSettingsPattern::Wildcard(), | 554 ContentSettingsPattern::Wildcard(), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
619 host_content_settings_map->GetContentSetting( | 647 host_content_settings_map->GetContentSetting( |
620 host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 648 host, host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
621 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 649 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
622 host_content_settings_map->GetContentSetting( | 650 host_content_settings_map->GetContentSetting( |
623 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 651 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
624 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 652 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
625 host_content_settings_map->GetContentSetting( | 653 host_content_settings_map->GetContentSetting( |
626 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 654 host, host, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
627 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 655 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
628 host_content_settings_map->GetContentSetting( | 656 host_content_settings_map->GetContentSetting( |
657 host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string())); | |
658 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
659 host_content_settings_map->GetContentSetting( | |
629 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); | 660 host, host, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); |
630 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 661 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
631 host_content_settings_map->GetContentSetting( | 662 host_content_settings_map->GetContentSetting( |
632 host, host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); | 663 host, host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
633 EXPECT_EQ(CONTENT_SETTING_ASK, | 664 EXPECT_EQ(CONTENT_SETTING_ASK, |
634 host_content_settings_map->GetContentSetting( | 665 host_content_settings_map->GetContentSetting( |
635 host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); | 666 host, host, CONTENT_SETTINGS_TYPE_GEOLOCATION, std::string())); |
636 EXPECT_EQ( | 667 EXPECT_EQ( |
637 CONTENT_SETTING_ASK, | 668 CONTENT_SETTING_ASK, |
638 host_content_settings_map->GetContentSetting( | 669 host_content_settings_map->GetContentSetting( |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 803 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
773 host_content_settings_map->GetDefaultContentSetting( | 804 host_content_settings_map->GetDefaultContentSetting( |
774 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); | 805 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); |
775 | 806 |
776 // Remove managed-default-content-settings-preferences. | 807 // Remove managed-default-content-settings-preferences. |
777 prefs->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting); | 808 prefs->RemoveManagedPref(prefs::kManagedDefaultJavaScriptSetting); |
778 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 809 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
779 host_content_settings_map->GetDefaultContentSetting( | 810 host_content_settings_map->GetDefaultContentSetting( |
780 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); | 811 CONTENT_SETTINGS_TYPE_JAVASCRIPT, NULL)); |
781 | 812 |
813 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
814 host_content_settings_map->GetDefaultContentSetting( | |
815 CONTENT_SETTINGS_TYPE_KEYGEN, NULL)); | |
816 | |
817 // Set managed-default-content-setting through the coresponding preferences. | |
818 prefs->SetManagedPref(prefs::kManagedDefaultKeygenSetting, | |
819 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); | |
820 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
821 host_content_settings_map->GetDefaultContentSetting( | |
822 CONTENT_SETTINGS_TYPE_KEYGEN, NULL)); | |
823 | |
824 // Remove managed-default-content-settings-preferences. | |
825 prefs->RemoveManagedPref(prefs::kManagedDefaultKeygenSetting); | |
826 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
827 host_content_settings_map->GetDefaultContentSetting( | |
828 CONTENT_SETTINGS_TYPE_KEYGEN, NULL)); | |
829 | |
782 // Set preference to manage the default-content-setting for Plugins. | 830 // Set preference to manage the default-content-setting for Plugins. |
783 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, | 831 prefs->SetManagedPref(prefs::kManagedDefaultPluginsSetting, |
784 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); | 832 new base::FundamentalValue(CONTENT_SETTING_BLOCK)); |
785 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 833 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
786 host_content_settings_map->GetDefaultContentSetting( | 834 host_content_settings_map->GetDefaultContentSetting( |
787 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); | 835 CONTENT_SETTINGS_TYPE_PLUGINS, NULL)); |
788 | 836 |
789 #if defined(ENABLE_PLUGINS) | 837 #if defined(ENABLE_PLUGINS) |
790 // Remove the preference to manage the default-content-setting for Plugins. | 838 // Remove the preference to manage the default-content-setting for Plugins. |
791 prefs->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting); | 839 prefs->RemoveManagedPref(prefs::kManagedDefaultPluginsSetting); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
985 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1033 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
986 host_content_settings_map->GetContentSetting( | 1034 host_content_settings_map->GetContentSetting( |
987 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1035 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
988 host_content_settings_map->SetContentSetting( | 1036 host_content_settings_map->SetContentSetting( |
989 pattern, | 1037 pattern, |
990 ContentSettingsPattern::Wildcard(), | 1038 ContentSettingsPattern::Wildcard(), |
991 CONTENT_SETTINGS_TYPE_IMAGES, | 1039 CONTENT_SETTINGS_TYPE_IMAGES, |
992 std::string(), | 1040 std::string(), |
993 CONTENT_SETTING_DEFAULT); | 1041 CONTENT_SETTING_DEFAULT); |
994 } | 1042 } |
OLD | NEW |