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 #include "xwalk/runtime/browser/android/xwalk_cookie_access_policy.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/browser/browser_thread.h"
12 using content::BrowserThread;
17 base::LazyInstance<XWalkCookieAccessPolicy>::Leaky g_lazy_instance;
20 XWalkCookieAccessPolicy::~XWalkCookieAccessPolicy() {
23 XWalkCookieAccessPolicy::XWalkCookieAccessPolicy()
24 : allow_access_(true) {
27 XWalkCookieAccessPolicy* XWalkCookieAccessPolicy::GetInstance() {
28 return g_lazy_instance.Pointer();
31 bool XWalkCookieAccessPolicy::GetGlobalAllowAccess() {
36 void XWalkCookieAccessPolicy::SetGlobalAllowAccess(bool allow) {
38 allow_access_ = allow;
41 bool XWalkCookieAccessPolicy::OnCanGetCookies(
42 const net::URLRequest& request,
43 const net::CookieList& cookie_list) {
44 return GetGlobalAllowAccess();
47 bool XWalkCookieAccessPolicy::OnCanSetCookie(
48 const net::URLRequest& request,
49 const std::string& cookie_line,
50 net::CookieOptions* options) {
51 return GetGlobalAllowAccess();
54 bool XWalkCookieAccessPolicy::AllowGetCookie(
56 const GURL& first_party,
57 const net::CookieList& cookie_list,
58 content::ResourceContext* context,
59 int render_process_id,
60 int render_frame_id) {
61 return GetGlobalAllowAccess();
64 bool XWalkCookieAccessPolicy::AllowSetCookie(
66 const GURL& first_party,
67 const std::string& cookie_line,
68 content::ResourceContext* context,
69 int render_process_id,
71 net::CookieOptions* options) {
72 return GetGlobalAllowAccess();