Chromium Code Reviews| Index: chrome/installer/setup/setup_main.cc |
| diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc |
| index 2010e4c18eb5f62a59f25e7fd3dc942d595f2b1a..1573cea2ae55a9c5c44e0ac7135a16c0bb975556 100644 |
| --- a/chrome/installer/setup/setup_main.cc |
| +++ b/chrome/installer/setup/setup_main.cc |
| @@ -356,6 +356,8 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, |
| if (installer_state->is_multi_install()) { |
| const Product* chrome = |
| installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| + const Product* binaries = |
| + installer_state->FindProduct(BrowserDistribution::CHROME_BINARIES); |
| const Product* chrome_frame = |
| installer_state->FindProduct(BrowserDistribution::CHROME_FRAME); |
| const ProductState* cf_state = |
| @@ -384,8 +386,8 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, |
| VLOG(1) << "Performing initial install of Chrome Frame ready-mode."; |
| } |
| } |
| - } else if (chrome_frame != NULL) { |
| - // We're being asked to install or update Chrome Frame alone. |
| + } else if (binaries != NULL) { |
| + // We're being asked to install or update the binaries without Chrome. |
| const ProductState* chrome_state = |
| original_state.GetProductState(system_level, |
| BrowserDistribution::CHROME_BROWSER); |
| @@ -397,9 +399,8 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, |
| BrowserDistribution::CHROME_BROWSER))); |
| multi_chrome->SetOption(installer::kOptionMultiInstall, true); |
| chrome = installer_state->AddProduct(&multi_chrome); |
| - VLOG(1) << "Upgrading existing multi-install Chrome browser along with " |
| - << chrome_frame->distribution()->GetAppShortCutName(); |
| - } else if (chrome_frame->HasOption(installer::kOptionReadyMode)) { |
| + VLOG(1) << "Upgrading existing Chrome browser in multi-install mode."; |
| + } else if (chrome_frame && chrome_frame->HasOption(installer::kOptionReadyMode)) { |
|
grt (UTC plus 2)
2012/07/12 18:37:10
80 cols
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| // Chrome Frame with ready-mode is to be installed, yet Chrome is |
| // neither installed nor being installed. Fail. |
| LOG(ERROR) << "Cannot install Chrome Frame in ready mode without " |
| @@ -434,6 +435,53 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, |
| return true; |
| } |
| +bool CheckAppHostPreconditions(const InstallationState& original_state, |
|
grt (UTC plus 2)
2012/07/12 18:37:10
please document the failure modes and side effects
erikwright (departed)
2012/07/16 20:13:11
The logic you refer to moved to InstallerState.
|
| + InstallerState* installer_state) { |
| + if (!installer_state->FindProduct(BrowserDistribution::CHROME_APP_HOST)) |
| + return true; |
| + |
| + if (installer_state->level() == InstallerState::SYSTEM_LEVEL) |
| + return false; |
|
grt (UTC plus 2)
2012/07/12 18:37:10
VLOG(1) the reason for failure
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| + |
|
grt (UTC plus 2)
2012/07/12 18:37:10
if (instaler_state->package_type() != InstallerSta
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| + const ProductState* chrome_state = original_state.GetProductState( |
| + true /* system level */, BrowserDistribution::CHROME_BROWSER); |
|
tommi (sloooow) - chröme
2012/07/12 08:11:31
nit: I think we avoid /**/ comments in general. in
grt (UTC plus 2)
2012/07/12 18:37:10
InstallerState::Level could be moved up into the "
erikwright (departed)
2012/07/16 20:13:11
Done.
erikwright (departed)
2012/07/16 20:13:11
Not done for this CL.
|
| + if (chrome_state) { |
| + // Chrome is at system-level, multi- or otherwise. We'll use it. |
| + return true; |
| + } |
| + |
| + const ProductState* binaries_state = original_state.GetProductState( |
| + false /* system level */, BrowserDistribution::CHROME_BINARIES); |
|
grt (UTC plus 2)
2012/07/12 18:37:10
should the comment be "!system level"? i find it
erikwright (departed)
2012/07/16 20:13:11
This particular instance is gone.
|
| + if (!binaries_state) { |
| + binaries_state = original_state.GetProductState( |
| + true /* system level */, BrowserDistribution::CHROME_BINARIES); |
| + } |
| + |
| + if (binaries_state) { |
| + // Binaries are installed somewhere. We'll use 'em. |
| + return true; |
| + } |
| + |
| + if (!binaries_state && ! installer_state->is_multi_install()) { |
|
grt (UTC plus 2)
2012/07/12 18:37:10
remove this block as discussed
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| + // Can't install binaries because this isn't a multi install. |
| + return false; |
| + } |
| + |
| + if (!installer_state->FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
| + // Force binaries to be installed. |
| + scoped_ptr<Product> binaries_product(new Product( |
| + BrowserDistribution::GetSpecificDistribution( |
| + BrowserDistribution::CHROME_BINARIES))); |
| + binaries_product->SetOption(installer::kOptionMultiInstall, true); |
| + if (!installer_state->AddProduct(&binaries_product)) { |
| + // Can't install binaries for some reason. |
| + return false; |
| + } |
| + } |
| + |
| + return true; |
| +} |
| + |
| // Checks for compatibility between the current state of the system and the |
| // desired operation. Also applies policy that mutates the desired operation; |
| // specifically, the |installer_state| object. |
| @@ -446,6 +494,9 @@ bool CheckMultiInstallConditions(const InstallationState& original_state, |
| bool CheckPreInstallConditions(const InstallationState& original_state, |
| InstallerState* installer_state, |
| installer::InstallStatus* status) { |
| + if (!CheckAppHostPreconditions(original_state, installer_state)) |
| + return false; |
| + |
| // See what products are already installed in multi mode. When we do multi |
| // installs, we must upgrade all installations since they share the binaries. |
| AddExistingMultiInstalls(original_state, installer_state); |
| @@ -624,22 +675,28 @@ installer::InstallStatus InstallProductsHelper( |
| } |
| if (higher_products != 0) { |
| - COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 3, |
| + COMPILE_ASSERT(BrowserDistribution::NUM_TYPES == 4, |
| add_support_for_new_products_here_); |
| const uint32 kBrowserBit = 1 << BrowserDistribution::CHROME_BROWSER; |
| const uint32 kGCFBit = 1 << BrowserDistribution::CHROME_FRAME; |
| + const uint32 kAppHostBit = 1 << BrowserDistribution::CHROME_APP_HOST; |
| int message_id = 0; |
| proceed_with_installation = false; |
| install_status = installer::HIGHER_VERSION_EXISTS; |
| - if ((higher_products & kBrowserBit) != 0) { |
| - if ((higher_products & kGCFBit) != 0) |
| - message_id = IDS_INSTALL_HIGHER_VERSION_CB_CF_BASE; |
| - else |
| + switch (higher_products) { |
| + case kBrowserBit: |
| message_id = IDS_INSTALL_HIGHER_VERSION_BASE; |
| - } else { |
| - DCHECK(higher_products == kGCFBit); |
| - message_id = IDS_INSTALL_HIGHER_VERSION_CF_BASE; |
| + break; |
| + case kGCFBit: |
| + message_id = IDS_INSTALL_HIGHER_VERSION_CF_BASE; |
| + break; |
| + case kGCFBit & kBrowserBit: |
|
grt (UTC plus 2)
2012/07/12 18:37:10
i think you mean "kGCFBit | kBrowserBit" here.
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| + message_id = IDS_INSTALL_HIGHER_VERSION_CB_CF_BASE; |
| + break; |
| + default: |
| + message_id = IDS_INSTALL_HIGHER_VERSION_APP_HOST_BASE; |
| + break; |
| } |
| installer_state.WriteInstallerResult(install_status, message_id, NULL); |
| @@ -883,7 +940,7 @@ installer::InstallStatus UninstallProducts( |
| // here for this reason: if Chrome is in-use, the user will be prompted to |
| // confirm uninstallation. Upon cancel, we should not continue with the |
| // other products. |
| - DCHECK(products.size() < 2 || products[0]->is_chrome()); |
| + // TODO(erikwright): if product 0 is not chrome, assert chrome not in products |
|
tommi (sloooow) - chröme
2012/07/12 08:11:31
do you intend to do that before checkin?
erikwright (departed)
2012/07/16 20:13:11
Done.
|
| installer::InstallStatus install_status = installer::UNINSTALL_SUCCESSFUL; |
| installer::InstallStatus prod_status = installer::UNKNOWN_STATUS; |
| const bool force = cmd_line.HasSwitch(installer::switches::kForceUninstall); |