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

Unified Diff: net/base/platform_mime_util_linux.cc

Issue 113168: Add xdg mime support on Linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/third_party/xdg_mime/xdgmimeparent.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/platform_mime_util_linux.cc
===================================================================
--- net/base/platform_mime_util_linux.cc (revision 16095)
+++ net/base/platform_mime_util_linux.cc (working copy)
@@ -4,23 +4,22 @@
#include <string>
+#include "base/logging.h"
+#include "base/mime_util.h"
#include "net/base/platform_mime_util.h"
namespace net {
bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
const FilePath::StringType& ext, std::string* result) const {
- // The correct thing to do is to interact somehow with the freedesktop shared
- // mime info cache. Since Linux (and other traditional *IX systems) don't use
- // file extensions; they use mime types and have multiple ways of detecting
- // that; some types can be guessed from globs (*.gif), but there's a whole
- // bunch that use a magic byte test.
- //
- // Since this method only is called from inside mime_util where there is
- // already a hard coded table of mime types, we just return false because it
- // doesn't matter.
-
- return false;
+ 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;
+ *result = out;
+ return true;
}
bool PlatformMimeUtil::GetPreferredExtensionForMimeType(
@@ -34,6 +33,7 @@
// (image/gif). We look up the "heaviest" glob for a certain mime type and
// then then try to chop off "*.".
+ NOTIMPLEMENTED();
return false;
}
« no previous file with comments | « base/third_party/xdg_mime/xdgmimeparent.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698