• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef BASE_NIX_XDG_UTIL_H_
6 #define BASE_NIX_XDG_UTIL_H_
7 
8 // XDG refers to http://en.wikipedia.org/wiki/Freedesktop.org .
9 // This file contains utilities found across free desktop environments.
10 //
11 // TODO(brettw) this file should be in app/x11, but is currently used by
12 // net. We should have a net API to allow the embedder to specify the behavior
13 // that it uses XDG for, and then move this file.
14 
15 #include "base/base_export.h"
16 
17 #ifdef nix
18 #error asdf
19 #endif
20 
21 namespace base {
22 
23 class Environment;
24 class FilePath;
25 
26 namespace nix {
27 
28 // The default XDG config directory name.
29 BASE_EXPORT extern const char kDotConfigDir[];
30 
31 // The XDG config directory environment variable.
32 BASE_EXPORT extern const char kXdgConfigHomeEnvVar[];
33 
34 // Utility function for getting XDG directories.
35 // |env_name| is the name of an environment variable that we want to use to get
36 // a directory path. |fallback_dir| is the directory relative to $HOME that we
37 // use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL.
38 // Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME.
39 BASE_EXPORT FilePath GetXDGDirectory(Environment* env, const char* env_name,
40                                      const char* fallback_dir);
41 
42 // Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs
43 // This looks up "well known" user directories like the desktop and music
44 // folder. Examples of |dir_name| are DESKTOP and MUSIC.
45 BASE_EXPORT FilePath GetXDGUserDirectory(const char* dir_name,
46                                          const char* fallback_dir);
47 
48 enum DesktopEnvironment {
49   DESKTOP_ENVIRONMENT_OTHER,
50   DESKTOP_ENVIRONMENT_GNOME,
51   // KDE3 and KDE4 are sufficiently different that we count
52   // them as two different desktop environments here.
53   DESKTOP_ENVIRONMENT_KDE3,
54   DESKTOP_ENVIRONMENT_KDE4,
55   DESKTOP_ENVIRONMENT_UNITY,
56   DESKTOP_ENVIRONMENT_XFCE,
57 };
58 
59 // Return an entry from the DesktopEnvironment enum with a best guess
60 // of which desktop environment we're using.  We use this to know when
61 // to attempt to use preferences from the desktop environment --
62 // proxy settings, password manager, etc.
63 BASE_EXPORT DesktopEnvironment GetDesktopEnvironment(Environment* env);
64 
65 // Return a string representation of the given desktop environment.
66 // May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER.
67 BASE_EXPORT const char* GetDesktopEnvironmentName(DesktopEnvironment env);
68 // Convenience wrapper that calls GetDesktopEnvironment() first.
69 BASE_EXPORT const char* GetDesktopEnvironmentName(Environment* env);
70 
71 }  // namespace nix
72 }  // namespace base
73 
74 #endif  // BASE_NIX_XDG_UTIL_H_
75