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 |