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/setup/installer_state.h" | 5 #include "chrome/installer/setup/installer_state.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <functional> | 10 #include <functional> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 InstallerState::InstallerState() | 67 InstallerState::InstallerState() |
68 : operation_(UNINITIALIZED), | 68 : operation_(UNINITIALIZED), |
69 state_type_(BrowserDistribution::CHROME_BROWSER), | 69 state_type_(BrowserDistribution::CHROME_BROWSER), |
70 multi_package_distribution_(NULL), | 70 multi_package_distribution_(NULL), |
71 level_(UNKNOWN_LEVEL), | 71 level_(UNKNOWN_LEVEL), |
72 package_type_(UNKNOWN_PACKAGE_TYPE), | 72 package_type_(UNKNOWN_PACKAGE_TYPE), |
73 root_key_(NULL), | 73 root_key_(NULL), |
74 msi_(false), | 74 msi_(false), |
75 background_mode_(false), | 75 background_mode_(false), |
76 verbose_logging_(false) {} | 76 verbose_logging_(false), |
| 77 is_migrating_to_single_(false) {} |
77 | 78 |
78 InstallerState::InstallerState(Level level) | 79 InstallerState::InstallerState(Level level) |
79 : operation_(UNINITIALIZED), | 80 : operation_(UNINITIALIZED), |
80 state_type_(BrowserDistribution::CHROME_BROWSER), | 81 state_type_(BrowserDistribution::CHROME_BROWSER), |
81 multi_package_distribution_(NULL), | 82 multi_package_distribution_(NULL), |
82 level_(UNKNOWN_LEVEL), | 83 level_(UNKNOWN_LEVEL), |
83 package_type_(UNKNOWN_PACKAGE_TYPE), | 84 package_type_(UNKNOWN_PACKAGE_TYPE), |
84 root_key_(NULL), | 85 root_key_(NULL), |
85 msi_(false), | 86 msi_(false), |
86 background_mode_(false), | 87 background_mode_(false), |
87 verbose_logging_(false) { | 88 verbose_logging_(false), |
| 89 is_migrating_to_single_(false) { |
88 // Use set_level() so that root_key_ is updated properly. | 90 // Use set_level() so that root_key_ is updated properly. |
89 set_level(level); | 91 set_level(level); |
90 } | 92 } |
91 | 93 |
92 InstallerState::~InstallerState() { | 94 InstallerState::~InstallerState() { |
93 } | 95 } |
94 | 96 |
95 void InstallerState::Initialize(const base::CommandLine& command_line, | 97 void InstallerState::Initialize(const base::CommandLine& command_line, |
96 const MasterPreferences& prefs, | 98 const MasterPreferences& prefs, |
97 const InstallationState& machine_state) { | 99 const InstallationState& machine_state) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 133 } |
132 | 134 |
133 BrowserDistribution* operand = NULL; | 135 BrowserDistribution* operand = NULL; |
134 | 136 |
135 if (is_uninstall) { | 137 if (is_uninstall) { |
136 operation_ = UNINSTALL; | 138 operation_ = UNINSTALL; |
137 } else if (!prefs.is_multi_install()) { | 139 } else if (!prefs.is_multi_install()) { |
138 // For a single-install, the current browser dist is the operand. | 140 // For a single-install, the current browser dist is the operand. |
139 operand = BrowserDistribution::GetDistribution(); | 141 operand = BrowserDistribution::GetDistribution(); |
140 operation_ = SINGLE_INSTALL_OR_UPDATE; | 142 operation_ = SINGLE_INSTALL_OR_UPDATE; |
| 143 // Is this a migration from multi-install to single-install? |
| 144 const ProductState* state = |
| 145 machine_state.GetProductState(system_install(), operand->GetType()); |
| 146 is_migrating_to_single_ = state && state->is_multi_install(); |
141 } else if (IsMultiInstallUpdate(prefs, machine_state)) { | 147 } else if (IsMultiInstallUpdate(prefs, machine_state)) { |
142 // Updates driven by Google Update take place under the multi-installer's | 148 // Updates driven by Google Update take place under the multi-installer's |
143 // app guid. | 149 // app guid. |
144 operand = multi_package_distribution_; | 150 operand = multi_package_distribution_; |
145 operation_ = MULTI_UPDATE; | 151 operation_ = MULTI_UPDATE; |
146 } else { | 152 } else { |
147 operation_ = MULTI_INSTALL; | 153 operation_ = MULTI_INSTALL; |
148 } | 154 } |
149 | 155 |
150 // Initial, over, and un-installs will take place under Chrome or Binaries | 156 // Initial, over, and un-installs will take place under Chrome or Binaries |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 state_key_.clear(); | 472 state_key_.clear(); |
467 state_type_ = BrowserDistribution::CHROME_BROWSER; | 473 state_type_ = BrowserDistribution::CHROME_BROWSER; |
468 products_.clear(); | 474 products_.clear(); |
469 multi_package_distribution_ = NULL; | 475 multi_package_distribution_ = NULL; |
470 critical_update_version_ = base::Version(); | 476 critical_update_version_ = base::Version(); |
471 level_ = UNKNOWN_LEVEL; | 477 level_ = UNKNOWN_LEVEL; |
472 package_type_ = UNKNOWN_PACKAGE_TYPE; | 478 package_type_ = UNKNOWN_PACKAGE_TYPE; |
473 root_key_ = NULL; | 479 root_key_ = NULL; |
474 msi_ = false; | 480 msi_ = false; |
475 verbose_logging_ = false; | 481 verbose_logging_ = false; |
| 482 is_migrating_to_single_ = false; |
476 } | 483 } |
477 | 484 |
478 bool InstallerState::AnyExistsAndIsInUse(const InstallationState& machine_state, | 485 bool InstallerState::AnyExistsAndIsInUse(const InstallationState& machine_state, |
479 uint32_t file_bits) const { | 486 uint32_t file_bits) const { |
480 static const wchar_t* const kBinaryFileNames[] = { | 487 static const wchar_t* const kBinaryFileNames[] = { |
481 kChromeDll, | 488 kChromeDll, |
482 kChromeFrameDll, | 489 kChromeFrameDll, |
483 kChromeFrameHelperDll, | 490 kChromeFrameHelperDll, |
484 kChromeFrameHelperExe, | 491 kChromeFrameHelperExe, |
485 }; | 492 }; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 ++scan) { | 625 ++scan) { |
619 InstallUtil::AddInstallerResultItems( | 626 InstallUtil::AddInstallerResultItems( |
620 system_install, (*scan)->distribution()->GetStateKey(), status, | 627 system_install, (*scan)->distribution()->GetStateKey(), status, |
621 string_resource_id, launch_cmd, install_list.get()); | 628 string_resource_id, launch_cmd, install_list.get()); |
622 } | 629 } |
623 // And for the binaries if this is a multi-install. | 630 // And for the binaries if this is a multi-install. |
624 if (is_multi_install()) { | 631 if (is_multi_install()) { |
625 InstallUtil::AddInstallerResultItems( | 632 InstallUtil::AddInstallerResultItems( |
626 system_install, multi_package_binaries_distribution()->GetStateKey(), | 633 system_install, multi_package_binaries_distribution()->GetStateKey(), |
627 status, string_resource_id, launch_cmd, install_list.get()); | 634 status, string_resource_id, launch_cmd, install_list.get()); |
| 635 } else if (is_migrating_to_single() && |
| 636 InstallUtil::GetInstallReturnCode(status)) { |
| 637 #if defined(GOOGLE_CHROME_BUILD) |
| 638 // Also write to the binaries on error if this is a migration back to |
| 639 // single-install for Google Chrome builds. Skip this for Chromium builds |
| 640 // because they lump the "ClientState" and "Clients" keys into a single |
| 641 // key. As a consequence, writing this value causes Software\Chromium to be |
| 642 // re-created after it was deleted during the migration to single-install. |
| 643 // Google Chrome builds don't suffer this since the two keys are distinct |
| 644 // and have different lifetimes. The result is only written on failure since |
| 645 // for success, the binaries have been uninstalled and therefore the result |
| 646 // will not be read by Google Update. |
| 647 InstallUtil::AddInstallerResultItems( |
| 648 system_install, BrowserDistribution::GetSpecificDistribution( |
| 649 BrowserDistribution::CHROME_BINARIES) |
| 650 ->GetStateKey(), |
| 651 status, string_resource_id, launch_cmd, install_list.get()); |
| 652 #endif |
628 } | 653 } |
629 install_list->Do(); | 654 install_list->Do(); |
630 } | 655 } |
631 | 656 |
632 bool InstallerState::RequiresActiveSetup() const { | 657 bool InstallerState::RequiresActiveSetup() const { |
633 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 658 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
634 } | 659 } |
635 | 660 |
636 } // namespace installer | 661 } // namespace installer |
OLD | NEW |