OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/base/mime_extension_chromeos.h" | 5 #include "net/base/mime_extension_chromeos.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
11 namespace chromeos { | 11 namespace chromeos { |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 static const net::MimeInfo mimetype_extension_mapping[] = { | 15 static const net::MimeInfo mimetype_extension_mapping[] = { |
16 {"application/epub+zip", "epub"}, | 16 {"application/epub+zip", "epub"}, |
| 17 {"application/vnd.android.package-archive", "apk"}, |
17 {"application/zip", "zip"}, | 18 {"application/zip", "zip"}, |
18 {"text/calendar", "ics"}, | 19 {"text/calendar", "ics"}, |
19 }; | 20 }; |
20 } // namespace | 21 } // namespace |
21 | 22 |
22 // On linux, chrome uses xdgmime to read extension-mimetype database (e.g. | 23 // 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 // /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 // not have such database in it, we use |mimetype_extension_mapping| to resolve |
25 // mime type on ChromeOS. | 26 // mime type on ChromeOS. |
26 bool GetPlatformMimeTypeFromExtension(const base::FilePath::StringType& ext, | 27 bool GetPlatformMimeTypeFromExtension(const base::FilePath::StringType& ext, |
27 std::string* mime_type) { | 28 std::string* mime_type) { |
28 base::FilePath path_ext(ext); | 29 base::FilePath path_ext(ext); |
29 const std::string ext_narrow_str = path_ext.AsUTF8Unsafe(); | 30 const std::string ext_narrow_str = path_ext.AsUTF8Unsafe(); |
30 const char* result = | 31 const char* result = |
31 net::FindMimeType(mimetype_extension_mapping, | 32 net::FindMimeType(mimetype_extension_mapping, |
32 arraysize(mimetype_extension_mapping), ext_narrow_str); | 33 arraysize(mimetype_extension_mapping), ext_narrow_str); |
33 if (result) { | 34 if (result) { |
34 *mime_type = result; | 35 *mime_type = result; |
35 return true; | 36 return true; |
36 } | 37 } |
37 | 38 |
38 return false; | 39 return false; |
39 } | 40 } |
40 } // namespace chromeos | 41 } // namespace chromeos |
41 } // namespace net | 42 } // namespace net |
OLD | NEW |