Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1401)

Side by Side Diff: chrome/install_static/install_util.h

Issue 2422643002: Windows install_static refactor. (Closed)
Patch Set: sync to position 431863 Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // This file contains helper functions which provide information about the 5 // This file contains helper functions which provide information about the
5 // current version of Chrome. This includes channel information, version 6 // current version of Chrome. This includes channel information, version
6 // information etc. This functionality is provided by using functions in 7 // information etc. This functionality is provided by using functions in
7 // kernel32 and advapi32. No other dependencies are allowed in this file. 8 // kernel32 and advapi32. No other dependencies are allowed in this file.
8 9
9 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ 10 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_
10 #define CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ 11 #define CHROME_INSTALL_STATIC_INSTALL_UTIL_H_
11 12
12 #include <string> 13 #include <string>
13 #include <vector> 14 #include <vector>
14 15
15 namespace install_static { 16 namespace install_static {
16 17
18 struct InstallConstants;
19
17 enum class ProcessType { 20 enum class ProcessType {
18 UNINITIALIZED, 21 UNINITIALIZED,
19 NON_BROWSER_PROCESS, 22 NON_BROWSER_PROCESS,
20 BROWSER_PROCESS, 23 BROWSER_PROCESS,
21 }; 24 };
22 25
23 // TODO(ananta)
24 // https://crbug.com/604923
25 // The constants defined in this file are also defined in chrome/installer and
26 // other places. we need to unify them.
27 extern const wchar_t kChromeChannelUnknown[];
28 extern const wchar_t kChromeChannelCanary[];
29 extern const wchar_t kChromeChannelDev[];
30 extern const wchar_t kChromeChannelBeta[];
31 extern const wchar_t kChromeChannelStable[];
32 extern const wchar_t kChromeChannelStableExplicit[];
33 extern const wchar_t kRegPathClientState[];
34 extern const wchar_t kRegPathClientStateMedium[];
35 extern const wchar_t kRegPathChromePolicy[];
36 extern const wchar_t kRegApField[];
37 // Registry key to store the stats/crash sampling state of Chrome. If set to 1, 26 // Registry key to store the stats/crash sampling state of Chrome. If set to 1,
38 // stats and crash reports will be uploaded in line with the user's consent, 27 // stats and crash reports will be uploaded in line with the user's consent,
39 // otherwise, uploads will be disabled. It is used to sample clients, to reduce 28 // otherwise, uploads will be disabled. It is used to sample clients, to reduce
40 // server load for metics and crashes. This is controlled by the 29 // server load for metics and crashes. This is controlled by the
41 // MetricsReporting feature in chrome_metrics_services_manager_client.cc and is 30 // MetricsReporting feature in chrome_metrics_services_manager_client.cc and is
42 // written when metrics services are started up and when consent changes. 31 // written when metrics services are started up and when consent changes.
43 extern const wchar_t kRegValueChromeStatsSample[]; 32 extern const wchar_t kRegValueChromeStatsSample[];
44 // Used to retrieve consent for uploading crashes and metrics.
45 extern const wchar_t kRegValueUsageStats[];
46 extern const wchar_t kUninstallArgumentsField[];
47 extern const wchar_t kMetricsReportingEnabled[];
48 extern const wchar_t kAppGuidCanary[];
49 extern const wchar_t kAppGuidGoogleChrome[];
50 extern const wchar_t kAppGuidGoogleBinaries[];
51 33
52 // TODO(ananta) 34 // TODO(ananta)
53 // https://crbug.com/604923 35 // https://crbug.com/604923
54 // Unify these constants with env_vars.h. 36 // Unify these constants with env_vars.h.
55 extern const wchar_t kHeadless[]; 37 extern const wchar_t kHeadless[];
56 extern const wchar_t kShowRestart[]; 38 extern const wchar_t kShowRestart[];
57 extern const wchar_t kRestartInfo[]; 39 extern const wchar_t kRestartInfo[];
58 extern const wchar_t kRtlLocale[]; 40 extern const wchar_t kRtlLocale[];
59 41
60 // TODO(ananta) 42 // TODO(ananta)
61 // https://crbug.com/604923 43 // https://crbug.com/604923
62 // Unify these constants with those defined in content_switches.h. 44 // Unify these constants with those defined in content_switches.h.
63 extern const char kGpuProcess[]; 45 extern const char kGpuProcess[];
64 extern const char kPpapiPluginProcess[]; 46 extern const char kPpapiPluginProcess[];
65 extern const char kRendererProcess[]; 47 extern const char kRendererProcess[];
66 extern const char kUtilityProcess[]; 48 extern const char kUtilityProcess[];
67 extern const char kProcessType[]; 49 extern const char kProcessType[];
68 extern const char kCrashpadHandler[]; 50 extern const char kCrashpadHandler[];
69 51
70 // Returns true if |exe_path| points to a Chrome installed in an SxS 52 // Returns true if Chrome is running at system level.
71 // installation. 53 bool IsSystemInstall();
72 bool IsSxSChrome(const wchar_t* exe_path);
73
74 // Returns true if |exe_path| points to a per-user level Chrome installation.
75 bool IsSystemInstall(const wchar_t* exe_path);
76 54
77 // Returns true if current installation of Chrome is a multi-install. 55 // Returns true if current installation of Chrome is a multi-install.
78 bool IsMultiInstall(bool is_system_install); 56 bool IsMultiInstall();
79 57
80 // Returns true if usage stats collecting is enabled for this user for the 58 // Returns true if usage stats collecting is enabled for this user for the
81 // current executable. 59 // current executable.
82 bool GetCollectStatsConsent(); 60 bool GetCollectStatsConsent();
83 61
84 // Returns true if usage stats collecting is enabled for this user for the
85 // executable passed in as |exe_path|.
86 // Only used by tests.
87 bool GetCollectStatsConsentForTesting(const std::wstring& exe_path);
88
89 // Returns true if the current executable is currently in the chosen sample that 62 // Returns true if the current executable is currently in the chosen sample that
90 // will report stats and crashes. 63 // will report stats and crashes.
91 bool GetCollectStatsInSample(); 64 bool GetCollectStatsInSample();
92 65
93 // Sets the registry value used for checking if Chrome is in the chosen sample 66 // Sets the registry value used for checking if Chrome is in the chosen sample
94 // that will report stats and crashes. Returns true if writing was successful. 67 // that will report stats and crashes. Returns true if writing was successful.
95 bool SetCollectStatsInSample(bool in_sample); 68 bool SetCollectStatsInSample(bool in_sample);
96 69
97 // Returns true if if usage stats reporting is controlled by a mandatory 70 // Returns true if if usage stats reporting is controlled by a mandatory
98 // policy. |crash_reporting_enabled| determines whether it's enabled (true) or 71 // policy. |crash_reporting_enabled| determines whether it's enabled (true) or
(...skipping 20 matching lines...) Expand all
119 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. 92 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden.
120 // TODO(ananta) 93 // TODO(ananta)
121 // http://crbug.com/604923 94 // http://crbug.com/604923
122 // Unify this with the Browser Distribution code. 95 // Unify this with the Browser Distribution code.
123 bool GetDefaultCrashDumpLocation(std::wstring* crash_dir); 96 bool GetDefaultCrashDumpLocation(std::wstring* crash_dir);
124 97
125 // Returns the contents of the specified |variable_name| from the environment 98 // Returns the contents of the specified |variable_name| from the environment
126 // block of the calling process. Returns an empty string if the variable does 99 // block of the calling process. Returns an empty string if the variable does
127 // not exist. 100 // not exist.
128 std::string GetEnvironmentString(const std::string& variable_name); 101 std::string GetEnvironmentString(const std::string& variable_name);
129 std::wstring GetEnvironmentString16(const std::wstring& variable_name); 102 std::wstring GetEnvironmentString16(const wchar_t* variable_name);
130 103
131 // Sets the environment variable identified by |variable_name| to the value 104 // Sets the environment variable identified by |variable_name| to the value
132 // identified by |new_value|. 105 // identified by |new_value|.
133 bool SetEnvironmentString(const std::string& variable_name, 106 bool SetEnvironmentString(const std::string& variable_name,
134 const std::string& new_value); 107 const std::string& new_value);
135 bool SetEnvironmentString16(const std::wstring& variable_name, 108 bool SetEnvironmentString16(const std::wstring& variable_name,
136 const std::wstring& new_value); 109 const std::wstring& new_value);
137 110
138 // Returns true if the environment variable identified by |variable_name| 111 // Returns true if the environment variable identified by |variable_name|
139 // exists. 112 // exists.
140 bool HasEnvironmentVariable(const std::string& variable_name); 113 bool HasEnvironmentVariable(const std::string& variable_name);
141 bool HasEnvironmentVariable16(const std::wstring& variable_name); 114 bool HasEnvironmentVariable16(const std::wstring& variable_name);
142 115
143 // Gets the exe version details like the |product_name|, |version|, 116 // Gets the exe version details like the |product_name|, |version|,
144 // |special_build|, |channel_name|, etc. Most of this information is read 117 // |special_build|, |channel_name|, etc. Most of this information is read
145 // from the version resource. |exe_path| is the path of chrome.exe. 118 // from the version resource. |exe_path| is the path of chrome.exe.
146 // TODO(ananta) 119 // TODO(ananta)
147 // http://crbug.com/604923 120 // http://crbug.com/604923
148 // Unify this with the Browser Distribution code. 121 // Unify this with the Browser Distribution code.
149 bool GetExecutableVersionDetails(const std::wstring& exe_path, 122 void GetExecutableVersionDetails(const std::wstring& exe_path,
150 std::wstring* product_name, 123 std::wstring* product_name,
151 std::wstring* version, 124 std::wstring* version,
152 std::wstring* special_build, 125 std::wstring* special_build,
153 std::wstring* channel_name); 126 std::wstring* channel_name);
154 127
155 // Gets the channel name for the current Chrome process. 128 // Gets the channel name for the current Chrome process.
156 // If |add_modifier| is true the channel name is returned with the modifier 129 // If |add_modifier| is true the channel name is returned with the modifier
157 // prepended to it. Currently this is only done for multi installs, i.e (-m) 130 // prepended to it. Currently this is only done for multi installs, i.e (-m)
158 // is the only modifier supported. 131 // is the only modifier supported.
159 // TODO(ananta) 132 // TODO(ananta)
160 // http://crbug.com/604923 133 // http://crbug.com/604923
161 // Unify this with the Browser Distribution code. 134 // Unify this with the Browser Distribution code.
162 void GetChromeChannelName(bool is_per_user_install, 135 std::wstring GetChromeChannelName(bool add_modifier);
163 bool add_modifier,
164 std::wstring* channel_name);
165
166 // Returns the version of Google Update that is installed.
167 // TODO(ananta)
168 // http://crbug.com/604923
169 // Unify this with the Browser Distribution code.
170 std::string GetGoogleUpdateVersion();
171
172 // Returns the Chrome installation subdirectory, i.e. Google Chrome\Chromium,
173 // etc.
174 // TODO(ananta)
175 // http://crbug.com/604923
176 // Unify this with the Browser Distribution code.
177 std::wstring GetChromeInstallSubDirectory();
178 136
179 // Returns the registry path where the browser crash dumps metrics need to be 137 // Returns the registry path where the browser crash dumps metrics need to be
180 // written to. 138 // written to.
181 // TODO(ananta) 139 // TODO(ananta)
182 // http://crbug.com/604923 140 // http://crbug.com/604923
183 // Unify this with the version in 141 // Unify this with the version in
184 // chrome\common\metrics_constants_util_win.cc 142 // chrome\common\metrics_constants_util_win.cc
185 std::wstring GetBrowserCrashDumpAttemptsRegistryPath(); 143 std::wstring GetBrowserCrashDumpAttemptsRegistryPath();
186 144
187 // Returns true if the |source| string matches the |pattern|. The pattern 145 // Returns true if the |source| string matches the |pattern|. The pattern
(...skipping 12 matching lines...) Expand all
200 // Tokenizes a string |str| based on single character delimiter. 158 // Tokenizes a string |str| based on single character delimiter.
201 // The tokens are returned in a vector. The |trim_spaces| parameter indicates 159 // The tokens are returned in a vector. The |trim_spaces| parameter indicates
202 // whether the function should optionally trim spaces throughout the string. 160 // whether the function should optionally trim spaces throughout the string.
203 std::vector<std::string> TokenizeString(const std::string& str, 161 std::vector<std::string> TokenizeString(const std::string& str,
204 char delimiter, 162 char delimiter,
205 bool trim_spaces); 163 bool trim_spaces);
206 std::vector<std::wstring> TokenizeString16(const std::wstring& str, 164 std::vector<std::wstring> TokenizeString16(const std::wstring& str,
207 wchar_t delimiter, 165 wchar_t delimiter,
208 bool trim_spaces); 166 bool trim_spaces);
209 167
210 // Compares version strings of the form "X.X.X.X" and returns the result of the
211 // comparison in the |result| parameter. The result is as below:
212 // 0 if the versions are equal.
213 // -1 if version1 < version2.
214 // 1 if version1 > version2.
215 // Returns true on success, false on invalid strings being passed, etc.
216 bool CompareVersionStrings(const std::string& version1,
217 const std::string& version2,
218 int* result);
219
220 // We assume that the command line |command_line| contains multiple switches 168 // We assume that the command line |command_line| contains multiple switches
221 // with the format --<switch name>=<switch value>. This function returns the 169 // with the format --<switch name>=<switch value>. This function returns the
222 // value of the |switch_name| passed in. 170 // value of the |switch_name| passed in.
223 std::string GetSwitchValueFromCommandLine(const std::string& command_line, 171 std::string GetSwitchValueFromCommandLine(const std::string& command_line,
224 const std::string& switch_name); 172 const std::string& switch_name);
225 173
174 // Returns the unadorned channel name based on the channel strategy for the
175 // install mode.
176 std::wstring DetermineChannel(const InstallConstants& mode,
177 bool system_level,
178 bool multi_install);
179
226 // Caches the |ProcessType| of the current process. 180 // Caches the |ProcessType| of the current process.
227 extern ProcessType g_process_type; 181 extern ProcessType g_process_type;
228 182
229 } // namespace install_static 183 } // namespace install_static
230 184
231 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ 185 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698