• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 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 #ifndef BASE_MIME_UTIL_H_
6 #define BASE_MIME_UTIL_H_
7 #pragma once
8 
9 #include <string>
10 
11 class FilePath;
12 
13 namespace mime_util {
14 
15 // Gets the mime type for a file based on its filename. The file path does not
16 // have to exist. Please note because it doesn't touch the disk, this does not
17 // work for directories.
18 // If the mime type is unknown, this will return application/octet-stream.
19 std::string GetFileMimeType(const FilePath& filepath);
20 
21 // Get the mime type for a byte vector.
22 std::string GetDataMimeType(const std::string& data);
23 
24 #if defined(TOOLKIT_GTK)
25 // This detects the current GTK theme by calling gtk_settings_get_default().
26 // It should only be executed on the UI thread and must be called before
27 // GetMimeIcon().
28 void DetectGtkTheme();
29 #endif
30 
31 // Gets the file name for an icon given the mime type and icon pixel size.
32 // Where an icon is a square image of |size| x |size|.
33 // This will try to find the closest matching icon. If that's not available,
34 // then a generic icon, and finally an empty FilePath if all else fails.
35 FilePath GetMimeIcon(const std::string& mime_type, size_t size);
36 
37 }  // namespace mime_util
38 
39 #endif  // BASE_MIME_UTIL_H_
40