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