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 } | |
240 | 129 |
241 BrowserDistribution* operand = NULL; | 130 BrowserDistribution* operand = NULL; |
242 | 131 |
243 if (is_uninstall) { | 132 if (is_uninstall) { |
244 operation_ = UNINSTALL; | 133 operation_ = UNINSTALL; |
245 } else if (!prefs.is_multi_install()) { | 134 } else if (!prefs.is_multi_install()) { |
246 // For a single-install, the current browser dist is the operand. | 135 // For a single-install, the current browser dist is the operand. |
247 operand = BrowserDistribution::GetDistribution(); | 136 operand = BrowserDistribution::GetDistribution(); |
248 operation_ = SINGLE_INSTALL_OR_UPDATE; | 137 operation_ = SINGLE_INSTALL_OR_UPDATE; |
249 } else if (IsMultiInstallUpdate(prefs, machine_state)) { | 138 } else if (IsMultiInstallUpdate(prefs, machine_state)) { |
250 // Updates driven by Google Update take place under the multi-installer's | 139 // Updates driven by Google Update take place under the multi-installer's |
251 // app guid. | 140 // app guid. |
252 operand = multi_package_distribution_; | 141 operand = multi_package_distribution_; |
253 operation_ = MULTI_UPDATE; | 142 operation_ = MULTI_UPDATE; |
254 } else { | 143 } 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. |
255 operation_ = MULTI_INSTALL; | 147 operation_ = MULTI_INSTALL; |
256 } | 148 } |
257 | 149 |
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). | |
261 if (operand == NULL) { | 150 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 | |
273 operand = BrowserDistribution::GetSpecificDistribution( | 151 operand = BrowserDistribution::GetSpecificDistribution( |
274 operand_distribution_type); | 152 prefs.install_chrome() ? |
| 153 BrowserDistribution::CHROME_BROWSER : |
| 154 BrowserDistribution::CHROME_FRAME); |
275 } | 155 } |
276 | 156 |
277 state_key_ = operand->GetStateKey(); | 157 state_key_ = operand->GetStateKey(); |
278 state_type_ = operand->GetType(); | 158 state_type_ = operand->GetType(); |
279 | 159 |
280 // Parse --critical-update-version=W.X.Y.Z | 160 // Parse --critical-update-version=W.X.Y.Z |
281 std::string critical_version_value( | 161 std::string critical_version_value( |
282 command_line.GetSwitchValueASCII(switches::kCriticalUpdateVersion)); | 162 command_line.GetSwitchValueASCII(switches::kCriticalUpdateVersion)); |
283 critical_update_version_ = Version(critical_version_value); | 163 critical_update_version_ = Version(critical_version_value); |
284 } | 164 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 if (is_multi_install()) { | 617 if (is_multi_install()) { |
738 InstallUtil::AddInstallerResultItems( | 618 InstallUtil::AddInstallerResultItems( |
739 system_install, multi_package_binaries_distribution()->GetStateKey(), | 619 system_install, multi_package_binaries_distribution()->GetStateKey(), |
740 status, string_resource_id, launch_cmd, install_list.get()); | 620 status, string_resource_id, launch_cmd, install_list.get()); |
741 } | 621 } |
742 if (!install_list->Do()) | 622 if (!install_list->Do()) |
743 LOG(ERROR) << "Failed to record installer error information in registry."; | 623 LOG(ERROR) << "Failed to record installer error information in registry."; |
744 } | 624 } |
745 | 625 |
746 } // namespace installer | 626 } // namespace installer |
OLD | NEW |