| OLD | NEW |
| 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 "chrome/common/url_constants.h" |
| 19 #include "content/browser/user_metrics.h" | |
| 20 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/notification_source.h" | 21 #include "content/public/browser/notification_source.h" |
| 22 #include "content/public/browser/user_metrics.h" |
| 23 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 24 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 25 #include "net/base/static_cookie_policy.h" | 25 #include "net/base/static_cookie_policy.h" |
| 26 | 26 |
| 27 using content::BrowserThread; | 27 using content::BrowserThread; |
| 28 using content::UserMetricsAction; |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 | 31 |
| 31 bool IsValidSetting(ContentSetting setting) { | 32 bool IsValidSetting(ContentSetting setting) { |
| 32 return (setting == CONTENT_SETTING_ALLOW || | 33 return (setting == CONTENT_SETTING_ALLOW || |
| 33 setting == CONTENT_SETTING_SESSION_ONLY || | 34 setting == CONTENT_SETTING_SESSION_ONLY || |
| 34 setting == CONTENT_SETTING_BLOCK); | 35 setting == CONTENT_SETTING_BLOCK); |
| 35 } | 36 } |
| 36 | 37 |
| 37 bool IsAllowed(ContentSetting setting) { | 38 bool IsAllowed(ContentSetting setting) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return new CookieSettingsWrapper(cookie_settings); | 85 return new CookieSettingsWrapper(cookie_settings); |
| 85 } | 86 } |
| 86 | 87 |
| 87 CookieSettings::CookieSettings( | 88 CookieSettings::CookieSettings( |
| 88 HostContentSettingsMap* host_content_settings_map, | 89 HostContentSettingsMap* host_content_settings_map, |
| 89 PrefService* prefs) | 90 PrefService* prefs) |
| 90 : host_content_settings_map_(host_content_settings_map), | 91 : host_content_settings_map_(host_content_settings_map), |
| 91 block_third_party_cookies_( | 92 block_third_party_cookies_( |
| 92 prefs->GetBoolean(prefs::kBlockThirdPartyCookies)) { | 93 prefs->GetBoolean(prefs::kBlockThirdPartyCookies)) { |
| 93 if (block_third_party_cookies_) { | 94 if (block_third_party_cookies_) { |
| 94 UserMetrics::RecordAction( | 95 content::RecordAction( |
| 95 UserMetricsAction("ThirdPartyCookieBlockingEnabled")); | 96 UserMetricsAction("ThirdPartyCookieBlockingEnabled")); |
| 96 } else { | 97 } else { |
| 97 UserMetrics::RecordAction( | 98 content::RecordAction( |
| 98 UserMetricsAction("ThirdPartyCookieBlockingDisabled")); | 99 UserMetricsAction("ThirdPartyCookieBlockingDisabled")); |
| 99 } | 100 } |
| 100 | 101 |
| 101 pref_change_registrar_.Init(prefs); | 102 pref_change_registrar_.Init(prefs); |
| 102 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); | 103 pref_change_registrar_.Add(prefs::kBlockThirdPartyCookies, this); |
| 103 } | 104 } |
| 104 | 105 |
| 105 CookieSettings::~CookieSettings() { | 106 CookieSettings::~CookieSettings() { |
| 106 } | 107 } |
| 107 | 108 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 void CookieSettings::RegisterUserPrefs(PrefService* prefs) { | 245 void CookieSettings::RegisterUserPrefs(PrefService* prefs) { |
| 245 prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, | 246 prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, |
| 246 false, | 247 false, |
| 247 PrefService::SYNCABLE_PREF); | 248 PrefService::SYNCABLE_PREF); |
| 248 } | 249 } |
| 249 | 250 |
| 250 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 251 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
| 251 base::AutoLock auto_lock(lock_); | 252 base::AutoLock auto_lock(lock_); |
| 252 return block_third_party_cookies_; | 253 return block_third_party_cookies_; |
| 253 } | 254 } |
| OLD | NEW |