Home | History | Annotate | Download | only in net
      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 CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_
      6 #define CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_
      7 #pragma once
      8 
      9 #include <map>
     10 #include <string>
     11 #include <vector>
     12 
     13 #include "base/memory/ref_counted.h"
     14 #include "googleurl/src/gurl.h"
     15 #include "net/base/cookie_policy.h"
     16 
     17 class HostContentSettingsMap;
     18 
     19 // Implements CookiePolicy that uses HostContentSettingsMap and
     20 // net::StaticCookiePolicy to decide if the cookie should be blocked.
     21 class ChromeCookiePolicy : public net::CookiePolicy {
     22  public:
     23   explicit ChromeCookiePolicy(HostContentSettingsMap* map);
     24   virtual ~ChromeCookiePolicy();
     25 
     26   // CookiePolicy methods:
     27   virtual int CanGetCookies(const GURL& url, const GURL& first_party) const;
     28   virtual int CanSetCookie(const GURL& url,
     29                            const GURL& first_party,
     30                            const std::string& cookie_line) const;
     31 
     32  private:
     33   int CheckPolicy(const GURL& url) const;
     34 
     35   const scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
     36 
     37   // True if blocking third-party cookies also applies to reading them.
     38   bool strict_third_party_blocking_;
     39 
     40   DISALLOW_COPY_AND_ASSIGN(ChromeCookiePolicy);
     41 };
     42 
     43 #endif  // CHROME_BROWSER_NET_CHROME_COOKIE_POLICY_H_
     44