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