Chromium Code Reviews| Index: chrome/browser/ui/webui/help/version_updater_chromeos.cc |
| diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chrome/browser/ui/webui/help/version_updater_chromeos.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b03f32b373593cec93312b2c0b2038962d1c3193 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/help/version_updater_chromeos.cc |
| @@ -0,0 +1,75 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| +#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| +#include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| +#include "chrome/browser/chromeos/login/wizard_controller.h" |
| + |
| +using chromeos::DBusThreadManager; |
| +using chromeos::UpdateEngineClient; |
| +using chromeos::WizardController; |
| + |
| +VersionUpdater* VersionUpdater::Create() { |
| + return static_cast<VersionUpdater*>(new VersionUpdaterCros); |
| +} |
| + |
| +bool VersionUpdaterCros::CanBeUpdated() const { |
| + return true; |
| +} |
| + |
| +void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback) { |
| + callback_ = callback; |
| + |
| + UpdateEngineClient* update_engine_client = |
| + DBusThreadManager::Get()->GetUpdateEngineClient(); |
| + update_engine_client->AddObserver(this); |
| + |
| + // Make sure that libcros is loaded and OOBE is complete. |
| + if (!WizardController::default_controller() || |
| + WizardController::IsDeviceRegistered()) { |
| + update_engine_client->RequestUpdateCheck( |
| + UpdateEngineClient::EmptyUpdateCheckCallback()); |
| + } |
| +} |
| + |
| +void VersionUpdaterCros::RelaunchBrowser() const { |
| + DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| +} |
| + |
| +VersionUpdaterCros::~VersionUpdaterCros() { |
| + UpdateEngineClient* update_engine_client = |
| + DBusThreadManager::Get()->GetUpdateEngineClient(); |
| + update_engine_client->RemoveObserver(this); |
| +} |
| + |
| +void VersionUpdaterCros::UpdateStatusChanged( |
| + const UpdateEngineClient::Status& status) OVERRIDE { |
|
Nico
2012/02/05 04:50:28
OVERRIDE in cc files is a compile error
|
| + Status my_status = UPDATED; |
| + int progress = 0; |
| + |
| + switch (status.status) { |
| + case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| + my_status = CHECKING; |
| + break; |
| + case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| + progress = static_cast<int>(status.download_progress * 100.0); |
| + // Fall through. |
| + case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: |
| + case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
| + case UpdateEngineClient::UPDATE_STATUS_FINALIZING: |
| + my_status = UPDATING; |
| + break; |
| + case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| + my_status = NEARLY_UPDATED; |
| + break; |
| + default: |
| + break; |
| + } |
| + |
| + callback_.Run(my_status, progress); |
| +} |