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"
15 static const net::MimeInfo mimetype_extension_mapping
[] = {
16 {"application/epub+zip", "epub"},
17 {"application/zip", "zip"},
18 {"text/calendar", "ics"},
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();
31 net::FindMimeType(mimetype_extension_mapping
,
32 arraysize(mimetype_extension_mapping
), ext_narrow_str
);
40 } // namespace chromeos