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

Side by Side Diff: chrome/installer/setup/install_worker.cc

Issue 10823437: Callback flow to register Chrome and update shortcuts after OS upgrade to Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactoring; renamed OnOsUpgrade() to HandleOsUpgradeForBrowser(). Created 8 years, 3 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 | Annotate | Revision Log
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 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // means that Chrome Frame is being uninstalled, so there's no need to do any 164 // means that Chrome Frame is being uninstalled, so there's no need to do any
165 // looping. 165 // looping.
166 if (product.is_chrome() && 166 if (product.is_chrome() &&
167 installer_state.operation() != InstallerState::UNINSTALL) { 167 installer_state.operation() != InstallerState::UNINSTALL) {
168 const Product* chrome_frame = 168 const Product* chrome_frame =
169 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); 169 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME);
170 if (chrome_frame && chrome_frame->HasOption(kOptionReadyMode)) 170 if (chrome_frame && chrome_frame->HasOption(kOptionReadyMode))
171 chrome_frame->AppendProductFlags(&uninstall_arguments); 171 chrome_frame->AppendProductFlags(&uninstall_arguments);
172 } 172 }
173 173
174 std::wstring update_state_key(browser_dist->GetStateKey()); 174 string16 update_state_key(browser_dist->GetStateKey());
175 install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key); 175 install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key);
176 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, 176 install_list->AddSetRegValueWorkItem(reg_root, update_state_key,
177 installer::kUninstallStringField, installer_path.value(), true); 177 installer::kUninstallStringField, installer_path.value(), true);
178 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, 178 install_list->AddSetRegValueWorkItem(reg_root, update_state_key,
179 installer::kUninstallArgumentsField, 179 installer::kUninstallArgumentsField,
180 uninstall_arguments.GetCommandLineString(), true); 180 uninstall_arguments.GetCommandLineString(), true);
181 181
182 // MSI installations will manage their own uninstall shortcuts. 182 // MSI installations will manage their own uninstall shortcuts.
183 if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) { 183 if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) {
184 // We need to quote the command line for the Add/Remove Programs dialog. 184 // We need to quote the command line for the Add/Remove Programs dialog.
185 CommandLine quoted_uninstall_cmd(installer_path); 185 CommandLine quoted_uninstall_cmd(installer_path);
186 DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"'); 186 DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"');
187 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false); 187 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false);
188 188
189 std::wstring uninstall_reg = browser_dist->GetUninstallRegPath(); 189 string16 uninstall_reg = browser_dist->GetUninstallRegPath();
190 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); 190 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg);
191 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 191 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
192 installer::kUninstallDisplayNameField, 192 installer::kUninstallDisplayNameField,
193 browser_dist->GetAppShortCutName(), true); 193 browser_dist->GetAppShortCutName(), true);
194 install_list->AddSetRegValueWorkItem(reg_root, 194 install_list->AddSetRegValueWorkItem(reg_root,
195 uninstall_reg, installer::kUninstallStringField, 195 uninstall_reg, installer::kUninstallStringField,
196 quoted_uninstall_cmd.GetCommandLineString(), true); 196 quoted_uninstall_cmd.GetCommandLineString(), true);
197 install_list->AddSetRegValueWorkItem(reg_root, 197 install_list->AddSetRegValueWorkItem(reg_root,
198 uninstall_reg, 198 uninstall_reg,
199 L"InstallLocation", 199 L"InstallLocation",
200 install_path.value(), 200 install_path.value(),
201 true); 201 true);
202 202
203 // DisplayIcon, NoModify and NoRepair 203 // DisplayIcon, NoModify and NoRepair
204 std::wstring chrome_icon = ShellUtil::GetChromeIcon( 204 string16 chrome_icon = ShellUtil::GetChromeIcon(
205 product.distribution(), 205 product.distribution(),
206 install_path.Append(installer::kChromeExe).value()); 206 install_path.Append(installer::kChromeExe).value());
207 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 207 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
208 L"DisplayIcon", chrome_icon, true); 208 L"DisplayIcon", chrome_icon, true);
209 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 209 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
210 L"NoModify", static_cast<DWORD>(1), 210 L"NoModify", static_cast<DWORD>(1),
211 true); 211 true);
212 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 212 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
213 L"NoRepair", static_cast<DWORD>(1), 213 L"NoRepair", static_cast<DWORD>(1),
214 true); 214 true);
(...skipping 28 matching lines...) Expand all
243 243
244 // Create Version key for a product (if not already present) and sets the new 244 // Create Version key for a product (if not already present) and sets the new
245 // product version as the last step. 245 // product version as the last step.
246 void AddVersionKeyWorkItems(HKEY root, 246 void AddVersionKeyWorkItems(HKEY root,
247 BrowserDistribution* dist, 247 BrowserDistribution* dist,
248 const Version& new_version, 248 const Version& new_version,
249 bool add_language_identifier, 249 bool add_language_identifier,
250 WorkItemList* list) { 250 WorkItemList* list) {
251 // Create Version key for each distribution (if not already present) and set 251 // Create Version key for each distribution (if not already present) and set
252 // the new product version as the last step. 252 // the new product version as the last step.
253 std::wstring version_key(dist->GetVersionKey()); 253 string16 version_key(dist->GetVersionKey());
254 list->AddCreateRegKeyWorkItem(root, version_key); 254 list->AddCreateRegKeyWorkItem(root, version_key);
255 255
256 std::wstring product_name(dist->GetAppShortCutName()); 256 string16 product_name(dist->GetAppShortCutName());
257 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, 257 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField,
258 product_name, true); // overwrite name also 258 product_name, true); // overwrite name also
259 list->AddSetRegValueWorkItem(root, version_key, 259 list->AddSetRegValueWorkItem(root, version_key,
260 google_update::kRegOopcrashesField, 260 google_update::kRegOopcrashesField,
261 static_cast<DWORD>(1), 261 static_cast<DWORD>(1),
262 false); // set during first install 262 false); // set during first install
263 if (add_language_identifier) { 263 if (add_language_identifier) {
264 // Write the language identifier of the current translation. Omaha's set of 264 // Write the language identifier of the current translation. Omaha's set of
265 // languages is a superset of Chrome's set of translations with this one 265 // languages is a superset of Chrome's set of translations with this one
266 // exception: what Chrome calls "en-us", Omaha calls "en". sigh. 266 // exception: what Chrome calls "en-us", Omaha calls "en". sigh.
267 std::wstring language(GetCurrentTranslation()); 267 string16 language(GetCurrentTranslation());
268 if (LowerCaseEqualsASCII(language, "en-us")) 268 if (LowerCaseEqualsASCII(language, "en-us"))
269 language.resize(2); 269 language.resize(2);
270 list->AddSetRegValueWorkItem(root, version_key, 270 list->AddSetRegValueWorkItem(root, version_key,
271 google_update::kRegLangField, language, 271 google_update::kRegLangField, language,
272 false); // do not overwrite language 272 false); // do not overwrite language
273 } 273 }
274 list->AddSetRegValueWorkItem(root, version_key, 274 list->AddSetRegValueWorkItem(root, version_key,
275 google_update::kRegVersionField, 275 google_update::kRegVersionField,
276 ASCIIToWide(new_version.GetString()), 276 ASCIIToWide(new_version.GetString()),
277 true); // overwrite version 277 true); // overwrite version
278 } 278 }
279 279
280 void AddInstallAppCommandWorkItems(const InstallerState& installer_state, 280 void AddInstallAppCommandWorkItems(const InstallerState& installer_state,
281 const InstallationState& machine_state, 281 const InstallationState& machine_state,
282 const FilePath* setup_path, 282 const FilePath* setup_path,
283 const Version* new_version, 283 const Version* new_version,
284 const Product& product, 284 const Product& product,
285 WorkItemList* work_item_list) { 285 WorkItemList* work_item_list) {
286 DCHECK(product.is_chrome_app_host()); 286 DCHECK(product.is_chrome_app_host());
287 287
288 std::wstring cmd_key(product.distribution()->GetVersionKey()); 288 string16 cmd_key(product.distribution()->GetVersionKey());
289 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) 289 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey)
290 .append(1, L'\\').append(kCmdInstallApp); 290 .append(1, L'\\').append(kCmdInstallApp);
291 291
292 if (installer_state.operation() != InstallerState::UNINSTALL) { 292 if (installer_state.operation() != InstallerState::UNINSTALL) {
293 FilePath target_path(installer_state.target_path()); 293 FilePath target_path(installer_state.target_path());
294 CommandLine cmd_line(target_path.Append(installer::kChromeAppHostExe)); 294 CommandLine cmd_line(target_path.Append(installer::kChromeAppHostExe));
295 cmd_line.AppendSwitchASCII(::switches::kAppsInstallFromManifestURL, "%1"); 295 cmd_line.AppendSwitchASCII(::switches::kAppsInstallFromManifestURL, "%1");
296 296
297 AppCommand cmd(cmd_line.GetCommandLineString(), true, true); 297 AppCommand cmd(cmd_line.GetCommandLineString());
298 cmd.set_sends_pings(true);
299 cmd.set_is_web_accessible(true);
298 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 300 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
299 } else { 301 } else {
300 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 302 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
301 cmd_key)->set_log_message( 303 cmd_key)->set_log_message(
302 "removing install-application command"); 304 "removing install-application command");
303 } 305 }
304 } 306 }
305 307
306 void AddProductSpecificWorkItems(const InstallationState& original_state, 308 void AddProductSpecificWorkItems(const InstallationState& original_state,
307 const InstallerState& installer_state, 309 const InstallerState& installer_state,
308 const FilePath& setup_path, 310 const FilePath& setup_path,
309 const Version& new_version, 311 const Version& new_version,
310 WorkItemList* list) { 312 WorkItemList* list) {
311 const Products& products = installer_state.products(); 313 const Products& products = installer_state.products();
312 for (size_t i = 0; i < products.size(); ++i) { 314 for (size_t i = 0; i < products.size(); ++i) {
313 const Product& p = *products[i]; 315 const Product& p = *products[i];
314 if (p.is_chrome_frame()) { 316 if (p.is_chrome_frame()) {
315 AddChromeFrameWorkItems(original_state, installer_state, setup_path, 317 AddChromeFrameWorkItems(original_state, installer_state, setup_path,
316 new_version, p, list); 318 new_version, p, list);
317 } 319 }
318 if (p.is_chrome_app_host()) { 320 if (p.is_chrome_app_host()) {
319 AddInstallAppCommandWorkItems(installer_state, original_state, 321 AddInstallAppCommandWorkItems(installer_state, original_state,
320 &setup_path, &new_version, p, list); 322 &setup_path, &new_version, p, list);
321 } 323 }
324 if (p.is_chrome()) {
grt (UTC plus 2) 2012/08/30 19:10:18 remove braces
huangs 2012/08/30 20:14:22 No change; we have to pass &setup_path again => wr
325 AddOsUpgradeWorkItems(installer_state, &new_version, p, list);
326 }
322 } 327 }
323 } 328 }
324 329
325 // Mirror oeminstall the first time anything is installed multi. There is no 330 // Mirror oeminstall the first time anything is installed multi. There is no
326 // need to update the value on future install/update runs since this value never 331 // need to update the value on future install/update runs since this value never
327 // changes. Note that the value is removed by Google Update after EULA 332 // changes. Note that the value is removed by Google Update after EULA
328 // acceptance is processed. 333 // acceptance is processed.
329 void AddOemInstallWorkItems(const InstallationState& original_state, 334 void AddOemInstallWorkItems(const InstallationState& original_state,
330 const InstallerState& installer_state, 335 const InstallerState& installer_state,
331 WorkItemList* install_list) { 336 WorkItemList* install_list) {
332 DCHECK(installer_state.is_multi_install()); 337 DCHECK(installer_state.is_multi_install());
333 const bool system_install = installer_state.system_install(); 338 const bool system_install = installer_state.system_install();
334 if (!original_state.GetProductState(system_install, 339 if (!original_state.GetProductState(system_install,
335 BrowserDistribution::CHROME_BINARIES)) { 340 BrowserDistribution::CHROME_BINARIES)) {
336 const HKEY root_key = installer_state.root_key(); 341 const HKEY root_key = installer_state.root_key();
337 std::wstring multi_key( 342 string16 multi_key(
338 installer_state.multi_package_binaries_distribution()->GetStateKey()); 343 installer_state.multi_package_binaries_distribution()->GetStateKey());
339 344
340 // Copy the value from Chrome unless Chrome isn't installed or being 345 // Copy the value from Chrome unless Chrome isn't installed or being
341 // installed. 346 // installed.
342 BrowserDistribution::Type source_type; 347 BrowserDistribution::Type source_type;
343 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) { 348 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) {
344 source_type = BrowserDistribution::CHROME_BROWSER; 349 source_type = BrowserDistribution::CHROME_BROWSER;
345 } else if (!installer_state.products().empty()) { 350 } else if (!installer_state.products().empty()) {
346 // Pick a product, any product. 351 // Pick a product, any product.
347 source_type = installer_state.products()[0]->distribution()->GetType(); 352 source_type = installer_state.products()[0]->distribution()->GetType();
348 } else { 353 } else {
349 // Nothing is being installed? Entirely unexpected, so do no harm. 354 // Nothing is being installed? Entirely unexpected, so do no harm.
350 LOG(ERROR) << "No products found in AddOemInstallWorkItems"; 355 LOG(ERROR) << "No products found in AddOemInstallWorkItems";
351 return; 356 return;
352 } 357 }
353 const ProductState* source_product = 358 const ProductState* source_product =
354 original_state.GetNonVersionedProductState(system_install, source_type); 359 original_state.GetNonVersionedProductState(system_install, source_type);
355 360
356 std::wstring oem_install; 361 string16 oem_install;
357 if (source_product->GetOemInstall(&oem_install)) { 362 if (source_product->GetOemInstall(&oem_install)) {
358 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from " 363 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from "
359 << BrowserDistribution::GetSpecificDistribution(source_type) 364 << BrowserDistribution::GetSpecificDistribution(source_type)
360 ->GetAppShortCutName(); 365 ->GetAppShortCutName();
361 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 366 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
362 // Always overwrite an old value. 367 // Always overwrite an old value.
363 install_list->AddSetRegValueWorkItem(root_key, multi_key, 368 install_list->AddSetRegValueWorkItem(root_key, multi_key,
364 google_update::kRegOemInstallField, 369 google_update::kRegOemInstallField,
365 oem_install, true); 370 oem_install, true);
366 } else { 371 } else {
367 // Clear any old value. 372 // Clear any old value.
368 install_list->AddDeleteRegValueWorkItem( 373 install_list->AddDeleteRegValueWorkItem(
369 root_key, multi_key, google_update::kRegOemInstallField); 374 root_key, multi_key, google_update::kRegOemInstallField);
370 } 375 }
371 } 376 }
372 } 377 }
373 378
374 // Mirror eulaaccepted the first time anything is installed multi. There is no 379 // Mirror eulaaccepted the first time anything is installed multi. There is no
375 // need to update the value on future install/update runs since 380 // need to update the value on future install/update runs since
376 // GoogleUpdateSettings::SetEULAConsent will modify the value for both the 381 // GoogleUpdateSettings::SetEULAConsent will modify the value for both the
377 // relevant product and for the binaries. 382 // relevant product and for the binaries.
378 void AddEulaAcceptedWorkItems(const InstallationState& original_state, 383 void AddEulaAcceptedWorkItems(const InstallationState& original_state,
379 const InstallerState& installer_state, 384 const InstallerState& installer_state,
380 WorkItemList* install_list) { 385 WorkItemList* install_list) {
381 DCHECK(installer_state.is_multi_install()); 386 DCHECK(installer_state.is_multi_install());
382 const bool system_install = installer_state.system_install(); 387 const bool system_install = installer_state.system_install();
383 if (!original_state.GetProductState(system_install, 388 if (!original_state.GetProductState(system_install,
384 BrowserDistribution::CHROME_BINARIES)) { 389 BrowserDistribution::CHROME_BINARIES)) {
385 const HKEY root_key = installer_state.root_key(); 390 const HKEY root_key = installer_state.root_key();
386 std::wstring multi_key( 391 string16 multi_key(
387 installer_state.multi_package_binaries_distribution()->GetStateKey()); 392 installer_state.multi_package_binaries_distribution()->GetStateKey());
388 393
389 // Copy the value from the product with the greatest value. 394 // Copy the value from the product with the greatest value.
390 bool have_eula_accepted = false; 395 bool have_eula_accepted = false;
391 BrowserDistribution::Type product_type; 396 BrowserDistribution::Type product_type;
392 DWORD eula_accepted; 397 DWORD eula_accepted;
393 const Products& products = installer_state.products(); 398 const Products& products = installer_state.products();
394 for (size_t i = 0, count = products.size(); i != count; ++i) { 399 for (size_t i = 0, count = products.size(); i != count; ++i) {
395 if (products[i]->is_chrome_binaries()) 400 if (products[i]->is_chrome_binaries())
396 continue; 401 continue;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 WorkItemList* install_list) { 435 WorkItemList* install_list) {
431 // Is a multi-install product being installed or over-installed? 436 // Is a multi-install product being installed or over-installed?
432 if (installer_state.operation() != InstallerState::MULTI_INSTALL && 437 if (installer_state.operation() != InstallerState::MULTI_INSTALL &&
433 installer_state.operation() != InstallerState::MULTI_UPDATE) { 438 installer_state.operation() != InstallerState::MULTI_UPDATE) {
434 VLOG(1) << "AddGoogleUpdateWorkItems noop: " << installer_state.operation(); 439 VLOG(1) << "AddGoogleUpdateWorkItems noop: " << installer_state.operation();
435 return; 440 return;
436 } 441 }
437 442
438 const bool system_install = installer_state.system_install(); 443 const bool system_install = installer_state.system_install();
439 const HKEY root_key = installer_state.root_key(); 444 const HKEY root_key = installer_state.root_key();
440 std::wstring multi_key( 445 string16 multi_key(
441 installer_state.multi_package_binaries_distribution()->GetStateKey()); 446 installer_state.multi_package_binaries_distribution()->GetStateKey());
442 447
443 // For system-level installs, make sure the ClientStateMedium key for the 448 // For system-level installs, make sure the ClientStateMedium key for the
444 // binaries exists. 449 // binaries exists.
445 if (system_install) { 450 if (system_install) {
446 install_list->AddCreateRegKeyWorkItem( 451 install_list->AddCreateRegKeyWorkItem(
447 root_key, 452 root_key,
448 installer_state.multi_package_binaries_distribution()-> 453 installer_state.multi_package_binaries_distribution()->
449 GetStateMediumKey().c_str()); 454 GetStateMediumKey().c_str());
450 } 455 }
451 456
452 // Creating the ClientState key for binaries, if we're migrating to multi then 457 // Creating the ClientState key for binaries, if we're migrating to multi then
453 // copy over Chrome's brand code if it has one. Chrome Frame currently never 458 // copy over Chrome's brand code if it has one. Chrome Frame currently never
454 // has a brand code. 459 // has a brand code.
455 if (installer_state.state_type() != BrowserDistribution::CHROME_BINARIES) { 460 if (installer_state.state_type() != BrowserDistribution::CHROME_BINARIES) {
456 const ProductState* chrome_product_state = 461 const ProductState* chrome_product_state =
457 original_state.GetNonVersionedProductState( 462 original_state.GetNonVersionedProductState(
458 system_install, BrowserDistribution::CHROME_BROWSER); 463 system_install, BrowserDistribution::CHROME_BROWSER);
459 464
460 const std::wstring& brand(chrome_product_state->brand()); 465 const string16& brand(chrome_product_state->brand());
461 if (!brand.empty()) { 466 if (!brand.empty()) {
462 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 467 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
463 // Write Chrome's brand code to the multi key. Never overwrite the value 468 // Write Chrome's brand code to the multi key. Never overwrite the value
464 // if one is already present (although this shouldn't happen). 469 // if one is already present (although this shouldn't happen).
465 install_list->AddSetRegValueWorkItem(root_key, 470 install_list->AddSetRegValueWorkItem(root_key,
466 multi_key, 471 multi_key,
467 google_update::kRegBrandField, 472 google_update::kRegBrandField,
468 brand, 473 brand,
469 false); 474 false);
470 } 475 }
(...skipping 28 matching lines...) Expand all
499 BrowserDistribution* dist = (*scan)->distribution(); 504 BrowserDistribution* dist = (*scan)->distribution();
500 const ProductState* product_state = 505 const ProductState* product_state =
501 original_state.GetNonVersionedProductState( 506 original_state.GetNonVersionedProductState(
502 installer_state.system_install(), dist->GetType()); 507 installer_state.system_install(), dist->GetType());
503 value_found = product_state->GetUsageStats(&usagestats); 508 value_found = product_state->GetUsageStats(&usagestats);
504 } 509 }
505 510
506 // If a value was found, write it in the appropriate location for the 511 // If a value was found, write it in the appropriate location for the
507 // binaries and remove all values from the products. 512 // binaries and remove all values from the products.
508 if (value_found) { 513 if (value_found) {
509 std::wstring state_key( 514 string16 state_key(
510 installer_state.multi_package_binaries_distribution()->GetStateKey()); 515 installer_state.multi_package_binaries_distribution()->GetStateKey());
511 install_list->AddCreateRegKeyWorkItem(root_key, state_key); 516 install_list->AddCreateRegKeyWorkItem(root_key, state_key);
512 // Overwrite any existing value so that overinstalls (where Omaha writes a 517 // Overwrite any existing value so that overinstalls (where Omaha writes a
513 // new value into a product's state key) pick up the correct value. 518 // new value into a product's state key) pick up the correct value.
514 install_list->AddSetRegValueWorkItem(root_key, state_key, 519 install_list->AddSetRegValueWorkItem(root_key, state_key,
515 google_update::kRegUsageStatsField, 520 google_update::kRegUsageStatsField,
516 usagestats, true); 521 usagestats, true);
517 522
518 for (Products::const_iterator scan = products.begin(), end = products.end(); 523 for (Products::const_iterator scan = products.begin(), end = products.end();
519 scan != end; ++scan) { 524 scan != end; ++scan) {
(...skipping 24 matching lines...) Expand all
544 void AddDeleteUninstallShortcutsForMSIWorkItems( 549 void AddDeleteUninstallShortcutsForMSIWorkItems(
545 const InstallerState& installer_state, 550 const InstallerState& installer_state,
546 const Product& product, 551 const Product& product,
547 const FilePath& temp_path, 552 const FilePath& temp_path,
548 WorkItemList* work_item_list) { 553 WorkItemList* work_item_list) {
549 DCHECK(installer_state.is_msi()) 554 DCHECK(installer_state.is_msi())
550 << "This must only be called for MSI installations!"; 555 << "This must only be called for MSI installations!";
551 556
552 // First attempt to delete the old installation's ARP dialog entry. 557 // First attempt to delete the old installation's ARP dialog entry.
553 HKEY reg_root = installer_state.root_key(); 558 HKEY reg_root = installer_state.root_key();
554 std::wstring uninstall_reg(product.distribution()->GetUninstallRegPath()); 559 string16 uninstall_reg(product.distribution()->GetUninstallRegPath());
555 560
556 WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem( 561 WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem(
557 reg_root, uninstall_reg); 562 reg_root, uninstall_reg);
558 delete_reg_key->set_ignore_failure(true); 563 delete_reg_key->set_ignore_failure(true);
559 564
560 // Then attempt to delete the old installation's start menu shortcut. 565 // Then attempt to delete the old installation's start menu shortcut.
561 FilePath uninstall_link; 566 FilePath uninstall_link;
562 if (installer_state.system_install()) { 567 if (installer_state.system_install()) {
563 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link); 568 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link);
564 } else { 569 } else {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 .Append(setup_path.BaseName())); 627 .Append(setup_path.BaseName()));
623 628
624 CommandLine rename(installer_path); 629 CommandLine rename(installer_path);
625 rename.AppendSwitch(switches::kRenameChromeExe); 630 rename.AppendSwitch(switches::kRenameChromeExe);
626 if (installer_state.system_install()) 631 if (installer_state.system_install())
627 rename.AppendSwitch(switches::kSystemLevel); 632 rename.AppendSwitch(switches::kSystemLevel);
628 633
629 if (installer_state.verbose_logging()) 634 if (installer_state.verbose_logging())
630 rename.AppendSwitch(switches::kVerboseLogging); 635 rename.AppendSwitch(switches::kVerboseLogging);
631 636
632 std::wstring version_key; 637 string16 version_key;
633 for (size_t i = 0; i < products.size(); ++i) { 638 for (size_t i = 0; i < products.size(); ++i) {
634 BrowserDistribution* dist = products[i]->distribution(); 639 BrowserDistribution* dist = products[i]->distribution();
635 version_key = dist->GetVersionKey(); 640 version_key = dist->GetVersionKey();
636 641
637 if (current_version != NULL) { 642 if (current_version != NULL) {
638 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, 643 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key,
639 google_update::kRegOldVersionField, 644 google_update::kRegOldVersionField,
640 ASCIIToWide(current_version->GetString()), true); 645 ASCIIToWide(current_version->GetString()), true);
641 } 646 }
642 if (critical_version.IsValid()) { 647 if (critical_version.IsValid()) {
(...skipping 30 matching lines...) Expand all
673 // Append work items that will be executed if this was NOT an in-use update. 678 // Append work items that will be executed if this was NOT an in-use update.
674 { 679 {
675 scoped_ptr<WorkItemList> regular_update_work_items( 680 scoped_ptr<WorkItemList> regular_update_work_items(
676 WorkItem::CreateConditionalWorkItemList( 681 WorkItem::CreateConditionalWorkItemList(
677 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); 682 new Not(new ConditionRunIfFileExists(new_chrome_exe))));
678 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); 683 regular_update_work_items->set_log_message("RegularUpdateWorkItemList");
679 684
680 // Since this was not an in-use-update, delete 'opv', 'cpv', and 'cmd' keys. 685 // Since this was not an in-use-update, delete 'opv', 'cpv', and 'cmd' keys.
681 for (size_t i = 0; i < products.size(); ++i) { 686 for (size_t i = 0; i < products.size(); ++i) {
682 BrowserDistribution* dist = products[i]->distribution(); 687 BrowserDistribution* dist = products[i]->distribution();
683 std::wstring version_key(dist->GetVersionKey()); 688 string16 version_key(dist->GetVersionKey());
684 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 689 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
685 google_update::kRegOldVersionField); 690 google_update::kRegOldVersionField);
686 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 691 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
687 google_update::kRegCriticalVersionField); 692 google_update::kRegCriticalVersionField);
688 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 693 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
689 google_update::kRegRenameCmdField); 694 google_update::kRegRenameCmdField);
690 } 695 }
691 696
692 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { 697 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) {
693 AddDeleteOldIELowRightsPolicyWorkItems(installer_state, 698 AddDeleteOldIELowRightsPolicyWorkItems(installer_state,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 const FilePath& setup_path, 985 const FilePath& setup_path,
981 const Version& new_version, 986 const Version& new_version,
982 const Product& product, 987 const Product& product,
983 WorkItemList* list) { 988 WorkItemList* list) {
984 DCHECK(product.is_chrome_frame()); 989 DCHECK(product.is_chrome_frame());
985 if (!installer_state.is_multi_install()) { 990 if (!installer_state.is_multi_install()) {
986 VLOG(1) << "Not adding GCF specific work items for single install."; 991 VLOG(1) << "Not adding GCF specific work items for single install.";
987 return; 992 return;
988 } 993 }
989 994
990 std::wstring version_key(product.distribution()->GetVersionKey()); 995 string16 version_key(product.distribution()->GetVersionKey());
991 bool ready_mode = product.HasOption(kOptionReadyMode); 996 bool ready_mode = product.HasOption(kOptionReadyMode);
992 HKEY root = installer_state.root_key(); 997 HKEY root = installer_state.root_key();
993 const bool is_install = 998 const bool is_install =
994 (installer_state.operation() != InstallerState::UNINSTALL); 999 (installer_state.operation() != InstallerState::UNINSTALL);
995 bool update_chrome_uninstall_command = false; 1000 bool update_chrome_uninstall_command = false;
996 BrowserDistribution* dist = 1001 BrowserDistribution* dist =
997 installer_state.multi_package_binaries_distribution(); 1002 installer_state.multi_package_binaries_distribution();
998 if (ready_mode) { 1003 if (ready_mode) {
999 // If GCF is being installed in ready mode, we write an entry to the 1004 // If GCF is being installed in ready mode, we write an entry to the
1000 // multi-install state key. If the value already exists, we will not 1005 // multi-install state key. If the value already exists, we will not
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 // this is done only as a convenience; there is no need for the GUID of the Low 1296 // this is done only as a convenience; there is no need for the GUID of the Low
1292 // Rights policies to match the ChromeFrame class's GUID. Hence, it is safe to 1297 // Rights policies to match the ChromeFrame class's GUID. Hence, it is safe to
1293 // use this completely unrelated GUID for the "old" policies. 1298 // use this completely unrelated GUID for the "old" policies.
1294 const wchar_t kIELowRightsPolicyOldGuid[] = 1299 const wchar_t kIELowRightsPolicyOldGuid[] =
1295 L"{6C288DD7-76FB-4721-B628-56FAC252E199}"; 1300 L"{6C288DD7-76FB-4721-B628-56FAC252E199}";
1296 1301
1297 const wchar_t kElevationPolicyKeyPath[] = 1302 const wchar_t kElevationPolicyKeyPath[] =
1298 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"; 1303 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\";
1299 1304
1300 void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy, 1305 void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy,
1301 std::wstring* key_path) { 1306 string16* key_path) {
1302 DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY); 1307 DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY);
1303 1308
1304 key_path->assign(kElevationPolicyKeyPath, 1309 key_path->assign(kElevationPolicyKeyPath,
1305 arraysize(kElevationPolicyKeyPath) - 1); 1310 arraysize(kElevationPolicyKeyPath) - 1);
1306 if (policy == CURRENT_ELEVATION_POLICY) { 1311 if (policy == CURRENT_ELEVATION_POLICY) {
1307 wchar_t cf_clsid[64]; 1312 wchar_t cf_clsid[64];
1308 int len = StringFromGUID2(__uuidof(ChromeFrame), &cf_clsid[0], 1313 int len = StringFromGUID2(__uuidof(ChromeFrame), &cf_clsid[0],
1309 arraysize(cf_clsid)); 1314 arraysize(cf_clsid));
1310 key_path->append(&cf_clsid[0], len - 1); 1315 key_path->append(&cf_clsid[0], len - 1);
1311 } else { 1316 } else {
1312 key_path->append(kIELowRightsPolicyOldGuid, 1317 key_path->append(kIELowRightsPolicyOldGuid,
1313 arraysize(kIELowRightsPolicyOldGuid)- 1); 1318 arraysize(kIELowRightsPolicyOldGuid)- 1);
1314 } 1319 }
1315 } 1320 }
1316 1321
1317 } // namespace 1322 } // namespace
1318 1323
1319 void AddDeleteOldIELowRightsPolicyWorkItems( 1324 void AddDeleteOldIELowRightsPolicyWorkItems(
1320 const InstallerState& installer_state, 1325 const InstallerState& installer_state,
1321 WorkItemList* install_list) { 1326 WorkItemList* install_list) {
1322 DCHECK(install_list); 1327 DCHECK(install_list);
1323 1328
1324 std::wstring key_path; 1329 string16 key_path;
1325 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path); 1330 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path);
1326 install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path); 1331 install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path);
1327 } 1332 }
1328 1333
1329 // Adds work items to copy the chrome_launcher IE low rights elevation policy 1334 // Adds work items to copy the chrome_launcher IE low rights elevation policy
1330 // from the primary policy GUID to the "old" policy GUID. Take care not to 1335 // from the primary policy GUID to the "old" policy GUID. Take care not to
1331 // perform the copy if there is already an old policy present, as the ones under 1336 // perform the copy if there is already an old policy present, as the ones under
1332 // the main kElevationPolicyGuid would then correspond to an intermediate 1337 // the main kElevationPolicyGuid would then correspond to an intermediate
1333 // version (current_version < pv < new_version). 1338 // version (current_version < pv < new_version).
1334 void AddCopyIELowRightsPolicyWorkItems(const InstallerState& installer_state, 1339 void AddCopyIELowRightsPolicyWorkItems(const InstallerState& installer_state,
1335 WorkItemList* install_list) { 1340 WorkItemList* install_list) {
1336 DCHECK(install_list); 1341 DCHECK(install_list);
1337 1342
1338 std::wstring current_key_path; 1343 string16 current_key_path;
1339 std::wstring old_key_path; 1344 string16 old_key_path;
1340 1345
1341 GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY, 1346 GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY,
1342 &current_key_path); 1347 &current_key_path);
1343 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path); 1348 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path);
1344 // Do not clobber existing old policies. 1349 // Do not clobber existing old policies.
1345 install_list->AddCopyRegKeyWorkItem(installer_state.root_key(), 1350 install_list->AddCopyRegKeyWorkItem(installer_state.root_key(),
1346 current_key_path, old_key_path, 1351 current_key_path, old_key_path,
1347 WorkItem::IF_NOT_PRESENT); 1352 WorkItem::IF_NOT_PRESENT);
1348 } 1353 }
1349 1354
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } 1396 }
1392 } 1397 }
1393 1398
1394 void AddGenericQuickEnableWorkItems(const InstallerState& installer_state, 1399 void AddGenericQuickEnableWorkItems(const InstallerState& installer_state,
1395 const InstallationState& machine_state, 1400 const InstallationState& machine_state,
1396 const FilePath* setup_path, 1401 const FilePath* setup_path,
1397 const Version* new_version, 1402 const Version* new_version,
1398 WorkItemList* work_item_list, 1403 WorkItemList* work_item_list,
1399 bool have_child_product, 1404 bool have_child_product,
1400 const CommandLine& child_product_switches, 1405 const CommandLine& child_product_switches,
1401 const std::wstring& command_id) { 1406 const string16& command_id) {
1402 DCHECK(setup_path || 1407 DCHECK(setup_path ||
1403 installer_state.operation() == InstallerState::UNINSTALL); 1408 installer_state.operation() == InstallerState::UNINSTALL);
1404 DCHECK(new_version || 1409 DCHECK(new_version ||
1405 installer_state.operation() == InstallerState::UNINSTALL); 1410 installer_state.operation() == InstallerState::UNINSTALL);
1406 DCHECK(work_item_list); 1411 DCHECK(work_item_list);
1407 1412
1408 const bool system_install = installer_state.system_install(); 1413 const bool system_install = installer_state.system_install();
1409 bool have_chrome_binaries = false; 1414 bool have_chrome_binaries = false;
1410 1415
1411 // STEP 1: Figure out the state of the machine before the operation. 1416 // STEP 1: Figure out the state of the machine before the operation.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 setup_path->BaseName()); 1477 setup_path->BaseName());
1473 } 1478 }
1474 } 1479 }
1475 1480
1476 // STEP 4: Take action. 1481 // STEP 4: Take action.
1477 if (operation != DO_NOTHING) { 1482 if (operation != DO_NOTHING) {
1478 // Get the path to the quick-enable-cf command for the binaries. 1483 // Get the path to the quick-enable-cf command for the binaries.
1479 BrowserDistribution* binaries = 1484 BrowserDistribution* binaries =
1480 BrowserDistribution::GetSpecificDistribution( 1485 BrowserDistribution::GetSpecificDistribution(
1481 BrowserDistribution::CHROME_BINARIES); 1486 BrowserDistribution::CHROME_BINARIES);
1482 std::wstring cmd_key(binaries->GetVersionKey()); 1487 string16 cmd_key(binaries->GetVersionKey());
1483 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) 1488 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey)
1484 .append(1, L'\\').append(command_id); 1489 .append(1, L'\\').append(command_id);
1485 1490
1486 if (operation == ADD_COMMAND) { 1491 if (operation == ADD_COMMAND) {
1487 DCHECK(!binaries_setup_path.empty()); 1492 DCHECK(!binaries_setup_path.empty());
1488 CommandLine cmd_line(binaries_setup_path); 1493 CommandLine cmd_line(binaries_setup_path);
1489 cmd_line.AppendArguments(child_product_switches, 1494 cmd_line.AppendArguments(child_product_switches,
1490 false); // include_program 1495 false); // include_program
1491 if (installer_state.verbose_logging()) 1496 if (installer_state.verbose_logging())
1492 cmd_line.AppendSwitch(switches::kVerboseLogging); 1497 cmd_line.AppendSwitch(switches::kVerboseLogging);
1493 AppCommand cmd(cmd_line.GetCommandLineString(), true, true); 1498 AppCommand cmd(cmd_line.GetCommandLineString());
1499 cmd.set_sends_pings(true);
1500 cmd.set_is_web_accessible(true);
1494 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 1501 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
1495 } else { 1502 } else {
1496 DCHECK(operation == REMOVE_COMMAND); 1503 DCHECK(operation == REMOVE_COMMAND);
1497 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 1504 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
1498 cmd_key)->set_log_message( 1505 cmd_key)->set_log_message(
1499 "removing " + WideToASCII(command_id) + " command"); 1506 "removing " + WideToASCII(command_id) + " command");
1500 } 1507 }
1501 } 1508 }
1502 } 1509 }
1503 1510
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 AddGenericQuickEnableWorkItems(installer_state, 1593 AddGenericQuickEnableWorkItems(installer_state,
1587 machine_state, 1594 machine_state,
1588 setup_path, 1595 setup_path,
1589 new_version, 1596 new_version,
1590 work_item_list, 1597 work_item_list,
1591 false, // have_child_product 1598 false, // have_child_product
1592 cmd_line, 1599 cmd_line,
1593 kCmdQuickEnableApplicationHost); 1600 kCmdQuickEnableApplicationHost);
1594 } 1601 }
1595 1602
1603 void AddOsUpgradeWorkItems(const InstallerState& installer_state,
1604 const Version* new_version,
1605 const Product& product,
1606 WorkItemList* install_list) {
1607 const HKEY root_key = installer_state.root_key();
1608 string16 cmd_key(product.distribution()->GetVersionKey());
1609 cmd_key.append(1, FilePath::kSeparators[0])
1610 .append(google_update::kRegCommandsKey)
1611 .append(1, FilePath::kSeparators[0])
1612 .append(kCmdOnOsUpgrade);
1613
1614 // This will make Google Update call setup.exe with --on-os-upgrade switch.
1615 // For Chrome, this leads to HandleOsUpgradeForBrowser() being called.
1616 if (installer_state.operation() != InstallerState::UNINSTALL) {
1617 CommandLine cmd_line(installer_state
1618 .GetInstallerDirectory(*new_version)
1619 .Append(installer::kSetupExe));
gab 2012/08/30 17:55:19 Greg argued against this (preferring your original
grt (UTC plus 2) 2012/08/30 19:10:18 I do. :-) If you want setup to run on OS upgrade
huangs 2012/08/30 20:14:22 Okay, no-op.
1620 // Add the main option to indicate OS upgrade flow.
1621 cmd_line.AppendSwitch(installer::switches::kOnOsUpgrade);
1622 // Add product-specific options.
1623 product.AppendProductFlags(&cmd_line);
1624 if (installer_state.system_install())
1625 cmd_line.AppendSwitch(installer::switches::kSystemLevel);
1626 // Log everything for now.
1627 cmd_line.AppendSwitch(installer::switches::kVerboseLogging);
1628
1629 install_list->set_log_message("Adding OS upgrade command");
1630 AppCommand cmd(cmd_line.GetCommandLineString());
1631 cmd.set_is_auto_run_on_os_upgrade(true);
1632 cmd.AddWorkItems(installer_state.root_key(), cmd_key, install_list);
1633 } else {
1634 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key)
1635 ->set_log_message("Removing OS upgrade command");
1636 }
1637 }
1638
1596 } // namespace installer 1639 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698