| 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 #include "chrome/installer/util/installer_state.h" | 5 #include "chrome/installer/util/installer_state.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/installer/util/install_util.h" | 23 #include "chrome/installer/util/install_util.h" |
| 24 #include "chrome/installer/util/installation_state.h" | 24 #include "chrome/installer/util/installation_state.h" |
| 25 #include "chrome/installer/util/master_preferences.h" | 25 #include "chrome/installer/util/master_preferences.h" |
| 26 #include "chrome/installer/util/master_preferences_constants.h" | 26 #include "chrome/installer/util/master_preferences_constants.h" |
| 27 #include "chrome/installer/util/product.h" | 27 #include "chrome/installer/util/product.h" |
| 28 #include "chrome/installer/util/work_item.h" | 28 #include "chrome/installer/util/work_item.h" |
| 29 #include "chrome/installer/util/work_item_list.h" | 29 #include "chrome/installer/util/work_item_list.h" |
| 30 | 30 |
| 31 namespace installer { | 31 namespace installer { |
| 32 | 32 |
| 33 bool InstallerState::IsMultiInstallUpdate( | 33 bool InstallerState::IsMultiInstallUpdate(const MasterPreferences& prefs, |
| 34 const MasterPreferences& prefs, | |
| 35 const InstallationState& machine_state) { | 34 const InstallationState& machine_state) { |
| 36 // First, are the binaries present? | 35 // First, is the package present? |
| 37 const ProductState* binaries = | 36 const ProductState* package = |
| 38 machine_state.GetProductState(level_ == SYSTEM_LEVEL, | 37 machine_state.GetProductState(level_ == SYSTEM_LEVEL, |
| 39 BrowserDistribution::CHROME_BINARIES); | 38 BrowserDistribution::CHROME_BINARIES); |
| 40 if (binaries == NULL) { | 39 if (package == NULL) { |
| 41 // The multi-install binaries have not been installed, so they certainly | 40 // The multi-install package has not been installed, so it certainly isn't |
| 42 // aren't being updated. | 41 // being updated. |
| 43 return false; | 42 return false; |
| 44 } | 43 } |
| 45 | 44 |
| 46 if (prefs.install_chrome()) { | 45 BrowserDistribution::Type types[2]; |
| 46 size_t num_types = 0; |
| 47 if (prefs.install_chrome()) |
| 48 types[num_types++] = BrowserDistribution::CHROME_BROWSER; |
| 49 if (prefs.install_chrome_frame()) |
| 50 types[num_types++] = BrowserDistribution::CHROME_FRAME; |
| 51 |
| 52 for (const BrowserDistribution::Type* scan = &types[0], |
| 53 *end = &types[num_types]; scan != end; ++scan) { |
| 47 const ProductState* product = | 54 const ProductState* product = |
| 48 machine_state.GetProductState(level_ == SYSTEM_LEVEL, | 55 machine_state.GetProductState(level_ == SYSTEM_LEVEL, *scan); |
| 49 BrowserDistribution::CHROME_BROWSER); | |
| 50 if (product == NULL) { | 56 if (product == NULL) { |
| 51 VLOG(2) << "It seems that chrome is being installed for the first time."; | 57 VLOG(2) << "It seems that distribution type " << *scan |
| 58 << " is being installed for the first time."; |
| 52 return false; | 59 return false; |
| 53 } | 60 } |
| 54 if (!product->channel().Equals(binaries->channel())) { | 61 if (!product->channel().Equals(package->channel())) { |
| 55 VLOG(2) << "It seems that chrome is being over installed."; | 62 VLOG(2) << "It seems that distribution type " << *scan |
| 63 << " is being over installed."; |
| 56 return false; | 64 return false; |
| 57 } | 65 } |
| 58 } | 66 } |
| 59 | 67 |
| 60 VLOG(2) << "It seems that the binaries are being updated."; | 68 VLOG(2) << "It seems that the package is being updated."; |
| 61 | 69 |
| 62 return true; | 70 return true; |
| 63 } | 71 } |
| 64 | 72 |
| 65 InstallerState::InstallerState() | 73 InstallerState::InstallerState() |
| 66 : operation_(UNINITIALIZED), | 74 : operation_(UNINITIALIZED), |
| 67 state_type_(BrowserDistribution::CHROME_BROWSER), | 75 state_type_(BrowserDistribution::CHROME_BROWSER), |
| 68 multi_package_distribution_(NULL), | 76 multi_package_distribution_(NULL), |
| 69 level_(UNKNOWN_LEVEL), | 77 level_(UNKNOWN_LEVEL), |
| 70 package_type_(UNKNOWN_PACKAGE_TYPE), | 78 package_type_(UNKNOWN_PACKAGE_TYPE), |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); | 120 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); |
| 113 | 121 |
| 114 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); | 122 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); |
| 115 | 123 |
| 116 if (prefs.install_chrome()) { | 124 if (prefs.install_chrome()) { |
| 117 Product* p = AddProductFromPreferences( | 125 Product* p = AddProductFromPreferences( |
| 118 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); | 126 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); |
| 119 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 127 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 120 << " distribution: " << p->distribution()->GetDisplayName(); | 128 << " distribution: " << p->distribution()->GetDisplayName(); |
| 121 } | 129 } |
| 130 if (prefs.install_chrome_frame()) { |
| 131 Product* p = AddProductFromPreferences( |
| 132 BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| 133 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 134 << " distribution: " << p->distribution()->GetDisplayName(); |
| 135 } |
| 122 | 136 |
| 123 if (prefs.install_chrome_app_launcher()) { | 137 if (prefs.install_chrome_app_launcher()) { |
| 124 Product* p = AddProductFromPreferences( | 138 Product* p = AddProductFromPreferences( |
| 125 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); | 139 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); |
| 126 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 140 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 127 << " distribution: " << p->distribution()->GetDisplayName(); | 141 << " distribution: " << p->distribution()->GetDisplayName(); |
| 128 } | 142 } |
| 129 | 143 |
| 130 if (!is_uninstall && is_multi_install()) { | 144 if (!is_uninstall && is_multi_install()) { |
| 131 bool need_binaries = false; | 145 bool need_binaries = false; |
| 132 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | 146 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { |
| 133 // App Host will happily use Chrome at system level, or binaries at system | 147 // App Host will happily use Chrome at system level, or binaries at system |
| 134 // level, even if app host is user level. | 148 // level, even if app host is user level. |
| 135 const ProductState* chrome_state = machine_state.GetProductState( | 149 const ProductState* chrome_state = machine_state.GetProductState( |
| 136 true, // system level | 150 true, // system level |
| 137 BrowserDistribution::CHROME_BROWSER); | 151 BrowserDistribution::CHROME_BROWSER); |
| 138 // If Chrome is at system-level, multi- or otherwise. We'll use it. | 152 // If Chrome is at system-level, multi- or otherwise. We'll use it. |
| 139 if (!chrome_state) { | 153 if (!chrome_state) { |
| 140 const ProductState* binaries_state = machine_state.GetProductState( | 154 const ProductState* binaries_state = machine_state.GetProductState( |
| 141 true, // system level | 155 true, // system level |
| 142 BrowserDistribution::CHROME_BINARIES); | 156 BrowserDistribution::CHROME_BINARIES); |
| 143 if (!binaries_state) | 157 if (!binaries_state) |
| 144 need_binaries = true; | 158 need_binaries = true; |
| 145 } | 159 } |
| 146 } | 160 } |
| 147 | 161 |
| 148 // Chrome multi needs Binaries at its own level. | 162 // Chrome/Chrome Frame multi need Binaries at their own level. |
| 149 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) | 163 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) |
| 150 need_binaries = true; | 164 need_binaries = true; |
| 151 | 165 |
| 166 if (FindProduct(BrowserDistribution::CHROME_FRAME)) |
| 167 need_binaries = true; |
| 168 |
| 152 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 169 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
| 153 // Force binaries to be installed/updated. | 170 // Force binaries to be installed/updated. |
| 154 Product* p = AddProductFromPreferences( | 171 Product* p = AddProductFromPreferences( |
| 155 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); | 172 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| 156 VLOG(1) << "Install distribution: " | 173 VLOG(1) << "Install distribution: " |
| 157 << p->distribution()->GetDisplayName(); | 174 << p->distribution()->GetDisplayName(); |
| 158 } | 175 } |
| 159 } | 176 } |
| 160 | 177 |
| 161 if (is_uninstall && prefs.is_multi_install()) { | 178 if (is_uninstall && prefs.is_multi_install()) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 operation_ = SINGLE_INSTALL_OR_UPDATE; | 283 operation_ = SINGLE_INSTALL_OR_UPDATE; |
| 267 } else if (IsMultiInstallUpdate(prefs, machine_state)) { | 284 } else if (IsMultiInstallUpdate(prefs, machine_state)) { |
| 268 // Updates driven by Google Update take place under the multi-installer's | 285 // Updates driven by Google Update take place under the multi-installer's |
| 269 // app guid. | 286 // app guid. |
| 270 operand = multi_package_distribution_; | 287 operand = multi_package_distribution_; |
| 271 operation_ = MULTI_UPDATE; | 288 operation_ = MULTI_UPDATE; |
| 272 } else { | 289 } else { |
| 273 operation_ = MULTI_INSTALL; | 290 operation_ = MULTI_INSTALL; |
| 274 } | 291 } |
| 275 | 292 |
| 276 // Initial, over, and un-installs will take place under one of the product app | 293 // Initial, over, and un-installs will take place under one of the |
| 277 // guids (Chrome, App Host, or Binaries, in order of preference). | 294 // product app guids (Chrome, Chrome Frame, App Host, or Binaries, in order of |
| 295 // preference). |
| 278 if (operand == NULL) { | 296 if (operand == NULL) { |
| 279 BrowserDistribution::Type operand_distribution_type = | 297 BrowserDistribution::Type operand_distribution_type = |
| 280 BrowserDistribution::CHROME_BINARIES; | 298 BrowserDistribution::CHROME_BINARIES; |
| 281 if (prefs.install_chrome()) | 299 if (prefs.install_chrome()) |
| 282 operand_distribution_type = BrowserDistribution::CHROME_BROWSER; | 300 operand_distribution_type = BrowserDistribution::CHROME_BROWSER; |
| 301 else if (prefs.install_chrome_frame()) |
| 302 operand_distribution_type = BrowserDistribution::CHROME_FRAME; |
| 283 else if (prefs.install_chrome_app_launcher()) | 303 else if (prefs.install_chrome_app_launcher()) |
| 284 operand_distribution_type = BrowserDistribution::CHROME_APP_HOST; | 304 operand_distribution_type = BrowserDistribution::CHROME_APP_HOST; |
| 285 | 305 |
| 286 operand = BrowserDistribution::GetSpecificDistribution( | 306 operand = BrowserDistribution::GetSpecificDistribution( |
| 287 operand_distribution_type); | 307 operand_distribution_type); |
| 288 } | 308 } |
| 289 | 309 |
| 290 state_key_ = operand->GetStateKey(); | 310 state_key_ = operand->GetStateKey(); |
| 291 state_type_ = operand->GetType(); | 311 state_type_ = operand->GetType(); |
| 292 | 312 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 } | 843 } |
| 824 if (!install_list->Do()) | 844 if (!install_list->Do()) |
| 825 LOG(ERROR) << "Failed to record installer error information in registry."; | 845 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 826 } | 846 } |
| 827 | 847 |
| 828 bool InstallerState::RequiresActiveSetup() const { | 848 bool InstallerState::RequiresActiveSetup() const { |
| 829 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 849 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 830 } | 850 } |
| 831 | 851 |
| 832 } // namespace installer | 852 } // namespace installer |
| OLD | NEW |