diff options
author | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 00:12:33 +0000 |
---|---|---|
committer | nkostylev@chromium.org <nkostylev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 00:12:33 +0000 |
commit | 6bdc52278501985dd265048a5d14a2ba282d0717 (patch) | |
tree | d3ff2a034214199fd1969d21d96a508e5c5a1b99 | |
parent | 1c14973dde30f2281f74543d37df4aba711295d0 (diff) | |
download | chromium_src-6bdc52278501985dd265048a5d14a2ba282d0717.zip chromium_src-6bdc52278501985dd265048a5d14a2ba282d0717.tar.gz chromium_src-6bdc52278501985dd265048a5d14a2ba282d0717.tar.bz2 |
Move all callers of GetHomeDir() to PathService::Get(base::DIR_HOME).
* Fixes GetHomeDir() for multi-profiles case on Chrome OS.
* Once user signs in on Chrome OS base::DIR_HOME is overridden with primary user homedir.
* Added content switch --homedir to pass that information to ppapi plugins since they
run in a separate process and previous base::DIR_HOME override does not apply there.
This fix doesn't require checking for --multi-profiles switch
since user_id hash is known even without it.
Note:
download_prefs.cc still uses GetHomeDir() in its DownloadPathIsDangerous() check.
// Consider downloads 'dangerous' if they go to the home directory on Linux and
// to the desktop on any platform.
In this context correct behavior is to use "real" base::GetHomeDir() and not "virtual one" base::DIR_HOME.
Since latter is remapped to some test dir in tests, in some subfolders in Chrome OS etc.
BUG=331530
TBR=vitalybuka@chromium.org
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=270872
Review URL: https://codereview.chromium.org/200473002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272898 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 121 insertions, 41 deletions
diff --git a/base/file_util.h b/base/file_util.h index ca7bf626..9c9072f 100644 --- a/base/file_util.h +++ b/base/file_util.h @@ -218,6 +218,7 @@ BASE_EXPORT bool GetTempDir(FilePath* path); // // You should not generally call this directly. Instead use DIR_HOME with the // path service which will use this function but cache the value. +// Path service may also override DIR_HOME. BASE_EXPORT FilePath GetHomeDir(); // Creates a temporary file. The full path is placed in |path|, and the diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 9270e8a..e8dec94 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -458,8 +458,12 @@ bool GetTempDir(FilePath* path) { #if !defined(OS_MACOSX) // Mac implementation is in file_util_mac.mm. FilePath GetHomeDir() { #if defined(OS_CHROMEOS) - if (SysInfo::IsRunningOnChromeOS()) - return FilePath("/home/chronos/user"); + if (SysInfo::IsRunningOnChromeOS()) { + // On Chrome OS chrome::DIR_USER_DATA is overriden with a primary user + // homedir once it becomes available. + NOTREACHED() << "Called GetHomeDir() without base::DIR_HOME override"; + return FilePath("/"); + } #endif const char* home_dir = getenv("HOME"); diff --git a/base/nix/xdg_util.cc b/base/nix/xdg_util.cc index 4c1510f..4086a3d 100644 --- a/base/nix/xdg_util.cc +++ b/base/nix/xdg_util.cc @@ -6,9 +6,11 @@ #include <string> +#include "base/base_paths.h" #include "base/environment.h" #include "base/file_util.h" #include "base/files/file_path.h" +#include "base/path_service.h" #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" namespace { @@ -28,10 +30,12 @@ FilePath GetXDGDirectory(Environment* env, const char* env_name, const char* fallback_dir) { FilePath path; std::string env_value; - if (env->GetVar(env_name, &env_value) && !env_value.empty()) + if (env->GetVar(env_name, &env_value) && !env_value.empty()) { path = FilePath(env_value); - else - path = GetHomeDir().Append(fallback_dir); + } else { + PathService::Get(base::DIR_HOME, &path); + path = path.Append(fallback_dir); + } return path.StripTrailingSeparators(); } @@ -42,7 +46,8 @@ FilePath GetXDGUserDirectory(const char* dir_name, const char* fallback_dir) { path = FilePath(xdg_dir); free(xdg_dir); } else { - path = GetHomeDir().Append(fallback_dir); + PathService::Get(base::DIR_HOME, &path); + path = path.Append(fallback_dir); } return path.StripTrailingSeparators(); } diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc index 9d5f3f0..168b32e 100644 --- a/chrome/app/chrome_main_delegate.cc +++ b/chrome/app/chrome_main_delegate.cc @@ -4,6 +4,7 @@ #include "chrome/app/chrome_main_delegate.h" +#include "base/base_paths.h" #include "base/command_line.h" #include "base/cpu.h" #include "base/files/file_path.h" @@ -476,6 +477,16 @@ bool ChromeMainDelegate::BasicStartupComplete(int* exit_code) { #endif #if defined(OS_CHROMEOS) + // Initialize primary user homedir (in multi-profile session) as it may be + // passed as a command line switch. + base::FilePath homedir; + if (command_line.HasSwitch(chromeos::switches::kHomedir)) { + homedir = base::FilePath( + command_line.GetSwitchValueASCII(chromeos::switches::kHomedir)); + PathService::OverrideAndCreateIfNeeded( + base::DIR_HOME, homedir, true, false); + } + // If we are recovering from a crash on ChromeOS, then we will do some // recovery using the diagnostics module, and then continue on. We fake up a // command line to tell it that we want it to recover, and to preserve the diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 29f2d6b..fc4bec3 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -1512,6 +1512,14 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( arraysize(kIpcFuzzerSwitches)); #endif +#if defined(OS_CHROMEOS) + // On Chrome OS need to pass primary user homedir (in multi-profiles session). + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); + command_line->AppendSwitchASCII(chromeos::switches::kHomedir, + homedir.value().c_str()); +#endif + if (process_type == switches::kRendererProcess) { #if defined(OS_CHROMEOS) const std::string& login_profile = diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index 2d19d9a..caef573 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -8,6 +8,7 @@ #include <set> #include <vector> +#include "base/base_paths.h" #include "base/bind.h" #include "base/command_line.h" #include "base/compiler_specific.h" @@ -66,7 +67,6 @@ #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/ui/app_list/start_page_service.h" #include "chrome/browser/ui/startup/startup_browser_creator.h" -#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/pref_names.h" @@ -99,7 +99,9 @@ const base::FilePath::CharType kRLZDisabledFlagName[] = FILE_PATH_LITERAL(".rlz_disabled"); base::FilePath GetRlzDisabledFlagPath() { - return base::GetHomeDir().Append(kRLZDisabledFlagName); + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); + return homedir.Append(kRLZDisabledFlagName); } #endif diff --git a/chrome/browser/chromeos/login/users/user_manager_impl.cc b/chrome/browser/chromeos/login/users/user_manager_impl.cc index 86bf5da..9b67230 100644 --- a/chrome/browser/chromeos/login/users/user_manager_impl.cc +++ b/chrome/browser/chromeos/login/users/user_manager_impl.cc @@ -8,6 +8,7 @@ #include <set> #include "ash/multi_profile_uma.h" +#include "base/base_paths.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" @@ -16,6 +17,7 @@ #include "base/format_macros.h" #include "base/logging.h" #include "base/metrics/histogram.h" +#include "base/path_service.h" #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" #include "base/prefs/scoped_user_pref_update.h" @@ -58,6 +60,7 @@ #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/common/chrome_constants.h" +#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/crash_keys.h" #include "chrome/common/pref_names.h" @@ -1552,6 +1555,16 @@ void UserManagerImpl::RetailModeUserLoggedIn() { void UserManagerImpl::NotifyOnLogin() { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + // Override user homedir, check for ProfileManager being initialized as + // it may not exist in unit tests. + if (g_browser_process->profile_manager()) { + if (GetLoggedInUsers().size() == 1) { + base::FilePath homedir = ProfileHelper::GetProfilePathByUserIdHash( + primary_user_->username_hash()); + PathService::Override(base::DIR_HOME, homedir); + } + } + UpdateNumberOfUsers(); NotifyActiveUserHashChanged(active_user_->username_hash()); NotifyActiveUserChanged(active_user_); diff --git a/chrome/browser/diagnostics/diagnostics_controller_unittest.cc b/chrome/browser/diagnostics/diagnostics_controller_unittest.cc index 369dde6..cc2180b 100644 --- a/chrome/browser/diagnostics/diagnostics_controller_unittest.cc +++ b/chrome/browser/diagnostics/diagnostics_controller_unittest.cc @@ -4,6 +4,7 @@ #include "chrome/browser/diagnostics/diagnostics_controller.h" +#include "base/base_paths.h" #include "base/command_line.h" #include "base/file_util.h" #include "base/files/scoped_temp_dir.h" @@ -40,14 +41,8 @@ class DiagnosticsControllerTest : public testing::Test { // Redirect the home dir to the profile directory. We have to do this // because NSS uses the HOME directory to find where to store it's database, // so that's where the diagnostics and recovery code looks for it. - - // Preserve existing home directory setting, if any. - const char* old_home_dir = ::getenv("HOME"); - if (old_home_dir) - old_home_dir_ = old_home_dir; - else - old_home_dir_.clear(); - ::setenv("HOME", profile_dir_.value().c_str(), 1); + PathService::Get(base::DIR_HOME, &old_home_dir_); + PathService::Override(base::DIR_HOME, profile_dir_); #endif cmdline_ = CommandLine(CommandLine::NO_PROGRAM); @@ -62,11 +57,7 @@ class DiagnosticsControllerTest : public testing::Test { virtual void TearDown() { DiagnosticsController::GetInstance()->ClearResults(); #if defined(OS_CHROMEOS) - if (!old_home_dir_.empty()) { - ::setenv("HOME", old_home_dir_.c_str(), 1); - } else { - ::unsetenv("HOME"); - } + PathService::Override(base::DIR_HOME, old_home_dir_); old_home_dir_.clear(); #endif } @@ -85,7 +76,7 @@ class DiagnosticsControllerTest : public testing::Test { base::FilePath profile_dir_; #if defined(OS_CHROMEOS) - std::string old_home_dir_; + base::FilePath old_home_dir_; #endif DISALLOW_COPY_AND_ASSIGN(DiagnosticsControllerTest); diff --git a/chrome/browser/diagnostics/sqlite_diagnostics.cc b/chrome/browser/diagnostics/sqlite_diagnostics.cc index 046dc29..840d525 100644 --- a/chrome/browser/diagnostics/sqlite_diagnostics.cc +++ b/chrome/browser/diagnostics/sqlite_diagnostics.cc @@ -4,6 +4,7 @@ #include "chrome/browser/diagnostics/sqlite_diagnostics.h" +#include "base/base_paths.h" #include "base/file_util.h" #include "base/logging.h" #include "base/memory/ref_counted.h" @@ -240,14 +241,16 @@ DiagnosticsTest* MakeSqliteHistoryDbTest() { #if defined(OS_CHROMEOS) DiagnosticsTest* MakeSqliteNssCertDbTest() { - base::FilePath home_dir = base::GetHomeDir(); + base::FilePath home_dir; + PathService::Get(base::DIR_HOME, &home_dir); return new SqliteIntegrityTest(SqliteIntegrityTest::REMOVE_IF_CORRUPT, DIAGNOSTICS_SQLITE_INTEGRITY_NSS_CERT_TEST, home_dir.Append(chromeos::kNssCertDbPath)); } DiagnosticsTest* MakeSqliteNssKeyDbTest() { - base::FilePath home_dir = base::GetHomeDir(); + base::FilePath home_dir; + PathService::Get(base::DIR_HOME, &home_dir); return new SqliteIntegrityTest(SqliteIntegrityTest::REMOVE_IF_CORRUPT, DIAGNOSTICS_SQLITE_INTEGRITY_NSS_KEY_TEST, home_dir.Append(chromeos::kNssKeyDbPath)); diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc index eeb1b9a..95dd086 100644 --- a/chrome/common/chrome_paths_linux.cc +++ b/chrome/common/chrome_paths_linux.cc @@ -4,11 +4,13 @@ #include "chrome/common/chrome_paths_internal.h" +#include "base/base_paths.h" #include "base/environment.h" #include "base/file_util.h" #include "base/memory/scoped_ptr.h" #include "base/nix/xdg_util.h" #include "base/path_service.h" +#include "chrome/common/chrome_paths.h" namespace chrome { @@ -34,7 +36,8 @@ bool GetUserMediaDirectory(const std::string& xdg_name, #else *result = GetXDGUserDirectory(xdg_name.c_str(), fallback_name.c_str()); - base::FilePath home = base::GetHomeDir(); + base::FilePath home; + PathService::Get(base::DIR_HOME, &home); if (*result != home) { base::FilePath desktop; if (!PathService::Get(base::DIR_USER_DESKTOP, &desktop)) @@ -103,7 +106,8 @@ bool GetUserDocumentsDirectory(base::FilePath* result) { } bool GetUserDownloadsDirectorySafe(base::FilePath* result) { - base::FilePath home = base::GetHomeDir(); + base::FilePath home; + PathService::Get(base::DIR_HOME, &home); *result = home.Append(kDownloadsDir); return true; } diff --git a/chrome/common/chrome_paths_unittest.cc b/chrome/common/chrome_paths_unittest.cc index 5251154..3816cf6 100644 --- a/chrome/common/chrome_paths_unittest.cc +++ b/chrome/common/chrome_paths_unittest.cc @@ -6,6 +6,7 @@ #include <stdlib.h> +#include "base/base_paths.h" #include "base/file_util.h" #include "base/files/file_path.h" #include "base/path_service.h" @@ -29,7 +30,8 @@ TEST(ChromePaths, UserCacheDir) { base::FilePath expected_cache_dir; ASSERT_TRUE(PathService::Get(base::DIR_CACHE, &expected_cache_dir)); #elif(OS_POSIX) - base::FilePath homedir = base::GetHomeDir(); + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); // Note: we assume XDG_CACHE_HOME/XDG_CONFIG_HOME are at their // default settings. test_profile_dir = homedir.Append(".config/foobar"); diff --git a/chrome/common/importer/firefox_importer_utils_linux.cc b/chrome/common/importer/firefox_importer_utils_linux.cc index 71f1a26..081a294 100644 --- a/chrome/common/importer/firefox_importer_utils_linux.cc +++ b/chrome/common/importer/firefox_importer_utils_linux.cc @@ -4,13 +4,17 @@ #include "chrome/common/importer/firefox_importer_utils.h" +#include "base/base_paths.h" #include "base/file_util.h" +#include "base/files/file_path.h" +#include "base/path_service.h" base::FilePath GetProfilesINI() { base::FilePath ini_file; // The default location of the profile folder containing user data is // under user HOME directory in .mozilla/firefox folder on Linux. - base::FilePath home = base::GetHomeDir(); + base::FilePath home; + PathService::Get(base::DIR_HOME, &home); if (!home.empty()) { ini_file = home.Append(".mozilla/firefox/profiles.ini"); } diff --git a/chrome/test/data/extensions/api_test/file_system/open_directory/test.js b/chrome/test/data/extensions/api_test/file_system/open_directory/test.js index db4a01e..3b60cd0 100644 --- a/chrome/test/data/extensions/api_test/file_system/open_directory/test.js +++ b/chrome/test/data/extensions/api_test/file_system/open_directory/test.js @@ -21,9 +21,17 @@ chrome.test.runTests([ chrome.test.callbackPass(function(directoryEntry) { var reader = directoryEntry.createReader(); reader.readEntries(chrome.test.callback(function(entries) { - chrome.test.assertEq(entries.length, 1); - var entry = entries[0]; - checkEntry(entry, 'open_existing.txt', false, false); + // On POSIX systems DIR_HOME is overridden for this test and + // [.config] directory may be created there, ignore it + // See https://codereview.chromium.org/200473002/ + var testEntry; + entries.forEach(function(entry) { + if (entry.name != '.config') { + chrome.test.assertEq(entry.name, 'open_existing.txt'); + testEntry = entry; + } + }); + checkEntry(testEntry, 'open_existing.txt', false, false); })); })); }, diff --git a/chromeos/chromeos_switches.cc b/chromeos/chromeos_switches.cc index 74ab74c..0037cfc 100644 --- a/chromeos/chromeos_switches.cc +++ b/chromeos/chromeos_switches.cc @@ -138,6 +138,9 @@ const char kHasChromeOSKeyboard[] = "has-chromeos-keyboard"; // If true, the Chromebook has a keyboard with a diamond key. const char kHasChromeOSDiamondKey[] = "has-chromeos-diamond-key"; +// Defines user homedir. This defaults to primary user homedir. +const char kHomedir[] = "homedir"; + // If true, profile selection in UserManager will always return active user's // profile. // TODO(nkostlyev): http://crbug.com/364604 - Get rid of this switch after we diff --git a/chromeos/chromeos_switches.h b/chromeos/chromeos_switches.h index 257e214..31c6c77 100644 --- a/chromeos/chromeos_switches.h +++ b/chromeos/chromeos_switches.h @@ -56,6 +56,7 @@ CHROMEOS_EXPORT extern const char kForceLoginManagerInTests[]; CHROMEOS_EXPORT extern const char kGuestSession[]; CHROMEOS_EXPORT extern const char kHasChromeOSDiamondKey[]; CHROMEOS_EXPORT extern const char kHasChromeOSKeyboard[]; +CHROMEOS_EXPORT extern const char kHomedir[]; CHROMEOS_EXPORT extern const char kIgnoreUserProfileMappingForTests[]; CHROMEOS_EXPORT extern const char kKioskModeScreensaverPath[]; CHROMEOS_EXPORT extern const char kLoginManager[]; diff --git a/content/ppapi_plugin/ppapi_plugin_main.cc b/content/ppapi_plugin/ppapi_plugin_main.cc index ab32b66..81ca51e 100644 --- a/content/ppapi_plugin/ppapi_plugin_main.cc +++ b/content/ppapi_plugin/ppapi_plugin_main.cc @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/base_paths.h" #include "base/command_line.h" #include "base/debug/debugger.h" +#include "base/files/file_path.h" #include "base/i18n/rtl.h" #include "base/message_loop/message_loop.h" +#include "base/path_service.h" #include "base/threading/platform_thread.h" #include "build/build_config.h" #include "content/child/child_process.h" @@ -101,7 +104,9 @@ int PpapiPluginMain(const MainFunctionParams& parameters) { #if defined(OS_CHROMEOS) // Specifies $HOME explicitly because some plugins rely on $HOME but // no other part of Chrome OS uses that. See crbug.com/335290. - setenv("HOME", base::GetHomeDir().value().c_str(), 1); + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); + setenv("HOME", homedir.value().c_str(), 1); #endif base::MessageLoop main_message_loop; diff --git a/crypto/nss_util.cc b/crypto/nss_util.cc index da46b63..5958ad9 100644 --- a/crypto/nss_util.cc +++ b/crypto/nss_util.cc @@ -21,6 +21,7 @@ #include <map> #include <vector> +#include "base/base_paths.h" #include "base/bind.h" #include "base/cpu.h" #include "base/debug/alias.h" @@ -34,6 +35,7 @@ #include "base/message_loop/message_loop.h" #include "base/metrics/histogram.h" #include "base/native_library.h" +#include "base/path_service.h" #include "base/stl_util.h" #include "base/strings/stringprintf.h" #include "base/threading/thread_checker.h" @@ -80,7 +82,8 @@ std::string GetNSSErrorMessage() { #if defined(USE_NSS) base::FilePath GetDefaultConfigDirectory() { - base::FilePath dir = base::GetHomeDir(); + base::FilePath dir; + PathService::Get(base::DIR_HOME, &dir); if (dir.empty()) { LOG(ERROR) << "Failed to get home directory."; return dir; diff --git a/printing/backend/cups_helper.cc b/printing/backend/cups_helper.cc index 296b95e..e183841 100644 --- a/printing/backend/cups_helper.cc +++ b/printing/backend/cups_helper.cc @@ -6,8 +6,10 @@ #include <cups/ppd.h> +#include "base/base_paths.h" #include "base/file_util.h" #include "base/logging.h" +#include "base/path_service.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" @@ -99,8 +101,9 @@ void MarkLpOptions(const std::string& printer_name, ppd_file_t** ppd) { std::vector<base::FilePath> file_locations; file_locations.push_back(base::FilePath(kSystemLpOptionPath)); - file_locations.push_back(base::FilePath( - base::GetHomeDir().Append(kUserLpOptionPath))); + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); + file_locations.push_back(base::FilePath(homedir.Append(kUserLpOptionPath))); for (std::vector<base::FilePath>::const_iterator it = file_locations.begin(); it != file_locations.end(); ++it) { diff --git a/remoting/host/branding.cc b/remoting/host/branding.cc index 840e982..fe95479 100644 --- a/remoting/host/branding.cc +++ b/remoting/host/branding.cc @@ -4,7 +4,7 @@ #include "remoting/host/branding.h" -#include "base/file_util.h" +#include "base/base_paths.h" #include "base/path_service.h" namespace { @@ -46,7 +46,7 @@ base::FilePath GetConfigDir() { #elif defined(OS_MACOSX) PathService::Get(base::DIR_APP_DATA, &app_data_dir); #else - app_data_dir = base::GetHomeDir(); + PathService::Get(base::DIR_HOME, &app_data_dir); #endif return app_data_dir.Append(kConfigDir); diff --git a/remoting/host/setup/daemon_controller_delegate_linux.cc b/remoting/host/setup/daemon_controller_delegate_linux.cc index c5a8344..5bc659d 100644 --- a/remoting/host/setup/daemon_controller_delegate_linux.cc +++ b/remoting/host/setup/daemon_controller_delegate_linux.cc @@ -6,6 +6,7 @@ #include <unistd.h> +#include "base/base_paths.h" #include "base/basictypes.h" #include "base/bind.h" #include "base/command_line.h" @@ -16,6 +17,7 @@ #include "base/json/json_writer.h" #include "base/logging.h" #include "base/md5.h" +#include "base/path_service.h" #include "base/process/kill.h" #include "base/process/launch.h" #include "base/process/process_handle.h" @@ -55,8 +57,9 @@ std::string GetMd5(const std::string& value) { base::FilePath GetConfigPath() { std::string filename = "host#" + GetMd5(net::GetHostName()) + ".json"; - return base::GetHomeDir(). - Append(".config/chrome-remote-desktop").Append(filename); + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); + return homedir.Append(".config/chrome-remote-desktop").Append(filename); } bool GetScriptPath(base::FilePath* result) { diff --git a/rlz/chromeos/lib/rlz_value_store_chromeos.cc b/rlz/chromeos/lib/rlz_value_store_chromeos.cc index 0cd87af..c54a194 100644 --- a/rlz/chromeos/lib/rlz_value_store_chromeos.cc +++ b/rlz/chromeos/lib/rlz_value_store_chromeos.cc @@ -4,11 +4,13 @@ #include "rlz/chromeos/lib/rlz_value_store_chromeos.h" +#include "base/base_paths.h" #include "base/file_util.h" #include "base/files/important_file_writer.h" #include "base/json/json_file_value_serializer.h" #include "base/json/json_string_value_serializer.h" #include "base/logging.h" +#include "base/path_service.h" #include "base/sequenced_task_runner.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" @@ -42,15 +44,19 @@ base::FilePath g_testing_rlz_store_path_; // Returns file path of the RLZ storage. base::FilePath GetRlzStorePath() { + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); return g_testing_rlz_store_path_.empty() ? - base::GetHomeDir().Append(kRLZDataFileName) : + homedir.Append(kRLZDataFileName) : g_testing_rlz_store_path_.Append(kRLZDataFileName); } // Returns file path of the RLZ storage lock file. base::FilePath GetRlzStoreLockPath() { + base::FilePath homedir; + PathService::Get(base::DIR_HOME, &homedir); return g_testing_rlz_store_path_.empty() ? - base::GetHomeDir().Append(kRLZLockFileName) : + homedir.Append(kRLZLockFileName) : g_testing_rlz_store_path_.Append(kRLZLockFileName); } |