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