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

Side by Side Diff: chrome/installer/util/google_chrome_distribution.cc

Issue 2725007: Reverting this as it caused installer_unit_tests to fail. Please fix and rela... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 6 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) 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
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
367 std::wstring GoogleChromeDistribution::GetPublisherName() { 393 std::wstring GoogleChromeDistribution::GetPublisherName() {
368 const std::wstring& publisher_name = 394 const std::wstring& publisher_name =
369 installer_util::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); 395 installer_util::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE);
370 return publisher_name; 396 return publisher_name;
371 } 397 }
372 398
373 std::wstring GoogleChromeDistribution::GetAppDescription() { 399 std::wstring GoogleChromeDistribution::GetAppDescription() {
374 const std::wstring& app_description = 400 const std::wstring& app_description =
375 installer_util::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE); 401 installer_util::GetLocalizedString(IDS_SHORTCUT_TOOLTIP_BASE);
376 return app_description; 402 return app_description;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // This method checks if we need to change "ap" key in Google Update to try 486 // This method checks if we need to change "ap" key in Google Update to try
461 // full installer as fall back method in case incremental installer fails. 487 // full installer as fall back method in case incremental installer fails.
462 // - If incremental installer fails we append a magic string ("-full"), if 488 // - If incremental installer fails we append a magic string ("-full"), if
463 // it is not present already, so that Google Update server next time will send 489 // it is not present already, so that Google Update server next time will send
464 // full installer to update Chrome on the local machine 490 // full installer to update Chrome on the local machine
465 // - If we are currently running full installer, we remove this magic 491 // - If we are currently running full installer, we remove this magic
466 // string (if it is present) regardless of whether installer failed or not. 492 // string (if it is present) regardless of whether installer failed or not.
467 // There is no fall-back for full installer :) 493 // There is no fall-back for full installer :)
468 void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, 494 void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install,
469 bool incremental_install, installer_util::InstallStatus install_status) { 495 bool incremental_install, installer_util::InstallStatus install_status) {
470 GoogleUpdateSettings::UpdateDiffInstallStatus(system_install, 496 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
471 incremental_install, GetInstallReturnCode(install_status), 497
472 product_guid().c_str()); 498 RegKey key;
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();
473 } 529 }
474 530
475 // The functions below are not used by the 64-bit Windows binary - 531 // The functions below are not used by the 64-bit Windows binary -
476 // see the comment in google_chrome_distribution_dummy.cc 532 // see the comment in google_chrome_distribution_dummy.cc
477 #ifndef _WIN64 533 #ifndef _WIN64
478 // Currently we only have one experiment: the inactive user toast. Which only 534 // Currently we only have one experiment: the inactive user toast. Which only
479 // applies for users doing upgrades. 535 // applies for users doing upgrades.
480 // 536 //
481 // There are three scenarios when this function is called: 537 // There are three scenarios when this function is called:
482 // 1- Is a per-user-install and it updated: perform the experiment 538 // 1- Is a per-user-install and it updated: perform the experiment
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 GoogleUpdateSettings::SetClient(GetExperimentGroup(outcome, flavor)); 637 GoogleUpdateSettings::SetClient(GetExperimentGroup(outcome, flavor));
582 if (outcome != kToastExpUninstallGroup) 638 if (outcome != kToastExpUninstallGroup)
583 return; 639 return;
584 // The user wants to uninstall. This is a best effort operation. Note that 640 // The user wants to uninstall. This is a best effort operation. Note that
585 // we waited for chrome to exit so the uninstall would not detect chrome 641 // we waited for chrome to exit so the uninstall would not detect chrome
586 // running. 642 // running.
587 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install), 643 base::LaunchApp(InstallUtil::GetChromeUninstallCmd(system_install),
588 false, false, NULL); 644 false, false, NULL);
589 } 645 }
590 #endif 646 #endif
OLDNEW
« no previous file with comments | « chrome/installer/util/google_chrome_distribution.h ('k') | chrome/installer/util/google_chrome_distribution_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698