Index: chrome/installer/util/google_chrome_distribution.cc |
=================================================================== |
--- chrome/installer/util/google_chrome_distribution.cc (revision 49358) |
+++ chrome/installer/util/google_chrome_distribution.cc (working copy) |
@@ -364,6 +364,32 @@ |
return sub_dir; |
} |
+std::wstring GoogleChromeDistribution::GetNewGoogleUpdateApKey( |
+ bool diff_install, installer_util::InstallStatus status, |
+ const std::wstring& value) { |
+ // Magic suffix that we need to add or remove to "ap" key value. |
+ const std::wstring kMagicSuffix = L"-full"; |
+ |
+ bool has_magic_string = false; |
+ if ((value.length() >= kMagicSuffix.length()) && |
+ (value.rfind(kMagicSuffix) == (value.length() - kMagicSuffix.length()))) { |
+ LOG(INFO) << "Incremental installer failure key already set."; |
+ has_magic_string = true; |
+ } |
+ |
+ std::wstring new_value(value); |
+ if ((!diff_install || !GetInstallReturnCode(status)) && has_magic_string) { |
+ LOG(INFO) << "Removing failure key from value " << value; |
+ new_value = value.substr(0, value.length() - kMagicSuffix.length()); |
+ } else if ((diff_install && GetInstallReturnCode(status)) && |
+ !has_magic_string) { |
+ LOG(INFO) << "Incremental installer failed, setting failure key."; |
+ new_value.append(kMagicSuffix); |
+ } |
+ |
+ return new_value; |
+} |
+ |
std::wstring GoogleChromeDistribution::GetPublisherName() { |
const std::wstring& publisher_name = |
installer_util::GetLocalizedString(IDS_ABOUT_VERSION_COMPANY_NAME_BASE); |
@@ -467,9 +493,39 @@ |
// There is no fall-back for full installer :) |
void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, |
bool incremental_install, installer_util::InstallStatus install_status) { |
- GoogleUpdateSettings::UpdateDiffInstallStatus(system_install, |
- incremental_install, GetInstallReturnCode(install_status), |
- product_guid().c_str()); |
+ HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
+ |
+ RegKey key; |
+ std::wstring ap_key_value; |
+ std::wstring reg_key(google_update::kRegPathClientState); |
+ reg_key.append(L"\\"); |
+ reg_key.append(product_guid()); |
+ if (!key.Open(reg_root, reg_key.c_str(), KEY_ALL_ACCESS) || |
+ !key.ReadValue(google_update::kRegApField, &ap_key_value)) { |
+ LOG(INFO) << "Application key not found."; |
+ if (!incremental_install || !GetInstallReturnCode(install_status)) { |
+ LOG(INFO) << "Returning without changing application key."; |
+ key.Close(); |
+ return; |
+ } else if (!key.Valid()) { |
+ reg_key.assign(google_update::kRegPathClientState); |
+ if (!key.Open(reg_root, reg_key.c_str(), KEY_ALL_ACCESS) || |
+ !key.CreateKey(product_guid().c_str(), KEY_ALL_ACCESS)) { |
+ LOG(ERROR) << "Failed to create application key."; |
+ key.Close(); |
+ return; |
+ } |
+ } |
+ } |
+ |
+ std::wstring new_value = GoogleChromeDistribution::GetNewGoogleUpdateApKey( |
+ incremental_install, install_status, ap_key_value); |
+ if ((new_value.compare(ap_key_value) != 0) && |
+ !key.WriteValue(google_update::kRegApField, new_value.c_str())) { |
+ LOG(ERROR) << "Failed to write value " << new_value |
+ << " to the registry field " << google_update::kRegApField; |
+ } |
+ key.Close(); |
} |
// The functions below are not used by the 64-bit Windows binary - |