| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/net/chrome_network_delegate.h" | 5 #include "chrome/browser/net/chrome_network_delegate.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } kEligibleMasks[] = { | 167 } kEligibleMasks[] = { |
| 168 // All text/ types are eligible, even if not displayable. | 168 // All text/ types are eligible, even if not displayable. |
| 169 { "text/", NULL }, | 169 { "text/", NULL }, |
| 170 // JSON (application/json and application/*+json) is eligible. | 170 // JSON (application/json and application/*+json) is eligible. |
| 171 { "application/", "json" }, | 171 { "application/", "json" }, |
| 172 // Javascript is eligible. | 172 // Javascript is eligible. |
| 173 { "application/", "javascript" }, | 173 { "application/", "javascript" }, |
| 174 // XML (application/xml and application/*+xml) is eligible. | 174 // XML (application/xml and application/*+xml) is eligible. |
| 175 { "application/", "xml" }, | 175 { "application/", "xml" }, |
| 176 }; | 176 }; |
| 177 const bool kCaseSensitive = true; | |
| 178 | 177 |
| 179 std::string mime_type; | 178 std::string mime_type; |
| 180 request->GetMimeType(&mime_type); | 179 request->GetMimeType(&mime_type); |
| 181 | 180 |
| 182 for (size_t i = 0; i < arraysize(kEligibleMasks); i++) { | 181 for (size_t i = 0; i < arraysize(kEligibleMasks); i++) { |
| 183 const char *prefix = kEligibleMasks[i].prefix; | 182 const char *prefix = kEligibleMasks[i].prefix; |
| 184 const char *suffix = kEligibleMasks[i].suffix; | 183 const char *suffix = kEligibleMasks[i].suffix; |
| 185 if (prefix && !base::StartsWithASCII(mime_type, prefix, kCaseSensitive)) | 184 if (prefix && |
| 185 !base::StartsWith(mime_type, prefix, base::CompareCase::SENSITIVE)) |
| 186 continue; | 186 continue; |
| 187 if (suffix && !base::EndsWith(mime_type, suffix, kCaseSensitive)) | 187 if (suffix && |
| 188 !base::EndsWith(mime_type, suffix, base::CompareCase::SENSITIVE)) |
| 188 continue; | 189 continue; |
| 189 return true; | 190 return true; |
| 190 } | 191 } |
| 191 return false; | 192 return false; |
| 192 } | 193 } |
| 193 | 194 |
| 194 // Returns whether |request| was issued by a renderer process, as opposed to | 195 // Returns whether |request| was issued by a renderer process, as opposed to |
| 195 // the browser process or a plugin process. | 196 // the browser process or a plugin process. |
| 196 bool IsRendererInitiatedRequest(const net::URLRequest* request) { | 197 bool IsRendererInitiatedRequest(const net::URLRequest* request) { |
| 197 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); | 198 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 return experimental_web_platform_features_enabled_; | 684 return experimental_web_platform_features_enabled_; |
| 684 } | 685 } |
| 685 | 686 |
| 686 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( | 687 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( |
| 687 const net::URLRequest& request, | 688 const net::URLRequest& request, |
| 688 const GURL& target_url, | 689 const GURL& target_url, |
| 689 const GURL& referrer_url) const { | 690 const GURL& referrer_url) const { |
| 690 ReportInvalidReferrerSend(target_url, referrer_url); | 691 ReportInvalidReferrerSend(target_url, referrer_url); |
| 691 return true; | 692 return true; |
| 692 } | 693 } |
| OLD | NEW |