| 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 "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 | 13 |
| 14 namespace install_static { | |
| 15 | |
| 16 enum class ProcessType { | 14 enum class ProcessType { |
| 17 UNINITIALIZED, | 15 UNINITIALIZED, |
| 18 NON_BROWSER_PROCESS, | 16 NON_BROWSER_PROCESS, |
| 19 BROWSER_PROCESS, | 17 BROWSER_PROCESS, |
| 20 }; | 18 }; |
| 21 | 19 |
| 22 // TODO(ananta) | |
| 23 // http://crbug.com/604923 | |
| 24 // The constants defined in this file are also defined in chrome/installer and | |
| 25 // other places. we need to unify them. | |
| 26 | |
| 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 extern const wchar_t kRegValueUsageStats[]; | |
| 38 extern const wchar_t kUninstallArgumentsField[]; | |
| 39 extern const wchar_t kMetricsReportingEnabled[]; | |
| 40 extern const wchar_t kAppGuidCanary[]; | |
| 41 extern const wchar_t kAppGuidGoogleChrome[]; | |
| 42 extern const wchar_t kAppGuidGoogleBinaries[]; | |
| 43 | |
| 44 // Returns true if |exe_path| points to a Chrome installed in an SxS | 20 // Returns true if |exe_path| points to a Chrome installed in an SxS |
| 45 // installation. | 21 // installation. |
| 46 bool IsSxSChrome(const wchar_t* exe_path); | 22 bool IsCanary(const wchar_t* exe_path); |
| 47 | 23 |
| 48 // Returns true if |exe_path| points to a per-user level Chrome installation. | 24 // Returns true if |exe_path| points to a per-user level Chrome installation. |
| 49 bool IsSystemInstall(const wchar_t* exe_path); | 25 bool IsSystemInstall(const wchar_t* exe_path); |
| 50 | 26 |
| 51 // Returns true if current installation of Chrome is a multi-install. | 27 // Returns true if current installation of Chrome is a multi-install. |
| 52 bool IsMultiInstall(bool is_system_install); | 28 bool IsMultiInstall(bool is_system_install); |
| 53 | 29 |
| 54 // Returns true if usage stats collecting is enabled for this user for the | 30 // Returns true if usage stats collecting is enabled for this user. |
| 55 // current executable. | 31 bool AreUsageStatsEnabled(const wchar_t* exe_path); |
| 56 bool GetCollectStatsConsent(); | |
| 57 | 32 |
| 58 // Returns true if usage stats collecting is enabled for this user for the | 33 // Returns true if a policy is in effect. |breakpad_enabled| will be set to true |
| 59 // executable passed in as |exe_path|. | 34 // if stats collecting is permitted by this policy and false if not. |
| 60 // Only used by tests. | 35 bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); |
| 61 bool GetCollectStatsConsentForTesting(const base::string16& exe_path); | |
| 62 | 36 |
| 63 // Returns true if if usage stats reporting is controlled by a mandatory | 37 // Initializes |g_process_type| which stores whether or not the current process |
| 64 // policy. |metrics_is_enforced_by_policy| will be set to true accordingly. | 38 // is the main browser process. |
| 65 // TODO(ananta) | |
| 66 // Make this function private to install_util. | |
| 67 bool ReportingIsEnforcedByPolicy(bool* metrics_is_enforced_by_policy); | |
| 68 | |
| 69 // Initializes |g_process_type| which stores whether or not the current | |
| 70 // process is the main browser process. | |
| 71 void InitializeProcessType(); | 39 void InitializeProcessType(); |
| 72 | 40 |
| 73 // Returns true if invoked in a Chrome process other than the main browser | 41 // Returns true if invoked in a Chrome process other than the main browser |
| 74 // process. False otherwise. | 42 // process. False otherwise. |
| 75 bool IsNonBrowserProcess(); | 43 bool IsNonBrowserProcess(); |
| 76 | 44 |
| 77 // Populates |result| with the default User Data directory for the current | |
| 78 // user.This may be overidden by a command line option.Returns false if all | |
| 79 // attempts at locating a User Data directory fail | |
| 80 // TODO(ananta) | |
| 81 // http://crbug.com/604923 | |
| 82 // Unify this with the Browser Distribution code. | |
| 83 bool GetDefaultUserDataDirectory(base::string16* result); | |
| 84 | |
| 85 // Populates |crash_dir| with the default crash dump location regardless of | |
| 86 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. | |
| 87 // TODO(ananta) | |
| 88 // http://crbug.com/604923 | |
| 89 // Unify this with the Browser Distribution code. | |
| 90 bool GetDefaultCrashDumpLocation(base::string16* crash_dir); | |
| 91 | |
| 92 // Returns the contents of the specified |variable_name| from the environment | |
| 93 // block of the calling process. Returns an empty string if the variable does | |
| 94 // not exist. | |
| 95 std::string GetEnvironmentString(const std::string& variable_name); | |
| 96 | |
| 97 // Sets the environment variable identified by |variable_name| to the value | |
| 98 // identified by |new_value|. | |
| 99 bool SetEnvironmentString(const std::string& variable_name, | |
| 100 const std::string& new_value); | |
| 101 | |
| 102 // Returns true if the environment variable identified by |variable_name| | |
| 103 // exists. | |
| 104 bool HasEnvironmentVariable(const std::string& variable_name); | |
| 105 | |
| 106 // Gets the exe version details like the |product_name|, |version|, | |
| 107 // |special_build|, |channel_name|, etc. Most of this information is read | |
| 108 // from the version resource. |exe_path| is the path of chrome.exe. | |
| 109 // TODO(ananta) | |
| 110 // http://crbug.com/604923 | |
| 111 // Unify this with the Browser Distribution code. | |
| 112 bool GetExecutableVersionDetails(const base::string16& exe_path, | |
| 113 base::string16* product_name, | |
| 114 base::string16* version, | |
| 115 base::string16* special_build, | |
| 116 base::string16* channel_name); | |
| 117 | |
| 118 // Gets the channel name for the current Chrome process. | |
| 119 // If |add_modifier| is true the channel name is returned with the modifier | |
| 120 // prepended to it. Currently this is only done for multi installs, i.e (-m) | |
| 121 // is the only modifier supported. | |
| 122 // TODO(ananta) | |
| 123 // http://crbug.com/604923 | |
| 124 // Unify this with the Browser Distribution code. | |
| 125 void GetChromeChannelName(bool is_per_user_install, | |
| 126 bool add_modifier, | |
| 127 base::string16* channel_name); | |
| 128 | |
| 129 | |
| 130 // Returns the version of Google Update that is installed. | |
| 131 // TODO(ananta) | |
| 132 // http://crbug.com/604923 | |
| 133 // Unify this with the Browser Distribution code. | |
| 134 std::string GetGoogleUpdateVersion(); | |
| 135 | |
| 136 // Returns the Chrome installation subdirectory, i.e. Google Chrome\Chromium, | |
| 137 // etc. | |
| 138 // TODO(ananta) | |
| 139 // http://crbug.com/604923 | |
| 140 // Unify this with the Browser Distribution code. | |
| 141 base::string16 GetChromeInstallSubDirectory(); | |
| 142 | |
| 143 // Returns the registry path where the browser crash dumps metrics need to be | |
| 144 // written to. | |
| 145 // TODO(ananta) | |
| 146 // http://crbug.com/604923 | |
| 147 // Unify this with the version in | |
| 148 // chrome\common\metrics_constants_util_win.cc | |
| 149 base::string16 GetBrowserCrashDumpAttemptsRegistryPath(); | |
| 150 | |
| 151 // Returns true if the |source| string matches the |pattern|. The pattern | |
| 152 // may contain wildcards like '?', which matches one character or a '*' | |
| 153 // which matches 0 or more characters. | |
| 154 // Please note that pattern matches the whole string. If you want to find | |
| 155 // something in the middle of the string then you need to specify the pattern | |
| 156 // as '*xyz*'. | |
| 157 bool MatchPattern(const base::string16& source, const base::string16& pattern); | |
| 158 | |
| 159 // Caches the |ProcessType| of the current process. | 45 // Caches the |ProcessType| of the current process. |
| 160 extern ProcessType g_process_type; | 46 extern ProcessType g_process_type; |
| 161 | 47 |
| 162 } // namespace install_static | |
| 163 | |
| 164 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 48 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
| OLD | NEW |