Commit 45be7c12 authored by abodenha@chromium.org's avatar abodenha@chromium.org

Allow chrome://* to always include cookies in secure XHRs.

If the user has third party cookies blocked and a piece of Chrome's
web ui needs to make an XHR to a logged in Google service (for
example Print Preview talking to Cloud Print) the cookies would be
blocked in the request.
Consensus on chromium-dev is that content block settings like this
should not apply to chrome UI.

Also adds unit tests for ShouldAllowAllContent.

BUG=136391
TEST=Unit tests should pass. Verify 136391.


Review URL: https://chromiumcodereview.appspot.com/10826089

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149317 0039d316-1c4b-4281-b951-d872f2087c98
parent e7b6cfe6
......@@ -497,6 +497,11 @@ bool HostContentSettingsMap::ShouldAllowAllContent(
content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
return false;
}
if (secondary_url.SchemeIs(chrome::kChromeUIScheme) &&
content_type == CONTENT_SETTINGS_TYPE_COOKIES &&
primary_url.SchemeIsSecure()) {
return true;
}
if (primary_url.SchemeIs(chrome::kExtensionScheme)) {
return content_type != CONTENT_SETTINGS_TYPE_PLUGINS &&
(content_type != CONTENT_SETTINGS_TYPE_COOKIES ||
......
......@@ -1017,7 +1017,7 @@ TEST_F(HostContentSettingsMapTest, SettingDefaultContentSettingsWhenManaged) {
CONTENT_SETTINGS_TYPE_PLUGINS, NULL));
}
TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) {
TEST_F(HostContentSettingsMapTest, GetContentSetting) {
TestingProfile profile;
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
......@@ -1040,6 +1040,37 @@ TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) {
embedder, host, CONTENT_SETTINGS_TYPE_IMAGES, ""));
}
TEST_F(HostContentSettingsMapTest, ShouldAllowAllContent) {
TestingProfile profile;
HostContentSettingsMap* host_content_settings_map =
profile.GetHostContentSettingsMap();
GURL http_host("http://example.com/");
GURL https_host("https://example.com/");
GURL embedder("chrome://foo");
GURL extension("chrome-extension://foo");
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
http_host, embedder, CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
http_host, embedder, CONTENT_SETTINGS_TYPE_GEOLOCATION));
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
http_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent(
https_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent(
https_host, embedder, CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent(
embedder, http_host, CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent(
extension, extension, CONTENT_SETTINGS_TYPE_COOKIES));
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
extension, extension, CONTENT_SETTINGS_TYPE_PLUGINS));
EXPECT_TRUE(host_content_settings_map->ShouldAllowAllContent(
extension, extension, CONTENT_SETTINGS_TYPE_INTENTS));
EXPECT_FALSE(host_content_settings_map->ShouldAllowAllContent(
extension, http_host, CONTENT_SETTINGS_TYPE_COOKIES));
}
TEST_F(HostContentSettingsMapTest, MigrateClearOnExit) {
TestingProfile profile;
TestingPrefService* prefs = profile.GetTestingPrefService();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment