Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / base / nix / xdg_util.h
blobfc72663a2151c0e3fb6f49c7499f611b8dea1433
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.
5 #ifndef BASE_NIX_XDG_UTIL_H_
6 #define BASE_NIX_XDG_UTIL_H_
8 // XDG refers to http://en.wikipedia.org/wiki/Freedesktop.org .
9 // This file contains utilities found across free desktop environments.
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.
15 #include "base/base_export.h"
17 #ifdef nix
18 #error asdf
19 #endif
21 class FilePath;
23 namespace base {
25 class Environment;
27 namespace nix {
29 // The default XDG config directory name.
30 BASE_EXPORT extern const char kDotConfigDir[];
32 // The XDG config directory environment variable.
33 BASE_EXPORT extern const char kXdgConfigHomeEnvVar[];
35 // Utility function for getting XDG directories.
36 // |env_name| is the name of an environment variable that we want to use to get
37 // a directory path. |fallback_dir| is the directory relative to $HOME that we
38 // use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL.
39 // Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME.
40 BASE_EXPORT FilePath GetXDGDirectory(Environment* env, const char* env_name,
41 const char* fallback_dir);
43 // Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs
44 // This looks up "well known" user directories like the desktop and music
45 // folder. Examples of |dir_name| are DESKTOP and MUSIC.
46 BASE_EXPORT FilePath GetXDGUserDirectory(const char* dir_name,
47 const char* fallback_dir);
49 enum DesktopEnvironment {
50 DESKTOP_ENVIRONMENT_OTHER,
51 DESKTOP_ENVIRONMENT_GNOME,
52 // KDE3 and KDE4 are sufficiently different that we count
53 // them as two different desktop environments here.
54 DESKTOP_ENVIRONMENT_KDE3,
55 DESKTOP_ENVIRONMENT_KDE4,
56 DESKTOP_ENVIRONMENT_UNITY,
57 DESKTOP_ENVIRONMENT_XFCE,
60 // Return an entry from the DesktopEnvironment enum with a best guess
61 // of which desktop environment we're using. We use this to know when
62 // to attempt to use preferences from the desktop environment --
63 // proxy settings, password manager, etc.
64 BASE_EXPORT DesktopEnvironment GetDesktopEnvironment(Environment* env);
66 // Return a string representation of the given desktop environment.
67 // May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER.
68 BASE_EXPORT const char* GetDesktopEnvironmentName(DesktopEnvironment env);
69 // Convenience wrapper that calls GetDesktopEnvironment() first.
70 BASE_EXPORT const char* GetDesktopEnvironmentName(Environment* env);
72 } // namespace nix
73 } // namespace base
75 #endif // BASE_NIX_XDG_UTIL_H_