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 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 CONTENT_SETTING_BLOCK); | 907 CONTENT_SETTING_BLOCK); |
908 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 908 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
909 host_content_settings_map->GetContentSetting( | 909 host_content_settings_map->GetContentSetting( |
910 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 910 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
911 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 911 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
912 host_content_settings_map->GetContentSetting( | 912 host_content_settings_map->GetContentSetting( |
913 embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 913 embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
914 } | 914 } |
915 | 915 |
916 TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) { | 916 TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) { |
917 TestingProfile profile; | |
918 HostContentSettingsMap* host_content_settings_map = | |
919 profile.GetHostContentSettingsMap(); | |
920 | |
921 GURL http_host("http://example.com/"); | 917 GURL http_host("http://example.com/"); |
922 GURL https_host("https://example.com/"); | 918 GURL https_host("https://example.com/"); |
923 GURL embedder("chrome://foo"); | 919 GURL embedder("chrome://foo"); |
924 GURL extension("chrome-extension://foo"); | 920 GURL extension("chrome-extension://foo"); |
925 EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent( | 921 EXPECT_FALSE(HostContentSettingsMap::ShouldAllowAllContent( |
926 http_host, embedder, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); | 922 http_host, embedder, CONTENT_SETTINGS_TYPE_NOTIFICATIONS)); |
927 EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent( | 923 EXPECT_FALSE(HostContentSettingsMap::ShouldAllowAllContent( |
928 http_host, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 924 http_host, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
929 EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent( | 925 EXPECT_FALSE(HostContentSettingsMap::ShouldAllowAllContent( |
930 http_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES)); | 926 http_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES)); |
931 EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent( | 927 EXPECT_TRUE(HostContentSettingsMap::ShouldAllowAllContent( |
932 https_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES)); | 928 https_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES)); |
933 EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent( | 929 EXPECT_TRUE(HostContentSettingsMap::ShouldAllowAllContent( |
934 https_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES)); | 930 https_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES)); |
935 EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent( | 931 EXPECT_TRUE(HostContentSettingsMap::ShouldAllowAllContent( |
936 embedder, http_host, CONTENT_SETTINGS_TYPE_COOKIES)); | 932 embedder, http_host, CONTENT_SETTINGS_TYPE_COOKIES)); |
937 #if defined(ENABLE_EXTENSIONS) | 933 #if defined(ENABLE_EXTENSIONS) |
938 EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent( | 934 EXPECT_TRUE(HostContentSettingsMap::ShouldAllowAllContent( |
939 extension, extension, CONTENT_SETTINGS_TYPE_COOKIES)); | 935 extension, extension, CONTENT_SETTINGS_TYPE_COOKIES)); |
940 #else | 936 #else |
941 EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent( | 937 EXPECT_FALSE(HostContentSettingsMap::ShouldAllowAllContent( |
942 extension, extension, CONTENT_SETTINGS_TYPE_COOKIES)); | 938 extension, extension, CONTENT_SETTINGS_TYPE_COOKIES)); |
943 #endif | 939 #endif |
944 EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent( | 940 EXPECT_FALSE(HostContentSettingsMap::ShouldAllowAllContent( |
945 extension, extension, CONTENT_SETTINGS_TYPE_PLUGINS)); | 941 extension, extension, CONTENT_SETTINGS_TYPE_PLUGINS)); |
946 EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent( | 942 EXPECT_FALSE(HostContentSettingsMap::ShouldAllowAllContent( |
947 extension, http_host, CONTENT_SETTINGS_TYPE_COOKIES)); | 943 extension, http_host, CONTENT_SETTINGS_TYPE_COOKIES)); |
948 } | 944 } |
949 | 945 |
950 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { | 946 TEST_F(HostContentSettingsMapTest, AddContentSettingsObserver) { |
951 TestingProfile profile; | 947 TestingProfile profile; |
952 HostContentSettingsMap* host_content_settings_map = | 948 HostContentSettingsMap* host_content_settings_map = |
953 profile.GetHostContentSettingsMap(); | 949 profile.GetHostContentSettingsMap(); |
954 content_settings::MockObserver mock_observer; | 950 content_settings::MockObserver mock_observer; |
955 | 951 |
956 GURL host("http://example.com/"); | 952 GURL host("http://example.com/"); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 CONTENT_SETTINGS_TYPE_IMAGES, true); | 1030 CONTENT_SETTINGS_TYPE_IMAGES, true); |
1035 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1031 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
1036 host_content_settings_map->GetContentSetting( | 1032 host_content_settings_map->GetContentSetting( |
1037 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1033 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
1038 host_content_settings_map->SetDefaultContentSetting( | 1034 host_content_settings_map->SetDefaultContentSetting( |
1039 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); | 1035 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); |
1040 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 1036 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
1041 host_content_settings_map->GetContentSetting( | 1037 host_content_settings_map->GetContentSetting( |
1042 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1038 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
1043 } | 1039 } |
OLD | NEW |