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

Unified Diff: net/base/mime_extension_chromeos.cc

Issue 1134393002: Implement ChromeOS mime type extension mappings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 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 | « net/base/mime_extension_chromeos.h ('k') | net/base/mime_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/mime_extension_chromeos.cc
diff --git a/net/base/mime_extension_chromeos.cc b/net/base/mime_extension_chromeos.cc
new file mode 100644
index 0000000000000000000000000000000000000000..864a0efdc1449282661a6b8786e2202394cbb06b
--- /dev/null
+++ b/net/base/mime_extension_chromeos.cc
@@ -0,0 +1,41 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/mime_extension_chromeos.h"
+
+#include "base/logging.h"
+#include "net/base/mime_util.h"
+
+namespace net {
+namespace chromeos {
+
+namespace {
+
+static const net::MimeInfo mimetype_extension_mapping[] = {
+ {"application/epub+zip", "epub"},
+ {"application/zip", "zip"},
+ {"text/calendar", "ics"},
+};
+} // namespace
+
+// On linux, chrome uses xdgmime to read extension-mimetype database (e.g.
+// /usr/share/mime) and estimate mime type from extension. However ChromeOS does
+// not have such database in it, we use |mimetype_extension_mapping| to resolve
+// mime type on ChromeOS.
+bool GetPlatformMimeTypeFromExtension(const base::FilePath::StringType& ext,
+ std::string* mime_type) {
+ base::FilePath path_ext(ext);
+ const std::string ext_narrow_str = path_ext.AsUTF8Unsafe();
+ const char* result = net::FindMimeType(mimetype_extension_mapping,
+ arraysize(mimetype_extension_mapping),
+ ext_narrow_str.c_str());
+ if (result) {
+ *mime_type = result;
+ return true;
+ }
+
+ return false;
+}
+} // namespace chromeos
+} // namespace net
« no previous file with comments | « net/base/mime_extension_chromeos.h ('k') | net/base/mime_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698