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.
5 #include "chrome/browser/chromeos/file_manager/mime_util.h"
7 #include "base/files/file_path.h"
8 #include "net/base/mime_util.h"
10 namespace file_manager {
13 std::string GetMimeTypeForPath(const base::FilePath& file_path) {
14 const base::FilePath::StringType file_extension = file_path.Extension();
16 // TODO(thorogood): Rearchitect this call so it can run on the File thread;
17 // GetMimeTypeFromFile requires this on Linux. Right now, we use
18 // Chrome-level knowledge only.
19 std::string mime_type;
20 if (file_extension.empty() ||
21 !net::GetWellKnownMimeTypeFromExtension(file_extension.substr(1),
23 // If the file doesn't have an extension or its mime-type cannot be
24 // determined, then indicate that it has the empty mime-type. This will
25 // only be matched if the Web Intents accepts "*" or "*/*".
33 } // namespace file_manager