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 // This file contains helper functions which provide information about the | 5 // This file contains helper functions which provide information about the |
6 // current version of Chrome. This includes channel information, version | 6 // current version of Chrome. This includes channel information, version |
7 // information etc. This functionality is provided by using functions in | 7 // information etc. This functionality is provided by using functions in |
8 // kernel32 and advapi32. No other dependencies are allowed in this file. | 8 // kernel32 and advapi32. No other dependencies are allowed in this file. |
9 | 9 |
10 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 10 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
(...skipping 24 matching lines...) Expand all Loading... |
35 // https://crbug.com/604923 | 35 // https://crbug.com/604923 |
36 // Unify these constants with env_vars.h. | 36 // Unify these constants with env_vars.h. |
37 extern const wchar_t kHeadless[]; | 37 extern const wchar_t kHeadless[]; |
38 extern const wchar_t kShowRestart[]; | 38 extern const wchar_t kShowRestart[]; |
39 extern const wchar_t kRestartInfo[]; | 39 extern const wchar_t kRestartInfo[]; |
40 extern const wchar_t kRtlLocale[]; | 40 extern const wchar_t kRtlLocale[]; |
41 | 41 |
42 // TODO(ananta) | 42 // TODO(ananta) |
43 // https://crbug.com/604923 | 43 // https://crbug.com/604923 |
44 // Unify these constants with those defined in content_switches.h. | 44 // Unify these constants with those defined in content_switches.h. |
45 extern const char kGpuProcess[]; | 45 extern const wchar_t kCrashpadHandler[]; |
46 extern const char kPpapiPluginProcess[]; | 46 extern const wchar_t kProcessType[]; |
47 extern const char kRendererProcess[]; | 47 extern const wchar_t kUserDataDirSwitch[]; |
48 extern const char kUtilityProcess[]; | 48 extern const wchar_t kUtilityProcess[]; |
49 extern const char kProcessType[]; | 49 |
50 extern const char kCrashpadHandler[]; | 50 // Used for suppressing warnings. |
| 51 template <typename T> inline void IgnoreUnused(T) {} |
51 | 52 |
52 // Returns true if Chrome is running at system level. | 53 // Returns true if Chrome is running at system level. |
53 bool IsSystemInstall(); | 54 bool IsSystemInstall(); |
54 | 55 |
55 // Returns true if current installation of Chrome is a multi-install. | 56 // Returns true if current installation of Chrome is a multi-install. |
56 bool IsMultiInstall(); | 57 bool IsMultiInstall(); |
57 | 58 |
58 // Returns true if usage stats collecting is enabled for this user for the | 59 // Returns true if usage stats collecting is enabled for this user for the |
59 // current executable. | 60 // current executable. |
60 bool GetCollectStatsConsent(); | 61 bool GetCollectStatsConsent(); |
61 | 62 |
62 // Returns true if the current executable is currently in the chosen sample that | 63 // Returns true if the current executable is currently in the chosen sample that |
63 // will report stats and crashes. | 64 // will report stats and crashes. |
64 bool GetCollectStatsInSample(); | 65 bool GetCollectStatsInSample(); |
65 | 66 |
66 // Sets the registry value used for checking if Chrome is in the chosen sample | 67 // Sets the registry value used for checking if Chrome is in the chosen sample |
67 // that will report stats and crashes. Returns true if writing was successful. | 68 // that will report stats and crashes. Returns true if writing was successful. |
68 bool SetCollectStatsInSample(bool in_sample); | 69 bool SetCollectStatsInSample(bool in_sample); |
69 | 70 |
| 71 // Appends "[kCompanyPathName\]kProductPathName[install_suffix]" to |path|, |
| 72 // returning a reference to |path|. |
| 73 std::wstring& AppendChromeInstallSubDirectory(const InstallConstants& mode, |
| 74 bool include_suffix, |
| 75 std::wstring* path); |
| 76 |
70 // Returns true if if usage stats reporting is controlled by a mandatory | 77 // Returns true if if usage stats reporting is controlled by a mandatory |
71 // policy. |crash_reporting_enabled| determines whether it's enabled (true) or | 78 // policy. |crash_reporting_enabled| determines whether it's enabled (true) or |
72 // disabled (false). | 79 // disabled (false). |
73 bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled); | 80 bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled); |
74 | 81 |
75 // Initializes |g_process_type| which stores whether or not the current | 82 // Initializes |g_process_type| which stores whether or not the current |
76 // process is the main browser process. | 83 // process is the main browser process. |
77 void InitializeProcessType(); | 84 void InitializeProcessType(); |
78 | 85 |
79 // Returns true if invoked in a Chrome process other than the main browser | 86 // Returns true if invoked in a Chrome process other than the main browser |
80 // process. False otherwise. | 87 // process. False otherwise. |
81 bool IsNonBrowserProcess(); | 88 bool IsNonBrowserProcess(); |
82 | 89 |
83 // Populates |result| with the default User Data directory for the current | 90 // Populates |crash_dir| with the crash dump location, respecting modifications |
84 // user.This may be overidden by a command line option.Returns false if all | 91 // to user-data-dir. |
85 // attempts at locating a User Data directory fail | |
86 // TODO(ananta) | 92 // TODO(ananta) |
87 // http://crbug.com/604923 | 93 // http://crbug.com/604923 |
88 // Unify this with the Browser Distribution code. | 94 // Unify this with the Browser Distribution code. |
89 bool GetDefaultUserDataDirectory(std::wstring* result); | 95 std::wstring GetCrashDumpLocation(); |
90 | |
91 // Populates |crash_dir| with the default crash dump location regardless of | |
92 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. | |
93 // TODO(ananta) | |
94 // http://crbug.com/604923 | |
95 // Unify this with the Browser Distribution code. | |
96 bool GetDefaultCrashDumpLocation(std::wstring* crash_dir); | |
97 | 96 |
98 // Returns the contents of the specified |variable_name| from the environment | 97 // Returns the contents of the specified |variable_name| from the environment |
99 // block of the calling process. Returns an empty string if the variable does | 98 // block of the calling process. Returns an empty string if the variable does |
100 // not exist. | 99 // not exist. |
101 std::string GetEnvironmentString(const std::string& variable_name); | 100 std::string GetEnvironmentString(const std::string& variable_name); |
102 std::wstring GetEnvironmentString16(const wchar_t* variable_name); | 101 std::wstring GetEnvironmentString16(const wchar_t* variable_name); |
103 | 102 |
104 // Sets the environment variable identified by |variable_name| to the value | 103 // Sets the environment variable identified by |variable_name| to the value |
105 // identified by |new_value|. | 104 // identified by |new_value|. |
106 bool SetEnvironmentString(const std::string& variable_name, | 105 bool SetEnvironmentString(const std::string& variable_name, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 std::vector<std::string> TokenizeString(const std::string& str, | 160 std::vector<std::string> TokenizeString(const std::string& str, |
162 char delimiter, | 161 char delimiter, |
163 bool trim_spaces); | 162 bool trim_spaces); |
164 std::vector<std::wstring> TokenizeString16(const std::wstring& str, | 163 std::vector<std::wstring> TokenizeString16(const std::wstring& str, |
165 wchar_t delimiter, | 164 wchar_t delimiter, |
166 bool trim_spaces); | 165 bool trim_spaces); |
167 | 166 |
168 // We assume that the command line |command_line| contains multiple switches | 167 // We assume that the command line |command_line| contains multiple switches |
169 // with the format --<switch name>=<switch value>. This function returns the | 168 // with the format --<switch name>=<switch value>. This function returns the |
170 // value of the |switch_name| passed in. | 169 // value of the |switch_name| passed in. |
171 std::string GetSwitchValueFromCommandLine(const std::string& command_line, | 170 std::wstring GetSwitchValueFromCommandLine(const std::wstring& command_line, |
172 const std::string& switch_name); | 171 const std::wstring& switch_name); |
| 172 |
| 173 // Ensures that the given |full_path| exists, and that the tail component is a |
| 174 // directory. If the directory does not already exist, it will be created. |
| 175 // Returns false if the final component exists but is not a directory, or on |
| 176 // failure to create a directory. |
| 177 bool RecursiveDirectoryCreate(const std::wstring& full_path); |
173 | 178 |
174 // Returns the unadorned channel name based on the channel strategy for the | 179 // Returns the unadorned channel name based on the channel strategy for the |
175 // install mode. | 180 // install mode. |
176 std::wstring DetermineChannel(const InstallConstants& mode, | 181 std::wstring DetermineChannel(const InstallConstants& mode, |
177 bool system_level, | 182 bool system_level, |
178 bool multi_install); | 183 bool multi_install); |
179 | 184 |
180 // Caches the |ProcessType| of the current process. | 185 // Caches the |ProcessType| of the current process. |
181 extern ProcessType g_process_type; | 186 extern ProcessType g_process_type; |
182 | 187 |
183 } // namespace install_static | 188 } // namespace install_static |
184 | 189 |
185 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 190 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
OLD | NEW |