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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/mime_util.cc

Issue 23945002: file_manager: Move non-binding code to c/b/chromeos/file_manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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 "chrome/browser/chromeos/extensions/file_manager/mime_util.h"
6
7 #include <utility>
8 #include "base/files/file_path.h"
9 #include "base/strings/string_util.h"
10 #include "net/base/mime_util.h"
11
12 namespace file_manager {
13 namespace util {
14
15 std::string GetMimeTypeForPath(const base::FilePath& file_path) {
16 const base::FilePath::StringType file_extension =
17 StringToLowerASCII(file_path.Extension());
18
19 // TODO(thorogood): Rearchitect this call so it can run on the File thread;
20 // GetMimeTypeFromFile requires this on Linux. Right now, we use
21 // Chrome-level knowledge only.
22 std::string mime_type;
23 if (file_extension.empty() ||
24 !net::GetWellKnownMimeTypeFromExtension(file_extension.substr(1),
25 &mime_type)) {
26 // If the file doesn't have an extension or its mime-type cannot be
27 // determined, then indicate that it has the empty mime-type. This will
28 // only be matched if the Web Intents accepts "*" or "*/*".
29 return "";
30 } else {
31 return mime_type;
32 }
33 }
34
35 } // namespace util
36 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698