| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/content_settings/cookie_settings.h" |
| 6 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_content_settings_api.h" | 9 #include "chrome/browser/extensions/extension_content_settings_api.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 #include "webkit/plugins/npapi/mock_plugin_list.h" | 15 #include "webkit/plugins/npapi/mock_plugin_list.h" |
| 15 | 16 |
| 16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { | 17 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { |
| 17 CommandLine::ForCurrentProcess()->AppendSwitch( | 18 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 18 switches::kEnableExperimentalExtensionApis); | 19 switches::kEnableExperimentalExtensionApis); |
| 19 | 20 |
| 20 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; | 21 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; |
| 21 | 22 |
| 22 HostContentSettingsMap* map = | 23 HostContentSettingsMap* map = |
| 23 browser()->profile()->GetHostContentSettingsMap(); | 24 browser()->profile()->GetHostContentSettingsMap(); |
| 25 CookieSettings* cookie_settings = |
| 26 CookieSettings::GetForProfile(browser()->profile()); |
| 24 | 27 |
| 25 // Check default content settings by using an unknown URL. | 28 // Check default content settings by using an unknown URL. |
| 26 GURL example_url("http://www.example.com"); | 29 GURL example_url("http://www.example.com"); |
| 27 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | 30 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed( |
| 28 map->GetCookieContentSetting( | 31 example_url, example_url)); |
| 29 example_url, example_url, false)); | 32 EXPECT_TRUE(cookie_settings->IsSettingCookieAllowed( |
| 33 example_url, example_url)); |
| 34 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url)); |
| 30 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 35 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 31 map->GetContentSetting(example_url, | 36 map->GetContentSetting(example_url, |
| 32 example_url, | 37 example_url, |
| 33 CONTENT_SETTINGS_TYPE_IMAGES, | 38 CONTENT_SETTINGS_TYPE_IMAGES, |
| 34 std::string())); | 39 std::string())); |
| 35 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 40 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 36 map->GetContentSetting(example_url, | 41 map->GetContentSetting(example_url, |
| 37 example_url, | 42 example_url, |
| 38 CONTENT_SETTINGS_TYPE_JAVASCRIPT, | 43 CONTENT_SETTINGS_TYPE_JAVASCRIPT, |
| 39 std::string())); | 44 std::string())); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 std::string())); | 62 std::string())); |
| 58 #endif | 63 #endif |
| 59 EXPECT_EQ(CONTENT_SETTING_ASK, | 64 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 60 map->GetContentSetting(example_url, | 65 map->GetContentSetting(example_url, |
| 61 example_url, | 66 example_url, |
| 62 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, | 67 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, |
| 63 std::string())); | 68 std::string())); |
| 64 | 69 |
| 65 // Check content settings for www.google.com | 70 // Check content settings for www.google.com |
| 66 GURL url("http://www.google.com"); | 71 GURL url("http://www.google.com"); |
| 67 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 72 EXPECT_FALSE(cookie_settings->IsReadingCookieAllowed(url, url)); |
| 68 map->GetCookieContentSetting(url, url, false)); | |
| 69 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 73 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 70 map->GetContentSetting( | 74 map->GetContentSetting( |
| 71 url, url, CONTENT_SETTINGS_TYPE_IMAGES, "")); | 75 url, url, CONTENT_SETTINGS_TYPE_IMAGES, "")); |
| 72 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 76 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 73 map->GetContentSetting( | 77 map->GetContentSetting( |
| 74 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); | 78 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); |
| 75 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 79 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 76 map->GetContentSetting( | 80 map->GetContentSetting( |
| 77 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, "")); | 81 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, "")); |
| 78 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 82 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 FilePath(kBarPath), | 120 FilePath(kBarPath), |
| 117 ASCIIToUTF16("2.3.4"), | 121 ASCIIToUTF16("2.3.4"), |
| 118 ASCIIToUTF16("bar"))); | 122 ASCIIToUTF16("bar"))); |
| 119 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); | 123 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); |
| 120 | 124 |
| 121 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) | 125 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) |
| 122 << message_; | 126 << message_; |
| 123 | 127 |
| 124 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); | 128 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); |
| 125 } | 129 } |
| OLD | NEW |