Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 may delay queries to ask the user to decide. |
| 20 // | 20 // |
| 21 // We will only prompt the user before setting a cookie. We do not prompt the | 21 // We will only prompt the user before setting a cookie. We do not prompt the |
|
jochen (gone - plz use gerrit)
2011/03/30 08:15:32
update the comment please
willchan no longer on Chromium
2011/04/04 12:29:18
Done.
| |
| 22 // user before getting a cookie. However, if we are in the process of | 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. | 23 // prompting the user, then any requests to get cookies will be deferred. |
| 24 // This is done so that cookie requests remain FIFO. | 24 // This is done so that cookie requests remain FIFO. |
| 25 // | 25 // |
| 26 class ChromeCookiePolicy | 26 class ChromeCookiePolicy : public net::CookiePolicy { |
| 27 : public base::RefCountedThreadSafe<ChromeCookiePolicy>, | |
| 28 public net::CookiePolicy { | |
| 29 public: | 27 public: |
| 30 explicit ChromeCookiePolicy(HostContentSettingsMap* map); | 28 explicit ChromeCookiePolicy(HostContentSettingsMap* map); |
| 31 virtual ~ChromeCookiePolicy(); | 29 virtual ~ChromeCookiePolicy(); |
| 32 | 30 |
| 33 // CookiePolicy methods: | 31 // CookiePolicy methods: |
| 34 virtual int CanGetCookies(const GURL& url, const GURL& first_party, | 32 virtual int CanGetCookies(const GURL& url, const GURL& first_party) const; |
| 35 net::CompletionCallback* callback); | 33 virtual int CanSetCookie(const GURL& url, |
| 36 virtual int CanSetCookie(const GURL& url, const GURL& first_party, | 34 const GURL& first_party, |
| 37 const std::string& cookie_line, | 35 const std::string& cookie_line) const; |
| 38 net::CompletionCallback* callback); | |
| 39 | 36 |
| 40 private: | 37 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; | 38 int CheckPolicy(const GURL& url) const; |
| 67 | 39 |
| 68 // A map from hostname to callbacks awaiting a cookie policy response. | 40 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 | 41 |
| 74 // True if blocking third-party cookies also applies to reading them. | 42 // True if blocking third-party cookies also applies to reading them. |
| 75 bool strict_third_party_blocking_; | 43 bool strict_third_party_blocking_; |
| 76 | 44 |
| 77 DISALLOW_COPY_AND_ASSIGN(ChromeCookiePolicy); | 45 DISALLOW_COPY_AND_ASSIGN(ChromeCookiePolicy); |
| 78 }; | 46 }; |
| 79 | 47 |
| 80 #endif // CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ | 48 #endif // CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_ |
| OLD | NEW |