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

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

Issue 7713034: HostContentSettingsMap refactoring. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixing the previous patch set. Created 9 years, 4 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_
7 #pragma once
8
9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/lock.h"
11 #include "chrome/browser/prefs/pref_change_registrar.h"
12 #include "chrome/common/content_settings.h"
13 #include "content/common/notification_observer.h"
14
15 class ContentSettingsPattern;
16 class GURL;
17 class HostContentSettingsMap;
18
19 // A frontend to the cookie-specific settings of HostContentSettingsMap. Handles
20 // cookie-specific logic such as blocking third-party cookies.
Bernhard Bauer 2011/08/28 19:18:49 You should add some comments about thread safety o
marja 2011/09/01 11:03:19 Done.
21 class CookieSettings
22 : public NotificationObserver,
23 public base::RefCountedThreadSafe<CookieSettings> {
24 public:
25 CookieSettings(
26 HostContentSettingsMap* host_content_settings_map,
27 PrefService* prefs,
28 bool incognito);
Bernhard Bauer 2011/08/28 19:18:49 These are all attributes of the Profile, so we cou
markusheintz_ 2011/08/29 08:47:09 If we do not pass in the profile but the stuff tha
marja 2011/08/30 13:14:08 I bumped into a problem when trying to make it a P
Bernhard Bauer 2011/08/30 13:20:25 Right (also, I guess you're on the IO thread there
marja 2011/09/01 11:03:19 Ok, I made it a ProfileKeyedService, and made Prof
Bernhard Bauer 2011/09/01 11:41:54 OK… but what happens after the profile is shutdown
marja 2011/09/01 13:34:48 Thanks for the hint. I did that, and changed raw p
29
30 // Returns the default content setting (CONTENT_SETTING_ALLOW,
31 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies.
32 ContentSetting GetDefaultSetting() const;
33
34 // Returns true if the page identified by (url, first_party_url) is allowed to
35 // set a cookie (permanent or session only).
36 bool IsCookieAllowed(const GURL& url,
Bernhard Bauer 2011/08/28 19:18:49 I think splitting this method up into two methods
marja 2011/09/01 11:03:19 Done.
37 const GURL& first_party_url,
38 bool setting_cookie) const;
39
40 // Returns true if the cookie set by a page identified by url should be
41 // session only. Querying this only makes sense if IsCookieAllowed has
42 // returned true.
43 bool IsCookieSessionOnly(const GURL& url) const;
44
45 // Sets the default content setting (CONTENT_SETTING_ALLOW,
46 // CONTENT_SETTING_BLOCK, or CONTENT_SETTING_SESSION_ONLY) for cookies.
47 void SetDefaultSetting(ContentSetting setting);
48
49 // Sets cookies allowed for (url, first_party_url) patterns matching
50 // (primary_pattern, secondary_pattern). The cookies can be permanent or
51 // session-only.
52 void SetCookieAllowed(const ContentSettingsPattern& primary_pattern,
53 const ContentSettingsPattern& secondary_pattern,
54 bool allowed);
55
56 // Sets whether an origin matching primary pattern can set session-only
57 // cookies or permanent cookies.
58 void SetCookieSessionOnly(const ContentSettingsPattern& primary_pattern,
59 bool session_only);
60
61 void ResetCookieAllowed(const ContentSettingsPattern& primary_pattern,
62 const ContentSettingsPattern& secondary_pattern);
63 void ResetCookieSessionOnly(const ContentSettingsPattern& primary_pattern);
64
65 // This setting trumps any host-specific settings.
66 bool BlockThirdPartyCookies() const { return block_third_party_cookies_; }
67 bool IsBlockThirdPartyCookiesManaged() const {
Bernhard Bauer 2011/08/28 19:18:49 Is this method called anywhere?
marja 2011/09/01 11:03:19 No; I removed it.
68 return is_block_third_party_cookies_managed_;
69 }
70
71 // Sets whether we block all third-party cookies. This method must not be
72 // invoked on an incognito map.
73 //
74 // This should only be called on the UI thread.
75 void SetBlockThirdPartyCookies(bool block);
Bernhard Bauer 2011/08/28 19:18:49 In the interest of simplicity, we could remove thi
marja 2011/09/01 11:03:19 This CL is getting bigger than expected; can I lea
Bernhard Bauer 2011/09/01 11:41:54 Ok, can you add a TODO for me (or yourself ;-) ) t
marja 2011/09/01 13:34:48 Done.
76
77 // NotificationObserver implementation.
78 virtual void Observe(int type,
79 const NotificationSource& source,
80 const NotificationDetails& details);
81
82 // Detaches the CookieSettings from all Profile-related objects like
83 // PrefService. This methods needs to be called before destroying the Profile.
84 // Afterwards, none of the methods above that should only be called on the UI
85 // thread should be called anymore.
86 void ShutdownOnUIThread();
87
88 private:
89 // Various migration methods (old cookie, popup and per-host data gets
90 // migrated to the new format).
91 void MigrateObsoleteCookiePref();
92
93 // A helper for retrieving data for CONTENT_TYPE_COOKIES and
94 // CONTENT_TYPE_COOKIES_SESSION_ONLY.
95 ContentSetting GetCookieContentSetting(const GURL& url,
96 const GURL& first_party_url,
97 ContentSettingsType content_type,
98 bool setting_cookie) const;
99
100 // Weak pointer to the data backend (which also owns this object).
101 HostContentSettingsMap* host_content_settings_map_;
102
103 // Weak; owned by the profile.
104 PrefService* prefs_;
105 PrefChangeRegistrar pref_change_registrar_;
106
107 bool is_off_the_record_;
108
109 // Used around accesses to the following objects to guarantee thread safety.
110 mutable base::Lock lock_;
111
112 // Misc global settings.
Bernhard Bauer 2011/08/28 19:18:49 Nit: This comment could be updated.
marja 2011/09/01 11:03:19 Done.
113 bool block_third_party_cookies_;
114 bool is_block_third_party_cookies_managed_;
115 };
116
117 #endif // CHROME_BROWSER_CONTENT_SETTINGS_COOKIE_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698