Chromium Code Reviews| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <iterator> | 6 #include <iterator> |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 | 75 |
| 76 bool GetMimeTypeFromFile(const base::FilePath& file_path, | 76 bool GetMimeTypeFromFile(const base::FilePath& file_path, |
| 77 std::string* mime_type) const; | 77 std::string* mime_type) const; |
| 78 | 78 |
| 79 bool GetWellKnownMimeTypeFromExtension(const base::FilePath::StringType& ext, | 79 bool GetWellKnownMimeTypeFromExtension(const base::FilePath::StringType& ext, |
| 80 std::string* mime_type) const; | 80 std::string* mime_type) const; |
| 81 | 81 |
| 82 bool IsSupportedImageMimeType(const std::string& mime_type) const; | 82 bool IsSupportedImageMimeType(const std::string& mime_type) const; |
| 83 bool IsSupportedMediaMimeType(const std::string& mime_type) const; | 83 bool IsSupportedMediaMimeType(const std::string& mime_type) const; |
| 84 bool IsSupportedNonImageMimeType(const std::string& mime_type) const; | 84 bool IsSupportedNonImageMimeType(const std::string& mime_type) const; |
| 85 bool IsSupportedImagePrefixedMimeType(const std::string& mime_type) const; | |
| 85 bool IsUnsupportedTextMimeType(const std::string& mime_type) const; | 86 bool IsUnsupportedTextMimeType(const std::string& mime_type) const; |
| 86 bool IsSupportedJavascriptMimeType(const std::string& mime_type) const; | 87 bool IsSupportedJavascriptMimeType(const std::string& mime_type) const; |
| 87 | 88 |
| 88 bool IsSupportedMimeType(const std::string& mime_type) const; | 89 bool IsSupportedMimeType(const std::string& mime_type) const; |
| 89 | 90 |
| 90 bool MatchesMimeType(const std::string &mime_type_pattern, | 91 bool MatchesMimeType(const std::string &mime_type_pattern, |
| 91 const std::string &mime_type) const; | 92 const std::string &mime_type) const; |
| 92 | 93 |
| 93 bool ParseMimeTypeWithoutParameter(const std::string& type_string, | 94 bool ParseMimeTypeWithoutParameter(const std::string& type_string, |
| 94 std::string* top_level_type, | 95 std::string* top_level_type, |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 return javascript_map_.find(mime_type) != javascript_map_.end(); | 721 return javascript_map_.find(mime_type) != javascript_map_.end(); |
| 721 } | 722 } |
| 722 | 723 |
| 723 // Mirrors WebViewImpl::CanShowMIMEType() | 724 // Mirrors WebViewImpl::CanShowMIMEType() |
| 724 bool MimeUtil::IsSupportedMimeType(const std::string& mime_type) const { | 725 bool MimeUtil::IsSupportedMimeType(const std::string& mime_type) const { |
| 725 return (mime_type.compare(0, 6, "image/") == 0 && | 726 return (mime_type.compare(0, 6, "image/") == 0 && |
| 726 IsSupportedImageMimeType(mime_type)) || | 727 IsSupportedImageMimeType(mime_type)) || |
| 727 IsSupportedNonImageMimeType(mime_type); | 728 IsSupportedNonImageMimeType(mime_type); |
| 728 } | 729 } |
| 729 | 730 |
| 731 bool MimeUtil::IsSupportedImagePrefixedMimeType( | |
| 732 const std::string& mime_type) const { | |
| 733 return (mime_type.compare(0, 6, "image/") == 0 && | |
| 734 (IsSupportedImageMimeType(mime_type) || | |
| 735 IsSupportedNonImageMimeType(mime_type))); | |
|
Ryan Sleevi
2014/08/22 23:08:35
This doesn't really make sense to me.
Ryan Sleevi
2014/08/23 05:09:45
What I specifically mean is that you check for the
| |
| 736 } | |
| 730 // Tests for MIME parameter equality. Each parameter in the |mime_type_pattern| | 737 // Tests for MIME parameter equality. Each parameter in the |mime_type_pattern| |
| 731 // must be matched by a parameter in the |mime_type|. If there are no | 738 // must be matched by a parameter in the |mime_type|. If there are no |
| 732 // parameters in the pattern, the match is a success. | 739 // parameters in the pattern, the match is a success. |
| 733 bool MatchesMimeTypeParameters(const std::string& mime_type_pattern, | 740 bool MatchesMimeTypeParameters(const std::string& mime_type_pattern, |
| 734 const std::string& mime_type) { | 741 const std::string& mime_type) { |
| 735 const std::string::size_type semicolon = mime_type_pattern.find(';'); | 742 const std::string::size_type semicolon = mime_type_pattern.find(';'); |
| 736 const std::string::size_type test_semicolon = mime_type.find(';'); | 743 const std::string::size_type test_semicolon = mime_type.find(';'); |
| 737 if (semicolon != std::string::npos) { | 744 if (semicolon != std::string::npos) { |
| 738 if (test_semicolon == std::string::npos) | 745 if (test_semicolon == std::string::npos) |
| 739 return false; | 746 return false; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 } | 1080 } |
| 1074 | 1081 |
| 1075 bool IsSupportedMediaMimeType(const std::string& mime_type) { | 1082 bool IsSupportedMediaMimeType(const std::string& mime_type) { |
| 1076 return g_mime_util.Get().IsSupportedMediaMimeType(mime_type); | 1083 return g_mime_util.Get().IsSupportedMediaMimeType(mime_type); |
| 1077 } | 1084 } |
| 1078 | 1085 |
| 1079 bool IsSupportedNonImageMimeType(const std::string& mime_type) { | 1086 bool IsSupportedNonImageMimeType(const std::string& mime_type) { |
| 1080 return g_mime_util.Get().IsSupportedNonImageMimeType(mime_type); | 1087 return g_mime_util.Get().IsSupportedNonImageMimeType(mime_type); |
| 1081 } | 1088 } |
| 1082 | 1089 |
| 1090 bool IsSupportedImagePrefixedMimeType(const std::string& mime_type) { | |
| 1091 return g_mime_util.Get().IsSupportedImagePrefixedMimeType(mime_type); | |
| 1092 } | |
| 1093 | |
| 1083 bool IsUnsupportedTextMimeType(const std::string& mime_type) { | 1094 bool IsUnsupportedTextMimeType(const std::string& mime_type) { |
| 1084 return g_mime_util.Get().IsUnsupportedTextMimeType(mime_type); | 1095 return g_mime_util.Get().IsUnsupportedTextMimeType(mime_type); |
| 1085 } | 1096 } |
| 1086 | 1097 |
| 1087 bool IsSupportedJavascriptMimeType(const std::string& mime_type) { | 1098 bool IsSupportedJavascriptMimeType(const std::string& mime_type) { |
| 1088 return g_mime_util.Get().IsSupportedJavascriptMimeType(mime_type); | 1099 return g_mime_util.Get().IsSupportedJavascriptMimeType(mime_type); |
| 1089 } | 1100 } |
| 1090 | 1101 |
| 1091 bool IsSupportedMimeType(const std::string& mime_type) { | 1102 bool IsSupportedMimeType(const std::string& mime_type) { |
| 1092 return g_mime_util.Get().IsSupportedMimeType(mime_type); | 1103 return g_mime_util.Get().IsSupportedMimeType(mime_type); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1359 post_data->append("\r\n" + value + "\r\n"); | 1370 post_data->append("\r\n" + value + "\r\n"); |
| 1360 } | 1371 } |
| 1361 | 1372 |
| 1362 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 1373 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 1363 std::string* post_data) { | 1374 std::string* post_data) { |
| 1364 DCHECK(post_data); | 1375 DCHECK(post_data); |
| 1365 post_data->append("--" + mime_boundary + "--\r\n"); | 1376 post_data->append("--" + mime_boundary + "--\r\n"); |
| 1366 } | 1377 } |
| 1367 | 1378 |
| 1368 } // namespace net | 1379 } // namespace net |
| OLD | NEW |