Make DIR_APP_DATA available on Linux

This commit is contained in:
Cheng Zhao 2015-01-18 17:19:25 -08:00
parent 5b4e5a7e55
commit 76e3d56760
2 changed files with 17 additions and 3 deletions

View file

@ -5,6 +5,14 @@
#ifndef BROWSER_BRIGHTRAY_PATHS_H_ #ifndef BROWSER_BRIGHTRAY_PATHS_H_
#define BROWSER_BRIGHTRAY_PATHS_H_ #define BROWSER_BRIGHTRAY_PATHS_H_
#include "base/compiler_specific.h"
#if defined(OS_WIN)
#include "base/base_paths_win.h"
#elif defined(OS_MACOSX)
#include "base/base_paths_mac.h"
#endif
namespace brightray { namespace brightray {
enum { enum {
@ -12,6 +20,12 @@ enum {
DIR_USER_DATA = PATH_START, // Directory where user data can be written. DIR_USER_DATA = PATH_START, // Directory where user data can be written.
#if defined(OS_LINUX)
DIR_APP_DATA, // Application Data directory under the user profile.
#else
DIR_APP_DATA = base::DIR_APP_DATA,
#endif
PATH_END PATH_END
}; };

View file

@ -33,13 +33,13 @@ namespace {
#if defined(OS_LINUX) #if defined(OS_LINUX)
void OverrideLinuxAppDataPath() { void OverrideLinuxAppDataPath() {
base::FilePath path; base::FilePath path;
if (PathService::Get(base::DIR_APP_DATA, &path)) if (PathService::Get(DIR_APP_DATA, &path))
return; return;
scoped_ptr<base::Environment> env(base::Environment::Create()); scoped_ptr<base::Environment> env(base::Environment::Create());
path = base::nix::GetXDGDirectory(env.get(), path = base::nix::GetXDGDirectory(env.get(),
base::nix::kXdgConfigHomeEnvVar, base::nix::kXdgConfigHomeEnvVar,
base::nix::kDotConfigDir); base::nix::kDotConfigDir);
PathService::Override(base::DIR_APP_DATA, path); PathService::Override(DIR_APP_DATA, path);
} }
#endif #endif
@ -74,7 +74,7 @@ void BrowserContext::Initialize() {
#endif #endif
if (!PathService::Get(DIR_USER_DATA, &path_)) { if (!PathService::Get(DIR_USER_DATA, &path_)) {
PathService::Get(base::DIR_APP_DATA, &path_); PathService::Get(DIR_APP_DATA, &path_);
path_ = path_.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); path_ = path_.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName()));
PathService::Override(DIR_USER_DATA, path_); PathService::Override(DIR_USER_DATA, path_);
} }