| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/nix/mime_util_xdg.h" | 5 #include "base/nix/mime_util_xdg.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "base/third_party/xdg_mime/xdgmime.h" | 10 #include "base/third_party/xdg_mime/xdgmime.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 std::string GetFileMimeType(const FilePath& filepath) { | 24 std::string GetFileMimeType(const FilePath& filepath) { |
| 25 if (filepath.empty()) | 25 if (filepath.empty()) |
| 26 return std::string(); | 26 return std::string(); |
| 27 ThreadRestrictions::AssertIOAllowed(); | 27 ThreadRestrictions::AssertIOAllowed(); |
| 28 AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); | 28 AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); |
| 29 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); | 29 return xdg_mime_get_mime_type_from_file_name(filepath.value().c_str()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 std::string GetDataMimeType(const std::string& data) { | |
| 33 ThreadRestrictions::AssertIOAllowed(); | |
| 34 AutoLock scoped_lock(g_mime_util_xdg_lock.Get()); | |
| 35 return xdg_mime_get_mime_type_for_data(data.data(), data.length(), NULL); | |
| 36 } | |
| 37 | |
| 38 } // namespace nix | 32 } // namespace nix |
| 39 } // namespace base | 33 } // namespace base |
| OLD | NEW |