| 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/location.h" | 5 #include "base/location.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 12 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 13 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" | 14 #include "chrome/browser/extensions/api/content_settings/content_settings_api.h" |
| 14 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "components/content_settings/core/browser/cookie_settings.h" | 19 #include "components/content_settings/core/browser/cookie_settings.h" |
| 19 #include "components/content_settings/core/browser/host_content_settings_map.h" | 20 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 20 #include "components/content_settings/core/browser/plugins_field_trial.h" | 21 #include "components/content_settings/core/browser/plugins_field_trial.h" |
| 21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/plugin_service.h" | 23 #include "content/public/browser/plugin_service.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 base::ThreadTaskRunnerHandle::Get()->PostTask( | 66 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 66 FROM_HERE, base::Bind(&ReleaseBrowserProcessModule)); | 67 FROM_HERE, base::Bind(&ReleaseBrowserProcessModule)); |
| 67 content::RunAllPendingInMessageLoop(); | 68 content::RunAllPendingInMessageLoop(); |
| 68 | 69 |
| 69 ExtensionApiTest::TearDownOnMainThread(); | 70 ExtensionApiTest::TearDownOnMainThread(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 protected: | 73 protected: |
| 73 void CheckContentSettingsSet() { | 74 void CheckContentSettingsSet() { |
| 74 HostContentSettingsMap* map = | 75 HostContentSettingsMap* map = |
| 75 profile_->GetHostContentSettingsMap(); | 76 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 76 content_settings::CookieSettings* cookie_settings = | 77 content_settings::CookieSettings* cookie_settings = |
| 77 CookieSettingsFactory::GetForProfile(profile_).get(); | 78 CookieSettingsFactory::GetForProfile(profile_).get(); |
| 78 | 79 |
| 79 // Check default content settings by using an unknown URL. | 80 // Check default content settings by using an unknown URL. |
| 80 GURL example_url("http://www.example.com"); | 81 GURL example_url("http://www.example.com"); |
| 81 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed( | 82 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed( |
| 82 example_url, example_url)); | 83 example_url, example_url)); |
| 83 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed( | 84 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed( |
| 84 example_url, example_url)); | 85 example_url, example_url)); |
| 85 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url)); | 86 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url)); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 map->GetContentSetting( | 183 map->GetContentSetting( |
| 183 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); | 184 url, url, CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string())); |
| 184 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 185 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 185 map->GetContentSetting( | 186 map->GetContentSetting( |
| 186 url, url, CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, | 187 url, url, CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, |
| 187 std::string())); | 188 std::string())); |
| 188 } | 189 } |
| 189 | 190 |
| 190 void CheckContentSettingsDefault() { | 191 void CheckContentSettingsDefault() { |
| 191 HostContentSettingsMap* map = | 192 HostContentSettingsMap* map = |
| 192 profile_->GetHostContentSettingsMap(); | 193 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 193 content_settings::CookieSettings* cookie_settings = | 194 content_settings::CookieSettings* cookie_settings = |
| 194 CookieSettingsFactory::GetForProfile(profile_).get(); | 195 CookieSettingsFactory::GetForProfile(profile_).get(); |
| 195 | 196 |
| 196 // Check content settings for www.google.com | 197 // Check content settings for www.google.com |
| 197 GURL url("http://www.google.com"); | 198 GURL url("http://www.google.com"); |
| 198 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(url, url)); | 199 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(url, url)); |
| 199 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(url, url)); | 200 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed(url, url)); |
| 200 EXPECT_FALSE(cookie_settings->IsCookieSessionOnly(url)); | 201 EXPECT_FALSE(cookie_settings->IsCookieSessionOnly(url)); |
| 201 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 202 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 202 map->GetContentSetting( | 203 map->GetContentSetting( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 << message_; | 300 << message_; |
| 300 } | 301 } |
| 301 | 302 |
| 302 IN_PROC_BROWSER_TEST_F(ExtensionContentSettingsApiTest, | 303 IN_PROC_BROWSER_TEST_F(ExtensionContentSettingsApiTest, |
| 303 UnsupportedDefaultSettings) { | 304 UnsupportedDefaultSettings) { |
| 304 const char kExtensionPath[] = "content_settings/unsupporteddefaultsettings"; | 305 const char kExtensionPath[] = "content_settings/unsupporteddefaultsettings"; |
| 305 EXPECT_TRUE(RunExtensionSubtest(kExtensionPath, "test.html")) << message_; | 306 EXPECT_TRUE(RunExtensionSubtest(kExtensionPath, "test.html")) << message_; |
| 306 } | 307 } |
| 307 | 308 |
| 308 } // namespace extensions | 309 } // namespace extensions |
| OLD | NEW |