From 1c657854c20ee288f8812c707d4bf4fcfecb7495 Mon Sep 17 00:00:00 2001 From: "evan@chromium.org" Date: Thu, 22 Apr 2010 23:28:05 +0000 Subject: bsd: refactor XDG bits of linux_util into a shared file. This allows the shared code to build on the BSDs without them needing to build _linux files. Review URL: http://codereview.chromium.org/1701005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45380 0039d316-1c4b-4281-b951-d872f2087c98 --- base/xdg_util.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 base/xdg_util.h (limited to 'base/xdg_util.h') diff --git a/base/xdg_util.h b/base/xdg_util.h new file mode 100644 index 0000000..b69ce51 --- /dev/null +++ b/base/xdg_util.h @@ -0,0 +1,56 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BASE_XDG_UTIL_H_ +#define BASE_XDG_UTIL_H_ + +// XDG refers to http://en.wikipedia.org/wiki/Freedesktop.org . +// This file contains utilities found across free desktop +// environments. + +class FilePath; + +namespace base { + +class EnvVarGetter; + +// Utility function for getting XDG directories. +// |env_name| is the name of an environment variable that we want to use to get +// a directory path. |fallback_dir| is the directory relative to $HOME that we +// use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL. +// Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME. +FilePath GetXDGDirectory(EnvVarGetter* env, const char* env_name, + const char* fallback_dir); + +// Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs +// This looks up "well known" user directories like the desktop and music +// folder. Examples of |dir_name| are DESKTOP and MUSIC. +FilePath GetXDGUserDirectory(EnvVarGetter* env, const char* dir_name, + const char* fallback_dir); + +enum DesktopEnvironment { + DESKTOP_ENVIRONMENT_OTHER, + DESKTOP_ENVIRONMENT_GNOME, + // KDE3 and KDE4 are sufficiently different that we count + // them as two different desktop environments here. + DESKTOP_ENVIRONMENT_KDE3, + DESKTOP_ENVIRONMENT_KDE4, + DESKTOP_ENVIRONMENT_XFCE, +}; + +// Return an entry from the DesktopEnvironment enum with a best guess +// of which desktop environment we're using. We use this to know when +// to attempt to use preferences from the desktop environment -- +// proxy settings, password manager, etc. +DesktopEnvironment GetDesktopEnvironment(EnvVarGetter* env); + +// Return a string representation of the given desktop environment. +// May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER. +const char* GetDesktopEnvironmentName(DesktopEnvironment env); +// Convenience wrapper that calls GetDesktopEnvironment() first. +const char* GetDesktopEnvironmentName(EnvVarGetter* env); + +} // namespace base + +#endif // BASE_XDG_UTIL_H_ -- cgit v1.1