diff options
author | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 19:54:32 +0000 |
---|---|---|
committer | dhg@chromium.org <dhg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 19:54:32 +0000 |
commit | f54962b7878f7dcec1c24da53c35f4dbaf2f83d7 (patch) | |
tree | 6778de8314523e42e3671c1aba755a3d389b2811 /net/base/platform_mime_util_linux.cc | |
parent | fcf8140461d458a769fae218c87afd6816d9e785 (diff) | |
download | chromium_src-f54962b7878f7dcec1c24da53c35f4dbaf2f83d7.zip chromium_src-f54962b7878f7dcec1c24da53c35f4dbaf2f83d7.tar.gz chromium_src-f54962b7878f7dcec1c24da53c35f4dbaf2f83d7.tar.bz2 |
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
Diffstat (limited to 'net/base/platform_mime_util_linux.cc')
-rw-r--r-- | net/base/platform_mime_util_linux.cc | 29 |
1 files changed, 29 insertions, 0 deletions
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. |