Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/user_data_dir_extractor.h" | 5 #include "chrome/browser/user_data_dir_extractor.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 IsStringUTF8(user_data_dir_string)) { | 87 IsStringUTF8(user_data_dir_string)) { |
| 88 user_data_dir = base::FilePath::FromUTF8Unsafe(user_data_dir_string); | 88 user_data_dir = base::FilePath::FromUTF8Unsafe(user_data_dir_string); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 #endif | 91 #endif |
| 92 #if defined(OS_MACOSX) || defined(OS_WIN) | 92 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 93 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); | 93 policy::path_parser::CheckUserDataDirPolicy(&user_data_dir); |
| 94 #endif | 94 #endif |
| 95 | 95 |
| 96 // If the directory does not exist and cannot be created, prompt the user. | 96 // If the directory does not exist and cannot be created, prompt the user. |
| 97 if (!user_data_dir.empty() && | 97 const bool specified_directory_was_invalid = !user_data_dir.empty() && |
| 98 !PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA, | 98 !PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA, |
| 99 user_data_dir, chrome::ProcessNeedsProfileDir(process_type))) { | 99 user_data_dir, chrome::ProcessNeedsProfileDir(process_type)); |
| 100 if (specified_directory_was_invalid) | |
| 100 ShowUserDataDirWarning(user_data_dir); | 101 ShowUserDataDirWarning(user_data_dir); |
| 101 } | |
| 102 | 102 |
| 103 // Getting the user data directory can fail if the directory isn't creatable. | 103 // Getting the user data directory can fail if the directory isn't creatable. |
| 104 // ProcessSingleton needs a real user data directory on Mac/Linux, so it's | 104 // ProcessSingleton needs a real user data directory on Mac/Linux, so it's |
| 105 // better to fail here than fail mysteriously elsewhere. | 105 // better to fail here than fail mysteriously elsewhere. |
| 106 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 106 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) |
| 107 << "Must be able to get user data directory!"; | 107 << "Must be able to get user data directory!"; |
| 108 | |
| 109 // Append the fallback user data directory to the commandline. Otherwise, | |
| 110 // child or service processes will attempt to use the invalid directory. | |
| 111 if (specified_directory_was_invalid) | |
| 112 CommandLine::ForCurrentProcess()->AppendSwitchPath(switches::kUserDataDir, | |
|
Vitaly Buka (NO REVIEWS)
2014/02/20 21:28:05
actually you just did that
| |
| 113 user_data_dir); | |
| 114 | |
| 108 return user_data_dir; | 115 return user_data_dir; |
| 109 } | 116 } |
| 110 | 117 |
| 111 } // namespace chrome | 118 } // namespace chrome |
| OLD | NEW |