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

Side by Side Diff: chrome/browser/net/chrome_cookie_policy.h

Issue 6749044: Remove async functionality from net::CookiePolicy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/net/chrome_cookie_policy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_NET_CHROME_COOKIE_POLICY_H_ 5 #ifndef CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_
6 #define CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ 6 #define CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "net/base/cookie_policy.h" 15 #include "net/base/cookie_policy.h"
16 16
17 class HostContentSettingsMap; 17 class HostContentSettingsMap;
18 18
19 // Implements CookiePolicy that may delay queries to ask the user to decide. 19 // Implements CookiePolicy that uses HostContentSettingsMap and
20 // 20 // net::StaticCookiePolicy to decide if the cookie should be blocked.
21 // We will only prompt the user before setting a cookie. We do not prompt the 21 class ChromeCookiePolicy : public net::CookiePolicy {
22 // user before getting a cookie. However, if we are in the process of
23 // prompting the user, then any requests to get cookies will be deferred.
24 // This is done so that cookie requests remain FIFO.
25 //
26 class ChromeCookiePolicy
27 : public base::RefCountedThreadSafe<ChromeCookiePolicy>,
28 public net::CookiePolicy {
29 public: 22 public:
30 explicit ChromeCookiePolicy(HostContentSettingsMap* map); 23 explicit ChromeCookiePolicy(HostContentSettingsMap* map);
31 virtual ~ChromeCookiePolicy(); 24 virtual ~ChromeCookiePolicy();
32 25
33 // CookiePolicy methods: 26 // CookiePolicy methods:
34 virtual int CanGetCookies(const GURL& url, const GURL& first_party, 27 virtual int CanGetCookies(const GURL& url, const GURL& first_party) const;
35 net::CompletionCallback* callback); 28 virtual int CanSetCookie(const GURL& url,
36 virtual int CanSetCookie(const GURL& url, const GURL& first_party, 29 const GURL& first_party,
37 const std::string& cookie_line, 30 const std::string& cookie_line) const;
38 net::CompletionCallback* callback);
39 31
40 private: 32 private:
41 class Completion {
42 public:
43 static Completion ForSetCookie(net::CompletionCallback* callback) {
44 return Completion(true, callback);
45 }
46
47 static Completion ForGetCookies(net::CompletionCallback* callback) {
48 return Completion(false, callback);
49 }
50
51 bool is_set_cookie_request() const { return is_set_cookie_request_; }
52 net::CompletionCallback* callback() const { return callback_; }
53
54 private:
55 Completion(bool is_set_cookie_request, net::CompletionCallback* callback)
56 : is_set_cookie_request_(is_set_cookie_request),
57 callback_(callback) {
58 }
59
60 bool is_set_cookie_request_;
61 net::CompletionCallback* callback_;
62 };
63 typedef std::vector<Completion> Completions;
64 typedef std::map<std::string, Completions> HostCompletionsMap;
65
66 int CheckPolicy(const GURL& url) const; 33 int CheckPolicy(const GURL& url) const;
67 34
68 // A map from hostname to callbacks awaiting a cookie policy response. 35 const scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
69 // This map is only accessed on the IO thread.
70 HostCompletionsMap host_completions_map_;
71
72 scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
73 36
74 // True if blocking third-party cookies also applies to reading them. 37 // True if blocking third-party cookies also applies to reading them.
75 bool strict_third_party_blocking_; 38 bool strict_third_party_blocking_;
76 39
77 DISALLOW_COPY_AND_ASSIGN(ChromeCookiePolicy); 40 DISALLOW_COPY_AND_ASSIGN(ChromeCookiePolicy);
78 }; 41 };
79 42
80 #endif // CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ 43 #endif // CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/chrome_cookie_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698