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

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: Created 9 years, 4 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/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"
(...skipping 13 matching lines...) Expand all
24 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_; 24 EXPECT_TRUE(RunExtensionTest("content_settings/standard")) << message_;
25 25
26 const PrefService::Preference* pref = pref_service->FindPreference( 26 const PrefService::Preference* pref = pref_service->FindPreference(
27 prefs::kBlockThirdPartyCookies); 27 prefs::kBlockThirdPartyCookies);
28 ASSERT_TRUE(pref); 28 ASSERT_TRUE(pref);
29 EXPECT_TRUE(pref->IsExtensionControlled()); 29 EXPECT_TRUE(pref->IsExtensionControlled());
30 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies)); 30 EXPECT_FALSE(pref_service->GetBoolean(prefs::kBlockThirdPartyCookies));
31 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers)); 31 EXPECT_TRUE(pref_service->GetBoolean(prefs::kEnableReferrers));
32 HostContentSettingsMap* map = 32 HostContentSettingsMap* map =
33 browser()->profile()->GetHostContentSettingsMap(); 33 browser()->profile()->GetHostContentSettingsMap();
34 CookieContentSettings* cookie_content_settings =
35 browser()->profile()->GetCookieContentSettings();
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_content_settings->Allow(example_url, example_url, false));
38 map->GetCookieContentSetting( 40 EXPECT_TRUE(cookie_content_settings->EnforceSessionOnly(example_url));
39 example_url, example_url, false));
40 EXPECT_EQ(CONTENT_SETTING_ALLOW, 41 EXPECT_EQ(CONTENT_SETTING_ALLOW,
41 map->GetContentSetting(example_url, 42 map->GetContentSetting(example_url,
42 example_url, 43 example_url,
43 CONTENT_SETTINGS_TYPE_IMAGES, 44 CONTENT_SETTINGS_TYPE_IMAGES,
44 std::string())); 45 std::string()));
45 EXPECT_EQ(CONTENT_SETTING_BLOCK, 46 EXPECT_EQ(CONTENT_SETTING_BLOCK,
46 map->GetContentSetting(example_url, 47 map->GetContentSetting(example_url,
47 example_url, 48 example_url,
48 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 49 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
49 std::string())); 50 std::string()));
(...skipping 17 matching lines...) Expand all
67 std::string())); 68 std::string()));
68 #endif 69 #endif
69 EXPECT_EQ(CONTENT_SETTING_ASK, 70 EXPECT_EQ(CONTENT_SETTING_ASK,
70 map->GetContentSetting(example_url, 71 map->GetContentSetting(example_url,
71 example_url, 72 example_url,
72 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 73 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
73 std::string())); 74 std::string()));
74 75
75 // Check content settings for www.google.com 76 // Check content settings for www.google.com
76 GURL url("http://www.google.com"); 77 GURL url("http://www.google.com");
77 EXPECT_EQ(CONTENT_SETTING_BLOCK, 78 EXPECT_FALSE(cookie_content_settings->Allow(url, url, false));
78 map->GetCookieContentSetting(url, url, false));
79 EXPECT_EQ(CONTENT_SETTING_ALLOW, 79 EXPECT_EQ(CONTENT_SETTING_ALLOW,
80 map->GetContentSetting( 80 map->GetContentSetting(
81 url, url, CONTENT_SETTINGS_TYPE_IMAGES, "")); 81 url, url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
82 EXPECT_EQ(CONTENT_SETTING_BLOCK, 82 EXPECT_EQ(CONTENT_SETTING_BLOCK,
83 map->GetContentSetting( 83 map->GetContentSetting(
84 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, "")); 84 url, url, CONTENT_SETTINGS_TYPE_JAVASCRIPT, ""));
85 EXPECT_EQ(CONTENT_SETTING_BLOCK, 85 EXPECT_EQ(CONTENT_SETTING_BLOCK,
86 map->GetContentSetting( 86 map->GetContentSetting(
87 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, "")); 87 url, url, CONTENT_SETTINGS_TYPE_PLUGINS, ""));
88 EXPECT_EQ(CONTENT_SETTING_ALLOW, 88 EXPECT_EQ(CONTENT_SETTING_ALLOW,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 FilePath(kBarPath), 215 FilePath(kBarPath),
216 ASCIIToUTF16("2.3.4"), 216 ASCIIToUTF16("2.3.4"),
217 ASCIIToUTF16("bar"))); 217 ASCIIToUTF16("bar")));
218 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list); 218 GetResourceIdentifiersFunction::SetPluginListForTesting(&plugin_list);
219 219
220 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers")) 220 EXPECT_TRUE(RunExtensionTest("content_settings/getresourceidentifiers"))
221 << message_; 221 << message_;
222 222
223 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL); 223 GetResourceIdentifiersFunction::SetPluginListForTesting(NULL);
224 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698