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

Side by Side Diff: chrome/browser/content_settings/cookie_settings.cc

Issue 8462003: Exempt chrome-extension:// from third-party cookie rules, but not from regular content settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/content_settings/cookie_settings_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/content_settings/cookie_settings.h" 5 #include "chrome/browser/content_settings/cookie_settings.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/content_settings/content_settings_utils.h" 8 #include "chrome/browser/content_settings/content_settings_utils.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/profiles/profile_dependency_manager.h" 12 #include "chrome/browser/profiles/profile_dependency_manager.h"
13 #include "chrome/browser/profiles/profile_keyed_service.h" 13 #include "chrome/browser/profiles/profile_keyed_service.h"
14 #include "chrome/common/chrome_notification_types.h" 14 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/content_settings_pattern.h" 16 #include "chrome/common/content_settings_pattern.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/common/url_constants.h"
18 #include "content/browser/user_metrics.h" 19 #include "content/browser/user_metrics.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
22 #include "googleurl/src/gurl.h" 23 #include "googleurl/src/gurl.h"
23 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
24 #include "net/base/static_cookie_policy.h" 25 #include "net/base/static_cookie_policy.h"
25 26
26 using content::BrowserThread; 27 using content::BrowserThread;
27 28
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void CookieSettings::ShutdownOnUIThread() { 195 void CookieSettings::ShutdownOnUIThread() {
195 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 196 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
196 pref_change_registrar_.RemoveAll(); 197 pref_change_registrar_.RemoveAll();
197 } 198 }
198 199
199 ContentSetting CookieSettings::GetCookieSetting( 200 ContentSetting CookieSettings::GetCookieSetting(
200 const GURL& url, 201 const GURL& url,
201 const GURL& first_party_url, 202 const GURL& first_party_url,
202 bool setting_cookie) const { 203 bool setting_cookie) const {
203 if (HostContentSettingsMap::ShouldAllowAllContent( 204 if (HostContentSettingsMap::ShouldAllowAllContent(
204 url, CONTENT_SETTINGS_TYPE_COOKIES)) { 205 url, first_party_url, CONTENT_SETTINGS_TYPE_COOKIES))
205 return CONTENT_SETTING_ALLOW; 206 return CONTENT_SETTING_ALLOW;
206 }
207 207
208 ContentSettingsPattern primary_pattern; 208 ContentSettingsPattern primary_pattern;
209 ContentSettingsPattern secondary_pattern; 209 ContentSettingsPattern secondary_pattern;
210 // First get any host-specific settings. 210 // First get any host-specific settings.
211 scoped_ptr<base::Value> value( 211 scoped_ptr<base::Value> value(
212 host_content_settings_map_->GetContentSettingValue( 212 host_content_settings_map_->GetContentSettingValue(
213 url, first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, "", 213 url, first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, "",
214 &primary_pattern, &secondary_pattern)); 214 &primary_pattern, &secondary_pattern));
215 215
216 // If no explicit exception has been made and third-party cookies are blocked 216 // If no explicit exception has been made and third-party cookies are blocked
217 // by default, apply that rule. 217 // by default, apply that rule.
218 if (primary_pattern == ContentSettingsPattern::Wildcard() && 218 if (primary_pattern == ContentSettingsPattern::Wildcard() &&
219 secondary_pattern == ContentSettingsPattern::Wildcard() && 219 secondary_pattern == ContentSettingsPattern::Wildcard() &&
220 ShouldBlockThirdPartyCookies()) { 220 ShouldBlockThirdPartyCookies() &&
221 !first_party_url.SchemeIs(chrome::kExtensionScheme)) {
221 bool strict = CommandLine::ForCurrentProcess()->HasSwitch( 222 bool strict = CommandLine::ForCurrentProcess()->HasSwitch(
222 switches::kBlockReadingThirdPartyCookies); 223 switches::kBlockReadingThirdPartyCookies);
223 net::StaticCookiePolicy policy(strict ? 224 net::StaticCookiePolicy policy(strict ?
224 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : 225 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES :
225 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); 226 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES);
226 int rv; 227 int rv;
227 if (setting_cookie) 228 if (setting_cookie)
228 rv = policy.CanSetCookie(url, first_party_url); 229 rv = policy.CanSetCookie(url, first_party_url);
229 else 230 else
230 rv = policy.CanGetCookies(url, first_party_url); 231 rv = policy.CanGetCookies(url, first_party_url);
(...skipping 11 matching lines...) Expand all
242 void CookieSettings::RegisterUserPrefs(PrefService* prefs) { 243 void CookieSettings::RegisterUserPrefs(PrefService* prefs) {
243 prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, 244 prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies,
244 false, 245 false,
245 PrefService::SYNCABLE_PREF); 246 PrefService::SYNCABLE_PREF);
246 } 247 }
247 248
248 bool CookieSettings::ShouldBlockThirdPartyCookies() const { 249 bool CookieSettings::ShouldBlockThirdPartyCookies() const {
249 base::AutoLock auto_lock(lock_); 250 base::AutoLock auto_lock(lock_);
250 return block_third_party_cookies_; 251 return block_third_party_cookies_;
251 } 252 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/cookie_settings_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698