[Chromoting] Break up JS event handler registration into related groups.
[chromium-blink-merge.git] / android_webview / browser / aw_cookie_access_policy.cc
blob15158b919e39a133f0d3569863ae272e21d02708
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 "android_webview/browser/aw_cookie_access_policy.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "content/public/browser/browser_thread.h"
11 using base::AutoLock;
12 using content::BrowserThread;
14 namespace android_webview {
16 namespace {
17 base::LazyInstance<AwCookieAccessPolicy>::Leaky g_lazy_instance;
18 } // namespace
20 AwCookieAccessPolicy::~AwCookieAccessPolicy() {
23 AwCookieAccessPolicy::AwCookieAccessPolicy()
24 : allow_access_(true) {
27 AwCookieAccessPolicy* AwCookieAccessPolicy::GetInstance() {
28 return g_lazy_instance.Pointer();
31 bool AwCookieAccessPolicy::GetGlobalAllowAccess() {
32 AutoLock lock(lock_);
33 return allow_access_;
36 void AwCookieAccessPolicy::SetGlobalAllowAccess(bool allow) {
37 AutoLock lock(lock_);
38 allow_access_ = allow;
41 bool AwCookieAccessPolicy::OnCanGetCookies(const net::URLRequest& request,
42 const net::CookieList& cookie_list) {
43 return GetGlobalAllowAccess();
46 bool AwCookieAccessPolicy::OnCanSetCookie(const net::URLRequest& request,
47 const std::string& cookie_line,
48 net::CookieOptions* options) {
49 return GetGlobalAllowAccess();
52 bool AwCookieAccessPolicy::AllowGetCookie(const GURL& url,
53 const GURL& first_party,
54 const net::CookieList& cookie_list,
55 content::ResourceContext* context,
56 int render_process_id,
57 int render_frame_id) {
58 return GetGlobalAllowAccess();
61 bool AwCookieAccessPolicy::AllowSetCookie(const GURL& url,
62 const GURL& first_party,
63 const std::string& cookie_line,
64 content::ResourceContext* context,
65 int render_process_id,
66 int render_frame_id,
67 net::CookieOptions* options) {
68 return GetGlobalAllowAccess();
71 } // namespace android_webview