Chromium Code Reviews| Index: chrome/install_static/user_data_dir.h |
| diff --git a/chrome/install_static/user_data_dir.h b/chrome/install_static/user_data_dir.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f7b35ec428ee187f02931b269401199164b9c8d8 |
| --- /dev/null |
| +++ b/chrome/install_static/user_data_dir.h |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2016 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 CHROME_INSTALL_STATIC_USER_DATA_DIR_H_ |
| +#define CHROME_INSTALL_STATIC_USER_DATA_DIR_H_ |
| + |
| +#include <string> |
| + |
| +namespace install_static { |
| + |
| +struct InstallConstants; |
| + |
| +// Populates |result| with the user data dir, respecting various overrides in |
| +// the manner of chrome_main_delegate.cc InitializeUserDataDir(). This includes |
| +// overrides on the command line, overrides by registry policy, and fallback to |
| +// the default User Data dir if the directory is invalid or unspecified. |
| +// |
| +// If a directory was given by the user (either on the command line, or by |
| +// registry policy), but it was invalid or unusable, then |
| +// |invalid_supplied_directory| will be filled with the value that was unusable |
| +// for reporting an error to the user. |
| +// |
| +// Other than in test situations, it is generally only appropriate to call this |
| +// function once on startup and use the result for subsequent callers, otherwise |
| +// there's a race with registry modification (which could cause a different |
| +// derivation) so different subsystems would see different values). In normal |
| +// usage, it should be called only once and cached. GetUserDataDirectory() does |
| +// this, and should be preferred. |
| +bool GetUserDataDirectoryImpl( |
| + const std::wstring& user_data_dir_from_command_line, |
| + const InstallConstants& mode, |
|
scottmg
2016/11/22 20:40:42
I maintained passing this in rather than using the
|
| + std::wstring* result, |
| + std::wstring* invalid_supplied_directory); |
| + |
| +// Retrieves the user data directory, and any invalid directory specified on the |
| +// command line, for reporting an error to the user. These values are cached on |
| +// the first call. |invalid_user_data_directory| may be null if not required. |
| +bool GetUserDataDirectory(std::wstring* user_data_directory, |
| + std::wstring* invalid_user_data_directory); |
| + |
| +} // namespace install_static |
| + |
| +#endif // CHROME_INSTALL_STATIC_USER_DATA_DIR_H_ |