| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" | 5 #include "ios/chrome/browser/net/ios_chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; | 122 return net::NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION; |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool IOSChromeNetworkDelegate::OnCanGetCookies( | 125 bool IOSChromeNetworkDelegate::OnCanGetCookies( |
| 126 const net::URLRequest& request, | 126 const net::URLRequest& request, |
| 127 const net::CookieList& cookie_list) { | 127 const net::CookieList& cookie_list) { |
| 128 // Null during tests, or when we're running in the system context. | 128 // Null during tests, or when we're running in the system context. |
| 129 if (!cookie_settings_) | 129 if (!cookie_settings_) |
| 130 return true; | 130 return true; |
| 131 | 131 |
| 132 return cookie_settings_->IsReadingCookieAllowed( | 132 return cookie_settings_->IsCookieAccessAllowed( |
| 133 request.url(), request.first_party_for_cookies()); | 133 request.url(), request.first_party_for_cookies()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool IOSChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, | 136 bool IOSChromeNetworkDelegate::OnCanSetCookie(const net::URLRequest& request, |
| 137 const std::string& cookie_line, | 137 const std::string& cookie_line, |
| 138 net::CookieOptions* options) { | 138 net::CookieOptions* options) { |
| 139 // Null during tests, or when we're running in the system context. | 139 // Null during tests, or when we're running in the system context. |
| 140 if (!cookie_settings_) | 140 if (!cookie_settings_) |
| 141 return true; | 141 return true; |
| 142 | 142 |
| 143 return cookie_settings_->IsSettingCookieAllowed( | 143 return cookie_settings_->IsCookieAccessAllowed( |
| 144 request.url(), request.first_party_for_cookies()); | 144 request.url(), request.first_party_for_cookies()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool IOSChromeNetworkDelegate::OnCanAccessFile( | 147 bool IOSChromeNetworkDelegate::OnCanAccessFile( |
| 148 const net::URLRequest& request, | 148 const net::URLRequest& request, |
| 149 const base::FilePath& path) const { | 149 const base::FilePath& path) const { |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool IOSChromeNetworkDelegate::OnCanEnablePrivacyMode( | 153 bool IOSChromeNetworkDelegate::OnCanEnablePrivacyMode( |
| 154 const GURL& url, | 154 const GURL& url, |
| 155 const GURL& first_party_for_cookies) const { | 155 const GURL& first_party_for_cookies) const { |
| 156 // Null during tests, or when we're running in the system context. | 156 // Null during tests, or when we're running in the system context. |
| 157 if (!cookie_settings_.get()) | 157 if (!cookie_settings_.get()) |
| 158 return false; | 158 return false; |
| 159 | 159 |
| 160 bool reading_cookie_allowed = | 160 return !cookie_settings_->IsCookieAccessAllowed(url, first_party_for_cookies); |
| 161 cookie_settings_->IsReadingCookieAllowed(url, first_party_for_cookies); | |
| 162 bool setting_cookie_allowed = | |
| 163 cookie_settings_->IsSettingCookieAllowed(url, first_party_for_cookies); | |
| 164 bool privacy_mode = !(reading_cookie_allowed && setting_cookie_allowed); | |
| 165 return privacy_mode; | |
| 166 } | 161 } |
| 167 | 162 |
| 168 bool IOSChromeNetworkDelegate:: | 163 bool IOSChromeNetworkDelegate:: |
| 169 OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 164 OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
| 170 const net::URLRequest& request, | 165 const net::URLRequest& request, |
| 171 const GURL& target_url, | 166 const GURL& target_url, |
| 172 const GURL& referrer_url) const { | 167 const GURL& referrer_url) const { |
| 173 ReportInvalidReferrerSend(target_url, referrer_url); | 168 ReportInvalidReferrerSend(target_url, referrer_url); |
| 174 return true; | 169 return true; |
| 175 } | 170 } |
| OLD | NEW |