Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/installer/util/installer_state.cc

Issue 869153004: Support migrating multi-install Chrome to single-install. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) {
747 channel_info.Initialize(state_key); 733 channel_info.Initialize(state_key);
748 734
749 // This is a multi-install product. 735 // This is a multi-install product.
750 bool modified = channel_info.SetMultiInstall(true); 736 bool modified = channel_info.SetMultiInstall(is_multi_install());
751 737
752 // Add the appropriate modifiers for all products and their options. 738 if (is_multi_install()) {
753 modified |= SetChannelFlags(true, &channel_info); 739 // Add the appropriate modifiers for all products and their options.
740 for (auto* product : products_)
741 modified |= product->SetChannelFlags(true, &channel_info);
742 } else {
743 // Remove all multi-install products from the channel name.
744 modified |= channel_info.SetChrome(false);
745 modified |= channel_info.SetChromeFrame(false);
746 modified |= channel_info.SetAppLauncher(false);
747 }
754 748
755 VLOG(1) << "ap: " << channel_info.value(); 749 VLOG(1) << "ap: " << channel_info.value();
756 750
757 // Write the results if needed. 751 // Write the results if needed.
758 if (modified) 752 if (modified)
759 channel_info.Write(&state_key); 753 channel_info.Write(&state_key);
760 754
761 // Remove the -stage: modifier since we don't want to propagate that to the 755 if (is_multi_install()) {
762 // other app_guids. 756 // Remove the -stage: modifier since we don't want to propagate that to
763 channel_info.SetStage(NULL); 757 // the other app_guids.
758 channel_info.SetStage(NULL);
764 759
765 // Synchronize the other products and the package with this one. 760 // Synchronize the other products and the package with this one.
766 ChannelInfo other_info; 761 ChannelInfo other_info;
767 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { 762 for (int i = 0; i < BrowserDistribution::NUM_TYPES; ++i) {
768 BrowserDistribution::Type type = 763 BrowserDistribution::Type type =
769 static_cast<BrowserDistribution::Type>(i); 764 static_cast<BrowserDistribution::Type>(i);
770 // Skip the app_guid we started with. 765 // Skip the app_guid we started with.
771 if (type == state_type_) 766 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; 767 continue;
782 dist = product->distribution(); 768 BrowserDistribution* dist = NULL;
783 } 769 // Always operate on the binaries.
784 result = 770 if (i == BrowserDistribution::CHROME_BINARIES) {
785 state_key.Create(root_key_, 771 dist = multi_package_distribution_;
786 dist->GetStateKey().c_str(), 772 } else {
787 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); 773 const Product* product = FindProduct(type);
788 if (result == ERROR_SUCCESS) { 774 // Skip this one if it's for a product we're not operating on.
789 other_info.Initialize(state_key); 775 if (product == NULL)
790 if (!other_info.Equals(channel_info)) 776 continue;
791 channel_info.Write(&state_key); 777 dist = product->distribution();
792 } else { 778 }
793 LOG(ERROR) << "Failed opening key " << dist->GetStateKey() 779 result =
794 << " to update app channels; result: " << result; 780 state_key.Create(root_key_,
781 dist->GetStateKey().c_str(),
782 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY);
783 if (result == ERROR_SUCCESS) {
784 other_info.Initialize(state_key);
785 if (!other_info.Equals(channel_info))
786 channel_info.Write(&state_key);
787 } else {
788 LOG(ERROR) << "Failed opening key " << dist->GetStateKey()
789 << " to update app channels; result: " << result;
790 }
795 } 791 }
796 } 792 }
797 } else { 793 } else {
798 LOG(ERROR) << "Failed opening key " << state_key_ 794 LOG(ERROR) << "Failed opening key " << state_key_
799 << " to update app channels; result: " << result; 795 << " to update app channels; result: " << result;
800 } 796 }
801 } 797 }
802 798
803 void InstallerState::WriteInstallerResult( 799 void InstallerState::WriteInstallerResult(
804 InstallStatus status, 800 InstallStatus status,
(...skipping 19 matching lines...) Expand all
824 } 820 }
825 if (!install_list->Do()) 821 if (!install_list->Do())
826 LOG(ERROR) << "Failed to record installer error information in registry."; 822 LOG(ERROR) << "Failed to record installer error information in registry.";
827 } 823 }
828 824
829 bool InstallerState::RequiresActiveSetup() const { 825 bool InstallerState::RequiresActiveSetup() const {
830 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); 826 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER);
831 } 827 }
832 828
833 } // namespace installer 829 } // namespace installer
OLDNEW
« chrome/installer/util/installation_validator.cc ('K') | « chrome/installer/util/installer_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698