OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 defines specific implementation of BrowserDistribution class for | 5 // This file defines specific implementation of BrowserDistribution class for |
6 // Google Chrome. | 6 // Google Chrome. |
7 | 7 |
8 #include "chrome/installer/util/google_chrome_distribution.h" | 8 #include "chrome/installer/util/google_chrome_distribution.h" |
9 | 9 |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 return alt_product_name; | 357 return alt_product_name; |
358 } | 358 } |
359 | 359 |
360 std::wstring GoogleChromeDistribution::GetInstallSubDir() { | 360 std::wstring GoogleChromeDistribution::GetInstallSubDir() { |
361 std::wstring sub_dir(installer_util::kGoogleChromeInstallSubDir1); | 361 std::wstring sub_dir(installer_util::kGoogleChromeInstallSubDir1); |
362 sub_dir.append(L"\\"); | 362 sub_dir.append(L"\\"); |
363 sub_dir.append(installer_util::kGoogleChromeInstallSubDir2); | 363 sub_dir.append(installer_util::kGoogleChromeInstallSubDir2); |
364 return sub_dir; | 364 return sub_dir; |
365 } | 365 } |
366 | 366 |
367 std::wstring GoogleChromeDistribution::GetNewGoogleUpdateApKey( | |
368 bool diff_install, installer_util::InstallStatus status, | |
369 const std::wstring& value) { | |
370 // Magic suffix that we need to add or remove to "ap" key value. | |
371 const std::wstring kMagicSuffix = L"-full"; | |
372 | |
373 bool has_magic_string = false; | |
374 if ((value.length() >= kMagicSuffix.length()) && | |
375 (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) { | |
376 LOG(INFO) << "Incremental installer failure key already set."; | |
377 has_magic_string = true; | |
378 } | |
379 | |
380 std::wstring new_value(value); | |
381 if ((!diff_install || !GetInstallReturnCode(status)) && has_magic_string) { | |
382 LOG(INFO) << "Removing failure key from value " << value; | |
383 new_value = value.substr(0, value.length() - kMagicSuffix.length()); | |
384 } else if ((diff_install && GetInstallReturnCode(status)) && | |
385 !has_magic_string) { | |
386 LOG(INFO) << "Incremental installer failed, setting failure key."; | |
387 new_value.append(kMagicSuffix); | |
388 } | |
389 | |
390 return new_value; | |
391 } | |
392 | |
393 std::wstring GoogleChromeDistribution::GetPublisherName() { | 367 std::wstring GoogleChromeDistribution::GetPublisherName() { |
394 const std::wstring& publisher_name = | 368 const std::wstring& publisher_name = |
395 installer_util::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); | 369 installer_util::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); |
396 return publisher_name; | 370 return publisher_name; |
397 } | 371 } |
398 | 372 |
399 std::wstring GoogleChromeDistribution::GetAppDescription() { | 373 std::wstring GoogleChromeDistribution::GetAppDescription() { |
400 const std::wstring& app_description = | 374 const std::wstring& app_description = |
401 installer_util::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE); | 375 installer_util::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE); |
402 return app_description; | 376 return app_description; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // This method checks if we need to change "ap" key in Google Update to try | 460 // This method checks if we need to change "ap" key in Google Update to try |
487 // full installer as fall back method in case incremental installer fails. | 461 // full installer as fall back method in case incremental installer fails. |
488 // - If incremental installer fails we append a magic string ("-full"), if | 462 // - If incremental installer fails we append a magic string ("-full"), if |
489 // it is not present already, so that Google Update server next time will send | 463 // it is not present already, so that Google Update server next time will send |
490 // full installer to update Chrome on the local machine | 464 // full installer to update Chrome on the local machine |
491 // - If we are currently running full installer, we remove this magic | 465 // - If we are currently running full installer, we remove this magic |
492 // string (if it is present) regardless of whether installer failed or not. | 466 // string (if it is present) regardless of whether installer failed or not. |
493 // There is no fall-back for full installer :) | 467 // There is no fall-back for full installer :) |
494 void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, | 468 void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, |
495 bool incremental_install, installer_util::InstallStatus install_status) { | 469 bool incremental_install, installer_util::InstallStatus install_status) { |
496 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 470 GoogleUpdateSettings::UpdateDiffInstallStatus(system_install, |
497 | 471 incremental_install, GetInstallReturnCode(install_status), |
498 RegKey key; | 472 product_guid().c_str()); |
499 std::wstring ap_key_value; | |
500 std::wstring reg_key(google_update::kRegPathClientState); | |
501 reg_key.append(L"\\"); | |
502 reg_key.append(product_guid()); | |
503 if (!key.Open(reg_root, reg_key.c_str(), KEY_ALL_ACCESS) || | |
504 !key.ReadValue(google_update::kRegApField, &ap_key_value)) { | |
505 LOG(INFO) << "Application key not found."; | |
506 if (!incremental_install || !GetInstallReturnCode(install_status)) { | |
507 LOG(INFO) << "Returning without changing application key."; | |
508 key.Close(); | |
509 return; | |
510 } else if (!key.Valid()) { | |
511 reg_key.assign(google_update::kRegPathClientState); | |
512 if (!key.Open(reg_root, reg_key.c_str(), KEY_ALL_ACCESS) || | |
513 !key.CreateKey(product_guid().c_str(), KEY_ALL_ACCESS)) { | |
514 LOG(ERROR) << "Failed to create application key."; | |
515 key.Close(); | |
516 return; | |
517 } | |
518 } | |
519 } | |
520 | |
521 std::wstring new_value = GoogleChromeDistribution::GetNewGoogleUpdateApKey( | |
522 incremental_install, install_status, ap_key_value); | |
523 if ((new_value.compare(ap_key_value) != 0) && | |
524 !key.WriteValue(google_update::kRegApField, new_value.c_str())) { | |
525 LOG(ERROR) << "Failed to write value " << new_value | |
526 << " to the registry field " << google_update::kRegApField; | |
527 } | |
528 key.Close(); | |
529 } | 473 } |
530 | 474 |
531 // The functions below are not used by the 64-bit Windows binary - | 475 // The functions below are not used by the 64-bit Windows binary - |
532 // see the comment in google_chrome_distribution_dummy.cc | 476 // see the comment in google_chrome_distribution_dummy.cc |
533 #ifndef _WIN64 | 477 #ifndef _WIN64 |
534 // Currently we only have one experiment: the inactive user toast. Which only | 478 // Currently we only have one experiment: the inactive user toast. Which only |
535 // applies for users doing upgrades. | 479 // applies for users doing upgrades. |
536 // | 480 // |
537 // There are three scenarios when this function is called: | 481 // There are three scenarios when this function is called: |
538 // 1- Is a per-user-install and it updated: perform the experiment | 482 // 1- Is a per-user-install and it updated: perform the experiment |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 GoogleUpdateSettings::SetClient(GetExperimentGroup(outcome, flavor)); | 581 GoogleUpdateSettings::SetClient(GetExperimentGroup(outcome, flavor)); |
638 if (outcome != kToastExpUninstallGroup) | 582 if (outcome != kToastExpUninstallGroup) |
639 return; | 583 return; |
640 // The user wants to uninstall. This is a best effort operation. Note that | 584 // The user wants to uninstall. This is a best effort operation. Note that |
641 // we waited for chrome to exit so the uninstall would not detect chrome | 585 // we waited for chrome to exit so the uninstall would not detect chrome |
642 // running. | 586 // running. |
643 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), | 587 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), |
644 false, false, NULL); | 588 false, false, NULL); |
645 } | 589 } |
646 #endif | 590 #endif |
OLD | NEW |