1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_INSTALL_STATIC_USER_DATA_DIR_H_
6 #define CHROME_INSTALL_STATIC_USER_DATA_DIR_H_
7 
8 #include <string>
9 
10 namespace install_static {
11 
12 struct InstallConstants;
13 
14 // Populates |result| with the user data dir, respecting various overrides in
15 // the manner of chrome_main_delegate.cc InitializeUserDataDir(). This includes
16 // overrides on the command line, overrides by registry policy, and fallback to
17 // the default User Data dir if the directory is invalid or unspecified.
18 //
19 // If a directory was given by the user (either on the command line, or by
20 // registry policy), but it was invalid or unusable, then
21 // |invalid_supplied_directory| will be filled with the value that was unusable
22 // for reporting an error to the user.
23 //
24 // Other than in test situations, it is generally only appropriate to call this
25 // function once on startup and use the result for subsequent callers, otherwise
26 // there's a race with registry modification (which could cause a different
27 // derivation) so different subsystems would see different values). In normal
28 // usage, it should be called only once and cached. GetUserDataDirectory() does
29 // this, and should be preferred.
30 bool GetUserDataDirectoryImpl(
31     const std::wstring& user_data_dir_from_command_line,
32     const InstallConstants& mode,
33     std::wstring* result,
34     std::wstring* invalid_supplied_directory);
35 
36 // Retrieves the user data directory, and any invalid directory specified on the
37 // command line, for reporting an error to the user. These values are cached on
38 // the first call. |invalid_user_data_directory| may be null if not required.
39 bool GetUserDataDirectory(std::wstring* user_data_directory,
40                           std::wstring* invalid_user_data_directory);
41 
42 }  // namespace install_static
43 
44 #endif  // CHROME_INSTALL_STATIC_USER_DATA_DIR_H_
45