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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 void CookieSettings::Factory::RegisterProfilePrefs( | 67 void CookieSettings::Factory::RegisterProfilePrefs( |
68 user_prefs::PrefRegistrySyncable* registry) { | 68 user_prefs::PrefRegistrySyncable* registry) { |
69 registry->RegisterBooleanPref( | 69 registry->RegisterBooleanPref( |
70 prefs::kBlockThirdPartyCookies, | 70 prefs::kBlockThirdPartyCookies, |
71 false, | 71 false, |
72 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 72 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
73 } | 73 } |
74 | 74 |
75 content::BrowserContext* CookieSettings::Factory::GetBrowserContextToUse( | 75 content::BrowserContext* CookieSettings::Factory::GetBrowserContextToUse( |
76 content::BrowserContext* context) const { | 76 content::BrowserContext* context) const { |
77 return chrome::GetBrowserContextRedirectedInIncognito(context); | 77 // The incognito profile has its own content settings map. Therefore, it |
| 78 // should get its own CookieSettings. |
| 79 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
78 } | 80 } |
79 | 81 |
80 scoped_refptr<RefcountedKeyedService> | 82 scoped_refptr<RefcountedKeyedService> |
81 CookieSettings::Factory::BuildServiceInstanceFor( | 83 CookieSettings::Factory::BuildServiceInstanceFor( |
82 content::BrowserContext* context) const { | 84 content::BrowserContext* context) const { |
83 Profile* profile = static_cast<Profile*>(context); | 85 Profile* profile = static_cast<Profile*>(context); |
84 return new CookieSettings(profile->GetHostContentSettingsMap(), | 86 return new CookieSettings(profile->GetHostContentSettingsMap(), |
85 profile->GetPrefs()); | 87 profile->GetPrefs()); |
86 } | 88 } |
87 | 89 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 224 |
223 base::AutoLock auto_lock(lock_); | 225 base::AutoLock auto_lock(lock_); |
224 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( | 226 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( |
225 prefs::kBlockThirdPartyCookies); | 227 prefs::kBlockThirdPartyCookies); |
226 } | 228 } |
227 | 229 |
228 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 230 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
229 base::AutoLock auto_lock(lock_); | 231 base::AutoLock auto_lock(lock_); |
230 return block_third_party_cookies_; | 232 return block_third_party_cookies_; |
231 } | 233 } |
OLD | NEW |