Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_INSTALLER_MINI_INSTALLER_CONFIGURATION_H_ | 5 #ifndef CHROME_INSTALLER_MINI_INSTALLER_CONFIGURATION_H_ |
| 6 #define CHROME_INSTALLER_MINI_INSTALLER_CONFIGURATION_H_ | 6 #define CHROME_INSTALLER_MINI_INSTALLER_CONFIGURATION_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "chrome/installer/mini_installer/mini_string.h" | 10 #include "chrome/installer/mini_installer/mini_string.h" |
| 11 | 11 |
| 12 namespace mini_installer { | 12 namespace mini_installer { |
| 13 | 13 |
| 14 // A simple container of the mini_installer's configuration, as dictated by the | 14 // A simple container of the mini_installer's configuration, as dictated by the |
| 15 // command line used to invoke it. | 15 // command line used to invoke it. |
| 16 class Configuration { | 16 class Configuration { |
| 17 public: | 17 public: |
| 18 enum Operation { | 18 enum Operation { |
| 19 INSTALL_PRODUCT, | 19 INSTALL_PRODUCT, |
| 20 CLEANUP, | 20 CLEANUP, |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 Configuration(); | 23 Configuration(); |
| 24 ~Configuration(); | 24 ~Configuration(); |
|
gab
2016/12/12 21:38:16
Presence of virtual methods (even if protected and
grt (UTC plus 2)
2016/12/13 09:20:37
Switched to overriding the registry.
| |
| 25 | 25 |
| 26 // Initializes this instance on the basis of the process's command line. | 26 // Initializes this instance on the basis of the process's command line. |
| 27 bool Initialize(HMODULE module); | 27 bool Initialize(HMODULE module); |
| 28 | 28 |
| 29 // Returns the desired operation dictated by the command line options. | 29 // Returns the desired operation dictated by the command line options. |
| 30 Operation operation() const { return operation_; } | 30 Operation operation() const { return operation_; } |
| 31 | 31 |
| 32 // Returns the program portion of the command line, or NULL if it cannot be | 32 // Returns the program portion of the command line, or NULL if it cannot be |
| 33 // determined (e.g., by misuse). | 33 // determined (e.g., by misuse). |
| 34 const wchar_t* program() const; | 34 const wchar_t* program() const; |
| 35 | 35 |
| 36 // Returns the number of arguments specified on the command line, including | 36 // Returns the number of arguments specified on the command line, including |
| 37 // the program itself. | 37 // the program itself. |
| 38 int argument_count() const { return argument_count_; } | 38 int argument_count() const { return argument_count_; } |
| 39 | 39 |
| 40 // Returns the original command line. | 40 // Returns the original command line. |
| 41 const wchar_t* command_line() const { return command_line_; } | 41 const wchar_t* command_line() const { return command_line_; } |
| 42 | 42 |
| 43 // Returns the app guid to be used for Chrome. --chrome-sxs on the command | 43 // Returns the app guid to be used for Chrome. --chrome-sxs on the command |
| 44 // line makes this the canary's app guid. | 44 // line makes this the canary's app guid (Google Chrome only). |
| 45 const wchar_t* chrome_app_guid() const { return chrome_app_guid_; } | 45 const wchar_t* chrome_app_guid() const { return chrome_app_guid_; } |
| 46 | 46 |
| 47 // Returns true if --chrome is explicitly or implicitly on the command line. | |
| 48 bool has_chrome() const { return has_chrome_; } | |
| 49 | |
| 50 // Returns true if --multi-install is on the command line. | |
| 51 bool is_multi_install() const { return is_multi_install_; } | |
| 52 | |
| 53 // Returns true if --system-level is on the command line or if | 47 // Returns true if --system-level is on the command line or if |
| 54 // GoogleUpdateIsMachine=1 is set in the process's environment. | 48 // GoogleUpdateIsMachine=1 is set in the process's environment. |
| 55 bool is_system_level() const { return is_system_level_; } | 49 bool is_system_level() const { return is_system_level_; } |
| 56 | 50 |
| 57 // Retuns true if --chrome-sxs is on the command line. | 51 // Retuns true if --chrome-sxs is on the command line (Google Chrome only). |
|
gab
2016/12/12 21:38:16
Why make this Google Chrome only? Chromium SxS exi
grt (UTC plus 2)
2016/12/13 09:20:37
Nope: https://cs.chromium.org/chromium/src/chrome/
gab
2016/12/14 16:33:38
I see, thought it did because we have test_install
grt (UTC plus 2)
2016/12/14 20:38:45
It's magic!
(well, not really, but it isn't obvio
| |
| 58 bool is_side_by_side() const { return is_side_by_side_; } | 52 bool is_side_by_side() const { return is_side_by_side_; } |
| 59 | 53 |
| 54 // Returns true if an existing multi-install Chrome is being updated (Google | |
| 55 // Chrome only). | |
| 56 bool is_updating_multi_chrome() const { return is_updating_multi_chrome_; } | |
| 57 | |
| 60 // Returns true if any invalid switch is found on the command line. | 58 // Returns true if any invalid switch is found on the command line. |
| 61 bool has_invalid_switch() const { return has_invalid_switch_; } | 59 bool has_invalid_switch() const { return has_invalid_switch_; } |
| 62 | 60 |
| 63 // Returns the previous version contained in the image's resource. | 61 // Returns the previous version contained in the image's resource. |
| 64 const wchar_t* previous_version() const { return previous_version_; } | 62 const wchar_t* previous_version() const { return previous_version_; } |
| 65 | 63 |
| 66 protected: | 64 protected: |
| 67 void Clear(); | 65 void Clear(); |
| 68 bool ParseCommandLine(const wchar_t* command_line); | 66 bool ParseCommandLine(const wchar_t* command_line); |
| 69 void ReadResources(HMODULE module); | 67 void ReadResources(HMODULE module); |
| 70 | 68 |
| 71 wchar_t** args_; | 69 wchar_t** args_; |
| 72 const wchar_t* chrome_app_guid_; | 70 const wchar_t* chrome_app_guid_; |
| 73 const wchar_t* command_line_; | 71 const wchar_t* command_line_; |
| 74 int argument_count_; | 72 int argument_count_; |
| 75 Operation operation_; | 73 Operation operation_; |
| 76 bool has_chrome_; | |
| 77 bool is_multi_install_; | |
| 78 bool is_system_level_; | 74 bool is_system_level_; |
| 79 bool is_side_by_side_; | 75 bool is_side_by_side_; |
| 76 bool is_updating_multi_chrome_; | |
| 80 bool has_invalid_switch_; | 77 bool has_invalid_switch_; |
| 81 const wchar_t* previous_version_; | 78 const wchar_t* previous_version_; |
| 82 | 79 |
| 83 protected: | 80 protected: |
| 84 typedef StackString<128> ValueString; | 81 typedef StackString<128> ValueString; |
| 82 enum class RegistryLocation { | |
| 83 CLIENTS_KEY, | |
| 84 CLIENT_STATE_KEY, | |
| 85 }; | |
| 85 | 86 |
| 86 // Virtual for testing. | 87 // Virtual for testing. |
| 87 virtual bool ReadClientStateRegistryValue( | 88 virtual LONG ReadRegistryValue(RegistryLocation location, |
| 88 const HKEY root_key, const wchar_t* app_guid, | 89 const wchar_t* app_guid, |
| 89 LONG* retval, ValueString& value); | 90 const wchar_t* value_name, |
| 91 ValueString* value) const; | |
| 90 | 92 |
| 91 private: | 93 private: |
| 92 Configuration(const Configuration&); | 94 Configuration(const Configuration&); |
| 93 Configuration& operator=(const Configuration&); | 95 Configuration& operator=(const Configuration&); |
| 94 | 96 |
| 95 void SetChromeAppGuid(); | 97 // Returns true if multi-install Chrome is already present on the machine. |
| 98 bool IsUpdatingMultiChrome() const; | |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 } // namespace mini_installer | 101 } // namespace mini_installer |
| 99 | 102 |
| 100 #endif // CHROME_INSTALLER_MINI_INSTALLER_CONFIGURATION_H_ | 103 #endif // CHROME_INSTALLER_MINI_INSTALLER_CONFIGURATION_H_ |
| OLD | NEW |