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 // This file contains helper functions which provide information about the | 4 // This file contains helper functions which provide information about the |
5 // current version of Chrome. This includes channel information, version | 5 // current version of Chrome. This includes channel information, version |
6 // information etc. This functionality is provided by using functions in | 6 // information etc. This functionality is provided by using functions in |
7 // kernel32 and advapi32. No other dependencies are allowed in this file. | 7 // kernel32 and advapi32. No other dependencies are allowed in this file. |
8 | 8 |
9 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 9 #ifndef CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
10 #define CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 10 #define CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
11 | 11 |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 | 16 |
17 namespace install_static { | 17 namespace install_static { |
18 | 18 |
19 enum class ProcessType { | 19 enum class ProcessType { |
20 UNINITIALIZED, | 20 UNINITIALIZED, |
21 NON_BROWSER_PROCESS, | 21 NON_BROWSER_PROCESS, |
22 BROWSER_PROCESS, | 22 BROWSER_PROCESS, |
23 }; | 23 }; |
24 | 24 |
25 // TODO(ananta) | 25 // TODO(ananta) |
26 // http://crbug.com/604923 | 26 // https://crbug.com/604923 |
27 // The constants defined in this file are also defined in chrome/installer and | 27 // The constants defined in this file are also defined in chrome/installer and |
28 // other places. we need to unify them. | 28 // other places. we need to unify them. |
29 | |
30 extern const wchar_t kChromeChannelUnknown[]; | 29 extern const wchar_t kChromeChannelUnknown[]; |
31 extern const wchar_t kChromeChannelCanary[]; | 30 extern const wchar_t kChromeChannelCanary[]; |
32 extern const wchar_t kChromeChannelDev[]; | 31 extern const wchar_t kChromeChannelDev[]; |
33 extern const wchar_t kChromeChannelBeta[]; | 32 extern const wchar_t kChromeChannelBeta[]; |
34 extern const wchar_t kChromeChannelStable[]; | 33 extern const wchar_t kChromeChannelStable[]; |
35 extern const wchar_t kChromeChannelStableExplicit[]; | 34 extern const wchar_t kChromeChannelStableExplicit[]; |
36 extern const wchar_t kRegPathClientState[]; | 35 extern const wchar_t kRegPathClientState[]; |
37 extern const wchar_t kRegPathClientStateMedium[]; | 36 extern const wchar_t kRegPathClientStateMedium[]; |
38 extern const wchar_t kRegPathChromePolicy[]; | 37 extern const wchar_t kRegPathChromePolicy[]; |
39 extern const wchar_t kRegApField[]; | 38 extern const wchar_t kRegApField[]; |
40 extern const wchar_t kRegValueUsageStats[]; | 39 extern const wchar_t kRegValueUsageStats[]; |
41 extern const wchar_t kUninstallArgumentsField[]; | 40 extern const wchar_t kUninstallArgumentsField[]; |
42 extern const wchar_t kMetricsReportingEnabled[]; | 41 extern const wchar_t kMetricsReportingEnabled[]; |
43 extern const wchar_t kAppGuidCanary[]; | 42 extern const wchar_t kAppGuidCanary[]; |
44 extern const wchar_t kAppGuidGoogleChrome[]; | 43 extern const wchar_t kAppGuidGoogleChrome[]; |
45 extern const wchar_t kAppGuidGoogleBinaries[]; | 44 extern const wchar_t kAppGuidGoogleBinaries[]; |
46 | 45 |
| 46 // TODO(ananta) |
| 47 // https://crbug.com/604923 |
| 48 // Unify these constants with env_vars.h. |
| 49 extern const wchar_t kHeadless[]; |
| 50 extern const wchar_t kShowRestart[]; |
| 51 extern const wchar_t kRestartInfo[]; |
| 52 extern const wchar_t kRtlLocale[]; |
| 53 |
| 54 // TODO(ananta) |
| 55 // https://crbug.com/604923 |
| 56 // Unify these constants with those defined in content_switches.h. |
| 57 extern const char kGpuProcess[]; |
| 58 extern const char kPpapiPluginProcess[]; |
| 59 extern const char kRendererProcess[]; |
| 60 extern const char kUtilityProcess[]; |
| 61 |
47 // Returns true if |exe_path| points to a Chrome installed in an SxS | 62 // Returns true if |exe_path| points to a Chrome installed in an SxS |
48 // installation. | 63 // installation. |
49 bool IsSxSChrome(const wchar_t* exe_path); | 64 bool IsSxSChrome(const wchar_t* exe_path); |
50 | 65 |
51 // Returns true if |exe_path| points to a per-user level Chrome installation. | 66 // Returns true if |exe_path| points to a per-user level Chrome installation. |
52 bool IsSystemInstall(const wchar_t* exe_path); | 67 bool IsSystemInstall(const wchar_t* exe_path); |
53 | 68 |
54 // Returns true if current installation of Chrome is a multi-install. | 69 // Returns true if current installation of Chrome is a multi-install. |
55 bool IsMultiInstall(bool is_system_install); | 70 bool IsMultiInstall(bool is_system_install); |
56 | 71 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. | 104 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. |
90 // TODO(ananta) | 105 // TODO(ananta) |
91 // http://crbug.com/604923 | 106 // http://crbug.com/604923 |
92 // Unify this with the Browser Distribution code. | 107 // Unify this with the Browser Distribution code. |
93 bool GetDefaultCrashDumpLocation(base::string16* crash_dir); | 108 bool GetDefaultCrashDumpLocation(base::string16* crash_dir); |
94 | 109 |
95 // Returns the contents of the specified |variable_name| from the environment | 110 // Returns the contents of the specified |variable_name| from the environment |
96 // block of the calling process. Returns an empty string if the variable does | 111 // block of the calling process. Returns an empty string if the variable does |
97 // not exist. | 112 // not exist. |
98 std::string GetEnvironmentString(const std::string& variable_name); | 113 std::string GetEnvironmentString(const std::string& variable_name); |
| 114 base::string16 GetEnvironmentString16(const base::string16& variable_name); |
99 | 115 |
100 // Sets the environment variable identified by |variable_name| to the value | 116 // Sets the environment variable identified by |variable_name| to the value |
101 // identified by |new_value|. | 117 // identified by |new_value|. |
102 bool SetEnvironmentString(const std::string& variable_name, | 118 bool SetEnvironmentString(const std::string& variable_name, |
103 const std::string& new_value); | 119 const std::string& new_value); |
| 120 bool SetEnvironmentString16(const base::string16& variable_name, |
| 121 const base::string16& new_value); |
104 | 122 |
105 // Returns true if the environment variable identified by |variable_name| | 123 // Returns true if the environment variable identified by |variable_name| |
106 // exists. | 124 // exists. |
107 bool HasEnvironmentVariable(const std::string& variable_name); | 125 bool HasEnvironmentVariable(const std::string& variable_name); |
| 126 bool HasEnvironmentVariable16(const base::string16& variable_name); |
108 | 127 |
109 // Gets the exe version details like the |product_name|, |version|, | 128 // Gets the exe version details like the |product_name|, |version|, |
110 // |special_build|, |channel_name|, etc. Most of this information is read | 129 // |special_build|, |channel_name|, etc. Most of this information is read |
111 // from the version resource. |exe_path| is the path of chrome.exe. | 130 // from the version resource. |exe_path| is the path of chrome.exe. |
112 // TODO(ananta) | 131 // TODO(ananta) |
113 // http://crbug.com/604923 | 132 // http://crbug.com/604923 |
114 // Unify this with the Browser Distribution code. | 133 // Unify this with the Browser Distribution code. |
115 bool GetExecutableVersionDetails(const base::string16& exe_path, | 134 bool GetExecutableVersionDetails(const base::string16& exe_path, |
116 base::string16* product_name, | 135 base::string16* product_name, |
117 base::string16* version, | 136 base::string16* version, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 base::string16 UTF8ToUTF16(const std::string& source); | 182 base::string16 UTF8ToUTF16(const std::string& source); |
164 | 183 |
165 std::string UTF16ToUTF8(const base::string16& source); | 184 std::string UTF16ToUTF8(const base::string16& source); |
166 | 185 |
167 // Tokenizes a string |str| based on single character delimiter. | 186 // Tokenizes a string |str| based on single character delimiter. |
168 // The tokens are returned in a vector. The |trim_spaces| parameter indicates | 187 // The tokens are returned in a vector. The |trim_spaces| parameter indicates |
169 // whether the function should optionally trim spaces throughout the string. | 188 // whether the function should optionally trim spaces throughout the string. |
170 std::vector<std::string> TokenizeString(const std::string& str, | 189 std::vector<std::string> TokenizeString(const std::string& str, |
171 char delimiter, | 190 char delimiter, |
172 bool trim_spaces); | 191 bool trim_spaces); |
| 192 std::vector<base::string16> TokenizeString16(const base::string16& str, |
| 193 base::char16 delimiter, |
| 194 bool trim_spaces); |
173 | 195 |
174 // Compares version strings of the form "X.X.X.X" and returns the result of the | 196 // Compares version strings of the form "X.X.X.X" and returns the result of the |
175 // comparison in the |result| parameter. The result is as below: | 197 // comparison in the |result| parameter. The result is as below: |
176 // 0 if the versions are equal. | 198 // 0 if the versions are equal. |
177 // -1 if version1 < version2. | 199 // -1 if version1 < version2. |
178 // 1 if version1 > version2. | 200 // 1 if version1 > version2. |
179 // Returns true on success, false on invalid strings being passed, etc. | 201 // Returns true on success, false on invalid strings being passed, etc. |
180 bool CompareVersionStrings(const std::string& version1, | 202 bool CompareVersionStrings(const std::string& version1, |
181 const std::string& version2, | 203 const std::string& version2, |
182 int* result); | 204 int* result); |
183 | 205 |
184 // Caches the |ProcessType| of the current process. | 206 // Caches the |ProcessType| of the current process. |
185 extern ProcessType g_process_type; | 207 extern ProcessType g_process_type; |
186 | 208 |
187 } // namespace install_static | 209 } // namespace install_static |
188 | 210 |
189 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 211 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
OLD | NEW |