Chromium Code Reviews| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/win/registry.h" | 18 #include "base/win/registry.h" |
| 19 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
| 20 #include "chrome/installer/util/delete_tree_work_item.h" | 20 #include "chrome/installer/util/delete_tree_work_item.h" |
| 21 #include "chrome/installer/util/helper.h" | 21 #include "chrome/installer/util/helper.h" |
| 22 #include "chrome/installer/util/install_util.h" | 22 #include "chrome/installer/util/install_util.h" |
| 23 #include "chrome/installer/util/installation_state.h" | 23 #include "chrome/installer/util/installation_state.h" |
| 24 #include "chrome/installer/util/master_preferences.h" | 24 #include "chrome/installer/util/master_preferences.h" |
| 25 #include "chrome/installer/util/master_preferences_constants.h" | 25 #include "chrome/installer/util/master_preferences_constants.h" |
| 26 #include "chrome/installer/util/product.h" | 26 #include "chrome/installer/util/product.h" |
| 27 #include "chrome/installer/util/util_constants.h" | |
| 27 #include "chrome/installer/util/work_item.h" | 28 #include "chrome/installer/util/work_item.h" |
| 28 #include "chrome/installer/util/work_item_list.h" | 29 #include "chrome/installer/util/work_item_list.h" |
| 29 | 30 |
| 30 namespace installer { | 31 namespace installer { |
| 31 | 32 |
| 32 bool InstallerState::IsMultiInstallUpdate(const MasterPreferences& prefs, | 33 bool InstallerState::IsMultiInstallUpdate(const MasterPreferences& prefs, |
| 33 const InstallationState& machine_state) { | 34 const InstallationState& machine_state) { |
| 34 // First, is the package present? | 35 // First, is the package present? |
| 35 const ProductState* package = | 36 const ProductState* package = |
| 36 machine_state.GetProductState(level_ == SYSTEM_LEVEL, | 37 machine_state.GetProductState(level_ == SYSTEM_LEVEL, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 | 72 |
| 72 InstallerState::InstallerState() | 73 InstallerState::InstallerState() |
| 73 : operation_(UNINITIALIZED), | 74 : operation_(UNINITIALIZED), |
| 74 multi_package_distribution_(NULL), | 75 multi_package_distribution_(NULL), |
| 75 level_(UNKNOWN_LEVEL), | 76 level_(UNKNOWN_LEVEL), |
| 76 package_type_(UNKNOWN_PACKAGE_TYPE), | 77 package_type_(UNKNOWN_PACKAGE_TYPE), |
| 77 state_type_(BrowserDistribution::CHROME_BROWSER), | 78 state_type_(BrowserDistribution::CHROME_BROWSER), |
| 78 root_key_(NULL), | 79 root_key_(NULL), |
| 79 msi_(false), | 80 msi_(false), |
| 80 verbose_logging_(false), | 81 verbose_logging_(false), |
| 81 ensure_google_update_present_(false) { | 82 ensure_google_update_present_(false), |
| 83 need_to_migrate_legacy_app_launcher_(false), | |
| 84 create_app_launcher_shortcuts_(false) { | |
| 82 } | 85 } |
| 83 | 86 |
| 84 InstallerState::InstallerState(Level level) | 87 InstallerState::InstallerState(Level level) |
| 85 : operation_(UNINITIALIZED), | 88 : operation_(UNINITIALIZED), |
| 86 multi_package_distribution_(NULL), | 89 multi_package_distribution_(NULL), |
| 87 level_(UNKNOWN_LEVEL), | 90 level_(UNKNOWN_LEVEL), |
| 88 package_type_(UNKNOWN_PACKAGE_TYPE), | 91 package_type_(UNKNOWN_PACKAGE_TYPE), |
| 89 state_type_(BrowserDistribution::CHROME_BROWSER), | 92 state_type_(BrowserDistribution::CHROME_BROWSER), |
| 90 root_key_(NULL), | 93 root_key_(NULL), |
| 91 msi_(false), | 94 msi_(false), |
| 92 verbose_logging_(false), | 95 verbose_logging_(false), |
| 93 ensure_google_update_present_(false) { | 96 ensure_google_update_present_(false), |
| 97 need_to_migrate_legacy_app_launcher_(false), | |
| 98 create_app_launcher_shortcuts_(false) { | |
| 94 // Use set_level() so that root_key_ is updated properly. | 99 // Use set_level() so that root_key_ is updated properly. |
| 95 set_level(level); | 100 set_level(level); |
| 96 } | 101 } |
| 97 | 102 |
| 98 void InstallerState::Initialize(const CommandLine& command_line, | 103 void InstallerState::Initialize(const CommandLine& command_line, |
| 99 const MasterPreferences& prefs, | 104 const MasterPreferences& prefs, |
| 100 const InstallationState& machine_state) { | 105 const InstallationState& machine_state) { |
| 101 bool pref_bool; | 106 bool pref_bool; |
| 102 if (!prefs.GetBool(master_preferences::kSystemLevel, &pref_bool)) | 107 if (!prefs.GetBool(master_preferences::kSystemLevel, &pref_bool)) |
| 103 pref_bool = false; | 108 pref_bool = false; |
| 104 set_level(pref_bool ? SYSTEM_LEVEL : USER_LEVEL); | 109 set_level(pref_bool ? SYSTEM_LEVEL : USER_LEVEL); |
| 105 | 110 |
| 106 if (!prefs.GetBool(master_preferences::kVerboseLogging, &verbose_logging_)) | 111 if (!prefs.GetBool(master_preferences::kVerboseLogging, &verbose_logging_)) |
| 107 verbose_logging_ = false; | 112 verbose_logging_ = false; |
| 108 | 113 |
| 109 if (!prefs.GetBool(master_preferences::kMultiInstall, &pref_bool)) | 114 if (!prefs.GetBool(master_preferences::kMultiInstall, &pref_bool)) |
| 110 pref_bool = false; | 115 pref_bool = false; |
| 111 set_package_type(pref_bool ? MULTI_PACKAGE : SINGLE_PACKAGE); | 116 set_package_type(pref_bool ? MULTI_PACKAGE : SINGLE_PACKAGE); |
| 112 | 117 |
| 113 if (!prefs.GetBool(master_preferences::kMsi, &msi_)) | 118 if (!prefs.GetBool(master_preferences::kMsi, &msi_)) |
| 114 msi_ = false; | 119 msi_ = false; |
| 115 | 120 |
| 116 ensure_google_update_present_ = | 121 ensure_google_update_present_ = |
| 117 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); | 122 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); |
| 118 | 123 |
| 119 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); | 124 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); |
| 120 | 125 |
| 121 if (prefs.install_chrome()) { | 126 // TODO(huangs): Remove by M30. |
| 122 Product* p = AddProductFromPreferences( | 127 // Create App Launcher shortcuts if --app-launcher is specified. |
|
grt (UTC plus 2)
2013/05/16 14:55:52
This comment also appears on line 154. Can one of
huangs
2013/05/17 20:59:24
Done (deleted this one).
| |
| 128 if (prefs.is_multi_install()) { | |
|
grt (UTC plus 2)
2013/05/16 14:55:52
if (!is_uninstall && ....)?
huangs
2013/05/17 20:59:24
Done.
| |
| 129 // Check the version of App Launcher ClientState to determine if legacy. | |
| 130 const ProductState* app_launcher_state = machine_state.GetProductState( | |
| 131 system_install(), BrowserDistribution::CHROME_APP_HOST); | |
|
grt (UTC plus 2)
2013/05/16 14:55:52
I forget: is the legacy AL only ever installed at
huangs
2013/05/17 20:59:24
Yes, but I'm relying on app_launcher_state == NULL
| |
| 132 if (app_launcher_state) { | |
| 133 need_to_migrate_legacy_app_launcher_ = | |
| 134 app_launcher_state->version().IsOlderThan("29.0.1506.0"); | |
|
gab
2013/05/15 22:42:20
Make sure this is the current version of trunk the
huangs
2013/05/17 20:59:24
Yes. In the planned change, we'll have need_to_mi
| |
| 135 } | |
| 136 } | |
| 137 | |
| 138 // App Launcher and Chrome are unified. | |
| 139 if (prefs.install_chrome() || prefs.install_chrome_app_launcher() || | |
|
grt (UTC plus 2)
2013/05/16 14:55:52
if (!is_uninstall && ...)?
huangs
2013/05/17 20:59:24
I'm "short-circuiting" the --chrome switch and the
| |
| 140 need_to_migrate_legacy_app_launcher_) { | |
|
grt (UTC plus 2)
2013/05/16 14:55:52
Does this mean that a user-level AL installation (
huangs
2013/05/17 20:59:24
That is correct; it's the product decision.
| |
| 141 Product* p1 = AddProductFromPreferences( | |
| 123 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); | 142 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); |
| 124 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 143 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 125 << " distribution: " << p->distribution()->GetAppShortCutName(); | 144 << " distribution: " << p1->distribution()->GetAppShortCutName(); |
| 145 | |
| 146 if (is_multi_install()) { | |
| 147 Product* p2 = AddProductFromPreferences( | |
| 148 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); | |
| 149 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | |
| 150 << " distribution: " << p2->distribution()->GetAppShortCutName(); | |
| 151 } | |
| 126 } | 152 } |
| 153 // TODO(huangs): Remove by M30. | |
| 154 // Create App Launcher shortcuts if --app-launcher is specified. | |
|
grt (UTC plus 2)
2013/05/16 14:55:52
Who/what will run the installer with --app-launche
huangs
2013/05/17 20:59:24
App command quick-enable-app-launcher, testing, an
| |
| 155 create_app_launcher_shortcuts_ = need_to_migrate_legacy_app_launcher_ || | |
| 156 prefs.install_chrome_app_launcher(); | |
| 157 | |
| 127 if (prefs.install_chrome_frame()) { | 158 if (prefs.install_chrome_frame()) { |
| 128 Product* p = AddProductFromPreferences( | 159 Product* p = AddProductFromPreferences( |
| 129 BrowserDistribution::CHROME_FRAME, prefs, machine_state); | 160 BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| 130 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 161 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 131 << " distribution: " << p->distribution()->GetAppShortCutName(); | 162 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 132 } | 163 } |
| 133 | 164 |
| 134 if (prefs.install_chrome_app_launcher()) { | |
| 135 Product* p = AddProductFromPreferences( | |
| 136 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); | |
| 137 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | |
| 138 << " distribution: " << p->distribution()->GetAppShortCutName(); | |
| 139 } | |
| 140 | |
| 141 if (!is_uninstall && is_multi_install()) { | 165 if (!is_uninstall && is_multi_install()) { |
|
grt (UTC plus 2)
2013/05/16 14:55:52
This whole block can be compacted:
if (!is_uninsta
huangs
2013/05/17 20:59:24
Done, but I'll have to remember to exclude the CHR
| |
| 142 bool need_binaries = false; | 166 bool need_binaries = false; |
| 143 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | 167 // Chrome/Chrome Frame/App Launcher multi need Binaries at their own level. |
| 144 // App Host will happily use Chrome at system level, or binaries at system | |
| 145 // level, even if app host is user level. | |
| 146 const ProductState* chrome_state = machine_state.GetProductState( | |
| 147 true, // system level | |
| 148 BrowserDistribution::CHROME_BROWSER); | |
| 149 // If Chrome is at system-level, multi- or otherwise. We'll use it. | |
| 150 if (!chrome_state) { | |
| 151 const ProductState* binaries_state = machine_state.GetProductState( | |
| 152 true, // system level | |
| 153 BrowserDistribution::CHROME_BINARIES); | |
| 154 if (!binaries_state) | |
| 155 need_binaries = true; | |
| 156 } | |
| 157 } | |
| 158 | |
| 159 // Chrome/Chrome Frame multi need Binaries at their own level. | |
| 160 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) | 168 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) |
| 161 need_binaries = true; | 169 need_binaries = true; |
| 162 | 170 |
| 163 if (FindProduct(BrowserDistribution::CHROME_FRAME)) | 171 if (FindProduct(BrowserDistribution::CHROME_FRAME)) |
| 164 need_binaries = true; | 172 need_binaries = true; |
| 165 | 173 |
| 174 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) | |
| 175 need_binaries = true; | |
| 176 | |
| 166 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 177 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
| 167 // Force binaries to be installed/updated. | 178 // Force binaries to be installed/updated. |
| 168 Product* p = AddProductFromPreferences( | 179 Product* p = AddProductFromPreferences( |
| 169 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); | 180 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| 170 VLOG(1) << "Install distribution: " | 181 VLOG(1) << "Install distribution: " |
| 171 << p->distribution()->GetAppShortCutName(); | 182 << p->distribution()->GetAppShortCutName(); |
| 172 } | 183 } |
| 173 } | 184 } |
| 174 | 185 |
| 175 if (is_uninstall && prefs.is_multi_install()) { | 186 if (is_uninstall && prefs.is_multi_install()) { |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 790 } | 801 } |
| 791 if (!install_list->Do()) | 802 if (!install_list->Do()) |
| 792 LOG(ERROR) << "Failed to record installer error information in registry."; | 803 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 793 } | 804 } |
| 794 | 805 |
| 795 bool InstallerState::RequiresActiveSetup() const { | 806 bool InstallerState::RequiresActiveSetup() const { |
| 796 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 807 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 797 } | 808 } |
| 798 | 809 |
| 799 } // namespace installer | 810 } // namespace installer |
| OLD | NEW |