From 449c5e76fcd8fc265b4be054d3783d63648ed6e0 Mon Sep 17 00:00:00 2001 From: "thestig@chromium.org" Date: Sat, 16 May 2009 06:54:06 +0000 Subject: Override .ico file's mime type on Linux. XDG's mime database has a bogus "image/x-ico" entry whereas the rest of the world uses "image/x-icon". TBR=estade Review URL: http://codereview.chromium.org/115440 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16231 0039d316-1c4b-4281-b951-d872f2087c98 --- net/base/platform_mime_util_linux.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'net') diff --git a/net/base/platform_mime_util_linux.cc b/net/base/platform_mime_util_linux.cc index acc14dc..2afdc47 100644 --- a/net/base/platform_mime_util_linux.cc +++ b/net/base/platform_mime_util_linux.cc @@ -14,10 +14,20 @@ bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( const FilePath::StringType& ext, std::string* result) const { FilePath::StringType dummy_path = "foo." + ext; std::string out = mime_util::GetFileMimeType(dummy_path); + // GetFileMimeType likes to return application/octet-stream // for everything it doesn't know - ignore that. if (out == "application/octet-stream" || !out.length()) return false; + + // GetFileMimeType returns image/x-ico because that's what's in the XDG + // mime database. That database is the merger of the Gnome and KDE mime + // databases. Apparently someone working on KDE in 2001 decided .ico + // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. + // FWIW, image/vnd.microsoft.icon is the official IANA assignment. + if (out == "image/x-ico") + out = "image/x-icon"; + *result = out; return true; } -- cgit v1.1