| 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 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 15 #include "chrome/browser/prefs/pref_change_registrar.h" | 16 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 16 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" | 17 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" |
| 17 #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h" | 18 #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h" |
| 18 #include "chrome/common/content_settings.h" | 19 #include "chrome/common/content_settings.h" |
| 19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 20 | 21 |
| 21 class ContentSettingsPattern; | 22 class ContentSettingsPattern; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 bool setting_cookie, | 111 bool setting_cookie, |
| 111 content_settings::SettingSource* source) const; | 112 content_settings::SettingSource* source) const; |
| 112 | 113 |
| 113 static void RegisterUserPrefs(PrefService* prefs); | 114 static void RegisterUserPrefs(PrefService* prefs); |
| 114 | 115 |
| 115 class Factory : public RefcountedProfileKeyedServiceFactory { | 116 class Factory : public RefcountedProfileKeyedServiceFactory { |
| 116 public: | 117 public: |
| 117 // Returns the |CookieSettings| associated with the |profile|. | 118 // Returns the |CookieSettings| associated with the |profile|. |
| 118 // | 119 // |
| 119 // This should only be called on the UI thread. | 120 // This should only be called on the UI thread. |
| 120 static CookieSettings* GetForProfile(Profile* profile); | 121 static scoped_refptr<CookieSettings> GetForProfile(Profile* profile); |
| 121 | 122 |
| 122 static Factory* GetInstance(); | 123 static Factory* GetInstance(); |
| 123 | 124 |
| 124 private: | 125 private: |
| 125 friend struct DefaultSingletonTraits<Factory>; | 126 friend struct DefaultSingletonTraits<Factory>; |
| 126 | 127 |
| 127 Factory(); | 128 Factory(); |
| 128 virtual ~Factory(); | 129 virtual ~Factory(); |
| 129 | 130 |
| 130 // |ProfileKeyedBaseFactory| methods: | 131 // |ProfileKeyedBaseFactory| methods: |
| 131 virtual void RegisterUserPrefs(PrefService* user_prefs) OVERRIDE; | 132 virtual void RegisterUserPrefs(PrefService* user_prefs) OVERRIDE; |
| 132 virtual bool ServiceRedirectedInIncognito() OVERRIDE; | 133 virtual bool ServiceRedirectedInIncognito() OVERRIDE; |
| 133 virtual RefcountedProfileKeyedService* BuildServiceInstanceFor( | 134 virtual scoped_refptr<RefcountedProfileKeyedService> |
| 134 Profile* profile) const OVERRIDE; | 135 BuildServiceInstanceFor(Profile* profile) const OVERRIDE; |
| 135 }; | 136 }; |
| 136 | 137 |
| 137 private: | 138 private: |
| 138 // Returns true if the "block third party cookies" preference is set. | 139 // Returns true if the "block third party cookies" preference is set. |
| 139 // | 140 // |
| 140 // This method may be called on any thread. | 141 // This method may be called on any thread. |
| 141 bool ShouldBlockThirdPartyCookies() const; | 142 bool ShouldBlockThirdPartyCookies() const; |
| 142 | 143 |
| 143 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 144 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 144 PrefChangeRegistrar pref_change_registrar_; | 145 PrefChangeRegistrar pref_change_registrar_; |
| 145 | 146 |
| 146 // Used around accesses to |block_third_party_cookies_| to guarantee thread | 147 // Used around accesses to |block_third_party_cookies_| to guarantee thread |
| 147 // safety. | 148 // safety. |
| 148 mutable base::Lock lock_; | 149 mutable base::Lock lock_; |
| 149 | 150 |
| 150 bool block_third_party_cookies_; | 151 bool block_third_party_cookies_; |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ | 154 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ |
| OLD | NEW |