| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 #include "blimp/engine/app/blimp_network_delegate.h" | |
| 6 | |
| 7 #include "net/base/net_errors.h" | |
| 8 #include "net/base/static_cookie_policy.h" | |
| 9 #include "net/url_request/url_request.h" | |
| 10 | |
| 11 namespace blimp { | |
| 12 namespace engine { | |
| 13 | |
| 14 namespace { | |
| 15 bool g_accept_all_cookies = true; | |
| 16 | |
| 17 net::StaticCookiePolicy::Type GetPolicyType() { | |
| 18 return g_accept_all_cookies | |
| 19 ? net::StaticCookiePolicy::ALLOW_ALL_COOKIES | |
| 20 : net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES; | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 BlimpNetworkDelegate::BlimpNetworkDelegate() {} | |
| 26 | |
| 27 BlimpNetworkDelegate::~BlimpNetworkDelegate() {} | |
| 28 | |
| 29 void BlimpNetworkDelegate::SetAcceptAllCookies(bool accept) { | |
| 30 g_accept_all_cookies = accept; | |
| 31 } | |
| 32 | |
| 33 bool BlimpNetworkDelegate::OnCanGetCookies(const net::URLRequest& request, | |
| 34 const net::CookieList& cookie_list) { | |
| 35 net::StaticCookiePolicy policy(GetPolicyType()); | |
| 36 int rv = | |
| 37 policy.CanGetCookies(request.url(), request.first_party_for_cookies()); | |
| 38 return rv == net::OK; | |
| 39 } | |
| 40 | |
| 41 bool BlimpNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, | |
| 42 const std::string& cookie_line, | |
| 43 net::CookieOptions* options) { | |
| 44 net::StaticCookiePolicy policy(GetPolicyType()); | |
| 45 int rv = | |
| 46 policy.CanSetCookie(request.url(), request.first_party_for_cookies()); | |
| 47 return rv == net::OK; | |
| 48 } | |
| 49 | |
| 50 } // namespace engine | |
| 51 } // namespace blimp | |
| OLD | NEW |