| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 void CheckContentSettingsSet() { | 66 void CheckContentSettingsSet() { |
| 67 HostContentSettingsMap* map = | 67 HostContentSettingsMap* map = |
| 68 HostContentSettingsMapFactory::GetForProfile(profile_); | 68 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 69 content_settings::CookieSettings* cookie_settings = | 69 content_settings::CookieSettings* cookie_settings = |
| 70 CookieSettingsFactory::GetForProfile(profile_).get(); | 70 CookieSettingsFactory::GetForProfile(profile_).get(); |
| 71 | 71 |
| 72 // Check default content settings by using an unknown URL. | 72 // Check default content settings by using an unknown URL. |
| 73 GURL example_url("http://www.example.com"); | 73 GURL example_url("http://www.example.com"); |
| 74 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed( | 74 EXPECT_TRUE( |
| 75 example_url, example_url)); | 75 cookie_settings->IsCookieAccessAllowed(example_url, example_url)); |
| 76 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed( | |
| 77 example_url, example_url)); | |
| 78 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url)); | 76 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url)); |
| 79 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 77 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 80 map->GetContentSetting(example_url, | 78 map->GetContentSetting(example_url, |
| 81 example_url, | 79 example_url, |
| 82 CONTENT_SETTINGS_TYPE_IMAGES, | 80 CONTENT_SETTINGS_TYPE_IMAGES, |
| 83 std::string())); | 81 std::string())); |
| 84 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 82 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 85 map->GetContentSetting(example_url, | 83 map->GetContentSetting(example_url, |
| 86 example_url, | 84 example_url, |
| 87 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 85 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, | 125 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
| 128 std::string())); | 126 std::string())); |
| 129 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 127 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 130 map->GetContentSetting(example_url, | 128 map->GetContentSetting(example_url, |
| 131 example_url, | 129 example_url, |
| 132 CONTENT_SETTINGS_TYPE_AUTOPLAY, | 130 CONTENT_SETTINGS_TYPE_AUTOPLAY, |
| 133 std::string())); | 131 std::string())); |
| 134 | 132 |
| 135 // Check content settings for www.google.com | 133 // Check content settings for www.google.com |
| 136 GURL url("http://www.google.com"); | 134 GURL url("http://www.google.com"); |
| 137 EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url)); | 135 EXPECT_FALSE(cookie_settings->IsCookieAccessAllowed(url, url)); |
| 138 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 136 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 139 map->GetContentSetting( | 137 map->GetContentSetting( |
| 140 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 138 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 141 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 139 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 142 map->GetContentSetting( | 140 map->GetContentSetting( |
| 143 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 141 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
| 144 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, | 142 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, |
| 145 map->GetContentSetting( | 143 map->GetContentSetting( |
| 146 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); | 144 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); |
| 147 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 145 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 173 } | 171 } |
| 174 | 172 |
| 175 void CheckContentSettingsDefault() { | 173 void CheckContentSettingsDefault() { |
| 176 HostContentSettingsMap* map = | 174 HostContentSettingsMap* map = |
| 177 HostContentSettingsMapFactory::GetForProfile(profile_); | 175 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 178 content_settings::CookieSettings* cookie_settings = | 176 content_settings::CookieSettings* cookie_settings = |
| 179 CookieSettingsFactory::GetForProfile(profile_).get(); | 177 CookieSettingsFactory::GetForProfile(profile_).get(); |
| 180 | 178 |
| 181 // Check content settings for www.google.com | 179 // Check content settings for www.google.com |
| 182 GURL url("http://www.google.com"); | 180 GURL url("http://www.google.com"); |
| 183 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(url, url)); | 181 EXPECT_TRUE(cookie_settings->IsCookieAccessAllowed(url, url)); |
| 184 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(url, url)); | |
| 185 EXPECT_FALSE(cookie_settings->IsCookieSessionOnly(url)); | 182 EXPECT_FALSE(cookie_settings->IsCookieSessionOnly(url)); |
| 186 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 183 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 187 map->GetContentSetting( | 184 map->GetContentSetting( |
| 188 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 185 url, url, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
| 189 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 186 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 190 map->GetContentSetting( | 187 map->GetContentSetting( |
| 191 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 188 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
| 192 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, | 189 EXPECT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, |
| 193 map->GetContentSetting( | 190 map->GetContentSetting( |
| 194 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); | 191 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, std::string())); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 << message_; | 279 << message_; |
| 283 } | 280 } |
| 284 | 281 |
| 285 IN_PROC_BROWSER_TEST_F(ExtensionContentSettingsApiTest, | 282 IN_PROC_BROWSER_TEST_F(ExtensionContentSettingsApiTest, |
| 286 UnsupportedDefaultSettings) { | 283 UnsupportedDefaultSettings) { |
| 287 const char kExtensionPath[] = "content_settings/unsupporteddefaultsettings"; | 284 const char kExtensionPath[] = "content_settings/unsupporteddefaultsettings"; |
| 288 EXPECT_TRUE(RunExtensionSubtest(kExtensionPath, "test.html")) << message_; | 285 EXPECT_TRUE(RunExtensionSubtest(kExtensionPath, "test.html")) << message_; |
| 289 } | 286 } |
| 290 | 287 |
| 291 } // namespace extensions | 288 } // namespace extensions |
| OLD | NEW |