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_ |
11 #define CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 11 #define CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
12 | 12 |
13 #include <string> | 13 #include <string> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "chrome/install_static/install_details.h" | |
grt (UTC plus 2)
2016/11/22 21:06:58
is this needed?
scottmg
2016/11/22 21:59:57
Done.
| |
17 | |
16 namespace install_static { | 18 namespace install_static { |
17 | 19 |
18 struct InstallConstants; | 20 struct InstallConstants; |
19 | 21 |
20 enum class ProcessType { | 22 enum class ProcessType { |
21 UNINITIALIZED, | 23 UNINITIALIZED, |
22 NON_BROWSER_PROCESS, | 24 NON_BROWSER_PROCESS, |
23 BROWSER_PROCESS, | 25 BROWSER_PROCESS, |
24 }; | 26 }; |
25 | 27 |
26 // Registry key to store the stats/crash sampling state of Chrome. If set to 1, | 28 // Registry key to store the stats/crash sampling state of Chrome. If set to 1, |
27 // stats and crash reports will be uploaded in line with the user's consent, | 29 // stats and crash reports will be uploaded in line with the user's consent, |
28 // otherwise, uploads will be disabled. It is used to sample clients, to reduce | 30 // otherwise, uploads will be disabled. It is used to sample clients, to reduce |
29 // server load for metics and crashes. This is controlled by the | 31 // server load for metics and crashes. This is controlled by the |
30 // MetricsReporting feature in chrome_metrics_services_manager_client.cc and is | 32 // MetricsReporting feature in chrome_metrics_services_manager_client.cc and is |
31 // written when metrics services are started up and when consent changes. | 33 // written when metrics services are started up and when consent changes. |
32 extern const wchar_t kRegValueChromeStatsSample[]; | 34 extern const wchar_t kRegValueChromeStatsSample[]; |
33 | 35 |
34 // TODO(ananta) | 36 // TODO(ananta) |
35 // https://crbug.com/604923 | 37 // https://crbug.com/604923 |
36 // Unify these constants with env_vars.h. | 38 // Unify these constants with env_vars.h. |
37 extern const wchar_t kHeadless[]; | 39 extern const wchar_t kHeadless[]; |
38 extern const wchar_t kShowRestart[]; | 40 extern const wchar_t kShowRestart[]; |
39 extern const wchar_t kRestartInfo[]; | 41 extern const wchar_t kRestartInfo[]; |
40 extern const wchar_t kRtlLocale[]; | 42 extern const wchar_t kRtlLocale[]; |
41 | 43 |
42 // TODO(ananta) | 44 // TODO(ananta) |
43 // https://crbug.com/604923 | 45 // https://crbug.com/604923 |
44 // Unify these constants with those defined in content_switches.h. | 46 // Unify these constants with those defined in content_switches.h. |
45 extern const char kGpuProcess[]; | 47 extern const wchar_t kCrashpadHandler[]; |
46 extern const char kPpapiPluginProcess[]; | 48 extern const wchar_t kProcessType[]; |
47 extern const char kRendererProcess[]; | 49 extern const wchar_t kUserDataDirSwitch[]; |
48 extern const char kUtilityProcess[]; | 50 extern const wchar_t kUtilityProcess[]; |
49 extern const char kProcessType[]; | |
50 extern const char kCrashpadHandler[]; | |
51 | 51 |
52 // Returns true if Chrome is running at system level. | 52 // Returns true if Chrome is running at system level. |
53 bool IsSystemInstall(); | 53 bool IsSystemInstall(); |
54 | 54 |
55 // Returns true if current installation of Chrome is a multi-install. | 55 // Returns true if current installation of Chrome is a multi-install. |
56 bool IsMultiInstall(); | 56 bool IsMultiInstall(); |
57 | 57 |
58 // 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 |
59 // current executable. | 59 // current executable. |
60 bool GetCollectStatsConsent(); | 60 bool GetCollectStatsConsent(); |
61 | 61 |
62 // 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 |
63 // will report stats and crashes. | 63 // will report stats and crashes. |
64 bool GetCollectStatsInSample(); | 64 bool GetCollectStatsInSample(); |
65 | 65 |
66 // 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 |
67 // 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. |
68 bool SetCollectStatsInSample(bool in_sample); | 68 bool SetCollectStatsInSample(bool in_sample); |
69 | 69 |
70 // Appends "[kCompanyPathName\]kProductPathName[install_suffix]" to |path|, | |
71 // returning a reference to |path|. | |
72 std::wstring& AppendChromeInstallSubDirectory(const InstallConstants& mode, | |
73 bool include_suffix, | |
74 std::wstring* path); | |
75 | |
70 // Returns true if if usage stats reporting is controlled by a mandatory | 76 // Returns true if if usage stats reporting is controlled by a mandatory |
71 // policy. |crash_reporting_enabled| determines whether it's enabled (true) or | 77 // policy. |crash_reporting_enabled| determines whether it's enabled (true) or |
72 // disabled (false). | 78 // disabled (false). |
73 bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled); | 79 bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled); |
74 | 80 |
75 // Initializes |g_process_type| which stores whether or not the current | 81 // Initializes |g_process_type| which stores whether or not the current |
76 // process is the main browser process. | 82 // process is the main browser process. |
77 void InitializeProcessType(); | 83 void InitializeProcessType(); |
78 | 84 |
79 // Returns true if invoked in a Chrome process other than the main browser | 85 // Returns true if invoked in a Chrome process other than the main browser |
80 // process. False otherwise. | 86 // process. False otherwise. |
81 bool IsNonBrowserProcess(); | 87 bool IsNonBrowserProcess(); |
82 | 88 |
83 // Populates |result| with the default User Data directory for the current | 89 // 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 | 90 // to user-data-dir. |
85 // attempts at locating a User Data directory fail | |
86 // TODO(ananta) | 91 // TODO(ananta) |
87 // http://crbug.com/604923 | 92 // http://crbug.com/604923 |
88 // Unify this with the Browser Distribution code. | 93 // Unify this with the Browser Distribution code. |
89 bool GetDefaultUserDataDirectory(std::wstring* result); | 94 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 | 95 |
98 // Returns the contents of the specified |variable_name| from the environment | 96 // 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 | 97 // block of the calling process. Returns an empty string if the variable does |
100 // not exist. | 98 // not exist. |
101 std::string GetEnvironmentString(const std::string& variable_name); | 99 std::string GetEnvironmentString(const std::string& variable_name); |
102 std::wstring GetEnvironmentString16(const wchar_t* variable_name); | 100 std::wstring GetEnvironmentString16(const wchar_t* variable_name); |
103 | 101 |
104 // Sets the environment variable identified by |variable_name| to the value | 102 // Sets the environment variable identified by |variable_name| to the value |
105 // identified by |new_value|. | 103 // identified by |new_value|. |
106 bool SetEnvironmentString(const std::string& variable_name, | 104 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, | 159 std::vector<std::string> TokenizeString(const std::string& str, |
162 char delimiter, | 160 char delimiter, |
163 bool trim_spaces); | 161 bool trim_spaces); |
164 std::vector<std::wstring> TokenizeString16(const std::wstring& str, | 162 std::vector<std::wstring> TokenizeString16(const std::wstring& str, |
165 wchar_t delimiter, | 163 wchar_t delimiter, |
166 bool trim_spaces); | 164 bool trim_spaces); |
167 | 165 |
168 // We assume that the command line |command_line| contains multiple switches | 166 // We assume that the command line |command_line| contains multiple switches |
169 // with the format --<switch name>=<switch value>. This function returns the | 167 // with the format --<switch name>=<switch value>. This function returns the |
170 // value of the |switch_name| passed in. | 168 // value of the |switch_name| passed in. |
171 std::string GetSwitchValueFromCommandLine(const std::string& command_line, | 169 std::wstring GetSwitchValueFromCommandLine(const std::wstring& command_line, |
172 const std::string& switch_name); | 170 const std::wstring& switch_name); |
171 | |
172 // Ensures that the given |full_path| exists, and that the tail component is a | |
173 // directory. If the directory does not already exist, it will be created. | |
174 // Returns false if the final component exists but is not a directory, or on | |
175 // failure to create a directory. | |
176 bool RecursiveDirectoryCreate(const std::wstring& full_path); | |
173 | 177 |
174 // Returns the unadorned channel name based on the channel strategy for the | 178 // Returns the unadorned channel name based on the channel strategy for the |
175 // install mode. | 179 // install mode. |
176 std::wstring DetermineChannel(const InstallConstants& mode, | 180 std::wstring DetermineChannel(const InstallConstants& mode, |
177 bool system_level, | 181 bool system_level, |
178 bool multi_install); | 182 bool multi_install); |
179 | 183 |
180 // Caches the |ProcessType| of the current process. | 184 // Caches the |ProcessType| of the current process. |
181 extern ProcessType g_process_type; | 185 extern ProcessType g_process_type; |
182 | 186 |
183 } // namespace install_static | 187 } // namespace install_static |
184 | 188 |
185 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 189 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
OLD | NEW |