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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 } | 569 } |
570 } | 570 } |
571 | 571 |
572 void InstallerState::AddComDllList( | 572 void InstallerState::AddComDllList( |
573 std::vector<base::FilePath>* com_dll_list) const { | 573 std::vector<base::FilePath>* com_dll_list) const { |
574 std::for_each(products_.begin(), products_.end(), | 574 std::for_each(products_.begin(), products_.end(), |
575 std::bind2nd(std::mem_fun(&Product::AddComDllList), | 575 std::bind2nd(std::mem_fun(&Product::AddComDllList), |
576 com_dll_list)); | 576 com_dll_list)); |
577 } | 577 } |
578 | 578 |
579 bool InstallerState::SetChannelFlags(bool set, | |
580 ChannelInfo* channel_info) const { | |
581 bool modified = false; | |
582 for (Products::const_iterator scan = products_.begin(), end = products_.end(); | |
583 scan != end; ++scan) { | |
584 modified |= (*scan)->SetChannelFlags(set, channel_info); | |
585 } | |
586 return modified; | |
587 } | |
588 | |
589 void InstallerState::UpdateStage(installer::InstallerStage stage) const { | 579 void InstallerState::UpdateStage(installer::InstallerStage stage) const { |
590 InstallUtil::UpdateInstallerStage(system_install(), state_key_, stage); | 580 InstallUtil::UpdateInstallerStage(system_install(), state_key_, stage); |
591 } | 581 } |
592 | 582 |
593 void InstallerState::UpdateChannels() const { | 583 void InstallerState::UpdateChannels() const { |
594 if (operation_ != MULTI_INSTALL && operation_ != MULTI_UPDATE) { | 584 DCHECK_NE(UNINSTALL, operation_); |
595 VLOG(1) << "InstallerState::UpdateChannels noop: " << operation_; | 585 // Update the "ap" value for the product being installed/updated. Use the |
596 return; | 586 // current value in the registry since the InstallationState instance used by |
597 } | 587 // the bulk of the installer does not track changes made by UpdateStage. |
598 | |
599 // Update the "ap" value for the product being installed/updated. We get the | |
600 // current value from the registry since the InstallationState instance used | |
601 // by the bulk of the installer does not track changes made by UpdateStage. | |
602 // Create the app's ClientState key if it doesn't exist. | 588 // Create the app's ClientState key if it doesn't exist. |
603 ChannelInfo channel_info; | 589 ChannelInfo channel_info; |
604 base::win::RegKey state_key; | 590 base::win::RegKey state_key; |
605 LONG result = | 591 LONG result = |
606 state_key.Create(root_key_, | 592 state_key.Create(root_key_, |
607 state_key_.c_str(), | 593 state_key_.c_str(), |
608 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); | 594 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
609 if (result == ERROR_SUCCESS) { | 595 if (result == ERROR_SUCCESS) { |
610 channel_info.Initialize(state_key); | 596 channel_info.Initialize(state_key); |
611 | 597 |
612 // This is a multi-install product. | 598 // This is a multi-install product. |
613 bool modified = channel_info.SetMultiInstall(true); | 599 bool modified = channel_info.SetMultiInstall(is_multi_install()); |
614 | 600 |
615 // Add the appropriate modifiers for all products and their options. | 601 if (is_multi_install()) { |
616 modified |= SetChannelFlags(true, &channel_info); | 602 // Add the appropriate modifiers for all products and their options. |
| 603 for (auto* product : products_) |
| 604 modified |= product->SetChannelFlags(true, &channel_info); |
| 605 } else { |
| 606 // Remove all multi-install products from the channel name. |
| 607 modified |= channel_info.SetChrome(false); |
| 608 modified |= channel_info.SetChromeFrame(false); |
| 609 modified |= channel_info.SetAppLauncher(false); |
| 610 } |
617 | 611 |
618 VLOG(1) << "ap: " << channel_info.value(); | 612 VLOG(1) << "ap: " << channel_info.value(); |
619 | 613 |
620 // Write the results if needed. | 614 // Write the results if needed. |
621 if (modified) | 615 if (modified) |
622 channel_info.Write(&state_key); | 616 channel_info.Write(&state_key); |
623 | 617 |
624 // Remove the -stage: modifier since we don't want to propagate that to the | 618 if (is_multi_install()) { |
625 // other app_guids. | 619 // Remove the -stage: modifier since we don't want to propagate that to |
626 channel_info.SetStage(NULL); | 620 // the other app_guids. |
| 621 channel_info.SetStage(NULL); |
627 | 622 |
628 // Synchronize the other products and the package with this one. | 623 // Synchronize the other products and the package with this one. |
629 ChannelInfo other_info; | 624 ChannelInfo other_info; |
630 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { | 625 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { |
631 BrowserDistribution::Type type = | 626 BrowserDistribution::Type type = |
632 static_cast<BrowserDistribution::Type>(i); | 627 static_cast<BrowserDistribution::Type>(i); |
633 // Skip the app_guid we started with. | 628 // Skip the app_guid we started with. |
634 if (type == state_type_) | 629 if (type == state_type_) |
635 continue; | |
636 BrowserDistribution* dist = NULL; | |
637 // Always operate on the binaries. | |
638 if (i == BrowserDistribution::CHROME_BINARIES) { | |
639 dist = multi_package_distribution_; | |
640 } else { | |
641 const Product* product = FindProduct(type); | |
642 // Skip this one if it's for a product we're not operating on. | |
643 if (product == NULL) | |
644 continue; | 630 continue; |
645 dist = product->distribution(); | 631 BrowserDistribution* dist = NULL; |
646 } | 632 // Always operate on the binaries. |
647 result = | 633 if (i == BrowserDistribution::CHROME_BINARIES) { |
648 state_key.Create(root_key_, | 634 dist = multi_package_distribution_; |
649 dist->GetStateKey().c_str(), | 635 } else { |
650 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); | 636 const Product* product = FindProduct(type); |
651 if (result == ERROR_SUCCESS) { | 637 // Skip this one if it's for a product we're not operating on. |
652 other_info.Initialize(state_key); | 638 if (product == NULL) |
653 if (!other_info.Equals(channel_info)) | 639 continue; |
654 channel_info.Write(&state_key); | 640 dist = product->distribution(); |
655 } else { | 641 } |
656 LOG(ERROR) << "Failed opening key " << dist->GetStateKey() | 642 result = |
657 << " to update app channels; result: " << result; | 643 state_key.Create(root_key_, |
| 644 dist->GetStateKey().c_str(), |
| 645 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
| 646 if (result == ERROR_SUCCESS) { |
| 647 other_info.Initialize(state_key); |
| 648 if (!other_info.Equals(channel_info)) |
| 649 channel_info.Write(&state_key); |
| 650 } else { |
| 651 LOG(ERROR) << "Failed opening key " << dist->GetStateKey() |
| 652 << " to update app channels; result: " << result; |
| 653 } |
658 } | 654 } |
659 } | 655 } |
660 } else { | 656 } else { |
661 LOG(ERROR) << "Failed opening key " << state_key_ | 657 LOG(ERROR) << "Failed opening key " << state_key_ |
662 << " to update app channels; result: " << result; | 658 << " to update app channels; result: " << result; |
663 } | 659 } |
664 } | 660 } |
665 | 661 |
666 void InstallerState::WriteInstallerResult( | 662 void InstallerState::WriteInstallerResult( |
667 InstallStatus status, | 663 InstallStatus status, |
(...skipping 19 matching lines...) Expand all Loading... |
687 } | 683 } |
688 if (!install_list->Do()) | 684 if (!install_list->Do()) |
689 LOG(ERROR) << "Failed to record installer error information in registry."; | 685 LOG(ERROR) << "Failed to record installer error information in registry."; |
690 } | 686 } |
691 | 687 |
692 bool InstallerState::RequiresActiveSetup() const { | 688 bool InstallerState::RequiresActiveSetup() const { |
693 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 689 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
694 } | 690 } |
695 | 691 |
696 } // namespace installer | 692 } // namespace installer |
OLD | NEW |