| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 bool IsAllowed(ContentSetting setting) { | 38 bool IsAllowed(ContentSetting setting) { |
| 39 DCHECK(IsValidSetting(setting)); | 39 DCHECK(IsValidSetting(setting)); |
| 40 return (setting == CONTENT_SETTING_ALLOW || | 40 return (setting == CONTENT_SETTING_ALLOW || |
| 41 setting == CONTENT_SETTING_SESSION_ONLY); | 41 setting == CONTENT_SETTING_SESSION_ONLY); |
| 42 } | 42 } |
| 43 | 43 |
| 44 } // namespace | 44 } // namespace |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 CookieSettings* CookieSettings::Factory::GetForProfile(Profile* profile) { | 47 scoped_refptr<CookieSettings> CookieSettings::Factory::GetForProfile( |
| 48 Profile* profile) { |
| 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 49 return static_cast<CookieSettings*>( | 50 return static_cast<CookieSettings*>( |
| 50 GetInstance()->GetBaseForProfile(profile, true)); | 51 GetInstance()->GetServiceForProfile(profile, true).get()); |
| 51 } | 52 } |
| 52 | 53 |
| 53 // static | 54 // static |
| 54 CookieSettings::Factory* CookieSettings::Factory::GetInstance() { | 55 CookieSettings::Factory* CookieSettings::Factory::GetInstance() { |
| 55 return Singleton<CookieSettings::Factory>::get(); | 56 return Singleton<CookieSettings::Factory>::get(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 CookieSettings::Factory::Factory() | 59 CookieSettings::Factory::Factory() |
| 59 : RefcountedProfileKeyedServiceFactory( | 60 : RefcountedProfileKeyedServiceFactory( |
| 60 "CookieSettings", | 61 "CookieSettings", |
| 61 ProfileDependencyManager::GetInstance()) { | 62 ProfileDependencyManager::GetInstance()) { |
| 62 } | 63 } |
| 63 | 64 |
| 64 CookieSettings::Factory::~Factory() {} | 65 CookieSettings::Factory::~Factory() {} |
| 65 | 66 |
| 66 void CookieSettings::Factory::RegisterUserPrefs(PrefService* user_prefs) { | 67 void CookieSettings::Factory::RegisterUserPrefs(PrefService* user_prefs) { |
| 67 user_prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, | 68 user_prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, |
| 68 false, | 69 false, |
| 69 PrefService::SYNCABLE_PREF); | 70 PrefService::SYNCABLE_PREF); |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool CookieSettings::Factory::ServiceRedirectedInIncognito() { | 73 bool CookieSettings::Factory::ServiceRedirectedInIncognito() { |
| 73 return true; | 74 return true; |
| 74 } | 75 } |
| 75 | 76 |
| 76 RefcountedProfileKeyedService* | 77 scoped_refptr<RefcountedProfileKeyedService> |
| 77 CookieSettings::Factory::BuildServiceInstanceFor(Profile* profile) const { | 78 CookieSettings::Factory::BuildServiceInstanceFor(Profile* profile) const { |
| 78 return new CookieSettings(profile->GetHostContentSettingsMap(), | 79 return new CookieSettings(profile->GetHostContentSettingsMap(), |
| 79 profile->GetPrefs()); | 80 profile->GetPrefs()); |
| 80 } | 81 } |
| 81 | 82 |
| 82 CookieSettings::CookieSettings( | 83 CookieSettings::CookieSettings( |
| 83 HostContentSettingsMap* host_content_settings_map, | 84 HostContentSettingsMap* host_content_settings_map, |
| 84 PrefService* prefs) | 85 PrefService* prefs) |
| 85 : host_content_settings_map_(host_content_settings_map), | 86 : host_content_settings_map_(host_content_settings_map), |
| 86 block_third_party_cookies_( | 87 block_third_party_cookies_( |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 224 |
| 224 // We should always have a value, at least from the default provider. | 225 // We should always have a value, at least from the default provider. |
| 225 DCHECK(value.get()); | 226 DCHECK(value.get()); |
| 226 return content_settings::ValueToContentSetting(value.get()); | 227 return content_settings::ValueToContentSetting(value.get()); |
| 227 } | 228 } |
| 228 | 229 |
| 229 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 230 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
| 230 base::AutoLock auto_lock(lock_); | 231 base::AutoLock auto_lock(lock_); |
| 231 return block_third_party_cookies_; | 232 return block_third_party_cookies_; |
| 232 } | 233 } |
| OLD | NEW |