| 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 // 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // definition and roughly the same as Firefox's definition. | 93 // definition and roughly the same as Firefox's definition. |
| 94 | 94 |
| 95 #include <string> | 95 #include <string> |
| 96 | 96 |
| 97 #include "net/base/mime_sniffer.h" | 97 #include "net/base/mime_sniffer.h" |
| 98 | 98 |
| 99 #include "base/basictypes.h" | 99 #include "base/basictypes.h" |
| 100 #include "base/logging.h" | 100 #include "base/logging.h" |
| 101 #include "base/metrics/histogram.h" | 101 #include "base/metrics/histogram.h" |
| 102 #include "base/strings/string_util.h" | 102 #include "base/strings/string_util.h" |
| 103 #include "googleurl/src/gurl.h" | |
| 104 #include "net/base/mime_util.h" | 103 #include "net/base/mime_util.h" |
| 104 #include "url/gurl.h" |
| 105 | 105 |
| 106 namespace net { | 106 namespace net { |
| 107 | 107 |
| 108 // The number of content bytes we need to use all our magic numbers. Feel free | 108 // The number of content bytes we need to use all our magic numbers. Feel free |
| 109 // to increase this number if you add a longer magic number. | 109 // to increase this number if you add a longer magic number. |
| 110 static const size_t kBytesRequiredForMagic = 42; | 110 static const size_t kBytesRequiredForMagic = 42; |
| 111 | 111 |
| 112 struct MagicNumber { | 112 struct MagicNumber { |
| 113 const char* mime_type; | 113 const char* mime_type; |
| 114 const char* magic; | 114 const char* magic; |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 // First check the extra table. | 959 // First check the extra table. |
| 960 if (CheckForMagicNumbers(content, size, kExtraMagicNumbers, | 960 if (CheckForMagicNumbers(content, size, kExtraMagicNumbers, |
| 961 arraysize(kExtraMagicNumbers), NULL, result)) | 961 arraysize(kExtraMagicNumbers), NULL, result)) |
| 962 return true; | 962 return true; |
| 963 // Finally check the original table. | 963 // Finally check the original table. |
| 964 return CheckForMagicNumbers(content, size, kMagicNumbers, | 964 return CheckForMagicNumbers(content, size, kMagicNumbers, |
| 965 arraysize(kMagicNumbers), NULL, result); | 965 arraysize(kMagicNumbers), NULL, result); |
| 966 } | 966 } |
| 967 | 967 |
| 968 } // namespace net | 968 } // namespace net |
| OLD | NEW |