Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: net/base/mime_util.cc

Issue 4232003: Add webp mime type for omnibpx (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const char* mime_type; 75 const char* mime_type;
76 const char* extensions; // comma separated list 76 const char* extensions; // comma separated list
77 }; 77 };
78 78
79 static const MimeInfo primary_mappings[] = { 79 static const MimeInfo primary_mappings[] = {
80 { "text/html", "html,htm" }, 80 { "text/html", "html,htm" },
81 { "text/css", "css" }, 81 { "text/css", "css" },
82 { "text/xml", "xml" }, 82 { "text/xml", "xml" },
83 { "image/gif", "gif" }, 83 { "image/gif", "gif" },
84 { "image/jpeg", "jpeg,jpg" }, 84 { "image/jpeg", "jpeg,jpg" },
85 { "image/webp", "webp" },
85 { "image/png", "png" }, 86 { "image/png", "png" },
86 { "video/mp4", "mp4,m4v" }, 87 { "video/mp4", "mp4,m4v" },
87 { "audio/x-m4a", "m4a" }, 88 { "audio/x-m4a", "m4a" },
88 { "audio/mp3", "mp3" }, 89 { "audio/mp3", "mp3" },
89 { "video/ogg", "ogv,ogm" }, 90 { "video/ogg", "ogv,ogm" },
90 { "audio/ogg", "ogg,oga" }, 91 { "audio/ogg", "ogg,oga" },
91 { "video/webm", "webm" }, 92 { "video/webm", "webm" },
92 { "audio/webm", "webm" }, 93 { "audio/webm", "webm" },
93 { "audio/wav", "wav" }, 94 { "audio/wav", "wav" },
94 { "application/xhtml+xml", "xhtml,xht" }, 95 { "application/xhtml+xml", "xhtml,xht" },
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return false; 186 return false;
186 return GetMimeTypeFromExtension(file_name_str.substr(1), result); 187 return GetMimeTypeFromExtension(file_name_str.substr(1), result);
187 } 188 }
188 189
189 // From WebKit's WebCore/platform/MIMETypeRegistry.cpp: 190 // From WebKit's WebCore/platform/MIMETypeRegistry.cpp:
190 191
191 static const char* const supported_image_types[] = { 192 static const char* const supported_image_types[] = {
192 "image/jpeg", 193 "image/jpeg",
193 "image/pjpeg", 194 "image/pjpeg",
194 "image/jpg", 195 "image/jpg",
196 "image/webp",
195 "image/png", 197 "image/png",
196 "image/gif", 198 "image/gif",
197 "image/bmp", 199 "image/bmp",
198 "image/x-icon", // ico 200 "image/x-icon", // ico
199 "image/x-xbitmap" // xbm 201 "image/x-xbitmap" // xbm
200 }; 202 };
201 203
202 // A list of media types: http://en.wikipedia.org/wiki/Internet_media_type 204 // A list of media types: http://en.wikipedia.org/wiki/Internet_media_type
203 // A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php 205 // A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php
204 static const char* const supported_media_types[] = { 206 static const char* const supported_media_types[] = {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 namespace { 542 namespace {
541 543
542 // From http://www.w3schools.com/media/media_mimeref.asp and 544 // From http://www.w3schools.com/media/media_mimeref.asp and
543 // http://plugindoc.mozdev.org/winmime.php 545 // http://plugindoc.mozdev.org/winmime.php
544 static const char* kStandardImageTypes[] = { 546 static const char* kStandardImageTypes[] = {
545 "image/bmp", 547 "image/bmp",
546 "image/cis-cod", 548 "image/cis-cod",
547 "image/gif", 549 "image/gif",
548 "image/ief", 550 "image/ief",
549 "image/jpeg", 551 "image/jpeg",
552 "image/webp",
550 "image/pict", 553 "image/pict",
551 "image/pipeg", 554 "image/pipeg",
552 "image/png", 555 "image/png",
553 "image/svg+xml", 556 "image/svg+xml",
554 "image/tiff", 557 "image/tiff",
555 "image/x-cmu-raster", 558 "image/x-cmu-raster",
556 "image/x-cmx", 559 "image/x-cmx",
557 "image/x-icon", 560 "image/x-icon",
558 "image/x-portable-anymap", 561 "image/x-portable-anymap",
559 "image/x-portable-bitmap", 562 "image/x-portable-bitmap",
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 template<class T> 656 template<class T>
654 void HashSetToVector(base::hash_set<T>* source, std::vector<T>* target) { 657 void HashSetToVector(base::hash_set<T>* source, std::vector<T>* target) {
655 size_t old_target_size = target->size(); 658 size_t old_target_size = target->size();
656 target->resize(old_target_size + source->size()); 659 target->resize(old_target_size + source->size());
657 size_t i = 0; 660 size_t i = 0;
658 for (typename base::hash_set<T>::iterator iter = source->begin(); 661 for (typename base::hash_set<T>::iterator iter = source->begin();
659 iter != source->end(); ++iter, ++i) { 662 iter != source->end(); ++iter, ++i) {
660 target->at(old_target_size + i) = *iter; 663 target->at(old_target_size + i) = *iter;
661 } 664 }
662 } 665 }
663
664 } 666 }
665 667
666 void GetImageExtensions(std::vector<FilePath::StringType>* extensions) { 668 void GetImageExtensions(std::vector<FilePath::StringType>* extensions) {
667 base::hash_set<FilePath::StringType> unique_extensions; 669 base::hash_set<FilePath::StringType> unique_extensions;
668 GetExtensionsHelper(kStandardImageTypes, 670 GetExtensionsHelper(kStandardImageTypes,
669 arraysize(kStandardImageTypes), 671 arraysize(kStandardImageTypes),
670 "image/", 672 "image/",
671 &unique_extensions); 673 &unique_extensions);
672 HashSetToVector(&unique_extensions, extensions); 674 HashSetToVector(&unique_extensions, extensions);
673 } 675 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 708
707 GetExtensionsFromHardCodedMappings(secondary_mappings, 709 GetExtensionsFromHardCodedMappings(secondary_mappings,
708 arraysize(secondary_mappings), 710 arraysize(secondary_mappings),
709 mime_type, 711 mime_type,
710 &unique_extensions); 712 &unique_extensions);
711 713
712 HashSetToVector(&unique_extensions, extensions); 714 HashSetToVector(&unique_extensions, extensions);
713 } 715 }
714 716
715 } // namespace net 717 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698