OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/network/mime/MIMETypeRegistry.h" | 5 #include "platform/network/mime/MIMETypeRegistry.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "components/mime_util/mime_util.h" | 9 #include "components/mime_util/mime_util.h" |
10 #include "media/base/mime_util.h" | 10 #include "media/base/mime_util.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (equalIgnoringCase(mimeType, "image/webp")) | 119 if (equalIgnoringCase(mimeType, "image/webp")) |
120 return true; | 120 return true; |
121 return false; | 121 return false; |
122 } | 122 } |
123 | 123 |
124 bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType) { | 124 bool MIMETypeRegistry::isSupportedJavaScriptMIMEType(const String& mimeType) { |
125 return mime_util::IsSupportedJavascriptMimeType( | 125 return mime_util::IsSupportedJavascriptMimeType( |
126 ToLowerASCIIOrEmpty(mimeType)); | 126 ToLowerASCIIOrEmpty(mimeType)); |
127 } | 127 } |
128 | 128 |
| 129 bool MIMETypeRegistry::isLegacySupportedJavaScriptLanguage( |
| 130 const String& language) { |
| 131 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only |
| 132 // javascript1.1 - javascript1.3. |
| 133 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. |
| 134 // WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. |
| 135 // Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. |
| 136 // We want to accept all the values that either of these browsers accept, but |
| 137 // not other values. |
| 138 |
| 139 // FIXME: This function is not HTML5 compliant. These belong in the MIME |
| 140 // registry as "text/javascript<version>" entries. |
| 141 return equalIgnoringASCIICase(language, "javascript") || |
| 142 equalIgnoringASCIICase(language, "javascript1.0") || |
| 143 equalIgnoringASCIICase(language, "javascript1.1") || |
| 144 equalIgnoringASCIICase(language, "javascript1.2") || |
| 145 equalIgnoringASCIICase(language, "javascript1.3") || |
| 146 equalIgnoringASCIICase(language, "javascript1.4") || |
| 147 equalIgnoringASCIICase(language, "javascript1.5") || |
| 148 equalIgnoringASCIICase(language, "javascript1.6") || |
| 149 equalIgnoringASCIICase(language, "javascript1.7") || |
| 150 equalIgnoringASCIICase(language, "livescript") || |
| 151 equalIgnoringASCIICase(language, "ecmascript") || |
| 152 equalIgnoringASCIICase(language, "jscript"); |
| 153 } |
| 154 |
129 bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType) { | 155 bool MIMETypeRegistry::isSupportedNonImageMIMEType(const String& mimeType) { |
130 return mime_util::IsSupportedNonImageMimeType(ToLowerASCIIOrEmpty(mimeType)); | 156 return mime_util::IsSupportedNonImageMimeType(ToLowerASCIIOrEmpty(mimeType)); |
131 } | 157 } |
132 | 158 |
133 bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType, | 159 bool MIMETypeRegistry::isSupportedMediaMIMEType(const String& mimeType, |
134 const String& codecs) { | 160 const String& codecs) { |
135 return supportsMediaMIMEType(mimeType, codecs) != IsNotSupported; | 161 return supportsMediaMIMEType(mimeType, codecs) != IsNotSupported; |
136 } | 162 } |
137 | 163 |
138 MIMETypeRegistry::SupportsType MIMETypeRegistry::supportsMediaMIMEType( | 164 MIMETypeRegistry::SupportsType MIMETypeRegistry::supportsMediaMIMEType( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 String subType = mimeType.substring(fontLen).lower(); | 206 String subType = mimeType.substring(fontLen).lower(); |
181 return subType == "woff" || subType == "woff2" || subType == "otf" || | 207 return subType == "woff" || subType == "woff2" || subType == "otf" || |
182 subType == "ttf" || subType == "sfnt"; | 208 subType == "ttf" || subType == "sfnt"; |
183 } | 209 } |
184 | 210 |
185 bool MIMETypeRegistry::isSupportedTextTrackMIMEType(const String& mimeType) { | 211 bool MIMETypeRegistry::isSupportedTextTrackMIMEType(const String& mimeType) { |
186 return equalIgnoringCase(mimeType, "text/vtt"); | 212 return equalIgnoringCase(mimeType, "text/vtt"); |
187 } | 213 } |
188 | 214 |
189 } // namespace blink | 215 } // namespace blink |
OLD | NEW |