Chromium Code Reviews| 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/files/file_path.h" | |
| 12 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/version.h" | |
| 13 | 15 |
| 16 namespace install_static { | |
| 14 enum class ProcessType { | 17 enum class ProcessType { |
| 15 UNINITIALIZED, | 18 UNINITIALIZED, |
| 16 NON_BROWSER_PROCESS, | 19 NON_BROWSER_PROCESS, |
| 17 BROWSER_PROCESS, | 20 BROWSER_PROCESS, |
| 18 }; | 21 }; |
| 19 | 22 |
| 23 // Chrome channel display names. | |
| 24 extern const wchar_t kChromeChannelUnknown[]; | |
| 25 extern const wchar_t kChromeChannelCanary[]; | |
| 26 extern const wchar_t kChromeChannelDev[]; | |
| 27 extern const wchar_t kChromeChannelBeta[]; | |
| 28 extern const wchar_t kChromeChannelStable[]; | |
| 29 extern const wchar_t kChromeChannelStableExplicit[]; | |
| 30 | |
| 20 // Returns true if |exe_path| points to a Chrome installed in an SxS | 31 // Returns true if |exe_path| points to a Chrome installed in an SxS |
| 21 // installation. | 32 // installation. |
| 22 bool IsCanary(const wchar_t* exe_path); | 33 bool IsCanary(const wchar_t* exe_path); |
| 23 | 34 |
| 24 // Returns true if |exe_path| points to a per-user level Chrome installation. | 35 // Returns true if |exe_path| points to a per-user level Chrome installation. |
| 25 bool IsSystemInstall(const wchar_t* exe_path); | 36 bool IsSystemInstall(const wchar_t* exe_path); |
| 26 | 37 |
| 27 // Returns true if current installation of Chrome is a multi-install. | 38 // Returns true if current installation of Chrome is a multi-install. |
| 28 bool IsMultiInstall(bool is_system_install); | 39 bool IsMultiInstall(bool is_system_install); |
| 29 | 40 |
| 30 // Returns true if usage stats collecting is enabled for this user. | 41 // Returns true if usage stats collecting is enabled for this user. |
| 31 bool AreUsageStatsEnabled(const wchar_t* exe_path); | 42 bool GetCollectStatsConsent(); |
| 32 | 43 |
| 33 // Returns true if a policy is in effect. |breakpad_enabled| will be set to true | 44 // Returns true if a policy is in effect. |breakpad_enabled| will be set to |
| 34 // if stats collecting is permitted by this policy and false if not. | 45 // true if stats collecting is permitted by this policy and false if not. |
| 35 bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); | 46 bool ReportingIsEnforcedByPolicy(bool* breakpad_enabled); |
| 36 | 47 |
| 37 // Initializes |g_process_type| which stores whether or not the current process | 48 // Initializes |g_process_type| which stores whether or not the current |
| 38 // is the main browser process. | 49 // process is the main browser process. |
| 39 void InitializeProcessType(); | 50 void InitializeProcessType(); |
| 40 | 51 |
| 41 // Returns true if invoked in a Chrome process other than the main browser | 52 // Returns true if invoked in a Chrome process other than the main browser |
| 42 // process. False otherwise. | 53 // process. False otherwise. |
| 43 bool IsNonBrowserProcess(); | 54 bool IsNonBrowserProcess(); |
| 44 | 55 |
| 56 // Get the path to the user's data directory, regardless of whether | |
| 57 // DIR_USER_DATA has been overridden by a command-line option. | |
| 58 // TODO(ananta) | |
|
scottmg
2016/04/26 20:44:47
Add the crbug link on these TODOs.
ananta
2016/04/26 21:33:09
Done.
| |
| 59 // Unify this with the Browser Distribution code. | |
| 60 bool GetDefaultUserDataDirectory(base::FilePath* result); | |
| 61 | |
| 62 // Populates |crash_dir| with the default crash dump location regardless of | |
| 63 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. | |
| 64 // TODO(ananta) | |
| 65 // Unify this with the Browser Distribution code. | |
| 66 bool GetDefaultCrashDumpLocation(base::FilePath* crash_dir); | |
| 67 | |
| 68 // Returns the contents of the specified |variable_name| from the environment | |
| 69 // block of the calling process. Returns an empty string if the variable does | |
| 70 // not exist. | |
| 71 std::string GetEnvironmentString(const std::string& variable_name); | |
| 72 | |
| 73 // Sets the environment variable identified by |variable_name| to the value | |
| 74 // identified by |new_value|. | |
| 75 bool SetEnvironmentString(const std::string& variable_name, | |
| 76 const std::string& new_value); | |
| 77 | |
| 78 // Returns true if the environment variable identified by |variable_name| | |
| 79 // exists. | |
| 80 bool HasEnvironmentVariable(const std::string& variable_name); | |
| 81 | |
| 82 // Gets the exe version details like the |product_name|, |version|, | |
| 83 // |special_build|, |channel_name|, etc. Most of this information is read | |
| 84 // from the version resource. |exe_path| is the path of chrome.exe. | |
| 85 // TODO(ananta) | |
| 86 // Unify this with the Browser Distribution code. | |
| 87 bool GetExecutableVersionDetails(const base::string16& exe_path, | |
| 88 base::string16* product_name, | |
| 89 base::string16* version, | |
| 90 base::string16* special_build, | |
| 91 base::string16* channel_name); | |
| 92 | |
| 93 // Gets the channel name for the current Chrome process. | |
| 94 // TODO(ananta) | |
| 95 // Unify this with the Browser Distribution code. | |
| 96 void GetChromeChannelName(bool is_per_user_install, | |
| 97 base::string16* channel_name); | |
| 98 | |
| 99 | |
| 100 // Returns the version of Google Update that is installed. | |
| 101 // TODO(ananta) | |
| 102 // Unify this with the Browser Distribution code. | |
| 103 base::Version GetGoogleUpdateVersion(); | |
| 104 | |
| 105 // Returns the Chrome installation subdirectory, i.e. Google Chrome\Chromium, | |
| 106 // etc. | |
| 107 // TODO(ananta) | |
| 108 // Unify this with the Browser Distribution code. | |
| 109 base::string16 GetChromeInstallSubDirectory(); | |
| 110 | |
| 111 // Returns the registry path where the browser crash dumps metrics need to be | |
| 112 // written to. | |
| 113 // TODO(ananta) | |
| 114 // Unify this with the version in | |
| 115 // chrome\common\metrics_constants_util_win.cc | |
| 116 base::string16 GetBrowserCrashDumpAttemptsRegistryPath(); | |
| 117 | |
| 45 // Caches the |ProcessType| of the current process. | 118 // Caches the |ProcessType| of the current process. |
| 46 extern ProcessType g_process_type; | 119 extern ProcessType g_process_type; |
| 47 | 120 |
| 121 } // namespace install_static | |
| 122 | |
| 48 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 123 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
| OLD | NEW |