[Android] Implement 3-way sensor fallback for Device Orientation.
[chromium-blink-merge.git] / net / base / mime_extension_chromeos.cc
blob03e8e2594cd424d299aeb5bc960b58b30f53a004
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/base/mime_extension_chromeos.h"
7 #include "base/logging.h"
8 #include "net/base/mime_util.h"
10 namespace net {
11 namespace chromeos {
13 namespace {
15 static const net::MimeInfo mimetype_extension_mapping[] = {
16 {"application/epub+zip", "epub"},
17 {"application/zip", "zip"},
18 {"text/calendar", "ics"},
20 } // namespace
22 // On linux, chrome uses xdgmime to read extension-mimetype database (e.g.
23 // /usr/share/mime) and estimate mime type from extension. However ChromeOS does
24 // not have such database in it, we use |mimetype_extension_mapping| to resolve
25 // mime type on ChromeOS.
26 bool GetPlatformMimeTypeFromExtension(const base::FilePath::StringType& ext,
27 std::string* mime_type) {
28 base::FilePath path_ext(ext);
29 const std::string ext_narrow_str = path_ext.AsUTF8Unsafe();
30 const char* result =
31 net::FindMimeType(mimetype_extension_mapping,
32 arraysize(mimetype_extension_mapping), ext_narrow_str);
33 if (result) {
34 *mime_type = result;
35 return true;
38 return false;
40 } // namespace chromeos
41 } // namespace net