| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Detecting mime types is a tricky business because we need to balance | 5 // Detecting mime types is a tricky business because we need to balance |
| 6 // compatibility concerns with security issues. Here is a survey of how other | 6 // compatibility concerns with security issues. Here is a survey of how other |
| 7 // browsers behave and then a description of how we intend to behave. | 7 // browsers behave and then a description of how we intend to behave. |
| 8 // | 8 // |
| 9 // HTML payload, no Content-Type header: | 9 // HTML payload, no Content-Type header: |
| 10 // * IE 7: Render as HTML | 10 // * IE 7: Render as HTML |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 MAGIC_HTML_TAG("title") // Mozilla | 206 MAGIC_HTML_TAG("title") // Mozilla |
| 207 MAGIC_HTML_TAG("b") // Mozilla | 207 MAGIC_HTML_TAG("b") // Mozilla |
| 208 MAGIC_HTML_TAG("body") // Mozilla | 208 MAGIC_HTML_TAG("body") // Mozilla |
| 209 MAGIC_HTML_TAG("br") | 209 MAGIC_HTML_TAG("br") |
| 210 MAGIC_HTML_TAG("p") // Mozilla | 210 MAGIC_HTML_TAG("p") // Mozilla |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 static scoped_refptr<Histogram> UMASnifferHistogramGet(const char* name, | 213 static scoped_refptr<Histogram> UMASnifferHistogramGet(const char* name, |
| 214 int array_size) { | 214 int array_size) { |
| 215 scoped_refptr<Histogram> counter = | 215 scoped_refptr<Histogram> counter = |
| 216 LinearHistogram::LinearHistogramFactoryGet( | 216 LinearHistogram::FactoryGet(name, 1, array_size - 1, array_size, |
| 217 name, 1, array_size - 1, array_size); | 217 Histogram::kUmaTargetedHistogramFlag); |
| 218 counter->SetFlags(kUmaTargetedHistogramFlag); | |
| 219 return counter; | 218 return counter; |
| 220 } | 219 } |
| 221 | 220 |
| 222 static bool MatchMagicNumber(const char* content, size_t size, | 221 static bool MatchMagicNumber(const char* content, size_t size, |
| 223 const MagicNumber* magic_entry, | 222 const MagicNumber* magic_entry, |
| 224 std::string* result) { | 223 std::string* result) { |
| 225 const size_t len = magic_entry->magic_len; | 224 const size_t len = magic_entry->magic_len; |
| 226 | 225 |
| 227 // Keep kBytesRequiredForMagic honest. | 226 // Keep kBytesRequiredForMagic honest. |
| 228 DCHECK(len <= kBytesRequiredForMagic); | 227 DCHECK(len <= kBytesRequiredForMagic); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 result->assign("text/plain"); | 602 result->assign("text/plain"); |
| 604 // We could change our mind if a binary-looking byte appears later in | 603 // We could change our mind if a binary-looking byte appears later in |
| 605 // the content, so we only have enough content if we have the max. | 604 // the content, so we only have enough content if we have the max. |
| 606 return content_size >= kMaxBytesToSniff; | 605 return content_size >= kMaxBytesToSniff; |
| 607 } | 606 } |
| 608 | 607 |
| 609 return have_enough_content; | 608 return have_enough_content; |
| 610 } | 609 } |
| 611 | 610 |
| 612 } // namespace net | 611 } // namespace net |
| OLD | NEW |