xdg_util.h 2.9 KB

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