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.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/content_settings/content_settings_details.h" | 10 #include "chrome/browser/content_settings/content_settings_details.h" |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( | 720 EXPECT_TRUE(all_settings_dictionary->GetDictionaryWithoutPathExpansion( |
721 "[*.]xn--ira-ppa.com,*", &result)); | 721 "[*.]xn--ira-ppa.com,*", &result)); |
722 } | 722 } |
723 | 723 |
724 // If both Unicode and its punycode pattern exist, make sure we don't touch the | 724 // If both Unicode and its punycode pattern exist, make sure we don't touch the |
725 // settings for the punycode, and that Unicode pattern gets deleted. | 725 // settings for the punycode, and that Unicode pattern gets deleted. |
726 TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { | 726 TEST_F(HostContentSettingsMapTest, CanonicalizeExceptionsUnicodeAndPunycode) { |
727 TestingProfile profile; | 727 TestingProfile profile; |
728 | 728 |
729 scoped_ptr<Value> value(base::JSONReader::Read( | 729 scoped_ptr<Value> value(base::JSONReader::Read( |
730 "{\"[*.]\\xC4\\x87ira.com,*\":{\"images\":1}}", false)); | 730 "{\"[*.]\\xC4\\x87ira.com,*\":{\"images\":1}}")); |
731 profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *value); | 731 profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *value); |
732 | 732 |
733 // Set punycode equivalent, with different setting. | 733 // Set punycode equivalent, with different setting. |
734 scoped_ptr<Value> puny_value(base::JSONReader::Read( | 734 scoped_ptr<Value> puny_value(base::JSONReader::Read( |
735 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}", false)); | 735 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}")); |
736 profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *puny_value); | 736 profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *puny_value); |
737 | 737 |
738 // Initialize the content map. | 738 // Initialize the content map. |
739 profile.GetHostContentSettingsMap(); | 739 profile.GetHostContentSettingsMap(); |
740 | 740 |
741 const DictionaryValue* content_setting_prefs = | 741 const DictionaryValue* content_setting_prefs = |
742 profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatternPairs); | 742 profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatternPairs); |
743 std::string prefs_as_json; | 743 std::string prefs_as_json; |
744 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); | 744 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); |
745 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}", | 745 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}", |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 } | 792 } |
793 | 793 |
794 TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) { | 794 TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) { |
795 // This feature is currently behind a flag. | 795 // This feature is currently behind a flag. |
796 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 796 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
797 AutoReset<CommandLine> auto_reset(cmd, *cmd); | 797 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
798 cmd->AppendSwitch(switches::kEnableResourceContentSettings); | 798 cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
799 | 799 |
800 TestingProfile profile; | 800 TestingProfile profile; |
801 scoped_ptr<Value> value(base::JSONReader::Read( | 801 scoped_ptr<Value> value(base::JSONReader::Read( |
802 "{\"[*.]example.com,*\":{\"per_plugin\":{\"someplugin\":2}}}", false)); | 802 "{\"[*.]example.com,*\":{\"per_plugin\":{\"someplugin\":2}}}")); |
803 profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *value); | 803 profile.GetPrefs()->Set(prefs::kContentSettingsPatternPairs, *value); |
804 HostContentSettingsMap* host_content_settings_map = | 804 HostContentSettingsMap* host_content_settings_map = |
805 profile.GetHostContentSettingsMap(); | 805 profile.GetHostContentSettingsMap(); |
806 | 806 |
807 GURL host("http://example.com/"); | 807 GURL host("http://example.com/"); |
808 ContentSettingsPattern item_pattern = | 808 ContentSettingsPattern item_pattern = |
809 ContentSettingsPattern::FromString("[*.]example.com"); | 809 ContentSettingsPattern::FromString("[*.]example.com"); |
810 ContentSettingsPattern top_level_frame_pattern = | 810 ContentSettingsPattern top_level_frame_pattern = |
811 ContentSettingsPattern::Wildcard(); | 811 ContentSettingsPattern::Wildcard(); |
812 std::string resource1("someplugin"); | 812 std::string resource1("someplugin"); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 CONTENT_SETTINGS_TYPE_IMAGES, | 1033 CONTENT_SETTINGS_TYPE_IMAGES, |
1034 std::string(), | 1034 std::string(), |
1035 CONTENT_SETTING_BLOCK); | 1035 CONTENT_SETTING_BLOCK); |
1036 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 1036 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
1037 host_content_settings_map->GetContentSetting( | 1037 host_content_settings_map->GetContentSetting( |
1038 host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); | 1038 host, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); |
1039 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1039 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
1040 host_content_settings_map->GetContentSetting( | 1040 host_content_settings_map->GetContentSetting( |
1041 embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); | 1041 embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, "")); |
1042 } | 1042 } |
OLD | NEW |