mirror of
https://github.com/electron/electron.git
synced 2026-01-28 16:58:21 -05:00
Override DIR_USER_DATA as data path
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'browser/brightray_paths.h',
|
||||
'browser/browser_client.cc',
|
||||
'browser/browser_client.h',
|
||||
'browser/browser_context.cc',
|
||||
|
||||
20
brightray/browser/brightray_paths.h
Normal file
20
brightray/browser/brightray_paths.h
Normal file
@@ -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_
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user