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 NET_BASE_COOKIE_POLICY_H_ 6 #define NET_BASE_COOKIE_POLICY_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "net/base/completion_callback.h" 12 13 class GURL; 14 15 namespace net { 16 17 // Alternative success codes for CookiePolicy::Can{Get,Set}Cookie(s). 18 enum { 19 OK_FOR_SESSION_ONLY = 1, // The cookie may be set but not persisted. 20 }; 21 22 class CookiePolicy { 23 public: 24 virtual ~CookiePolicy() {} 25 26 // Determines if the URL's cookies may be read. 27 // 28 // Returns: 29 // OK - if allowed to read cookies 30 // ERR_ACCESS_DENIED - if not allowed to read cookies 31 virtual int CanGetCookies(const GURL& url, 32 const GURL& first_party_for_cookies) const = 0; 33 34 // Determines if the URL's cookies may be written. 35 // 36 // Returns: 37 // OK - if allowed to write cookies 38 // OK_FOR_SESSION_ONLY - if allowed to write cookies, but forces them to 39 // be stored as session cookies 40 // ERR_ACCESS_DENIED - if not allowed to write cookies 41 virtual int CanSetCookie(const GURL& url, 42 const GURL& first_party_for_cookies, 43 const std::string& cookie_line) const = 0; 44 }; 45 46 } // namespace net 47 48 #endif // NET_BASE_COOKIE_POLICY_H_ 49