From 5b4e5a7e55954b176d9c480561840d29490fc199 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 18 Jan 2015 16:59:57 -0800 Subject: [PATCH] Override DIR_USER_DATA as data path --- brightray/brightray.gyp | 1 + brightray/browser/brightray_paths.h | 20 ++++++++++++++++++++ brightray/browser/browser_context.cc | 9 ++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 brightray/browser/brightray_paths.h diff --git a/brightray/brightray.gyp b/brightray/brightray.gyp index 45b7bb5e4d0d..ad90b1def868 100644 --- a/brightray/brightray.gyp +++ b/brightray/brightray.gyp @@ -30,6 +30,7 @@ ], }, 'sources': [ + 'browser/brightray_paths.h', 'browser/browser_client.cc', 'browser/browser_client.h', 'browser/browser_context.cc', diff --git a/brightray/browser/brightray_paths.h b/brightray/browser/brightray_paths.h new file mode 100644 index 000000000000..f856337e9f90 --- /dev/null +++ b/brightray/browser/brightray_paths.h @@ -0,0 +1,20 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef BROWSER_BRIGHTRAY_PATHS_H_ +#define BROWSER_BRIGHTRAY_PATHS_H_ + +namespace brightray { + +enum { + PATH_START = 1000, + + DIR_USER_DATA = PATH_START, // Directory where user data can be written. + + PATH_END +}; + +} // namespace brightray + +#endif // BROWSER_BRIGHTRAY_PATHS_H_ diff --git a/brightray/browser/browser_context.cc b/brightray/browser/browser_context.cc index 7a9b56c05251..ed4d9f5d185e 100644 --- a/brightray/browser/browser_context.cc +++ b/brightray/browser/browser_context.cc @@ -4,6 +4,7 @@ #include "browser/browser_context.h" +#include "browser/brightray_paths.h" #include "browser/inspectable_web_contents_impl.h" #include "browser/network_delegate.h" #include "common/application_info.h" @@ -72,9 +73,11 @@ void BrowserContext::Initialize() { OverrideLinuxAppDataPath(); #endif - base::FilePath path; - PathService::Get(base::DIR_APP_DATA, &path); - path_ = path.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + if (!PathService::Get(DIR_USER_DATA, &path_)) { + PathService::Get(base::DIR_APP_DATA, &path_); + path_ = path_.Append(base::FilePath::FromUTF8Unsafe(GetApplicationName())); + PathService::Override(DIR_USER_DATA, path_); + } auto prefs_path = GetPath().Append(FILE_PATH_LITERAL("Preferences")); base::PrefServiceFactory prefs_factory;