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 // This file contains the definitions of the installer functions that build | 5 // This file contains the definitions of the installer functions that build |
6 // the WorkItemList used to install the application. | 6 // the WorkItemList used to install the application. |
7 | 7 |
8 #include "chrome/installer/setup/install_worker.h" | 8 #include "chrome/installer/setup/install_worker.h" |
9 | 9 |
10 #include <oaidl.h> | 10 #include <oaidl.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
30 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/installer/setup/install.h" | 32 #include "chrome/installer/setup/install.h" |
33 #include "chrome/installer/setup/setup_constants.h" | 33 #include "chrome/installer/setup/setup_constants.h" |
34 #include "chrome/installer/setup/setup_util.h" | 34 #include "chrome/installer/setup/setup_util.h" |
35 #include "chrome/installer/util/browser_distribution.h" | 35 #include "chrome/installer/util/browser_distribution.h" |
36 #include "chrome/installer/util/callback_work_item.h" | 36 #include "chrome/installer/util/callback_work_item.h" |
37 #include "chrome/installer/util/conditional_work_item_list.h" | 37 #include "chrome/installer/util/conditional_work_item_list.h" |
38 #include "chrome/installer/util/create_reg_key_work_item.h" | 38 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 39 #include "chrome/installer/util/firewall_manager.h" |
39 #include "chrome/installer/util/google_update_constants.h" | 40 #include "chrome/installer/util/google_update_constants.h" |
40 #include "chrome/installer/util/helper.h" | 41 #include "chrome/installer/util/helper.h" |
41 #include "chrome/installer/util/install_util.h" | 42 #include "chrome/installer/util/install_util.h" |
42 #include "chrome/installer/util/installation_state.h" | 43 #include "chrome/installer/util/installation_state.h" |
43 #include "chrome/installer/util/installer_state.h" | 44 #include "chrome/installer/util/installer_state.h" |
44 #include "chrome/installer/util/l10n_string_util.h" | 45 #include "chrome/installer/util/l10n_string_util.h" |
45 #include "chrome/installer/util/product.h" | 46 #include "chrome/installer/util/product.h" |
46 #include "chrome/installer/util/set_reg_value_work_item.h" | 47 #include "chrome/installer/util/set_reg_value_work_item.h" |
47 #include "chrome/installer/util/shell_util.h" | 48 #include "chrome/installer/util/shell_util.h" |
48 #include "chrome/installer/util/util_constants.h" | 49 #include "chrome/installer/util/util_constants.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 const Product& product, | 249 const Product& product, |
249 WorkItemList* work_item_list) { | 250 WorkItemList* work_item_list) { |
250 DCHECK(product.is_chrome()); | 251 DCHECK(product.is_chrome()); |
251 AddCommandWithParameterWorkItems(installer_state, machine_state, new_version, | 252 AddCommandWithParameterWorkItems(installer_state, machine_state, new_version, |
252 product, kCmdInstallExtension, | 253 product, kCmdInstallExtension, |
253 installer::kChromeExe, | 254 installer::kChromeExe, |
254 ::switches::kLimitedInstallFromWebstore, | 255 ::switches::kLimitedInstallFromWebstore, |
255 work_item_list); | 256 work_item_list); |
256 } | 257 } |
257 | 258 |
| 259 // A callback invoked by |work_item| that adds firewall rules for Chrome. Rules |
| 260 // are left in-place on rollback unless |remove_on_rollback| is true. This is |
| 261 // the case for new installs only. Updates and overinstalls leave the rule |
| 262 // in-place on rollback since a previous install of Chrome will be used in that |
| 263 // case. |
| 264 bool AddFirewallRulesCallback(bool system_level, |
| 265 BrowserDistribution* dist, |
| 266 const base::FilePath& chrome_path, |
| 267 bool remove_on_rollback, |
| 268 const CallbackWorkItem& work_item) { |
| 269 // There is no work to do on rollback if this is not a new install. |
| 270 if (work_item.IsRollback() && !remove_on_rollback) |
| 271 return true; |
| 272 |
| 273 scoped_ptr<FirewallManager> firewall_manager( |
| 274 FirewallManager::Create(dist, chrome_path)); |
| 275 if (!firewall_manager) { |
| 276 LOG(ERROR) << "Failed creating a FirewallManager to adjust rules." |
| 277 " Continuing with install."; |
| 278 return true; |
| 279 } |
| 280 |
| 281 if (work_item.IsRollback()) { |
| 282 firewall_manager->DeleteUDPFirewallRule(); |
| 283 return true; |
| 284 } |
| 285 |
| 286 // Adding the firewall rule is expected to fail for user-level installs on |
| 287 // Vista+. Try anyway in case the installer is running elevated. |
| 288 if (!firewall_manager->AddUDPFirewallRuleIfAbsent() && !system_level) |
| 289 LOG(ERROR) << "Failed to add UDP firewall rule. Continuing with install."; |
| 290 |
| 291 // Don't abort installation if the firewall rule couldn't be added. |
| 292 return true; |
| 293 } |
| 294 |
| 295 // Adds work items to |list| to create firewall rules. |
| 296 void AddFirewallRulesWorkItems(const InstallerState& installer_state, |
| 297 BrowserDistribution* dist, |
| 298 bool is_new_install, |
| 299 WorkItemList* list) { |
| 300 list->AddCallbackWorkItem( |
| 301 base::Bind(&AddFirewallRulesCallback, |
| 302 installer_state.system_install(), |
| 303 dist, |
| 304 installer_state.target_path().Append(kChromeExe), |
| 305 is_new_install)); |
| 306 } |
| 307 |
258 // Returns the basic CommandLine to setup.exe for a quick-enable operation on | 308 // Returns the basic CommandLine to setup.exe for a quick-enable operation on |
259 // the binaries. This will unconditionally include --multi-install as well as | 309 // the binaries. This will unconditionally include --multi-install as well as |
260 // --verbose-logging if the current installation was launched with | 310 // --verbose-logging if the current installation was launched with |
261 // --verbose-logging. |setup_path| and |new_version| are optional only when | 311 // --verbose-logging. |setup_path| and |new_version| are optional only when |
262 // the operation is an uninstall. | 312 // the operation is an uninstall. |
263 CommandLine GetGenericQuickEnableCommand( | 313 CommandLine GetGenericQuickEnableCommand( |
264 const InstallerState& installer_state, | 314 const InstallerState& installer_state, |
265 const InstallationState& machine_state, | 315 const InstallationState& machine_state, |
266 const base::FilePath& setup_path, | 316 const base::FilePath& setup_path, |
267 const Version& new_version) { | 317 const Version& new_version) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 cmd.set_is_web_accessible(true); | 388 cmd.set_is_web_accessible(true); |
339 cmd.set_is_run_as_user(true); | 389 cmd.set_is_run_as_user(true); |
340 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); | 390 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); |
341 } | 391 } |
342 } | 392 } |
343 | 393 |
344 void AddProductSpecificWorkItems(const InstallationState& original_state, | 394 void AddProductSpecificWorkItems(const InstallationState& original_state, |
345 const InstallerState& installer_state, | 395 const InstallerState& installer_state, |
346 const base::FilePath& setup_path, | 396 const base::FilePath& setup_path, |
347 const Version& new_version, | 397 const Version& new_version, |
| 398 bool is_new_install, |
348 WorkItemList* list) { | 399 WorkItemList* list) { |
349 const Products& products = installer_state.products(); | 400 const Products& products = installer_state.products(); |
350 for (Products::const_iterator it = products.begin(); it < products.end(); | 401 for (Products::const_iterator it = products.begin(); it < products.end(); |
351 ++it) { | 402 ++it) { |
352 const Product& p = **it; | 403 const Product& p = **it; |
353 if (p.is_chrome_app_host()) { | 404 if (p.is_chrome_app_host()) { |
354 AddInstallAppCommandWorkItems(installer_state, original_state, | 405 AddInstallAppCommandWorkItems(installer_state, original_state, |
355 new_version, p, list); | 406 new_version, p, list); |
356 } | 407 } |
357 if (p.is_chrome()) { | 408 if (p.is_chrome()) { |
358 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p, | 409 AddOsUpgradeWorkItems(installer_state, setup_path, new_version, p, |
359 list); | 410 list); |
360 AddInstallExtensionCommandWorkItem(installer_state, original_state, | 411 AddInstallExtensionCommandWorkItem(installer_state, original_state, |
361 setup_path, new_version, p, list); | 412 setup_path, new_version, p, list); |
| 413 AddFirewallRulesWorkItems(installer_state, p.distribution(), |
| 414 is_new_install, list); |
362 } | 415 } |
363 if (p.is_chrome_binaries()) { | 416 if (p.is_chrome_binaries()) { |
364 AddQueryEULAAcceptanceWorkItems( | 417 AddQueryEULAAcceptanceWorkItems( |
365 installer_state, setup_path, new_version, p, list); | 418 installer_state, setup_path, new_version, p, list); |
366 AddQuickEnableChromeFrameWorkItems(installer_state, list); | 419 AddQuickEnableChromeFrameWorkItems(installer_state, list); |
367 AddQuickEnableApplicationLauncherWorkItems( | 420 AddQuickEnableApplicationLauncherWorkItems( |
368 installer_state, original_state, setup_path, new_version, list); | 421 installer_state, original_state, setup_path, new_version, list); |
369 } | 422 } |
370 } | 423 } |
371 } | 424 } |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 BrowserDistribution* shadow_app_launcher_dist = | 1224 BrowserDistribution* shadow_app_launcher_dist = |
1172 BrowserDistribution::GetSpecificDistribution( | 1225 BrowserDistribution::GetSpecificDistribution( |
1173 BrowserDistribution::CHROME_APP_HOST); | 1226 BrowserDistribution::CHROME_APP_HOST); |
1174 AddVersionKeyWorkItems(root, shadow_app_launcher_dist, new_version, | 1227 AddVersionKeyWorkItems(root, shadow_app_launcher_dist, new_version, |
1175 add_language_identifier, install_list); | 1228 add_language_identifier, install_list); |
1176 } | 1229 } |
1177 | 1230 |
1178 // Add any remaining work items that involve special settings for | 1231 // Add any remaining work items that involve special settings for |
1179 // each product. | 1232 // each product. |
1180 AddProductSpecificWorkItems(original_state, installer_state, setup_path, | 1233 AddProductSpecificWorkItems(original_state, installer_state, setup_path, |
1181 new_version, install_list); | 1234 new_version, current_version == NULL, |
| 1235 install_list); |
1182 | 1236 |
1183 // Copy over brand, usagestats, and other values. | 1237 // Copy over brand, usagestats, and other values. |
1184 AddGoogleUpdateWorkItems(original_state, installer_state, install_list); | 1238 AddGoogleUpdateWorkItems(original_state, installer_state, install_list); |
1185 | 1239 |
1186 // Append the tasks that run after the installation. | 1240 // Append the tasks that run after the installation. |
1187 AppendPostInstallTasks(installer_state, | 1241 AppendPostInstallTasks(installer_state, |
1188 setup_path, | 1242 setup_path, |
1189 current_version, | 1243 current_version, |
1190 new_version, | 1244 new_version, |
1191 temp_path, | 1245 temp_path, |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 // Unconditionally remove the legacy Quick Enable command from the binaries. | 1511 // Unconditionally remove the legacy Quick Enable command from the binaries. |
1458 // Do this even if multi-install Chrome isn't installed to ensure that it is | 1512 // Do this even if multi-install Chrome isn't installed to ensure that it is |
1459 // not left behind in any case. | 1513 // not left behind in any case. |
1460 work_item_list->AddDeleteRegKeyWorkItem( | 1514 work_item_list->AddDeleteRegKeyWorkItem( |
1461 installer_state.root_key(), cmd_key)->set_log_message( | 1515 installer_state.root_key(), cmd_key)->set_log_message( |
1462 "removing " + WideToASCII(kCmdQuickEnableCf) + " command"); | 1516 "removing " + WideToASCII(kCmdQuickEnableCf) + " command"); |
1463 | 1517 |
1464 } | 1518 } |
1465 | 1519 |
1466 } // namespace installer | 1520 } // namespace installer |
OLD | NEW |