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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 713 |
714 // Set punycode equivalent, with different setting. | 714 // Set punycode equivalent, with different setting. |
715 scoped_ptr<base::Value> puny_value(base::JSONReader::Read( | 715 scoped_ptr<base::Value> puny_value(base::JSONReader::Read( |
716 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}")); | 716 "{\"[*.]xn--ira-ppa.com,*\":{\"images\":2}}")); |
717 profile.GetPrefs()->Set( | 717 profile.GetPrefs()->Set( |
718 prefs::kContentSettingsPatternPairs, *puny_value); | 718 prefs::kContentSettingsPatternPairs, *puny_value); |
719 | 719 |
720 // Initialize the content map. | 720 // Initialize the content map. |
721 profile.GetHostContentSettingsMap(); | 721 profile.GetHostContentSettingsMap(); |
722 | 722 |
723 const base::DictionaryValue* content_setting_prefs = | 723 const base::DictionaryValue& content_setting_prefs = |
724 profile.GetPrefs()->GetDictionary( | 724 *profile.GetPrefs()->GetDictionary( |
725 prefs::kContentSettingsImagesPatternPairs); | 725 prefs::kContentSettingsImagesPatternPairs); |
726 std::string prefs_as_json; | 726 std::string prefs_as_json; |
727 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); | 727 base::JSONWriter::Write(content_setting_prefs, &prefs_as_json); |
728 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}", | 728 EXPECT_STREQ("{\"[*.]xn--ira-ppa.com,*\":{\"setting\":2}}", |
729 prefs_as_json.c_str()); | 729 prefs_as_json.c_str()); |
730 } | 730 } |
731 | 731 |
732 // If a default-content-setting is managed, the managed value should be used | 732 // If a default-content-setting is managed, the managed value should be used |
733 // instead of the default value. | 733 // instead of the default value. |
734 TEST_F(HostContentSettingsMapTest, ManagedDefaultContentSetting) { | 734 TEST_F(HostContentSettingsMapTest, ManagedDefaultContentSetting) { |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 CONTENT_SETTINGS_TYPE_IMAGES, true); | 1082 CONTENT_SETTINGS_TYPE_IMAGES, true); |
1083 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1083 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
1084 host_content_settings_map->GetContentSetting( | 1084 host_content_settings_map->GetContentSetting( |
1085 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1085 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
1086 host_content_settings_map->SetDefaultContentSetting( | 1086 host_content_settings_map->SetDefaultContentSetting( |
1087 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 1087 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
1088 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 1088 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
1089 host_content_settings_map->GetContentSetting( | 1089 host_content_settings_map->GetContentSetting( |
1090 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1090 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
1091 } | 1091 } |
OLD | NEW |