| 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(); | 20 PrefService* pref_service = browser()->profile()->GetPrefs(); |
| 21 pref_service->SetBoolean(prefs::kAlternateErrorPagesEnabled, false); |
| 22 pref_service->SetBoolean(prefs::kAutofillEnabled, false); |
| 21 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); | 23 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); |
| 24 pref_service->SetBoolean(prefs::kClearSiteDataOnExit, false); |
| 25 pref_service->SetBoolean(prefs::kEnableHyperlinkAuditing, false); |
| 22 pref_service->SetBoolean(prefs::kEnableReferrers, false); | 26 pref_service->SetBoolean(prefs::kEnableReferrers, false); |
| 27 pref_service->SetBoolean(prefs::kEnableTranslate, false); |
| 28 pref_service->SetBoolean(prefs::kInstantEnabled, false); |
| 29 pref_service->SetBoolean(prefs::kNetworkPredictionEnabled, false); |
| 30 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); |
| 31 pref_service->SetBoolean(prefs::kSearchSuggestEnabled, false); |
| 23 | 32 |
| 24 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; | 33 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; |
| 25 | 34 |
| 26 const PrefService::Preference* pref = pref_service->FindPreference( | 35 const PrefService::Preference* pref = pref_service->FindPreference( |
| 27 prefs::kBlockThirdPartyCookies); | 36 prefs::kBlockThirdPartyCookies); |
| 28 ASSERT_TRUE(pref); | 37 ASSERT_TRUE(pref); |
| 29 EXPECT_TRUE(pref->IsExtensionControlled()); | 38 EXPECT_TRUE(pref->IsExtensionControlled()); |
| 39 EXPECT_TRUE(pref_service->GetBoolean(prefs::kAlternateErrorPagesEnabled)); |
| 40 EXPECT_TRUE(pref_service->GetBoolean(prefs::kAutofillEnabled)); |
| 30 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); | 41 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); |
| 42 EXPECT_TRUE(pref_service->GetBoolean(prefs::kClearSiteDataOnExit)); |
| 43 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableHyperlinkAuditing)); |
| 31 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers)); | 44 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers)); |
| 45 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableTranslate)); |
| 46 EXPECT_TRUE(pref_service->GetBoolean(prefs::kInstantEnabled)); |
| 47 EXPECT_TRUE(pref_service->GetBoolean(prefs::kNetworkPredictionEnabled)); |
| 48 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); |
| 49 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSearchSuggestEnabled)); |
| 32 HostContentSettingsMap* map = | 50 HostContentSettingsMap* map = |
| 33 browser()->profile()->GetHostContentSettingsMap(); | 51 browser()->profile()->GetHostContentSettingsMap(); |
| 34 | 52 |
| 35 // Check default content settings by using an unknown URL. | 53 // Check default content settings by using an unknown URL. |
| 36 GURL example_url("http://www.example.com"); | 54 GURL example_url("http://www.example.com"); |
| 37 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, | 55 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, |
| 38 map->GetCookieContentSetting( | 56 map->GetCookieContentSetting( |
| 39 example_url, example_url, false)); | 57 example_url, example_url, false)); |
| 40 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 58 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 41 map->GetContentSetting(example_url, | 59 map->GetContentSetting(example_url, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 FilePath(kBarPath), | 233 FilePath(kBarPath), |
| 216 ASCIIToUTF16("2.3.4"), | 234 ASCIIToUTF16("2.3.4"), |
| 217 ASCIIToUTF16("bar"))); | 235 ASCIIToUTF16("bar"))); |
| 218 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); | 236 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); |
| 219 | 237 |
| 220 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) | 238 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) |
| 221 << message_; | 239 << message_; |
| 222 | 240 |
| 223 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); | 241 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); |
| 224 } | 242 } |
| OLD | NEW |