Chromium Code Reviews| Index: chrome/installer/mini_installer/configuration.cc |
| diff --git a/chrome/installer/mini_installer/configuration.cc b/chrome/installer/mini_installer/configuration.cc |
| index 6d20d6d37783c95e16c102247cdcde9cffd3414d..3b5c51af08291a7029885bc4fa374ef9e7f28a0c 100644 |
| --- a/chrome/installer/mini_installer/configuration.cc |
| +++ b/chrome/installer/mini_installer/configuration.cc |
| @@ -36,54 +36,10 @@ Configuration::~Configuration() { |
| Clear(); |
| } |
| -// When multi_install is true, we are potentially: |
| -// 1. Performing a multi-install of some product(s) on a clean machine. |
| -// Neither the product(s) nor the multi-installer will have a |
| -// ClientState key in the registry, so there is no key to be modified. |
| -// 2. Upgrading an existing multi-install. The multi-installer will have |
| -// a ClientState key in the registry. Only it need be modified. |
| -// 3. Migrating a single-install into a multi-install. The product will |
| -// have a ClientState key in the registry. Only it need be modified. |
| -// To handle all cases, we inspect the product's ClientState to see if it |
| -// exists and its "ap" value does not contain "-multi". This is case 3, |
| -// so we modify the product's ClientState. Otherwise, we check the |
| -// multi-installer's ClientState and modify it if it exists. |
| -// TODO(bcwhite): Write a unit test for this that uses registry virtualization. |
| -void Configuration::SetChromeAppGuid() { |
| - const HKEY root_key = |
| - is_system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| - const wchar_t* app_guid = |
| - is_side_by_side_ ? google_update::kSxSAppGuid |
| - : google_update::kAppGuid; |
| - |
| - // This is the value for single-install and case 3. |
| - chrome_app_guid_ = app_guid; |
| - |
| - if (is_multi_install_) { |
| - ValueString value; |
| - LONG ret = ERROR_SUCCESS; |
| - if (ReadClientStateRegistryValue(root_key, app_guid, &ret, value)) { |
| - // The product has a client state key. See if it's a single-install. |
| - if (ret == ERROR_FILE_NOT_FOUND || |
| - (ret == ERROR_SUCCESS && |
| - !FindTagInStr(value.get(), kMultiInstallTag, NULL))) { |
| - // yes -- case 3: use the existing key. |
| - return; |
| - } |
| - } |
| - // error, case 1, or case 2: modify the multi-installer's key. |
| - chrome_app_guid_ = google_update::kMultiInstallAppGuid; |
| - } |
| -} |
| - |
| -bool Configuration::ReadClientStateRegistryValue( |
| - const HKEY root_key, const wchar_t* app_guid, |
| - LONG* retval, ValueString& value) { |
| - RegKey key; |
| - if (!OpenClientStateKey(root_key, app_guid, KEY_QUERY_VALUE, &key)) |
| - return false; |
| - *retval = key.ReadSZValue(kApRegistryValue, value.get(), value.capacity()); |
| - return true; |
| +bool Configuration::Initialize(HMODULE module) { |
| + Clear(); |
| + ReadResources(module); |
| + return ParseCommandLine(::GetCommandLine()); |
| } |
| const wchar_t* Configuration::program() const { |
| @@ -99,20 +55,13 @@ void Configuration::Clear() { |
| command_line_ = NULL; |
| operation_ = INSTALL_PRODUCT; |
| argument_count_ = 0; |
| - has_chrome_ = false; |
| - is_multi_install_ = false; |
| is_system_level_ = false; |
| is_side_by_side_ = false; |
| + is_updating_multi_chrome_ = false; |
| has_invalid_switch_ = false; |
| previous_version_ = NULL; |
| } |
| -bool Configuration::Initialize(HMODULE module) { |
| - Clear(); |
| - ReadResources(module); |
| - return ParseCommandLine(::GetCommandLine()); |
| -} |
| - |
| // |command_line| is shared with this instance in the sense that this |
| // instance may refer to it at will throughout its lifetime, yet it will |
| // not release it. |
| @@ -123,14 +72,12 @@ bool Configuration::ParseCommandLine(const wchar_t* command_line) { |
| return false; |
| for (int i = 1; i < argument_count_; ++i) { |
| - if (0 == ::lstrcmpi(args_[i], L"--chrome-sxs")) |
| - is_side_by_side_ = true; |
| - else if (0 == ::lstrcmpi(args_[i], L"--chrome")) |
| - has_chrome_ = true; |
| - else if (0 == ::lstrcmpi(args_[i], L"--multi-install")) |
| - is_multi_install_ = true; |
| - else if (0 == ::lstrcmpi(args_[i], L"--system-level")) |
| + if (0 == ::lstrcmpi(args_[i], L"--system-level")) |
| is_system_level_ = true; |
| +#if defined(GOOGLE_CHROME_BUILD) |
| + else if (0 == ::lstrcmpi(args_[i], L"--chrome-sxs")) |
| + is_side_by_side_ = true; |
| +#endif |
| else if (0 == ::lstrcmpi(args_[i], L"--cleanup")) |
| operation_ = CLEANUP; |
| else if (0 == ::lstrcmpi(args_[i], L"--chrome-frame")) |
| @@ -139,9 +86,10 @@ bool Configuration::ParseCommandLine(const wchar_t* command_line) { |
| if (!is_system_level_) |
| is_system_level_ = GetGoogleUpdateIsMachineEnvVar(); |
| - SetChromeAppGuid(); |
| - if (!is_multi_install_) |
| - has_chrome_ = true; |
| + if (is_side_by_side_) |
| + chrome_app_guid_ = google_update::kSxSAppGuid; |
|
gab
2016/12/12 21:38:16
Set this in above block on line 79
grt (UTC plus 2)
2016/12/13 09:20:37
Done.
|
| + |
| + is_updating_multi_chrome_ = IsUpdatingMultiChrome(); |
| return true; |
| } |
| @@ -175,4 +123,42 @@ void Configuration::ReadResources(HMODULE module) { |
| previous_version_ = version_string; |
| } |
| +LONG Configuration::ReadRegistryValue(RegistryLocation location, |
| + const wchar_t* app_guid, |
| + const wchar_t* value_name, |
| + ValueString* value) const { |
| + RegKey key; |
| + LONG result = location == RegistryLocation::CLIENTS_KEY |
| + ? OpenClientsKey(is_system_level_ ? HKEY_LOCAL_MACHINE |
| + : HKEY_CURRENT_USER, |
| + app_guid, KEY_QUERY_VALUE, &key) |
| + : OpenClientStateKey(is_system_level_ ? HKEY_LOCAL_MACHINE |
| + : HKEY_CURRENT_USER, |
| + app_guid, KEY_QUERY_VALUE, &key); |
| + if (result == ERROR_SUCCESS) |
| + result = key.ReadSZValue(value_name, value->get(), value->capacity()); |
| + return result; |
| +} |
| + |
| +bool Configuration::IsUpdatingMultiChrome() const { |
|
gab
2016/12/12 21:38:16
Writing my assumptions here:
1) We update from m
grt (UTC plus 2)
2016/12/13 09:20:37
This CL ensures that "--multi-install" on the comm
|
| +#if defined(GOOGLE_CHROME_BUILD) |
| + // SxS/canary does not support multi-install. |
| + if (is_side_by_side_) |
| + return false; |
| + |
| + // Is Chrome already installed as multi-install? |
| + ValueString value; |
| + return (ReadRegistryValue(RegistryLocation::CLIENTS_KEY, |
| + google_update::kAppGuid, kPvRegistryValue, |
| + &value) == ERROR_SUCCESS && |
| + value.length() != 0 && |
| + ReadRegistryValue( |
| + RegistryLocation::CLIENT_STATE_KEY, google_update::kAppGuid, |
| + kUninstallArgumentsRegistryValue, &value) == ERROR_SUCCESS && |
| + value.findi(L"--multi-install") != nullptr); |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| } // namespace mini_installer |