diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 04:56:06 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-16 04:56:06 +0000 |
commit | 6b0349ef4ab90a6b99fc568f40e872a7f2ca39c9 (patch) | |
tree | 9ba478afe564003c74927c1530741846f6aa1336 /base/nix/xdg_util.h | |
parent | b679032aef9317482f87ceaf67ee138aaa67a152 (diff) | |
download | chromium_src-6b0349ef4ab90a6b99fc568f40e872a7f2ca39c9.zip chromium_src-6b0349ef4ab90a6b99fc568f40e872a7f2ca39c9.tar.gz chromium_src-6b0349ef4ab90a6b99fc568f40e872a7f2ca39c9.tar.bz2 |
Move xdg_util into base/nix. I originally wanted to use base/linux, but you
can't have a namespace called "linux" because it's ifdefed by GCC to be a
number. Same for "unix". "x11" was discarded because some future stuff in
here will not be related to x11.
This also renames base_paths_posix to base_paths_linux since this does not
apply to mac, and normally posix applies to mac (this confused me when I had to
edit it for the XDG stuff).
TEST=it compiles
BUG=none
Review URL: http://codereview.chromium.org/3778007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/nix/xdg_util.h')
-rw-r--r-- | base/nix/xdg_util.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/base/nix/xdg_util.h b/base/nix/xdg_util.h new file mode 100644 index 0000000..5e711d5 --- /dev/null +++ b/base/nix/xdg_util.h @@ -0,0 +1,67 @@ +// 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_NIX_XDG_UTIL_H_ +#define BASE_NIX_XDG_UTIL_H_ +#pragma once + +// XDG refers to http://en.wikipedia.org/wiki/Freedesktop.org . +// This file contains utilities found across free desktop environments. +// +// TODO(brettw) this file should be in app/x11, but is currently used by +// net. We should have a net API to allow the embedder to specify the behavior +// that it uses XDG for, and then move this file. + +#ifdef nix +#error asdf +#endif + +class FilePath; + +namespace base { + +class Environment; + +namespace nix { + +// 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(Environment* 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(Environment* 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(Environment* 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(Environment* env); + +} // namespace nix +} // namespace base + +#endif // BASE_NIX_XDG_UTIL_H_ |