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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "net/base/mime_extension_chromeos.h"
6
7 #include "base/logging.h"
8 #include "net/base/mime_util.h"
9
10 namespace net {
11 namespace chromeos {
12
13 namespace {
14
15 static const net::MimeInfo mimetype_extension_mapping[] = {
16 {"application/epub+zip", "epub"},
17 {"application/zip", "zip"},
18 {"text/calendar", "ics"},
19 };
20 } // namespace
21
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 = net::FindMimeType(mimetype_extension_mapping,
31 arraysize(mimetype_extension_mapping),
32 ext_narrow_str.c_str());
33 if (result) {
34 *mime_type = result;
35 return true;
36 }
37
38 return false;
39 }
40 } // namespace chromeos
41 } // namespace net
OLDNEW
« 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