1// Copyright (c) 2012 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_COOKIES_COOKIE_UTIL_H_
6#define NET_COOKIES_COOKIE_UTIL_H_
7
8#include <string>
9
10#include "base/time/time.h"
11#include "net/base/net_export.h"
12
13class GURL;
14
15namespace net {
16namespace cookie_util {
17
18// Returns the effective TLD+1 for a given host. This only makes sense for http
19// and https schemes. For other schemes, the host will be returned unchanged
20// (minus any leading period).
21NET_EXPORT std::string GetEffectiveDomain(const std::string& scheme,
22                                          const std::string& host);
23
24// Determine the actual cookie domain based on the domain string passed
25// (if any) and the URL from which the cookie came.
26// On success returns true, and sets cookie_domain to either a
27//   -host cookie domain (ex: "google.com")
28//   -domain cookie domain (ex: ".google.com")
29NET_EXPORT bool GetCookieDomainWithString(const GURL& url,
30                                          const std::string& domain_string,
31                                          std::string* result);
32
33// Returns true if a domain string represents a host-only cookie,
34// i.e. it doesn't begin with a leading '.' character.
35NET_EXPORT bool DomainIsHostOnly(const std::string& domain_string);
36
37// Parses the string with the cookie time (very forgivingly).
38NET_EXPORT base::Time ParseCookieTime(const std::string& time_string);
39
40// Convenience for converting a cookie origin (domain and https pair) to a URL.
41NET_EXPORT GURL CookieOriginToURL(const std::string& domain, bool is_https);
42
43}  // namspace cookie_util
44}  // namespace net
45
46#endif  // NET_COOKIES_COOKIE_UTIL_H_
47