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_ |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // https://crbug.com/604923 | 53 // https://crbug.com/604923 |
| 54 // Unify these constants with env_vars.h. | 54 // Unify these constants with env_vars.h. |
| 55 extern const wchar_t kHeadless[]; | 55 extern const wchar_t kHeadless[]; |
| 56 extern const wchar_t kShowRestart[]; | 56 extern const wchar_t kShowRestart[]; |
| 57 extern const wchar_t kRestartInfo[]; | 57 extern const wchar_t kRestartInfo[]; |
| 58 extern const wchar_t kRtlLocale[]; | 58 extern const wchar_t kRtlLocale[]; |
| 59 | 59 |
| 60 // TODO(ananta) | 60 // TODO(ananta) |
| 61 // https://crbug.com/604923 | 61 // https://crbug.com/604923 |
| 62 // Unify these constants with those defined in content_switches.h. | 62 // Unify these constants with those defined in content_switches.h. |
| 63 extern const char kGpuProcess[]; | 63 extern const wchar_t kCrashpadHandler[]; |
| 64 extern const char kPpapiPluginProcess[]; | 64 extern const wchar_t kProcessType[]; |
| 65 extern const char kRendererProcess[]; | 65 extern const wchar_t kUserDataDirSwitch[]; |
| 66 extern const char kUtilityProcess[]; | 66 extern const wchar_t kUtilityProcess[]; |
| 67 extern const char kProcessType[]; | |
| 68 extern const char kCrashpadHandler[]; | |
| 69 | 67 |
| 70 // Returns true if |exe_path| points to a Chrome installed in an SxS | 68 // Returns true if |exe_path| points to a Chrome installed in an SxS |
| 71 // installation. | 69 // installation. |
| 72 bool IsSxSChrome(const wchar_t* exe_path); | 70 bool IsSxSChrome(const wchar_t* exe_path); |
| 73 | 71 |
| 74 // Returns true if |exe_path| points to a per-user level Chrome installation. | 72 // Returns true if |exe_path| points to a per-user level Chrome installation. |
| 75 bool IsSystemInstall(const wchar_t* exe_path); | 73 bool IsSystemInstall(const wchar_t* exe_path); |
| 76 | 74 |
| 77 // Returns true if current installation of Chrome is a multi-install. | 75 // Returns true if current installation of Chrome is a multi-install. |
| 78 bool IsMultiInstall(bool is_system_install); | 76 bool IsMultiInstall(bool is_system_install); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 101 | 99 |
| 102 // Initializes |g_process_type| which stores whether or not the current | 100 // Initializes |g_process_type| which stores whether or not the current |
| 103 // process is the main browser process. | 101 // process is the main browser process. |
| 104 void InitializeProcessType(); | 102 void InitializeProcessType(); |
| 105 | 103 |
| 106 // Returns true if invoked in a Chrome process other than the main browser | 104 // Returns true if invoked in a Chrome process other than the main browser |
| 107 // process. False otherwise. | 105 // process. False otherwise. |
| 108 bool IsNonBrowserProcess(); | 106 bool IsNonBrowserProcess(); |
| 109 | 107 |
| 110 // Populates |result| with the default User Data directory for the current | 108 // Populates |result| with the default User Data directory for the current |
| 111 // user.This may be overidden by a command line option.Returns false if all | 109 // user. Returns false if all attempts at locating a User Data directory fail. |
| 112 // attempts at locating a User Data directory fail | |
| 113 // TODO(ananta) | 110 // TODO(ananta) |
| 114 // http://crbug.com/604923 | 111 // http://crbug.com/604923 |
| 115 // Unify this with the Browser Distribution code. | 112 // Unify this with the Browser Distribution code. |
| 116 bool GetDefaultUserDataDirectory(std::wstring* result); | 113 bool GetDefaultUserDataDirectory(std::wstring* result); |
| 117 | 114 |
| 118 // Populates |crash_dir| with the default crash dump location regardless of | 115 // Populates |result| with the user data dir, respecting various overrides in |
| 119 // whether DIR_USER_DATA or DIR_CRASH_DUMPS has been overridden. | 116 // the manner of chrome_main_delegate.cc InitializeUserDataDir(). This includes |
| 117 // overrides on the command line, overrides by registry policy, and fallback to | |
| 118 // the default User Data dir if the directory is invalid or unspecified. | |
| 119 bool GetUserDataDirectory(const std::wstring& user_data_dir_from_command_line, | |
|
grt (UTC plus 2)
2016/11/16 13:24:52
could you add unit tests for these new functions?
scottmg
2016/11/16 21:01:18
Yeah, oops, they're in the file I forgot to add!
| |
| 120 std::wstring* result); | |
| 121 | |
| 122 // The same as GetUserDataDirectory(), but directly queries the global command | |
| 123 // line object for the --user-data-dir flag. This is the more commonly used | |
| 124 // function, where GetUserDataDirectory() is used primiarily for testing. | |
| 125 bool GetUserDataDirectoryUsingProcessCommandLine(std::wstring* result); | |
| 126 | |
| 127 // Populates |crash_dir| with the crash dump location, respecting modifications | |
| 128 // to user-data-dir. | |
| 120 // TODO(ananta) | 129 // TODO(ananta) |
| 121 // http://crbug.com/604923 | 130 // http://crbug.com/604923 |
| 122 // Unify this with the Browser Distribution code. | 131 // Unify this with the Browser Distribution code. |
| 123 bool GetDefaultCrashDumpLocation(std::wstring* crash_dir); | 132 bool GetCrashDumpLocation(std::wstring* crash_dir); |
| 124 | 133 |
| 125 // Returns the contents of the specified |variable_name| from the environment | 134 // 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 | 135 // block of the calling process. Returns an empty string if the variable does |
| 127 // not exist. | 136 // not exist. |
| 128 std::string GetEnvironmentString(const std::string& variable_name); | 137 std::string GetEnvironmentString(const std::string& variable_name); |
| 129 std::wstring GetEnvironmentString16(const std::wstring& variable_name); | 138 std::wstring GetEnvironmentString16(const std::wstring& variable_name); |
| 130 | 139 |
| 131 // Sets the environment variable identified by |variable_name| to the value | 140 // Sets the environment variable identified by |variable_name| to the value |
| 132 // identified by |new_value|. | 141 // identified by |new_value|. |
| 133 bool SetEnvironmentString(const std::string& variable_name, | 142 bool SetEnvironmentString(const std::string& variable_name, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 // -1 if version1 < version2. | 222 // -1 if version1 < version2. |
| 214 // 1 if version1 > version2. | 223 // 1 if version1 > version2. |
| 215 // Returns true on success, false on invalid strings being passed, etc. | 224 // Returns true on success, false on invalid strings being passed, etc. |
| 216 bool CompareVersionStrings(const std::string& version1, | 225 bool CompareVersionStrings(const std::string& version1, |
| 217 const std::string& version2, | 226 const std::string& version2, |
| 218 int* result); | 227 int* result); |
| 219 | 228 |
| 220 // We assume that the command line |command_line| contains multiple switches | 229 // We assume that the command line |command_line| contains multiple switches |
| 221 // with the format --<switch name>=<switch value>. This function returns the | 230 // with the format --<switch name>=<switch value>. This function returns the |
| 222 // value of the |switch_name| passed in. | 231 // value of the |switch_name| passed in. |
| 223 std::string GetSwitchValueFromCommandLine(const std::string& command_line, | 232 std::wstring GetSwitchValueFromCommandLine(const std::wstring& command_line, |
| 224 const std::string& switch_name); | 233 const std::wstring& switch_name); |
| 225 | 234 |
| 226 // Caches the |ProcessType| of the current process. | 235 // Caches the |ProcessType| of the current process. |
| 227 extern ProcessType g_process_type; | 236 extern ProcessType g_process_type; |
| 228 | 237 |
| 229 } // namespace install_static | 238 } // namespace install_static |
| 230 | 239 |
| 231 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ | 240 #endif // CHROME_INSTALL_STATIC_INSTALL_UTIL_H_ |
| OLD | NEW |