Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: chrome/browser/extensions/extension_content_settings_apitest.cc

Issue 7713034: HostContentSettingsMap refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixing the previous patch set. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 PrefService* pref_service = browser()->profile()->GetPrefs(); 21 PrefService* pref_service = browser()->profile()->GetPrefs();
21 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true); 22 pref_service->SetBoolean(prefs::kBlockThirdPartyCookies, true);
22 pref_service->SetBoolean(prefs::kEnableReferrers, false); 23 pref_service->SetBoolean(prefs::kEnableReferrers, false);
23 24
24 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; 25 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_;
25 26
26 const PrefService::Preference* pref = pref_service->FindPreference( 27 const PrefService::Preference* pref = pref_service->FindPreference(
27 prefs::kBlockThirdPartyCookies); 28 prefs::kBlockThirdPartyCookies);
28 ASSERT_TRUE(pref); 29 ASSERT_TRUE(pref);
29 EXPECT_TRUE(pref->IsExtensionControlled()); 30 EXPECT_TRUE(pref->IsExtensionControlled());
30 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); 31 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies));
31 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers)); 32 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers));
32 HostContentSettingsMap* map = 33 HostContentSettingsMap* map =
33 browser()->profile()->GetHostContentSettingsMap(); 34 browser()->profile()->GetHostContentSettingsMap();
35 CookieSettings* cookie_settings = map->GetCookieSettings();
34 36
35 // Check default content settings by using an unknown URL. 37 // Check default content settings by using an unknown URL.
36 GURL example_url("http://www.example.com"); 38 GURL example_url("http://www.example.com");
37 EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, 39 EXPECT_TRUE(cookie_settings->IsCookieAllowed(
38 map->GetCookieContentSetting( 40 example_url, example_url, false));
39 example_url, example_url, false)); 41 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(example_url));
40 EXPECT_EQ(CONTENT_SETTING_ALLOW, 42 EXPECT_EQ(CONTENT_SETTING_ALLOW,
41 map->GetContentSetting(example_url, 43 map->GetContentSetting(example_url,
42 example_url, 44 example_url,
43 CONTENT_SETTINGS_TYPE_IMAGES, 45 CONTENT_SETTINGS_TYPE_IMAGES,
44 std::string())); 46 std::string()));
45 EXPECT_EQ(CONTENT_SETTING_BLOCK, 47 EXPECT_EQ(CONTENT_SETTING_BLOCK,
46 map->GetContentSetting(example_url, 48 map->GetContentSetting(example_url,
47 example_url, 49 example_url,
48 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 50 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
49 std::string())); 51 std::string()));
(...skipping 17 matching lines...) Expand all
67 std::string())); 69 std::string()));
68 #endif 70 #endif
69 EXPECT_EQ(CONTENT_SETTING_ASK, 71 EXPECT_EQ(CONTENT_SETTING_ASK,
70 map->GetContentSetting(example_url, 72 map->GetContentSetting(example_url,
71 example_url, 73 example_url,
72 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 74 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
73 std::string())); 75 std::string()));
74 76
75 // Check content settings for www.google.com 77 // Check content settings for www.google.com
76 GURL url("http://www.google.com"); 78 GURL url("http://www.google.com");
77 EXPECT_EQ(CONTENT_SETTING_BLOCK, 79 EXPECT_FALSE(cookie_settings->IsCookieAllowed(url, url, false));
78 map->GetCookieContentSetting(url, url, false));
79 EXPECT_EQ(CONTENT_SETTING_ALLOW, 80 EXPECT_EQ(CONTENT_SETTING_ALLOW,
80 map->GetContentSetting( 81 map->GetContentSetting(
81 url, url, CONTENT_SETTINGS_TYPE_IMAGES, "")); 82 url, url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
82 EXPECT_EQ(CONTENT_SETTING_BLOCK, 83 EXPECT_EQ(CONTENT_SETTING_BLOCK,
83 map->GetContentSetting( 84 map->GetContentSetting(
84 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); 85 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
85 EXPECT_EQ(CONTENT_SETTING_BLOCK, 86 EXPECT_EQ(CONTENT_SETTING_BLOCK,
86 map->GetContentSetting( 87 map->GetContentSetting(
87 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, "")); 88 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
88 EXPECT_EQ(CONTENT_SETTING_ALLOW, 89 EXPECT_EQ(CONTENT_SETTING_ALLOW,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 FilePath(kBarPath), 216 FilePath(kBarPath),
216 ASCIIToUTF16("2.3.4"), 217 ASCIIToUTF16("2.3.4"),
217 ASCIIToUTF16("bar"))); 218 ASCIIToUTF16("bar")));
218 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); 219 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list);
219 220
220 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) 221 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers"))
221 << message_; 222 << message_;
222 223
223 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); 224 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL);
224 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698