| OLD | NEW |
| 1 // Copyright (c) 2010 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 NET_BASE_COOKIE_POLICY_H_ | 5 #ifndef NET_BASE_COOKIE_POLICY_H_ |
| 6 #define NET_BASE_COOKIE_POLICY_H_ | 6 #define NET_BASE_COOKIE_POLICY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
| 12 | 12 |
| 13 class GURL; | 13 class GURL; |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 // Alternative success codes for CookiePolicy::Can{Get,Set}Cookie(s). | 17 // Alternative success codes for CookiePolicy::Can{Get,Set}Cookie(s). |
| 18 enum { | 18 enum { |
| 19 OK_FOR_SESSION_ONLY = 1, // The cookie may be set but not persisted. | 19 OK_FOR_SESSION_ONLY = 1, // The cookie may be set but not persisted. |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 class CookiePolicy { | 22 class CookiePolicy { |
| 23 public: | 23 public: |
| 24 virtual ~CookiePolicy() {} | 24 virtual ~CookiePolicy() {} |
| 25 | 25 |
| 26 // Determines if the URL's cookies may be read. | 26 // Determines if the URL's cookies may be read. |
| 27 // | 27 // |
| 28 // Returns: | 28 // Returns: |
| 29 // OK - if allowed to read cookies | 29 // OK - if allowed to read cookies |
| 30 // ERR_ACCESS_DENIED - if not allowed to read cookies | 30 // ERR_ACCESS_DENIED - if not allowed to read cookies |
| 31 // ERR_IO_PENDING - if the result will be determined asynchronously | |
| 32 // | |
| 33 // If the return value is ERR_IO_PENDING, then the given callback will be | |
| 34 // notified once the final result is determined. Note: The callback must | |
| 35 // remain valid until notified. | |
| 36 virtual int CanGetCookies(const GURL& url, | 31 virtual int CanGetCookies(const GURL& url, |
| 37 const GURL& first_party_for_cookies, | 32 const GURL& first_party_for_cookies) const = 0; |
| 38 CompletionCallback* callback) = 0; | |
| 39 | |
| 40 // Determines if the URL's cookies may be written. Returns OK if allowed to | |
| 41 // write a cookie for the given URL. Returns ERR_IO_PENDING to indicate that | |
| 42 // the completion callback will be notified (asynchronously and on the | |
| 43 // current thread) of the final result. Note: The completion callback must | |
| 44 // remain valid until notified. | |
| 45 | 33 |
| 46 // Determines if the URL's cookies may be written. | 34 // Determines if the URL's cookies may be written. |
| 47 // | 35 // |
| 48 // Returns: | 36 // Returns: |
| 49 // OK - if allowed to write cookies | 37 // OK - if allowed to write cookies |
| 50 // OK_FOR_SESSION_ONLY - if allowed to write cookies, but forces them to | 38 // OK_FOR_SESSION_ONLY - if allowed to write cookies, but forces them to |
| 51 // be stored as session cookies | 39 // be stored as session cookies |
| 52 // ERR_ACCESS_DENIED - if not allowed to write cookies | 40 // ERR_ACCESS_DENIED - if not allowed to write cookies |
| 53 // ERR_IO_PENDING - if the result will be determined asynchronously | |
| 54 // | |
| 55 // If the return value is ERR_IO_PENDING, then the given callback will be | |
| 56 // notified once the final result is determined. Note: The callback must | |
| 57 // remain valid until notified. | |
| 58 virtual int CanSetCookie(const GURL& url, | 41 virtual int CanSetCookie(const GURL& url, |
| 59 const GURL& first_party_for_cookies, | 42 const GURL& first_party_for_cookies, |
| 60 const std::string& cookie_line, | 43 const std::string& cookie_line) const = 0; |
| 61 CompletionCallback* callback) = 0; | |
| 62 }; | 44 }; |
| 63 | 45 |
| 64 } // namespace net | 46 } // namespace net |
| 65 | 47 |
| 66 #endif // NET_BASE_COOKIE_POLICY_H_ | 48 #endif // NET_BASE_COOKIE_POLICY_H_ |
| OLD | NEW |