From f54962b7878f7dcec1c24da53c35f4dbaf2f83d7 Mon Sep 17 00:00:00 2001 From: "dhg@chromium.org" Date: Tue, 18 May 2010 19:54:32 +0000 Subject: Adding some known mime types to the platform_mime_utils on linux. This might not be a perfect solution right now, but its a simple stopgap. BUG=chromium-os:3242 TEST=none Review URL: http://codereview.chromium.org/2077006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47549 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/platform_mime_util_linux.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'net/base/platform_mime_util_linux.cc') diff --git a/net/base/platform_mime_util_linux.cc b/net/base/platform_mime_util_linux.cc index 7debe35..b39fe27 100644 --- a/net/base/platform_mime_util_linux.cc +++ b/net/base/platform_mime_util_linux.cc @@ -38,8 +38,37 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( return true; } +struct MimeToExt { + const char* mime_type; + const char* ext; +}; + +const struct MimeToExt mime_type_ext_map[] = { + {"image/jpeg", "jpg"}, + {"image/png", "png"}, + {"image/gif", "gif"}, + {"text/html", "html"}, + {"video/mp4", "mp4"}, + {"video/mpeg", "mpg"}, + {"audio/mpeg", "mp3"}, + {"text/plain", "txt"}, + {"application/pdf", "pdf"}, + {"application/x-tar", "tar"} +}; + bool PlatformMimeUtil::GetPreferredExtensionForMimeType( const std::string& mime_type, FilePath::StringType* ext) const { + + for (size_t x = 0; + x < (sizeof(mime_type_ext_map) / sizeof(MimeToExt)); + x++) { + if (mime_type_ext_map[x].mime_type == mime_type) { + *ext = mime_type_ext_map[x].ext; + return true; + } + } + + // TODO(dhg): Fix this the right way by implementing whats said below. // Unlike GetPlatformMimeTypeFromExtension, this method doesn't have a // default list that it uses, but for now we are also returning false since // this doesn't really matter as much under Linux. -- cgit v1.1