OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #ifndef NET_BASE_MIME_UTIL_H__ | 5 #ifndef NET_BASE_MIME_UTIL_H__ |
6 #define NET_BASE_MIME_UTIL_H__ | 6 #define NET_BASE_MIME_UTIL_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 // Get the mime type (if any) that is associated with the given file extension. | 14 // Get the mime type (if any) that is associated with the given file extension. |
15 // Returns true if a corresponding mime type exists. | 15 // Returns true if a corresponding mime type exists. |
16 bool GetMimeTypeFromExtension(const FilePath::StringType& ext, | 16 bool GetMimeTypeFromExtension(const FilePath::StringType& ext, |
17 std::string* mime_type); | 17 std::string* mime_type); |
18 | 18 |
19 // Get the mime type (if any) that is associated with the given file. Returns | 19 // Get the mime type (if any) that is associated with the given file. Returns |
20 // true if a corresponding mime type exists. | 20 // true if a corresponding mime type exists. |
21 bool GetMimeTypeFromFile(const FilePath& file_path, std::string* mime_type); | 21 bool GetMimeTypeFromFile(const FilePath& file_path, std::string* mime_type); |
22 | 22 |
23 // Get the preferred extension (if any) associated with the given mime type. | 23 // Get the preferred extension (if any) associated with the given mime type. |
24 // Returns true if a corresponding file extension exists. The extension is | 24 // Returns true if a corresponding file extension exists. The extension is |
25 // returned without a prefixed dot, ex "html". | 25 // returned without a prefixed dot, ex "html". |
26 bool GetPreferredExtensionForMimeType(const std::string& mime_type, | 26 bool GetPreferredExtensionForMimeType(const std::string& mime_type, |
27 FilePath::StringType* extension); | 27 FilePath::StringType* extension); |
28 | 28 |
29 // Check to see if a particular MIME type is in our list. | 29 // Check to see if a particular MIME type is in our list. |
30 bool IsSupportedImageMimeType(const char* mime_type); | 30 bool IsSupportedImageMimeType(const char* mime_type); |
| 31 bool IsSupportedMediaMimeType(const char* mime_type); |
31 bool IsSupportedNonImageMimeType(const char* mime_type); | 32 bool IsSupportedNonImageMimeType(const char* mime_type); |
32 bool IsSupportedJavascriptMimeType(const char* mime_type); | 33 bool IsSupportedJavascriptMimeType(const char* mime_type); |
33 | 34 |
34 // Get whether this mime type should be displayed in view-source mode. | 35 // Get whether this mime type should be displayed in view-source mode. |
35 // (For example, XML.) | 36 // (For example, XML.) |
36 bool IsViewSourceMimeType(const char* mime_type); | 37 bool IsViewSourceMimeType(const char* mime_type); |
37 | 38 |
38 // Convenience function. | 39 // Convenience function. |
39 bool IsSupportedMimeType(const std::string& mime_type); | 40 bool IsSupportedMimeType(const std::string& mime_type); |
40 | 41 |
41 // Returns true if this the mime_type_pattern matches a given mime-type. | 42 // Returns true if this the mime_type_pattern matches a given mime-type. |
42 // Checks for absolute matching and wildcards. mime-types should be in | 43 // Checks for absolute matching and wildcards. mime-types should be in |
43 // lower case. | 44 // lower case. |
44 bool MatchesMimeType(const std::string &mime_type_pattern, | 45 bool MatchesMimeType(const std::string &mime_type_pattern, |
45 const std::string &mime_type); | 46 const std::string &mime_type); |
46 | 47 |
47 } // namespace net | 48 } // namespace net |
48 | 49 |
49 #endif // NET_BASE_MIME_UTIL_H__ | 50 #endif // NET_BASE_MIME_UTIL_H__ |
OLD | NEW |