Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: chrome/browser/content_settings/cookie_settings.h

Issue 14622003: components: Move PrefRegistrySyncable into user_prefs namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/singleton.h" 12 #include "base/memory/singleton.h"
13 #include "base/prefs/pref_change_registrar.h" 13 #include "base/prefs/pref_change_registrar.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "chrome/browser/content_settings/host_content_settings_map.h" 15 #include "chrome/browser/content_settings/host_content_settings_map.h"
16 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" 16 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h"
17 #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h" 17 #include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h"
18 #include "chrome/common/content_settings.h" 18 #include "chrome/common/content_settings.h"
19 19
20 class ContentSettingsPattern; 20 class ContentSettingsPattern;
21 class CookieSettingsWrapper; 21 class CookieSettingsWrapper;
22 class GURL; 22 class GURL;
23 class PrefService; 23 class PrefService;
24 class PrefRegistrySyncable;
25 class Profile; 24 class Profile;
26 25
27 // A frontend to the cookie settings of |HostContentSettingsMap|. Handles 26 // A frontend to the cookie settings of |HostContentSettingsMap|. Handles
28 // cookie-specific logic such as blocking third-party cookies. Written on the UI 27 // cookie-specific logic such as blocking third-party cookies. Written on the UI
29 // thread and read on any thread. One instance per profile. 28 // thread and read on any thread. One instance per profile.
30 29 class CookieSettings : public RefcountedProfileKeyedService {
31 class CookieSettings
32 : public RefcountedProfileKeyedService {
33 public: 30 public:
34 CookieSettings( 31 CookieSettings(
35 HostContentSettingsMap* host_content_settings_map, 32 HostContentSettingsMap* host_content_settings_map,
36 PrefService* prefs); 33 PrefService* prefs);
37 34
38 // Returns the default content setting (CONTENT_SETTING_ALLOW, 35 // Returns the default content setting (CONTENT_SETTING_ALLOW,
39 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. If 36 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies. If
40 // |provider_id| is not NULL, the id of the provider which provided the 37 // |provider_id| is not NULL, the id of the provider which provided the
41 // default setting is assigned to it. 38 // default setting is assigned to it.
42 // 39 //
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // |Profile|. Afterwards, only const methods can be called. 92 // |Profile|. Afterwards, only const methods can be called.
96 virtual void ShutdownOnUIThread() OVERRIDE; 93 virtual void ShutdownOnUIThread() OVERRIDE;
97 94
98 // A helper for applying third party cookie blocking rules. 95 // A helper for applying third party cookie blocking rules.
99 ContentSetting GetCookieSetting( 96 ContentSetting GetCookieSetting(
100 const GURL& url, 97 const GURL& url,
101 const GURL& first_party_url, 98 const GURL& first_party_url,
102 bool setting_cookie, 99 bool setting_cookie,
103 content_settings::SettingSource* source) const; 100 content_settings::SettingSource* source) const;
104 101
105 static void RegisterUserPrefs(PrefRegistrySyncable* registry); 102 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry);
106 103
107 class Factory : public RefcountedProfileKeyedServiceFactory { 104 class Factory : public RefcountedProfileKeyedServiceFactory {
108 public: 105 public:
109 // Returns the |CookieSettings| associated with the |profile|. 106 // Returns the |CookieSettings| associated with the |profile|.
110 // 107 //
111 // This should only be called on the UI thread. 108 // This should only be called on the UI thread.
112 static scoped_refptr<CookieSettings> GetForProfile(Profile* profile); 109 static scoped_refptr<CookieSettings> GetForProfile(Profile* profile);
113 110
114 static Factory* GetInstance(); 111 static Factory* GetInstance();
115 112
116 private: 113 private:
117 friend struct DefaultSingletonTraits<Factory>; 114 friend struct DefaultSingletonTraits<Factory>;
118 115
119 Factory(); 116 Factory();
120 virtual ~Factory(); 117 virtual ~Factory();
121 118
122 // |ProfileKeyedBaseFactory| methods: 119 // |ProfileKeyedBaseFactory| methods:
123 virtual void RegisterUserPrefs(PrefRegistrySyncable* registry) OVERRIDE; 120 virtual void RegisterUserPrefs(
121 user_prefs::PrefRegistrySyncable* registry) OVERRIDE;
124 virtual content::BrowserContext* GetBrowserContextToUse( 122 virtual content::BrowserContext* GetBrowserContextToUse(
125 content::BrowserContext* context) const OVERRIDE; 123 content::BrowserContext* context) const OVERRIDE;
126 virtual scoped_refptr<RefcountedProfileKeyedService> 124 virtual scoped_refptr<RefcountedProfileKeyedService>
127 BuildServiceInstanceFor( 125 BuildServiceInstanceFor(
128 content::BrowserContext* context) const OVERRIDE; 126 content::BrowserContext* context) const OVERRIDE;
129 }; 127 };
130 128
131 private: 129 private:
132 virtual ~CookieSettings(); 130 virtual ~CookieSettings();
133 131
134 void OnBlockThirdPartyCookiesChanged(); 132 void OnBlockThirdPartyCookiesChanged();
135 133
136 // Returns true if the "block third party cookies" preference is set. 134 // Returns true if the "block third party cookies" preference is set.
137 // 135 //
138 // This method may be called on any thread. 136 // This method may be called on any thread.
139 bool ShouldBlockThirdPartyCookies() const; 137 bool ShouldBlockThirdPartyCookies() const;
140 138
141 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; 139 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
142 PrefChangeRegistrar pref_change_registrar_; 140 PrefChangeRegistrar pref_change_registrar_;
143 141
144 // Used around accesses to |block_third_party_cookies_| to guarantee thread 142 // Used around accesses to |block_third_party_cookies_| to guarantee thread
145 // safety. 143 // safety.
146 mutable base::Lock lock_; 144 mutable base::Lock lock_;
147 145
148 bool block_third_party_cookies_; 146 bool block_third_party_cookies_;
149 }; 147 };
150 148
151 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_ 149 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698