Index: chrome/browser/ui/webui/help/version_updater_win.cc |
diff --git a/chrome/browser/ui/webui/help/version_updater_win.cc b/chrome/browser/ui/webui/help/version_updater_win.cc |
index 449ef19d4506e52e2da50230bb0d4d6e6961a84f..174a16c8d4851ab486cdd70590ba698a90faeb53 100644 |
--- a/chrome/browser/ui/webui/help/version_updater_win.cc |
+++ b/chrome/browser/ui/webui/help/version_updater_win.cc |
@@ -28,8 +28,7 @@ namespace { |
// Windows implementation of version update functionality, used by the WebUI |
// About/Help page. |
-class VersionUpdaterWin : public VersionUpdater, |
- public GoogleUpdateStatusListener { |
+class VersionUpdaterWin : public VersionUpdater { |
private: |
friend class VersionReader; |
friend class VersionUpdater; |
@@ -42,11 +41,11 @@ class VersionUpdaterWin : public VersionUpdater, |
virtual void CheckForUpdate(const StatusCallback& callback) override; |
virtual void RelaunchBrowser() const override; |
- // GoogleUpdateStatusListener implementation. |
- virtual void OnReportResults(GoogleUpdateUpgradeResult result, |
- GoogleUpdateErrorCode error_code, |
- const base::string16& error_message, |
- const base::string16& version) override; |
+ // chrome::UpdateCheckCallback. |
+ void OnUpdateCheckResults(GoogleUpdateUpgradeResult result, |
+ GoogleUpdateErrorCode error_code, |
+ const base::string16& error_message, |
+ const base::string16& version); |
// Update the UI to show the status of the upgrade. |
void UpdateStatus(GoogleUpdateUpgradeResult result, |
@@ -57,19 +56,9 @@ class VersionUpdaterWin : public VersionUpdater, |
// result case can now be completeb on the UI thread. |
void GotInstalledVersion(const Version& version); |
- // Little helper function to create google_updater_. |
- void CreateGoogleUpdater(); |
- |
- // Helper function to clear google_updater_. |
- void ClearGoogleUpdater(); |
- |
// Returns a window that can be used for elevation. |
HWND GetElevationParent(); |
- // The class that communicates with Google Update to find out if an update is |
- // available and asks it to start an upgrade. |
- scoped_refptr<GoogleUpdate> google_updater_; |
- |
// Used for callbacks. |
base::WeakPtrFactory<VersionUpdaterWin> weak_factory_; |
@@ -122,13 +111,9 @@ class VersionReader |
VersionUpdaterWin::VersionUpdaterWin() |
: weak_factory_(this) { |
- CreateGoogleUpdater(); |
} |
VersionUpdaterWin::~VersionUpdaterWin() { |
- // The Google Updater will hold a pointer to the listener until it reports |
- // status, so that pointer must be cleared when the listener is destoyed. |
- ClearGoogleUpdater(); |
} |
void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback) { |
@@ -142,13 +127,12 @@ void VersionUpdaterWin::CheckForUpdate(const StatusCallback& callback) { |
if (!(base::win::GetVersion() == base::win::VERSION_VISTA && |
(base::win::OSInfo::GetInstance()->service_pack().major == 0) && |
!base::win::UserAccountControlIsEnabled())) { |
- // This could happen if the page got refreshed after results were returned. |
- if (!google_updater_.get()) |
- CreateGoogleUpdater(); |
UpdateStatus(UPGRADE_CHECK_STARTED, GOOGLE_UPDATE_NO_ERROR, |
base::string16()); |
// Specify false to not upgrade yet. |
- google_updater_->CheckForUpdate(false, GetElevationParent()); |
+ ::CheckForUpdate(false, GetElevationParent(), |
Peter Kasting
2014/11/26 22:13:05
Nit: "::" shouldn't be necessary here, I wouldn't
grt (UTC plus 2)
2014/11/27 04:44:57
ADL wasn't enough to find it. I've renamed the fun
|
+ base::Bind(&VersionUpdaterWin::OnUpdateCheckResults, |
+ weak_factory_.GetWeakPtr())); |
} |
} |
@@ -156,11 +140,11 @@ void VersionUpdaterWin::RelaunchBrowser() const { |
chrome::AttemptRestart(); |
} |
-void VersionUpdaterWin::OnReportResults( |
- GoogleUpdateUpgradeResult result, GoogleUpdateErrorCode error_code, |
- const base::string16& error_message, const base::string16& version) { |
- // Drop the last reference to the object so that it gets cleaned up here. |
- ClearGoogleUpdater(); |
+void VersionUpdaterWin::OnUpdateCheckResults( |
+ GoogleUpdateUpgradeResult result, |
+ GoogleUpdateErrorCode error_code, |
+ const base::string16& error_message, |
+ const base::string16& version) { |
UpdateStatus(result, error_code, error_message); |
} |
@@ -184,11 +168,11 @@ void VersionUpdaterWin::UpdateStatus(GoogleUpdateUpgradeResult result, |
break; |
} |
case UPGRADE_IS_AVAILABLE: { |
- DCHECK(!google_updater_.get()); // Should have been nulled out already. |
- CreateGoogleUpdater(); |
UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR, base::string16()); |
// Specify true to upgrade now. |
- google_updater_->CheckForUpdate(true, GetElevationParent()); |
+ ::CheckForUpdate(true, GetElevationParent(), |
+ base::Bind(&VersionUpdaterWin::OnUpdateCheckResults, |
+ weak_factory_.GetWeakPtr())); |
return; |
} |
case UPGRADE_ALREADY_UP_TO_DATE: { |
@@ -252,19 +236,6 @@ void VersionUpdaterWin::GotInstalledVersion(const Version& version) { |
base::string16()); |
} |
-void VersionUpdaterWin::CreateGoogleUpdater() { |
- ClearGoogleUpdater(); |
- google_updater_ = new GoogleUpdate(); |
- google_updater_->set_status_listener(this); |
-} |
- |
-void VersionUpdaterWin::ClearGoogleUpdater() { |
- if (google_updater_.get()) { |
- google_updater_->set_status_listener(NULL); |
- google_updater_ = NULL; |
- } |
-} |
- |
BOOL CALLBACK WindowEnumeration(HWND window, LPARAM param) { |
if (IsWindowVisible(window)) { |
HWND* returned_window = reinterpret_cast<HWND*>(param); |