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

Unified Diff: chrome/browser/ui/webui/help/version_updater_chromeos.cc

Issue 9320056: Help: Implement the initial version of the cross-platform help/about page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: String fix. Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
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);
+}

Powered by Google App Engine
This is Rietveld 408576698