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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 } | 706 } |
707 } | 707 } |
708 | 708 |
709 void InstallerState::AddComDllList( | 709 void InstallerState::AddComDllList( |
710 std::vector<base::FilePath>* com_dll_list) const { | 710 std::vector<base::FilePath>* com_dll_list) const { |
711 std::for_each(products_.begin(), products_.end(), | 711 std::for_each(products_.begin(), products_.end(), |
712 std::bind2nd(std::mem_fun(&Product::AddComDllList), | 712 std::bind2nd(std::mem_fun(&Product::AddComDllList), |
713 com_dll_list)); | 713 com_dll_list)); |
714 } | 714 } |
715 | 715 |
716 bool InstallerState::SetChannelFlags(bool set, | |
717 ChannelInfo* channel_info) const { | |
718 bool modified = false; | |
719 for (Products::const_iterator scan = products_.begin(), end = products_.end(); | |
720 scan != end; ++scan) { | |
721 modified |= (*scan)->SetChannelFlags(set, channel_info); | |
722 } | |
723 return modified; | |
724 } | |
725 | |
726 void InstallerState::UpdateStage(installer::InstallerStage stage) const { | 716 void InstallerState::UpdateStage(installer::InstallerStage stage) const { |
727 InstallUtil::UpdateInstallerStage(system_install(), state_key_, stage); | 717 InstallUtil::UpdateInstallerStage(system_install(), state_key_, stage); |
728 } | 718 } |
729 | 719 |
730 void InstallerState::UpdateChannels() const { | 720 void InstallerState::UpdateChannels() const { |
731 if (operation_ != MULTI_INSTALL && operation_ != MULTI_UPDATE) { | 721 DCHECK_NE(UNINSTALL, operation_); |
732 VLOG(1) << "InstallerState::UpdateChannels noop: " << operation_; | 722 // Update the "ap" value for the product being installed/updated. Use the |
733 return; | 723 // current value in the registry since the InstallationState instance used by |
734 } | 724 // the bulk of the installer does not track changes made by UpdateStage. |
735 | |
736 // Update the "ap" value for the product being installed/updated. We get the | |
737 // current value from the registry since the InstallationState instance used | |
738 // by the bulk of the installer does not track changes made by UpdateStage. | |
739 // Create the app's ClientState key if it doesn't exist. | 725 // Create the app's ClientState key if it doesn't exist. |
740 ChannelInfo channel_info; | 726 ChannelInfo channel_info; |
741 base::win::RegKey state_key; | 727 base::win::RegKey state_key; |
742 LONG result = | 728 LONG result = |
743 state_key.Create(root_key_, | 729 state_key.Create(root_key_, |
744 state_key_.c_str(), | 730 state_key_.c_str(), |
745 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); | 731 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
746 if (result == ERROR_SUCCESS) { | 732 if (result == ERROR_SUCCESS) { |
733 bool modified = false; | |
robertshield
2015/01/23 22:45:30
why declare this up here and then |= it below woul
grt (UTC plus 2)
2015/01/24 02:25:16
Yeah, that's better. This is an artifact of a prev
| |
747 channel_info.Initialize(state_key); | 734 channel_info.Initialize(state_key); |
748 | 735 |
749 // This is a multi-install product. | 736 // This is a multi-install product. |
750 bool modified = channel_info.SetMultiInstall(true); | 737 modified |= channel_info.SetMultiInstall(is_multi_install()); |
751 | 738 |
752 // Add the appropriate modifiers for all products and their options. | 739 if (is_multi_install()) { |
753 modified |= SetChannelFlags(true, &channel_info); | 740 // Add the appropriate modifiers for all products and their options. |
741 for (auto* product : products_) | |
742 modified |= product->SetChannelFlags(true, &channel_info); | |
743 } else { | |
744 // Remove all multi-install products from the channel name. | |
745 modified |= channel_info.SetChrome(false); | |
746 modified |= channel_info.SetChromeFrame(false); | |
747 modified |= channel_info.SetAppLauncher(false); | |
748 } | |
754 | 749 |
755 VLOG(1) << "ap: " << channel_info.value(); | 750 VLOG(1) << "ap: " << channel_info.value(); |
756 | 751 |
757 // Write the results if needed. | 752 // Write the results if needed. |
758 if (modified) | 753 if (modified) |
759 channel_info.Write(&state_key); | 754 channel_info.Write(&state_key); |
760 | 755 |
761 // Remove the -stage: modifier since we don't want to propagate that to the | 756 if (is_multi_install()) { |
762 // other app_guids. | 757 // Remove the -stage: modifier since we don't want to propagate that to |
763 channel_info.SetStage(NULL); | 758 // the other app_guids. |
759 channel_info.SetStage(NULL); | |
764 | 760 |
765 // Synchronize the other products and the package with this one. | 761 // Synchronize the other products and the package with this one. |
766 ChannelInfo other_info; | 762 ChannelInfo other_info; |
767 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { | 763 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { |
768 BrowserDistribution::Type type = | 764 BrowserDistribution::Type type = |
769 static_cast<BrowserDistribution::Type>(i); | 765 static_cast<BrowserDistribution::Type>(i); |
770 // Skip the app_guid we started with. | 766 // Skip the app_guid we started with. |
771 if (type == state_type_) | 767 if (type == state_type_) |
772 continue; | |
773 BrowserDistribution* dist = NULL; | |
774 // Always operate on the binaries. | |
775 if (i == BrowserDistribution::CHROME_BINARIES) { | |
776 dist = multi_package_distribution_; | |
777 } else { | |
778 const Product* product = FindProduct(type); | |
779 // Skip this one if it's for a product we're not operating on. | |
780 if (product == NULL) | |
781 continue; | 768 continue; |
782 dist = product->distribution(); | 769 BrowserDistribution* dist = NULL; |
783 } | 770 // Always operate on the binaries. |
784 result = | 771 if (i == BrowserDistribution::CHROME_BINARIES) { |
785 state_key.Create(root_key_, | 772 dist = multi_package_distribution_; |
786 dist->GetStateKey().c_str(), | 773 } else { |
787 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); | 774 const Product* product = FindProduct(type); |
788 if (result == ERROR_SUCCESS) { | 775 // Skip this one if it's for a product we're not operating on. |
789 other_info.Initialize(state_key); | 776 if (product == NULL) |
790 if (!other_info.Equals(channel_info)) | 777 continue; |
791 channel_info.Write(&state_key); | 778 dist = product->distribution(); |
792 } else { | 779 } |
793 LOG(ERROR) << "Failed opening key " << dist->GetStateKey() | 780 result = |
794 << " to update app channels; result: " << result; | 781 state_key.Create(root_key_, |
782 dist->GetStateKey().c_str(), | |
783 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); | |
784 if (result == ERROR_SUCCESS) { | |
785 other_info.Initialize(state_key); | |
786 if (!other_info.Equals(channel_info)) | |
787 channel_info.Write(&state_key); | |
788 } else { | |
789 LOG(ERROR) << "Failed opening key " << dist->GetStateKey() | |
790 << " to update app channels; result: " << result; | |
791 } | |
795 } | 792 } |
796 } | 793 } |
797 } else { | 794 } else { |
798 LOG(ERROR) << "Failed opening key " << state_key_ | 795 LOG(ERROR) << "Failed opening key " << state_key_ |
799 << " to update app channels; result: " << result; | 796 << " to update app channels; result: " << result; |
800 } | 797 } |
801 } | 798 } |
802 | 799 |
803 void InstallerState::WriteInstallerResult( | 800 void InstallerState::WriteInstallerResult( |
804 InstallStatus status, | 801 InstallStatus status, |
(...skipping 19 matching lines...) Expand all Loading... | |
824 } | 821 } |
825 if (!install_list->Do()) | 822 if (!install_list->Do()) |
826 LOG(ERROR) << "Failed to record installer error information in registry."; | 823 LOG(ERROR) << "Failed to record installer error information in registry."; |
827 } | 824 } |
828 | 825 |
829 bool InstallerState::RequiresActiveSetup() const { | 826 bool InstallerState::RequiresActiveSetup() const { |
830 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 827 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
831 } | 828 } |
832 | 829 |
833 } // namespace installer | 830 } // namespace installer |
OLD | NEW |