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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
9 #include "net/base/platform_mime_util.h" | 9 #include "net/base/platform_mime_util.h" |
10 | 10 |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 void ParseCodecString(const std::string& codecs, | 707 void ParseCodecString(const std::string& codecs, |
708 std::vector<std::string>* codecs_out, | 708 std::vector<std::string>* codecs_out, |
709 const bool strip) { | 709 const bool strip) { |
710 g_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); | 710 g_mime_util.Get().ParseCodecString(codecs, codecs_out, strip); |
711 } | 711 } |
712 | 712 |
713 namespace { | 713 namespace { |
714 | 714 |
715 // From http://www.w3schools.com/media/media_mimeref.asp and | 715 // From http://www.w3schools.com/media/media_mimeref.asp and |
716 // http://plugindoc.mozdev.org/winmime.php | 716 // http://plugindoc.mozdev.org/winmime.php |
717 static const char* kStandardImageTypes[] = { | 717 static const char* const kStandardImageTypes[] = { |
718 "image/bmp", | 718 "image/bmp", |
719 "image/cis-cod", | 719 "image/cis-cod", |
720 "image/gif", | 720 "image/gif", |
721 "image/ief", | 721 "image/ief", |
722 "image/jpeg", | 722 "image/jpeg", |
723 "image/webp", | 723 "image/webp", |
724 "image/pict", | 724 "image/pict", |
725 "image/pipeg", | 725 "image/pipeg", |
726 "image/png", | 726 "image/png", |
727 "image/svg+xml", | 727 "image/svg+xml", |
728 "image/tiff", | 728 "image/tiff", |
729 "image/x-cmu-raster", | 729 "image/x-cmu-raster", |
730 "image/x-cmx", | 730 "image/x-cmx", |
731 "image/x-icon", | 731 "image/x-icon", |
732 "image/x-portable-anymap", | 732 "image/x-portable-anymap", |
733 "image/x-portable-bitmap", | 733 "image/x-portable-bitmap", |
734 "image/x-portable-graymap", | 734 "image/x-portable-graymap", |
735 "image/x-portable-pixmap", | 735 "image/x-portable-pixmap", |
736 "image/x-rgb", | 736 "image/x-rgb", |
737 "image/x-xbitmap", | 737 "image/x-xbitmap", |
738 "image/x-xpixmap", | 738 "image/x-xpixmap", |
739 "image/x-xwindowdump" | 739 "image/x-xwindowdump" |
740 }; | 740 }; |
741 static const char* kStandardAudioTypes[] = { | 741 static const char* const kStandardAudioTypes[] = { |
742 "audio/aac", | 742 "audio/aac", |
743 "audio/aiff", | 743 "audio/aiff", |
744 "audio/amr", | 744 "audio/amr", |
745 "audio/basic", | 745 "audio/basic", |
746 "audio/midi", | 746 "audio/midi", |
747 "audio/mp3", | 747 "audio/mp3", |
748 "audio/mp4", | 748 "audio/mp4", |
749 "audio/mpeg", | 749 "audio/mpeg", |
750 "audio/mpeg3", | 750 "audio/mpeg3", |
751 "audio/ogg", | 751 "audio/ogg", |
752 "audio/vorbis", | 752 "audio/vorbis", |
753 "audio/wav", | 753 "audio/wav", |
754 "audio/webm", | 754 "audio/webm", |
755 "audio/x-m4a", | 755 "audio/x-m4a", |
756 "audio/x-ms-wma", | 756 "audio/x-ms-wma", |
757 "audio/vnd.rn-realaudio", | 757 "audio/vnd.rn-realaudio", |
758 "audio/vnd.wave" | 758 "audio/vnd.wave" |
759 }; | 759 }; |
760 static const char* kStandardVideoTypes[] = { | 760 static const char* const kStandardVideoTypes[] = { |
761 "video/avi", | 761 "video/avi", |
762 "video/divx", | 762 "video/divx", |
763 "video/flc", | 763 "video/flc", |
764 "video/mp4", | 764 "video/mp4", |
765 "video/mpeg", | 765 "video/mpeg", |
766 "video/ogg", | 766 "video/ogg", |
767 "video/quicktime", | 767 "video/quicktime", |
768 "video/sd-video", | 768 "video/sd-video", |
769 "video/webm", | 769 "video/webm", |
770 "video/x-dv", | 770 "video/x-dv", |
771 "video/x-m4v", | 771 "video/x-m4v", |
772 "video/x-mpeg", | 772 "video/x-mpeg", |
773 "video/x-ms-asf", | 773 "video/x-ms-asf", |
774 "video/x-ms-wmv" | 774 "video/x-ms-wmv" |
775 }; | 775 }; |
776 | 776 |
777 struct StandardType { | 777 struct StandardType { |
778 const char* leading_mime_type; | 778 const char* leading_mime_type; |
779 const char** standard_types; | 779 const char* const* standard_types; |
780 size_t standard_types_len; | 780 size_t standard_types_len; |
781 }; | 781 }; |
782 static const StandardType kStandardTypes[] = { | 782 static const StandardType kStandardTypes[] = { |
783 { "image/", kStandardImageTypes, arraysize(kStandardImageTypes) }, | 783 { "image/", kStandardImageTypes, arraysize(kStandardImageTypes) }, |
784 { "audio/", kStandardAudioTypes, arraysize(kStandardAudioTypes) }, | 784 { "audio/", kStandardAudioTypes, arraysize(kStandardAudioTypes) }, |
785 { "video/", kStandardVideoTypes, arraysize(kStandardVideoTypes) }, | 785 { "video/", kStandardVideoTypes, arraysize(kStandardVideoTypes) }, |
786 { NULL, NULL, 0 } | 786 { NULL, NULL, 0 } |
787 }; | 787 }; |
788 | 788 |
789 void GetExtensionsFromHardCodedMappings( | 789 void GetExtensionsFromHardCodedMappings( |
(...skipping 12 matching lines...) Expand all Loading... |
802 FilePath::StringType extension(UTF8ToWide(this_extensions[j])); | 802 FilePath::StringType extension(UTF8ToWide(this_extensions[j])); |
803 #else | 803 #else |
804 FilePath::StringType extension(this_extensions[j]); | 804 FilePath::StringType extension(this_extensions[j]); |
805 #endif | 805 #endif |
806 extensions->insert(extension); | 806 extensions->insert(extension); |
807 } | 807 } |
808 } | 808 } |
809 } | 809 } |
810 } | 810 } |
811 | 811 |
812 void GetExtensionsHelper(const char** standard_types, | 812 void GetExtensionsHelper(const char* const* standard_types, |
813 size_t standard_types_len, | 813 size_t standard_types_len, |
814 const std::string& leading_mime_type, | 814 const std::string& leading_mime_type, |
815 base::hash_set<FilePath::StringType>* extensions) { | 815 base::hash_set<FilePath::StringType>* extensions) { |
816 for (size_t i = 0; i < standard_types_len; ++i) { | 816 for (size_t i = 0; i < standard_types_len; ++i) { |
817 g_mime_util.Get().GetPlatformExtensionsForMimeType(standard_types[i], | 817 g_mime_util.Get().GetPlatformExtensionsForMimeType(standard_types[i], |
818 extensions); | 818 extensions); |
819 } | 819 } |
820 | 820 |
821 // Also look up the extensions from hard-coded mappings in case that some | 821 // Also look up the extensions from hard-coded mappings in case that some |
822 // supported extensions are not registered in the system registry, like ogg. | 822 // supported extensions are not registered in the system registry, like ogg. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 const std::string GetIANAMediaType(const std::string& mime_type) { | 916 const std::string GetIANAMediaType(const std::string& mime_type) { |
917 for (size_t i = 0; i < arraysize(kIanaMediaTypes); ++i) { | 917 for (size_t i = 0; i < arraysize(kIanaMediaTypes); ++i) { |
918 if (StartsWithASCII(mime_type, kIanaMediaTypes[i].matcher, true)) { | 918 if (StartsWithASCII(mime_type, kIanaMediaTypes[i].matcher, true)) { |
919 return kIanaMediaTypes[i].name; | 919 return kIanaMediaTypes[i].name; |
920 } | 920 } |
921 } | 921 } |
922 return ""; | 922 return ""; |
923 } | 923 } |
924 | 924 |
925 } // namespace net | 925 } // namespace net |
OLD | NEW |