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