| 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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 std::string(), | 951 std::string(), |
| 952 CONTENT_SETTING_BLOCK); | 952 CONTENT_SETTING_BLOCK); |
| 953 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 953 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 954 host_content_settings_map->GetContentSetting( | 954 host_content_settings_map->GetContentSetting( |
| 955 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 955 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 956 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 956 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 957 host_content_settings_map->GetContentSetting( | 957 host_content_settings_map->GetContentSetting( |
| 958 embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 958 embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 959 } | 959 } |
| 960 | 960 |
| 961 TEST_F(HostContentSettingsMapTest, IsSettingAllowedForType) { | 961 TEST_F(HostContentSettingsMapTest, IsDefaultSettingAllowedForType) { |
| 962 TestingProfile profile; | |
| 963 PrefService* prefs = profile.GetPrefs(); | |
| 964 | |
| 965 EXPECT_TRUE(HostContentSettingsMap::IsSettingAllowedForType( | |
| 966 prefs, CONTENT_SETTING_ASK, | |
| 967 CONTENT_SETTINGS_TYPE_FULLSCREEN)); | |
| 968 | |
| 969 // The mediastream setting is deprecated. | |
| 970 EXPECT_FALSE(HostContentSettingsMap::IsSettingAllowedForType( | |
| 971 prefs, CONTENT_SETTING_ALLOW, | |
| 972 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); | |
| 973 EXPECT_FALSE(HostContentSettingsMap::IsSettingAllowedForType( | |
| 974 prefs, CONTENT_SETTING_ASK, | |
| 975 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); | |
| 976 EXPECT_FALSE(HostContentSettingsMap::IsSettingAllowedForType( | |
| 977 prefs, CONTENT_SETTING_BLOCK, | |
| 978 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); | |
| 979 | |
| 980 // We support the ALLOW value for media permission exceptions, | |
| 981 // but not as the default setting. | |
| 982 EXPECT_TRUE(HostContentSettingsMap::IsSettingAllowedForType( | |
| 983 prefs, CONTENT_SETTING_ALLOW, | |
| 984 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | |
| 985 EXPECT_TRUE(HostContentSettingsMap::IsSettingAllowedForType( | |
| 986 prefs, CONTENT_SETTING_ALLOW, | |
| 987 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | |
| 988 EXPECT_FALSE(HostContentSettingsMap::IsDefaultSettingAllowedForType( | 962 EXPECT_FALSE(HostContentSettingsMap::IsDefaultSettingAllowedForType( |
| 989 prefs, CONTENT_SETTING_ALLOW, | 963 CONTENT_SETTING_ALLOW, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); |
| 990 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | |
| 991 EXPECT_FALSE(HostContentSettingsMap::IsDefaultSettingAllowedForType( | 964 EXPECT_FALSE(HostContentSettingsMap::IsDefaultSettingAllowedForType( |
| 992 prefs, CONTENT_SETTING_ALLOW, | 965 CONTENT_SETTING_ALLOW, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); |
| 993 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | |
| 994 | |
| 995 // TODO(msramek): Add more checks for setting type - setting pairs where | |
| 996 // it is not obvious whether or not they are allowed. | |
| 997 } | 966 } |
| 998 | 967 |
| 999 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { | 968 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { |
| 1000 TestingProfile profile; | 969 TestingProfile profile; |
| 1001 HostContentSettingsMap* host_content_settings_map = | 970 HostContentSettingsMap* host_content_settings_map = |
| 1002 HostContentSettingsMapFactory::GetForProfile(&profile); | 971 HostContentSettingsMapFactory::GetForProfile(&profile); |
| 1003 content_settings::MockObserver mock_observer; | 972 content_settings::MockObserver mock_observer; |
| 1004 | 973 |
| 1005 GURL host("http://example.com/"); | 974 GURL host("http://example.com/"); |
| 1006 ContentSettingsPattern pattern = | 975 ContentSettingsPattern pattern = |
| 1007 ContentSettingsPattern::FromString("[*.]example.com"); | 976 ContentSettingsPattern::FromString("[*.]example.com"); |
| 1008 EXPECT_CALL(mock_observer, | 977 EXPECT_CALL(mock_observer, |
| 1009 OnContentSettingChanged(pattern, | 978 OnContentSettingChanged(pattern, |
| 1010 ContentSettingsPattern::Wildcard(), | 979 ContentSettingsPattern::Wildcard(), |
| 1011 CONTENT_SETTINGS_TYPE_IMAGES, | 980 CONTENT_SETTINGS_TYPE_IMAGES, |
| 1012 "")); | 981 "")); |
| 1013 | 982 |
| 1014 host_content_settings_map->AddObserver(&mock_observer); | 983 host_content_settings_map->AddObserver(&mock_observer); |
| 1015 | 984 |
| 1016 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 985 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1017 host_content_settings_map->GetContentSetting( | 986 host_content_settings_map->GetContentSetting( |
| 1018 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 987 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 1019 host_content_settings_map->SetContentSetting( | 988 host_content_settings_map->SetContentSetting( |
| 1020 pattern, | 989 pattern, |
| 1021 ContentSettingsPattern::Wildcard(), | 990 ContentSettingsPattern::Wildcard(), |
| 1022 CONTENT_SETTINGS_TYPE_IMAGES, | 991 CONTENT_SETTINGS_TYPE_IMAGES, |
| 1023 std::string(), | 992 std::string(), |
| 1024 CONTENT_SETTING_DEFAULT); | 993 CONTENT_SETTING_DEFAULT); |
| 1025 } | 994 } |
| OLD | NEW |