| 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/host_content_settings_map.h" | 6 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/browser/extensions/extension_content_settings_api.h" | 8 #include "chrome/browser/extensions/extension_content_settings_api.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "webkit/plugins/npapi/mock_plugin_list.h" | 14 #include "webkit/plugins/npapi/mock_plugin_list.h" |
| 15 | 15 |
| 16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { | 16 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ContentSettings) { |
| 17 CommandLine::ForCurrentProcess()->AppendSwitch( | 17 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 18 switches::kEnableExperimentalExtensionApis); | 18 switches::kEnableExperimentalExtensionApis); |
| 19 | 19 |
| 20 PrefService* pref_service = browser()->profile()->GetPrefs(); | |
| 21 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); | |
| 22 pref_service->SetBoolean(prefs::kEnableReferrers, false); | |
| 23 | |
| 24 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; | 20 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; |
| 25 | 21 |
| 26 const PrefService::Preference* pref = pref_service->FindPreference( | |
| 27 prefs::kBlockThirdPartyCookies); | |
| 28 ASSERT_TRUE(pref); | |
| 29 EXPECT_TRUE(pref->IsExtensionControlled()); | |
| 30 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); | |
| 31 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers)); | |
| 32 HostContentSettingsMap* map = | 22 HostContentSettingsMap* map = |
| 33 browser()->profile()->GetHostContentSettingsMap(); | 23 browser()->profile()->GetHostContentSettingsMap(); |
| 34 | 24 |
| 35 // Check default content settings by using an unknown URL. | 25 // Check default content settings by using an unknown URL. |
| 36 GURL example_url("http://www.example.com"); | 26 GURL example_url("http://www.example.com"); |
| 37 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | 27 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 38 map->GetCookieContentSetting( | 28 map->GetCookieContentSetting( |
| 39 example_url, example_url, false)); | 29 example_url, example_url, false)); |
| 40 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 30 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 41 map->GetContentSetting(example_url, | 31 map->GetContentSetting(example_url, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FilePath(kBarPath), | 205 FilePath(kBarPath), |
| 216 ASCIIToUTF16("2.3.4"), | 206 ASCIIToUTF16("2.3.4"), |
| 217 ASCIIToUTF16("bar"))); | 207 ASCIIToUTF16("bar"))); |
| 218 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); | 208 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); |
| 219 | 209 |
| 220 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) | 210 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) |
| 221 << message_; | 211 << message_; |
| 222 | 212 |
| 223 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); | 213 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); |
| 224 } | 214 } |
| OLD | NEW |