diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-06 20:42:39 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-06 20:42:39 +0000 |
commit | 5f27dc1b618add9874c21f47adc0f6a57d0c2208 (patch) | |
tree | ad2f004ec5103555499d4bb443c3e7f13d850b2c /chrome/installer/setup/install_worker.cc | |
parent | ada41253c96b1f86b4e84ff6765b043e34ec2f7c (diff) | |
download | chromium_src-5f27dc1b618add9874c21f47adc0f6a57d0c2208.zip chromium_src-5f27dc1b618add9874c21f47adc0f6a57d0c2208.tar.gz chromium_src-5f27dc1b618add9874c21f47adc0f6a57d0c2208.tar.bz2 |
Add brand-code migration to the Chrome installer when creating the new multi-install app guid.
When upgrading a product from single to multi, the installer will now check if a Chrome install at that level (user/system) had a brand code, and if so it will copy the brand code to the ClientState key for the multi-install.
Also, some yak de-hairing: alter InstallationState such that it can be queried for partial ProductStates for products that are in the process of being installed. This can be used to query e.g. the ap value and the brand code, but not the version (since a product won't have a version until its first install is complete). This removes the need to go and manually re-query the registry in a couple of places, makes the installer's actions based solely on the original InstallationState and generally removes some hackiness.
BUG=61609
TEST=setup_unittests.exe, also when upgrading from single to multi, observe that brand codes are copied over.
Review URL: http://codereview.chromium.org/6604010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77089 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/setup/install_worker.cc')
-rw-r--r-- | chrome/installer/setup/install_worker.cc | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc index 70e1ab6..24fbf6d 100644 --- a/chrome/installer/setup/install_worker.cc +++ b/chrome/installer/setup/install_worker.cc @@ -254,7 +254,8 @@ void AddProductSpecificWorkItems(const InstallationState& original_state, // In the multi-install case, this value is used as the basis upon which the // package's channel value is built (by adding the ordered list of installed // products and their options). -void AddGoogleUpdateWorkItems(const InstallerState& installer_state, +void AddGoogleUpdateWorkItems(const InstallationState& original_state, + const InstallerState& installer_state, WorkItemList* install_list) { // Is a multi-install product being installed or over-installed? if (installer_state.operation() != InstallerState::MULTI_INSTALL && @@ -263,16 +264,16 @@ void AddGoogleUpdateWorkItems(const InstallerState& installer_state, return; } - const HKEY reg_root = installer_state.root_key(); - const std::wstring key_path = installer_state.state_key(); - ChannelInfo channel_info; - - // Update the "ap" value for the product being installed/updated. - // It is completely acceptable for there to be no "ap" value or even no - // ClientState key. Note that we check the registry rather than an - // InstallationState instance since on a fresh install the "ap" value will be - // present sans "pv" value. - channel_info.Initialize(RegKey(reg_root, key_path.c_str(), KEY_QUERY_VALUE)); + // Update the "ap" value for the product being installed/updated. We get + // this via GetNonVersionedProductState since the product whose ap value + // we are querying may be in the process of being installed for the first + // time. + BrowserDistribution::Type client_state_distribution = + installer_state.state_type(); + const ProductState* target_product_state = + original_state.GetNonVersionedProductState( + installer_state.system_install(), client_state_distribution); + ChannelInfo channel_info(target_product_state->channel()); // This is a multi-install product. bool modified = channel_info.SetMultiInstall(true); @@ -282,6 +283,9 @@ void AddGoogleUpdateWorkItems(const InstallerState& installer_state, VLOG(1) << "ap: " << channel_info.value(); + const HKEY reg_root = installer_state.root_key(); + const std::wstring& key_path(installer_state.state_key()); + // Write the results if needed. if (modified) { install_list->AddSetRegValueWorkItem(reg_root, key_path, @@ -292,26 +296,27 @@ void AddGoogleUpdateWorkItems(const InstallerState& installer_state, } // Synchronize the other products and the package with this one. - std::wstring other_key; - std::vector<std::wstring> keys; + std::vector<std::wstring> state_key_paths; + + state_key_paths.reserve(installer_state.products().size()); + std::wstring multi_key( + installer_state.multi_package_binaries_distribution()->GetStateKey()); + if (multi_key != key_path) + state_key_paths.push_back(multi_key); - keys.reserve(installer_state.products().size()); - other_key = - installer_state.multi_package_binaries_distribution()->GetStateKey(); - if (other_key != key_path) - keys.push_back(other_key); + std::wstring other_key; Products::const_iterator scan = installer_state.products().begin(); Products::const_iterator end = installer_state.products().end(); for (; scan != end; ++scan) { other_key = (*scan)->distribution()->GetStateKey(); if (other_key != key_path) - keys.push_back(other_key); + state_key_paths.push_back(other_key); } RegKey key; ChannelInfo other_info; - std::vector<std::wstring>::const_iterator kscan = keys.begin(); - std::vector<std::wstring>::const_iterator kend = keys.end(); + std::vector<std::wstring>::const_iterator kscan = state_key_paths.begin(); + std::vector<std::wstring>::const_iterator kend = state_key_paths.end(); for (; kscan != kend; ++kscan) { // Handle the case where the ClientState key doesn't exist by creating it. // This takes care of the multi-installer's package key, which is not @@ -321,13 +326,36 @@ void AddGoogleUpdateWorkItems(const InstallerState& installer_state, other_info.set_value(std::wstring()); } if (!other_info.Equals(channel_info)) { - if (!key.Valid()) + if (!key.Valid()) { install_list->AddCreateRegKeyWorkItem(reg_root, *kscan); + } install_list->AddSetRegValueWorkItem(reg_root, *kscan, google_update::kRegApField, channel_info.value(), true); } } + + // Creating the ClientState key for binaries, if we're migrating to multi then + // copy over Chrome's brand code if it has one. Chrome Frame currently never + // has a brand code. + if (multi_key != key_path) { + const ProductState* chrome_product_state = + original_state.GetNonVersionedProductState( + installer_state.system_install(), + BrowserDistribution::CHROME_BROWSER); + + const std::wstring& brand(chrome_product_state->brand()); + if (!brand.empty()) { + // Write Chrome's brand code to the multi key. Never overwrite the value + // if one is already present (although this shouldn't happen). + install_list->AddSetRegValueWorkItem(reg_root, + multi_key, + google_update::kRegBrandField, + brand, + false); + } + } + // TODO(grt): check for other keys/values we should put in the package's // ClientState and/or Clients key. } @@ -598,7 +626,7 @@ void AddInstallWorkItems(const InstallationState& original_state, AddProductSpecificWorkItems(original_state, installer_state, setup_path, new_version, install_list); - AddGoogleUpdateWorkItems(installer_state, install_list); + AddGoogleUpdateWorkItems(original_state, installer_state, install_list); AddQuickEnableWorkItems(installer_state, original_state, &setup_path, &new_version, install_list); |