| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 UserMetricsAction("ThirdPartyCookieBlockingEnabled")); | 91 UserMetricsAction("ThirdPartyCookieBlockingEnabled")); |
| 92 } else { | 92 } else { |
| 93 content::RecordAction( | 93 content::RecordAction( |
| 94 UserMetricsAction("ThirdPartyCookieBlockingDisabled")); | 94 UserMetricsAction("ThirdPartyCookieBlockingDisabled")); |
| 95 } | 95 } |
| 96 | 96 |
| 97 pref_change_registrar_.Init(prefs); | 97 pref_change_registrar_.Init(prefs); |
| 98 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); | 98 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); |
| 99 } | 99 } |
| 100 | 100 |
| 101 CookieSettings::~CookieSettings() { | |
| 102 } | |
| 103 | |
| 104 ContentSetting | 101 ContentSetting |
| 105 CookieSettings::GetDefaultCookieSetting(std::string* provider_id) const { | 102 CookieSettings::GetDefaultCookieSetting(std::string* provider_id) const { |
| 106 return host_content_settings_map_->GetDefaultContentSetting( | 103 return host_content_settings_map_->GetDefaultContentSetting( |
| 107 CONTENT_SETTINGS_TYPE_COOKIES, provider_id); | 104 CONTENT_SETTINGS_TYPE_COOKIES, provider_id); |
| 108 } | 105 } |
| 109 | 106 |
| 110 bool CookieSettings::IsReadingCookieAllowed(const GURL& url, | 107 bool CookieSettings::IsReadingCookieAllowed(const GURL& url, |
| 111 const GURL& first_party_url) const { | 108 const GURL& first_party_url) const { |
| 112 ContentSetting setting = GetCookieSetting(url, first_party_url, false, NULL); | 109 ContentSetting setting = GetCookieSetting(url, first_party_url, false, NULL); |
| 113 return IsAllowed(setting); | 110 return IsAllowed(setting); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 DCHECK_NE(net::ERR_IO_PENDING, rv); | 217 DCHECK_NE(net::ERR_IO_PENDING, rv); |
| 221 if (rv != net::OK) | 218 if (rv != net::OK) |
| 222 return CONTENT_SETTING_BLOCK; | 219 return CONTENT_SETTING_BLOCK; |
| 223 } | 220 } |
| 224 | 221 |
| 225 // We should always have a value, at least from the default provider. | 222 // We should always have a value, at least from the default provider. |
| 226 DCHECK(value.get()); | 223 DCHECK(value.get()); |
| 227 return content_settings::ValueToContentSetting(value.get()); | 224 return content_settings::ValueToContentSetting(value.get()); |
| 228 } | 225 } |
| 229 | 226 |
| 227 CookieSettings::~CookieSettings() {} |
| 228 |
| 230 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 229 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
| 231 base::AutoLock auto_lock(lock_); | 230 base::AutoLock auto_lock(lock_); |
| 232 return block_third_party_cookies_; | 231 return block_third_party_cookies_; |
| 233 } | 232 } |
| OLD | NEW |