| 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/browser/google/google_update_win.h" | 5 #include "chrome/browser/google/google_update_win.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 // Starts an update check. | 208 // Starts an update check. |
| 209 void BeginUpdateCheck(); | 209 void BeginUpdateCheck(); |
| 210 | 210 |
| 211 // Returns the result of initiating an update check. Sets |error_code| if the | 211 // Returns the result of initiating an update check. Sets |error_code| if the |
| 212 // result is any kind of failure. | 212 // result is any kind of failure. |
| 213 HRESULT BeginUpdateCheckInternal(GoogleUpdateErrorCode* error_code); | 213 HRESULT BeginUpdateCheckInternal(GoogleUpdateErrorCode* error_code); |
| 214 | 214 |
| 215 // Sets status_ to UPGRADE_ERROR, error_code_ to |error_code|, hresult_ to | 215 // Sets status_ to UPGRADE_ERROR, error_code_ to |error_code|, hresult_ to |
| 216 // |hresult|, installer_exit_code_ to |installer_exit_code|, and | 216 // |hresult|, installer_exit_code_ to |installer_exit_code|, and |
| 217 // error_message_ to a composition of all values suitable for display to the | 217 // html_error_message_ to a composition of all values suitable for display |
| 218 // user. This call should be followed by deletion of the driver, which will | 218 // to the user. This call should be followed by deletion of the driver, |
| 219 // result in the caller being notified via its delegate. | 219 // which will result in the caller being notified via its delegate. |
| 220 void OnUpgradeError(GoogleUpdateErrorCode error_code, | 220 void OnUpgradeError(GoogleUpdateErrorCode error_code, |
| 221 HRESULT hresult, | 221 HRESULT hresult, |
| 222 int installer_exit_code, | 222 int installer_exit_code, |
| 223 const base::string16& error_string); | 223 const base::string16& error_string); |
| 224 | 224 |
| 225 // Returns true if |current_state| and |state_value| can be obtained from the | 225 // Returns true if |current_state| and |state_value| can be obtained from the |
| 226 // ongoing update check. Otherwise, populates |hresult| with the reason they | 226 // ongoing update check. Otherwise, populates |hresult| with the reason they |
| 227 // could not be obtained. | 227 // could not be obtained. |
| 228 bool GetCurrentState(base::win::ScopedComPtr<ICurrentState>* current_state, | 228 bool GetCurrentState(base::win::ScopedComPtr<ICurrentState>* current_state, |
| 229 CurrentState* state_value, | 229 CurrentState* state_value, |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 // The application being updated (Chrome, Chrome Binaries, or Chrome SxS). | 308 // The application being updated (Chrome, Chrome Binaries, or Chrome SxS). |
| 309 base::win::ScopedComPtr<IAppWeb> app_; | 309 base::win::ScopedComPtr<IAppWeb> app_; |
| 310 | 310 |
| 311 // The progress value reported most recently to the caller. | 311 // The progress value reported most recently to the caller. |
| 312 int last_reported_progress_; | 312 int last_reported_progress_; |
| 313 | 313 |
| 314 // The results of the update check to be logged via UMA and/or reported to the | 314 // The results of the update check to be logged via UMA and/or reported to the |
| 315 // caller. | 315 // caller. |
| 316 GoogleUpdateUpgradeStatus status_; | 316 GoogleUpdateUpgradeStatus status_; |
| 317 GoogleUpdateErrorCode error_code_; | 317 GoogleUpdateErrorCode error_code_; |
| 318 base::string16 error_message_; | 318 base::string16 html_error_message_; |
| 319 base::string16 new_version_; | 319 base::string16 new_version_; |
| 320 HRESULT hresult_; | 320 HRESULT hresult_; |
| 321 int installer_exit_code_; | 321 int installer_exit_code_; |
| 322 | 322 |
| 323 DISALLOW_COPY_AND_ASSIGN(UpdateCheckDriver); | 323 DISALLOW_COPY_AND_ASSIGN(UpdateCheckDriver); |
| 324 }; | 324 }; |
| 325 | 325 |
| 326 // static | 326 // static |
| 327 void UpdateCheckDriver::RunUpdateCheck( | 327 void UpdateCheckDriver::RunUpdateCheck( |
| 328 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 328 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 NUM_ERROR_CODES); | 372 NUM_ERROR_CODES); |
| 373 if (FAILED(hresult_)) | 373 if (FAILED(hresult_)) |
| 374 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.ErrorHresult", hresult_); | 374 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.ErrorHresult", hresult_); |
| 375 if (installer_exit_code_ != -1) { | 375 if (installer_exit_code_ != -1) { |
| 376 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.InstallerExitCode", | 376 UMA_HISTOGRAM_SPARSE_SLOWLY("GoogleUpdate.InstallerExitCode", |
| 377 installer_exit_code_); | 377 installer_exit_code_); |
| 378 } | 378 } |
| 379 } | 379 } |
| 380 if (delegate_) { | 380 if (delegate_) { |
| 381 if (status_ == UPGRADE_ERROR) | 381 if (status_ == UPGRADE_ERROR) |
| 382 delegate_->OnError(error_code_, error_message_, new_version_); | 382 delegate_->OnError(error_code_, html_error_message_, new_version_); |
| 383 else if (install_update_if_possible_) | 383 else if (install_update_if_possible_) |
| 384 delegate_->OnUpgradeComplete(new_version_); | 384 delegate_->OnUpgradeComplete(new_version_); |
| 385 else | 385 else |
| 386 delegate_->OnUpdateCheckComplete(new_version_); | 386 delegate_->OnUpdateCheckComplete(new_version_); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 void UpdateCheckDriver::BeginUpdateCheck() { | 390 void UpdateCheckDriver::BeginUpdateCheck() { |
| 391 GoogleUpdateErrorCode error_code = GOOGLE_UPDATE_NO_ERROR; | 391 GoogleUpdateErrorCode error_code = GOOGLE_UPDATE_NO_ERROR; |
| 392 HRESULT hresult = BeginUpdateCheckInternal(&error_code); | 392 HRESULT hresult = BeginUpdateCheckInternal(&error_code); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 664 |
| 665 if (!GetCurrentState(&state, &state_value, &hresult)) { | 665 if (!GetCurrentState(&state, &state_value, &hresult)) { |
| 666 OnUpgradeError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, hresult, -1, | 666 OnUpgradeError(GOOGLE_UPDATE_ONDEMAND_CLASS_REPORTED_ERROR, hresult, -1, |
| 667 base::string16()); | 667 base::string16()); |
| 668 } else if (IsErrorState(state, state_value, &error_code, &hresult, | 668 } else if (IsErrorState(state, state_value, &error_code, &hresult, |
| 669 &installer_exit_code, &error_string)) { | 669 &installer_exit_code, &error_string)) { |
| 670 OnUpgradeError(error_code, hresult, installer_exit_code, error_string); | 670 OnUpgradeError(error_code, hresult, installer_exit_code, error_string); |
| 671 } else if (IsFinalState(state, state_value, &upgrade_status, &new_version)) { | 671 } else if (IsFinalState(state, state_value, &upgrade_status, &new_version)) { |
| 672 status_ = upgrade_status; | 672 status_ = upgrade_status; |
| 673 error_code_ = GOOGLE_UPDATE_NO_ERROR; | 673 error_code_ = GOOGLE_UPDATE_NO_ERROR; |
| 674 error_message_.clear(); | 674 html_error_message_.clear(); |
| 675 if (!new_version.empty()) | 675 if (!new_version.empty()) |
| 676 new_version_ = new_version; | 676 new_version_ = new_version; |
| 677 hresult_ = S_OK; | 677 hresult_ = S_OK; |
| 678 installer_exit_code_ = -1; | 678 installer_exit_code_ = -1; |
| 679 } else if (IsIntermediateState(state, state_value, &new_version, &progress)) { | 679 } else if (IsIntermediateState(state, state_value, &new_version, &progress)) { |
| 680 bool got_new_version = new_version_.empty() && !new_version.empty(); | 680 bool got_new_version = new_version_.empty() && !new_version.empty(); |
| 681 if (got_new_version) | 681 if (got_new_version) |
| 682 new_version_ = new_version; | 682 new_version_ = new_version; |
| 683 // Give the caller this status update if it differs from the last one given. | 683 // Give the caller this status update if it differs from the last one given. |
| 684 if (got_new_version || progress != last_reported_progress_) { | 684 if (got_new_version || progress != last_reported_progress_) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 712 } | 712 } |
| 713 | 713 |
| 714 void UpdateCheckDriver::OnUpgradeError(GoogleUpdateErrorCode error_code, | 714 void UpdateCheckDriver::OnUpgradeError(GoogleUpdateErrorCode error_code, |
| 715 HRESULT hresult, | 715 HRESULT hresult, |
| 716 int installer_exit_code, | 716 int installer_exit_code, |
| 717 const base::string16& error_string) { | 717 const base::string16& error_string) { |
| 718 status_ = UPGRADE_ERROR; | 718 status_ = UPGRADE_ERROR; |
| 719 error_code_ = error_code; | 719 error_code_ = error_code; |
| 720 hresult_ = hresult; | 720 hresult_ = hresult; |
| 721 installer_exit_code_ = installer_exit_code; | 721 installer_exit_code_ = installer_exit_code; |
| 722 base::string16 error_msg = | 722 base::string16 html_error_msg = |
| 723 base::StringPrintf(L"%d: <a href='%ls0x%X' target=_blank>0x%X</a>", | 723 base::StringPrintf(L"%d: <a href='%ls0x%X' target=_blank>0x%X</a>", |
| 724 error_code_, base::UTF8ToUTF16( | 724 error_code_, base::UTF8ToUTF16( |
| 725 chrome::kUpgradeHelpCenterBaseURL).c_str(), | 725 chrome::kUpgradeHelpCenterBaseURL).c_str(), |
| 726 hresult_, hresult_); | 726 hresult_, hresult_); |
| 727 if (installer_exit_code_ != -1) | 727 if (installer_exit_code_ != -1) |
| 728 error_msg += base::StringPrintf(L": %d", installer_exit_code_); | 728 html_error_msg += base::StringPrintf(L": %d", installer_exit_code_); |
| 729 if (system_level_install_) | 729 if (system_level_install_) |
| 730 error_msg += L" -- system level"; | 730 html_error_msg += L" -- system level"; |
| 731 if (error_string.empty()) { | 731 if (error_string.empty()) { |
| 732 error_message_ = l10n_util::GetStringFUTF16( | 732 html_error_message_ = l10n_util::GetStringFUTF16( |
| 733 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, error_msg); | 733 IDS_ABOUT_BOX_ERROR_UPDATE_CHECK_FAILED, html_error_msg); |
| 734 } else { | 734 } else { |
| 735 error_message_ = l10n_util::GetStringFUTF16( | 735 html_error_message_ = l10n_util::GetStringFUTF16( |
| 736 IDS_ABOUT_BOX_GOOGLE_UPDATE_ERROR, error_string, error_msg); | 736 IDS_ABOUT_BOX_GOOGLE_UPDATE_ERROR, error_string, html_error_msg); |
| 737 } | 737 } |
| 738 } | 738 } |
| 739 | 739 |
| 740 } // namespace | 740 } // namespace |
| 741 | 741 |
| 742 | 742 |
| 743 // Globals --------------------------------------------------------------------- | 743 // Globals --------------------------------------------------------------------- |
| 744 | 744 |
| 745 void BeginUpdateCheck( | 745 void BeginUpdateCheck( |
| 746 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 746 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 760 const GoogleUpdate3ClassFactory& google_update_factory) { | 760 const GoogleUpdate3ClassFactory& google_update_factory) { |
| 761 if (g_google_update_factory) { | 761 if (g_google_update_factory) { |
| 762 delete g_google_update_factory; | 762 delete g_google_update_factory; |
| 763 g_google_update_factory = nullptr; | 763 g_google_update_factory = nullptr; |
| 764 } | 764 } |
| 765 if (!google_update_factory.is_null()) { | 765 if (!google_update_factory.is_null()) { |
| 766 g_google_update_factory = | 766 g_google_update_factory = |
| 767 new GoogleUpdate3ClassFactory(google_update_factory); | 767 new GoogleUpdate3ClassFactory(google_update_factory); |
| 768 } | 768 } |
| 769 } | 769 } |
| OLD | NEW |