OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 192 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
193 L"NoRepair", static_cast<DWORD>(1), | 193 L"NoRepair", static_cast<DWORD>(1), |
194 true); | 194 true); |
195 | 195 |
196 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 196 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
197 L"Publisher", | 197 L"Publisher", |
198 browser_dist->GetPublisherName(), | 198 browser_dist->GetPublisherName(), |
199 true); | 199 true); |
200 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 200 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
201 L"Version", | 201 L"Version", |
202 UTF8ToWide(new_version.GetString()), | 202 ASCIIToWide(new_version.GetString()), |
203 true); | 203 true); |
204 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 204 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
205 L"DisplayVersion", | 205 L"DisplayVersion", |
206 UTF8ToWide(new_version.GetString()), | 206 ASCIIToWide(new_version.GetString()), |
207 true); | 207 true); |
208 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, | 208 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, |
209 L"InstallDate", | 209 L"InstallDate", |
210 InstallUtil::GetCurrentDate(), | 210 InstallUtil::GetCurrentDate(), |
211 false); | 211 false); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 // Add uninstall-related work items for multi-install scenarios. | 215 // Add uninstall-related work items for multi-install scenarios. |
216 void AddMultiUninstallWorkItems(const InstallerState& installer_state, | 216 void AddMultiUninstallWorkItems(const InstallerState& installer_state, |
(...skipping 30 matching lines...) Expand all Loading... |
247 | 247 |
248 std::wstring product_name(dist->GetAppShortCutName()); | 248 std::wstring product_name(dist->GetAppShortCutName()); |
249 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, | 249 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, |
250 product_name, true); // overwrite name also | 250 product_name, true); // overwrite name also |
251 list->AddSetRegValueWorkItem(root, version_key, | 251 list->AddSetRegValueWorkItem(root, version_key, |
252 google_update::kRegOopcrashesField, | 252 google_update::kRegOopcrashesField, |
253 static_cast<DWORD>(1), | 253 static_cast<DWORD>(1), |
254 false); // set during first install | 254 false); // set during first install |
255 list->AddSetRegValueWorkItem(root, version_key, | 255 list->AddSetRegValueWorkItem(root, version_key, |
256 google_update::kRegVersionField, | 256 google_update::kRegVersionField, |
257 UTF8ToWide(new_version.GetString()), | 257 ASCIIToWide(new_version.GetString()), |
258 true); // overwrite version | 258 true); // overwrite version |
259 } | 259 } |
260 | 260 |
261 void AddProductSpecificWorkItems(const InstallationState& original_state, | 261 void AddProductSpecificWorkItems(const InstallationState& original_state, |
262 const InstallerState& installer_state, | 262 const InstallerState& installer_state, |
263 const FilePath& setup_path, | 263 const FilePath& setup_path, |
264 const Version& new_version, | 264 const Version& new_version, |
265 WorkItemList* list) { | 265 WorkItemList* list) { |
266 const Products& products = installer_state.products(); | 266 const Products& products = installer_state.products(); |
267 for (size_t i = 0; i < products.size(); ++i) { | 267 for (size_t i = 0; i < products.size(); ++i) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 const Version* current_version, | 540 const Version* current_version, |
541 const Version& new_version, | 541 const Version& new_version, |
542 const FilePath& temp_path, | 542 const FilePath& temp_path, |
543 WorkItemList* post_install_task_list) { | 543 WorkItemList* post_install_task_list) { |
544 DCHECK(post_install_task_list); | 544 DCHECK(post_install_task_list); |
545 | 545 |
546 HKEY root = installer_state.root_key(); | 546 HKEY root = installer_state.root_key(); |
547 const Products& products = installer_state.products(); | 547 const Products& products = installer_state.products(); |
548 | 548 |
549 // Append work items that will only be executed if this was an update. | 549 // Append work items that will only be executed if this was an update. |
550 // We update the 'opv' key with the current version that is active and 'cmd' | 550 // We update the 'opv' value with the current version that is active, |
551 // key with the rename command to run. | 551 // the 'cpv' value with the critical update version (if present), and the |
| 552 // 'cmd' value with the rename command to run. |
552 { | 553 { |
553 scoped_ptr<WorkItemList> in_use_update_work_items( | 554 scoped_ptr<WorkItemList> in_use_update_work_items( |
554 WorkItem::CreateConditionalWorkItemList( | 555 WorkItem::CreateConditionalWorkItemList( |
555 new ConditionRunIfFileExists(new_chrome_exe))); | 556 new ConditionRunIfFileExists(new_chrome_exe))); |
556 in_use_update_work_items->set_log_message("InUseUpdateWorkItemList"); | 557 in_use_update_work_items->set_log_message("InUseUpdateWorkItemList"); |
557 | 558 |
| 559 // |critical_version| will be valid only if this in-use update includes a |
| 560 // version considered critical relative to the version being updated. |
| 561 Version critical_version(installer_state.DetermineCriticalVersion( |
| 562 current_version, new_version)); |
558 FilePath installer_path(installer_state.GetInstallerDirectory(new_version) | 563 FilePath installer_path(installer_state.GetInstallerDirectory(new_version) |
559 .Append(setup_path.BaseName())); | 564 .Append(setup_path.BaseName())); |
560 | 565 |
561 CommandLine rename(installer_path); | 566 CommandLine rename(installer_path); |
562 rename.AppendSwitch(switches::kRenameChromeExe); | 567 rename.AppendSwitch(switches::kRenameChromeExe); |
563 if (installer_state.system_install()) | 568 if (installer_state.system_install()) |
564 rename.AppendSwitch(switches::kSystemLevel); | 569 rename.AppendSwitch(switches::kSystemLevel); |
565 | 570 |
566 if (installer_state.verbose_logging()) | 571 if (installer_state.verbose_logging()) |
567 rename.AppendSwitch(switches::kVerboseLogging); | 572 rename.AppendSwitch(switches::kVerboseLogging); |
568 | 573 |
569 std::wstring version_key; | 574 std::wstring version_key; |
570 for (size_t i = 0; i < products.size(); ++i) { | 575 for (size_t i = 0; i < products.size(); ++i) { |
571 BrowserDistribution* dist = products[i]->distribution(); | 576 BrowserDistribution* dist = products[i]->distribution(); |
572 version_key = dist->GetVersionKey(); | 577 version_key = dist->GetVersionKey(); |
573 | 578 |
574 if (current_version != NULL) { | 579 if (current_version != NULL) { |
575 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, | 580 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, |
576 google_update::kRegOldVersionField, | 581 google_update::kRegOldVersionField, |
577 UTF8ToWide(current_version->GetString()), true); | 582 ASCIIToWide(current_version->GetString()), true); |
| 583 } |
| 584 if (critical_version.IsValid()) { |
| 585 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, |
| 586 google_update::kRegCriticalVersionField, |
| 587 ASCIIToWide(critical_version.GetString()), true); |
| 588 } else { |
| 589 in_use_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
| 590 google_update::kRegCriticalVersionField); |
578 } | 591 } |
579 | 592 |
580 // Adding this registry entry for all products is overkill. | 593 // Adding this registry entry for all products is overkill. |
581 // However, as it stands, we don't have a way to know which distribution | 594 // However, as it stands, we don't have a way to know which distribution |
582 // will check the key and run the command, so we add it for all. The | 595 // will check the key and run the command, so we add it for all. The |
583 // first to run it will perform the operation and clean up the other | 596 // first to run it will perform the operation and clean up the other |
584 // values. | 597 // values. |
585 CommandLine product_rename_cmd(rename); | 598 CommandLine product_rename_cmd(rename); |
586 products[i]->AppendRenameFlags(&product_rename_cmd); | 599 products[i]->AppendRenameFlags(&product_rename_cmd); |
587 in_use_update_work_items->AddSetRegValueWorkItem( | 600 in_use_update_work_items->AddSetRegValueWorkItem( |
588 root, | 601 root, version_key, google_update::kRegRenameCmdField, |
589 version_key, | 602 product_rename_cmd.GetCommandLineString(), true); |
590 google_update::kRegRenameCmdField, | |
591 product_rename_cmd.GetCommandLineString(), | |
592 true); | |
593 } | 603 } |
594 | 604 |
595 if (current_version != NULL && installer_state.is_multi_install()) { | 605 if (current_version != NULL && installer_state.is_multi_install()) { |
596 BrowserDistribution* dist = | 606 BrowserDistribution* dist = |
597 installer_state.multi_package_binaries_distribution(); | 607 installer_state.multi_package_binaries_distribution(); |
| 608 version_key = dist->GetVersionKey(); |
598 in_use_update_work_items->AddSetRegValueWorkItem( | 609 in_use_update_work_items->AddSetRegValueWorkItem( |
599 root, | 610 root, version_key, google_update::kRegOldVersionField, |
600 dist->GetVersionKey(), | 611 ASCIIToWide(current_version->GetString()), true); |
601 google_update::kRegOldVersionField, | 612 if (critical_version.IsValid()) { |
602 UTF8ToWide(current_version->GetString()), | 613 in_use_update_work_items->AddSetRegValueWorkItem( |
603 true); | 614 root, version_key, google_update::kRegCriticalVersionField, |
| 615 ASCIIToWide(critical_version.GetString()), true); |
| 616 } else { |
| 617 in_use_update_work_items->AddDeleteRegValueWorkItem( |
| 618 root, version_key, google_update::kRegCriticalVersionField); |
| 619 } |
604 // TODO(tommi): We should move the rename command here. We also need to | 620 // TODO(tommi): We should move the rename command here. We also need to |
605 // update upgrade_utils::SwapNewChromeExeIfPresent. | 621 // update upgrade_utils::SwapNewChromeExeIfPresent. |
606 } | 622 } |
607 | 623 |
608 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { | 624 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { |
609 AddCopyIELowRightsPolicyWorkItems(installer_state, | 625 AddCopyIELowRightsPolicyWorkItems(installer_state, |
610 in_use_update_work_items.get()); | 626 in_use_update_work_items.get()); |
611 } | 627 } |
612 | 628 |
613 post_install_task_list->AddWorkItem(in_use_update_work_items.release()); | 629 post_install_task_list->AddWorkItem(in_use_update_work_items.release()); |
614 } | 630 } |
615 | 631 |
616 // Append work items that will be executed if this was NOT an in-use update. | 632 // Append work items that will be executed if this was NOT an in-use update. |
617 { | 633 { |
618 scoped_ptr<WorkItemList> regular_update_work_items( | 634 scoped_ptr<WorkItemList> regular_update_work_items( |
619 WorkItem::CreateConditionalWorkItemList( | 635 WorkItem::CreateConditionalWorkItemList( |
620 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); | 636 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); |
621 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); | 637 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); |
622 | 638 |
623 // Since this was not an in-use-update, delete 'opv' and 'cmd' keys. | 639 // Since this was not an in-use-update, delete 'opv', 'cpv', and 'cmd' keys. |
624 for (size_t i = 0; i < products.size(); ++i) { | 640 for (size_t i = 0; i < products.size(); ++i) { |
625 BrowserDistribution* dist = products[i]->distribution(); | 641 BrowserDistribution* dist = products[i]->distribution(); |
626 std::wstring version_key(dist->GetVersionKey()); | 642 std::wstring version_key(dist->GetVersionKey()); |
627 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, | 643 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
628 google_update::kRegOldVersionField); | 644 google_update::kRegOldVersionField); |
629 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, | 645 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
630 google_update::kRegRenameCmdField); | 646 google_update::kRegCriticalVersionField); |
| 647 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, |
| 648 google_update::kRegRenameCmdField); |
631 } | 649 } |
632 | 650 |
633 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { | 651 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { |
634 AddDeleteOldIELowRightsPolicyWorkItems(installer_state, | 652 AddDeleteOldIELowRightsPolicyWorkItems(installer_state, |
635 regular_update_work_items.get()); | 653 regular_update_work_items.get()); |
636 } | 654 } |
637 | 655 |
638 post_install_task_list->AddWorkItem(regular_update_work_items.release()); | 656 post_install_task_list->AddWorkItem(regular_update_work_items.release()); |
639 } | 657 } |
640 | 658 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 } else { | 1237 } else { |
1220 DCHECK(operation == REMOVE_COMMAND); | 1238 DCHECK(operation == REMOVE_COMMAND); |
1221 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), | 1239 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), |
1222 cmd_key)->set_log_message( | 1240 cmd_key)->set_log_message( |
1223 "removing quick-enable-cf command"); | 1241 "removing quick-enable-cf command"); |
1224 } | 1242 } |
1225 } | 1243 } |
1226 } | 1244 } |
1227 | 1245 |
1228 } // namespace installer | 1246 } // namespace installer |
OLD | NEW |