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

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: Flag guard two test cases for ChromeOS. 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
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 chromeos {
11
12 namespace {
13
14 static const net::MimeInfo mimetype_extension_mapping[] = {
15 {"application/epub+zip", "epub"},
16 {"application/zip", "zip"},
17 {"text/calendar", "ics"},
18 };
19 } // namespace
20
21 // On linux, chrome uses xdgmime to read extension-mimetype database (e.g.
22 // /usr/share/mime) and estimate mime type from extension. However ChromeOS does
23 // not have such database in it, we use |mimetype_extension_mapping| to resolve
24 // mime type on ChromeOS.
25 bool GetPlatformMimeTypeFromExtension(const base::FilePath::StringType& ext,
26 std::string* mime_type) {
27 base::FilePath path_ext(ext);
28 const std::string ext_narrow_str = path_ext.AsUTF8Unsafe();
29 const char* result = net::FindMimeType(mimetype_extension_mapping,
30 arraysize(mimetype_extension_mapping),
31 ext_narrow_str.c_str());
32 if (result) {
33 *mime_type = result;
34 return true;
35 }
36
37 return false;
38 }
39 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698