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

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

Powered by Google App Engine
This is Rietveld 408576698