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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 119 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
120 << " distribution: " << p->distribution()->GetAppShortCutName(); | 120 << " distribution: " << p->distribution()->GetAppShortCutName(); |
121 } | 121 } |
122 if (prefs.install_chrome_frame()) { | 122 if (prefs.install_chrome_frame()) { |
123 Product* p = | 123 Product* p = |
124 AddProductFromPreferences(BrowserDistribution::CHROME_FRAME, prefs, | 124 AddProductFromPreferences(BrowserDistribution::CHROME_FRAME, prefs, |
125 machine_state); | 125 machine_state); |
126 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 126 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
127 << " distribution: " << p->distribution()->GetAppShortCutName(); | 127 << " distribution: " << p->distribution()->GetAppShortCutName(); |
128 } | 128 } |
| 129 if (prefs.install_chrome_app_host()) { |
| 130 Product* p = |
| 131 AddProductFromPreferences(BrowserDistribution::CHROME_APP_HOST, prefs, |
| 132 machine_state); |
| 133 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 134 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 135 } |
| 136 |
| 137 if (!is_uninstall && is_multi_install()) { |
| 138 bool need_binaries = false; |
| 139 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { |
| 140 // App Host will happily use Chrome at system level, or binaries at system |
| 141 // level, even if app host is user level. |
| 142 const ProductState* chrome_state = machine_state.GetProductState( |
| 143 true, // system level |
| 144 BrowserDistribution::CHROME_BROWSER); |
| 145 // If Chrome is at system-level, multi- or otherwise. We'll use it. |
| 146 if (!chrome_state) { |
| 147 const ProductState* binaries_state = machine_state.GetProductState( |
| 148 true, // system level |
| 149 BrowserDistribution::CHROME_BINARIES); |
| 150 if (!binaries_state) |
| 151 need_binaries = true; |
| 152 } |
| 153 } |
| 154 |
| 155 // Chrome/Chrome Frame multi need Binaries at their own level. |
| 156 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) |
| 157 need_binaries = true; |
| 158 |
| 159 if (FindProduct(BrowserDistribution::CHROME_FRAME)) |
| 160 need_binaries = true; |
| 161 |
| 162 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
| 163 // Force binaries to be installed/updated. |
| 164 Product* p = |
| 165 AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, |
| 166 prefs, |
| 167 machine_state); |
| 168 VLOG(1) << "Install distribution: " |
| 169 << p->distribution()->GetAppShortCutName(); |
| 170 } |
| 171 } |
| 172 |
| 173 if (is_uninstall && prefs.is_multi_install()) { |
| 174 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) { |
| 175 const ProductState* chrome_frame_state = machine_state.GetProductState( |
| 176 system_install(), BrowserDistribution::CHROME_FRAME); |
| 177 |
| 178 if (chrome_frame_state != NULL && |
| 179 chrome_frame_state->uninstall_command().HasSwitch( |
| 180 switches::kChromeFrameReadyMode) && |
| 181 !FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 182 // Chrome Frame is installed in Ready Mode. Remove it along with Chrome. |
| 183 Product* p = AddProductFromPreferences( |
| 184 BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| 185 |
| 186 VLOG(1) << "Uninstall distribution: " |
| 187 << p->distribution()->GetAppShortCutName(); |
| 188 } |
| 189 } |
| 190 |
| 191 bool keep_binaries = false; |
| 192 // Look for a product that is not the binaries and that is not being |
| 193 // uninstalled. If not found, binaries are uninstalled too. |
| 194 for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { |
| 195 BrowserDistribution::Type type = |
| 196 static_cast<BrowserDistribution::Type>(i); |
| 197 |
| 198 if (type == BrowserDistribution::CHROME_BINARIES) |
| 199 continue; |
| 200 |
| 201 if (machine_state.GetProductState(system_install(), type) == NULL) { |
| 202 // The product is not installed. |
| 203 continue; |
| 204 } |
| 205 |
| 206 // The product is installed. |
| 207 |
| 208 if (!FindProduct(type)) { |
| 209 // The product is not being uninstalled. |
| 210 if (type != BrowserDistribution::CHROME_APP_HOST) { |
| 211 keep_binaries = true; |
| 212 break; |
| 213 } else { |
| 214 // If binaries/chrome are at system-level, we can discard them at |
| 215 // user-level... |
| 216 if (!machine_state.GetProductState( |
| 217 true, // system-level |
| 218 BrowserDistribution::CHROME_BROWSER) && |
| 219 !machine_state.GetProductState( |
| 220 true, // system-level |
| 221 BrowserDistribution::CHROME_BINARIES)) { |
| 222 // ... otherwise keep them. |
| 223 keep_binaries = true; |
| 224 break; |
| 225 } |
| 226 |
| 227 } |
| 228 } |
| 229 |
| 230 // The product is being uninstalled. |
| 231 } |
| 232 if (!keep_binaries) { |
| 233 Product* p = |
| 234 AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, prefs, |
| 235 machine_state); |
| 236 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 237 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 238 } |
| 239 } |
129 | 240 |
130 BrowserDistribution* operand = NULL; | 241 BrowserDistribution* operand = NULL; |
131 | 242 |
132 if (is_uninstall) { | 243 if (is_uninstall) { |
133 operation_ = UNINSTALL; | 244 operation_ = UNINSTALL; |
134 } else if (!prefs.is_multi_install()) { | 245 } else if (!prefs.is_multi_install()) { |
135 // For a single-install, the current browser dist is the operand. | 246 // For a single-install, the current browser dist is the operand. |
136 operand = BrowserDistribution::GetDistribution(); | 247 operand = BrowserDistribution::GetDistribution(); |
137 operation_ = SINGLE_INSTALL_OR_UPDATE; | 248 operation_ = SINGLE_INSTALL_OR_UPDATE; |
138 } else if (IsMultiInstallUpdate(prefs, machine_state)) { | 249 } else if (IsMultiInstallUpdate(prefs, machine_state)) { |
139 // Updates driven by Google Update take place under the multi-installer's | 250 // Updates driven by Google Update take place under the multi-installer's |
140 // app guid. | 251 // app guid. |
141 operand = multi_package_distribution_; | 252 operand = multi_package_distribution_; |
142 operation_ = MULTI_UPDATE; | 253 operation_ = MULTI_UPDATE; |
143 } else { | 254 } else { |
144 // Initial and over installs will always take place under one of the | |
145 // product app guids. Chrome Frame's will be used if only Chrome Frame | |
146 // is being installed. In all other cases, Chrome's is used. | |
147 operation_ = MULTI_INSTALL; | 255 operation_ = MULTI_INSTALL; |
148 } | 256 } |
149 | 257 |
| 258 // Initial, over, and un-installs will always take place under one of the |
| 259 // product app guids (Chrome, Chrome Frame, or App Host, in order of |
| 260 // preference). |
150 if (operand == NULL) { | 261 if (operand == NULL) { |
| 262 BrowserDistribution::Type operand_distribution_type = |
| 263 BrowserDistribution::CHROME_BINARIES; |
| 264 if (prefs.install_chrome()) |
| 265 operand_distribution_type = BrowserDistribution::CHROME_BROWSER; |
| 266 else if (prefs.install_chrome_frame()) |
| 267 operand_distribution_type = BrowserDistribution::CHROME_FRAME; |
| 268 else if (prefs.install_chrome_app_host()) |
| 269 operand_distribution_type = BrowserDistribution::CHROME_APP_HOST; |
| 270 else |
| 271 NOTREACHED(); |
| 272 |
151 operand = BrowserDistribution::GetSpecificDistribution( | 273 operand = BrowserDistribution::GetSpecificDistribution( |
152 prefs.install_chrome() ? | 274 operand_distribution_type); |
153 BrowserDistribution::CHROME_BROWSER : | |
154 BrowserDistribution::CHROME_FRAME); | |
155 } | 275 } |
156 | 276 |
157 state_key_ = operand->GetStateKey(); | 277 state_key_ = operand->GetStateKey(); |
158 state_type_ = operand->GetType(); | 278 state_type_ = operand->GetType(); |
159 | 279 |
160 // Parse --critical-update-version=W.X.Y.Z | 280 // Parse --critical-update-version=W.X.Y.Z |
161 std::string critical_version_value( | 281 std::string critical_version_value( |
162 command_line.GetSwitchValueASCII(switches::kCriticalUpdateVersion)); | 282 command_line.GetSwitchValueASCII(switches::kCriticalUpdateVersion)); |
163 critical_update_version_ = Version(critical_version_value); | 283 critical_update_version_ = Version(critical_version_value); |
164 } | 284 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 if (is_multi_install()) { | 737 if (is_multi_install()) { |
618 InstallUtil::AddInstallerResultItems( | 738 InstallUtil::AddInstallerResultItems( |
619 system_install, multi_package_binaries_distribution()->GetStateKey(), | 739 system_install, multi_package_binaries_distribution()->GetStateKey(), |
620 status, string_resource_id, launch_cmd, install_list.get()); | 740 status, string_resource_id, launch_cmd, install_list.get()); |
621 } | 741 } |
622 if (!install_list->Do()) | 742 if (!install_list->Do()) |
623 LOG(ERROR) << "Failed to record installer error information in registry."; | 743 LOG(ERROR) << "Failed to record installer error information in registry."; |
624 } | 744 } |
625 | 745 |
626 } // namespace installer | 746 } // namespace installer |
OLD | NEW |