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.
5 #ifndef XWALK_RUNTIME_BROWSER_ANDROID_XWALK_COOKIE_ACCESS_POLICY_H_
6 #define XWALK_RUNTIME_BROWSER_ANDROID_XWALK_COOKIE_ACCESS_POLICY_H_
10 #include "base/basictypes.h"
11 #include "base/lazy_instance.h"
12 #include "base/synchronization/lock.h"
13 #include "net/cookies/canonical_cookie.h"
16 class ResourceContext;
28 // Manages the cookie access (both setting and getting) policy for WebView.
29 class XWalkCookieAccessPolicy {
31 static XWalkCookieAccessPolicy* GetInstance();
33 // These manage the global access state shared across requests regardless of
34 // source (i.e. network or JavaScript).
35 bool GetGlobalAllowAccess();
36 void SetGlobalAllowAccess(bool allow);
38 // These are the functions called when operating over cookies from the
39 // network. See NetworkDelegate for further descriptions.
40 bool OnCanGetCookies(const net::URLRequest& request,
41 const net::CookieList& cookie_list);
42 bool OnCanSetCookie(const net::URLRequest& request,
43 const std::string& cookie_line,
44 net::CookieOptions* options);
46 // These are the functions called when operating over cookies from the
47 // renderer. See ContentBrowserClient for further descriptions.
48 bool AllowGetCookie(const GURL& url,
49 const GURL& first_party,
50 const net::CookieList& cookie_list,
51 content::ResourceContext* context,
52 int render_process_id,
54 bool AllowSetCookie(const GURL& url,
55 const GURL& first_party,
56 const std::string& cookie_line,
57 content::ResourceContext* context,
58 int render_process_id,
60 net::CookieOptions* options);
63 friend struct base::DefaultLazyInstanceTraits<XWalkCookieAccessPolicy>;
65 XWalkCookieAccessPolicy();
66 ~XWalkCookieAccessPolicy();
70 DISALLOW_COPY_AND_ASSIGN(XWalkCookieAccessPolicy);
75 #endif // XWALK_RUNTIME_BROWSER_ANDROID_XWALK_COOKIE_ACCESS_POLICY_H_