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 "components/content_settings/core/browser/cookie_settings.h" | 5 #include "components/content_settings/core/browser/cookie_settings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "components/content_settings/core/browser/content_settings_utils.h" | 10 #include "components/content_settings/core/browser/content_settings_utils.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 bool CookieSettings::IsCookieSessionOnly(const GURL& origin) const { | 70 bool CookieSettings::IsCookieSessionOnly(const GURL& origin) const { |
71 ContentSetting setting = GetCookieSetting(origin, origin, true, NULL); | 71 ContentSetting setting = GetCookieSetting(origin, origin, true, NULL); |
72 DCHECK(IsValidSetting(setting)); | 72 DCHECK(IsValidSetting(setting)); |
73 return (setting == CONTENT_SETTING_SESSION_ONLY); | 73 return (setting == CONTENT_SETTING_SESSION_ONLY); |
74 } | 74 } |
75 | 75 |
76 void CookieSettings::GetCookieSettings( | 76 void CookieSettings::GetCookieSettings( |
77 ContentSettingsForOneType* settings) const { | 77 ContentSettingsForOneType* settings) const { |
| 78 // TODO(dgrogan): Why is this returning a value in a void function? |
78 return host_content_settings_map_->GetSettingsForOneType( | 79 return host_content_settings_map_->GetSettingsForOneType( |
79 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), settings); | 80 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), settings); |
80 } | 81 } |
81 | 82 |
82 void CookieSettings::RegisterProfilePrefs( | 83 void CookieSettings::RegisterProfilePrefs( |
83 user_prefs::PrefRegistrySyncable* registry) { | 84 user_prefs::PrefRegistrySyncable* registry) { |
84 registry->RegisterBooleanPref( | 85 registry->RegisterBooleanPref( |
85 prefs::kBlockThirdPartyCookies, false, | 86 prefs::kBlockThirdPartyCookies, false, |
86 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 87 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
87 } | 88 } |
(...skipping 18 matching lines...) Expand all Loading... |
106 } | 107 } |
107 | 108 |
108 void CookieSettings::ResetCookieSetting( | 109 void CookieSettings::ResetCookieSetting( |
109 const ContentSettingsPattern& primary_pattern, | 110 const ContentSettingsPattern& primary_pattern, |
110 const ContentSettingsPattern& secondary_pattern) { | 111 const ContentSettingsPattern& secondary_pattern) { |
111 host_content_settings_map_->SetContentSetting( | 112 host_content_settings_map_->SetContentSetting( |
112 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, | 113 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, |
113 std::string(), CONTENT_SETTING_DEFAULT); | 114 std::string(), CONTENT_SETTING_DEFAULT); |
114 } | 115 } |
115 | 116 |
| 117 void CookieSettings::GetDurableSettings( |
| 118 ContentSettingsForOneType* settings) const { |
| 119 // TODO(dgrogan): The std::string() is cargo culted and is a |
| 120 // "resource_identifier". The hell is that? |
| 121 host_content_settings_map_->GetSettingsForOneType( |
| 122 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), settings); |
| 123 } |
| 124 |
116 void CookieSettings::ShutdownOnUIThread() { | 125 void CookieSettings::ShutdownOnUIThread() { |
117 DCHECK(thread_checker_.CalledOnValidThread()); | 126 DCHECK(thread_checker_.CalledOnValidThread()); |
118 pref_change_registrar_.RemoveAll(); | 127 pref_change_registrar_.RemoveAll(); |
119 } | 128 } |
120 | 129 |
121 ContentSetting CookieSettings::GetCookieSetting(const GURL& url, | 130 ContentSetting CookieSettings::GetCookieSetting(const GURL& url, |
122 const GURL& first_party_url, | 131 const GURL& first_party_url, |
123 bool setting_cookie, | 132 bool setting_cookie, |
124 SettingSource* source) const { | 133 SettingSource* source) const { |
125 if (HostContentSettingsMap::ShouldAllowAllContent( | 134 if (HostContentSettingsMap::ShouldAllowAllContent( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( | 176 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( |
168 prefs::kBlockThirdPartyCookies); | 177 prefs::kBlockThirdPartyCookies); |
169 } | 178 } |
170 | 179 |
171 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 180 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
172 base::AutoLock auto_lock(lock_); | 181 base::AutoLock auto_lock(lock_); |
173 return block_third_party_cookies_; | 182 return block_third_party_cookies_; |
174 } | 183 } |
175 | 184 |
176 } // namespace content_settings | 185 } // namespace content_settings |
OLD | NEW |