| 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/ui/webui/help/version_updater_chromeos.h" | 5 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "chrome/browser/chromeos/cros_settings.h" | 9 #include "chrome/browser/chromeos/cros_settings.h" |
| 10 #include "chrome/browser/chromeos/cros_settings_names.h" | 10 #include "chrome/browser/chromeos/cros_settings_names.h" |
| 11 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 11 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 12 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 12 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chrome/browser/chromeos/login/wizard_controller.h" | 14 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 15 | 15 |
| 16 using chromeos::CrosSettings; | 16 using chromeos::CrosSettings; |
| 17 using chromeos::DBusThreadManager; | 17 using chromeos::DBusThreadManager; |
| 18 using chromeos::UpdateEngineClient; | 18 using chromeos::UpdateEngineClient; |
| 19 using chromeos::UserManager; | 19 using chromeos::UserManager; |
| 20 using chromeos::WizardController; | 20 using chromeos::WizardController; |
| 21 | 21 |
| 22 VersionUpdater* VersionUpdater::Create() { | 22 VersionUpdater* VersionUpdater::Create() { |
| 23 return new VersionUpdaterCros; | 23 return new VersionUpdaterCros; |
| 24 } | 24 } |
| 25 | 25 |
| 26 VersionUpdaterCros::VersionUpdaterCros() {} |
| 27 |
| 28 VersionUpdaterCros::~VersionUpdaterCros() { |
| 29 UpdateEngineClient* update_engine_client = |
| 30 DBusThreadManager::Get()->GetUpdateEngineClient(); |
| 31 update_engine_client->RemoveObserver(this); |
| 32 } |
| 33 |
| 26 void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback) { | 34 void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback) { |
| 27 callback_ = callback; | 35 callback_ = callback; |
| 28 | 36 |
| 29 UpdateEngineClient* update_engine_client = | 37 UpdateEngineClient* update_engine_client = |
| 30 DBusThreadManager::Get()->GetUpdateEngineClient(); | 38 DBusThreadManager::Get()->GetUpdateEngineClient(); |
| 31 update_engine_client->AddObserver(this); | 39 update_engine_client->AddObserver(this); |
| 32 | 40 |
| 33 // Make sure that libcros is loaded and OOBE is complete. | 41 // Make sure that libcros is loaded and OOBE is complete. |
| 34 if (!WizardController::default_controller() || | 42 if (!WizardController::default_controller() || |
| 35 WizardController::IsDeviceRegistered()) { | 43 WizardController::IsDeviceRegistered()) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 56 UpdateEngineClient* update_engine_client = | 64 UpdateEngineClient* update_engine_client = |
| 57 DBusThreadManager::Get()->GetUpdateEngineClient(); | 65 DBusThreadManager::Get()->GetUpdateEngineClient(); |
| 58 | 66 |
| 59 // Request the channel information. Use the observer to track the help page | 67 // Request the channel information. Use the observer to track the help page |
| 60 // handler and ensure it does not get deleted before the callback. | 68 // handler and ensure it does not get deleted before the callback. |
| 61 update_engine_client->GetReleaseTrack( | 69 update_engine_client->GetReleaseTrack( |
| 62 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel, | 70 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel, |
| 63 base::Unretained(this))); | 71 base::Unretained(this))); |
| 64 } | 72 } |
| 65 | 73 |
| 66 VersionUpdaterCros::VersionUpdaterCros() {} | |
| 67 | |
| 68 VersionUpdaterCros::~VersionUpdaterCros() { | |
| 69 UpdateEngineClient* update_engine_client = | |
| 70 DBusThreadManager::Get()->GetUpdateEngineClient(); | |
| 71 update_engine_client->RemoveObserver(this); | |
| 72 } | |
| 73 | |
| 74 void VersionUpdaterCros::UpdateStatusChanged( | 74 void VersionUpdaterCros::UpdateStatusChanged( |
| 75 const UpdateEngineClient::Status& status) { | 75 const UpdateEngineClient::Status& status) { |
| 76 Status my_status = UPDATED; | 76 Status my_status = UPDATED; |
| 77 int progress = 0; | 77 int progress = 0; |
| 78 | 78 |
| 79 switch (status.status) { | 79 switch (status.status) { |
| 80 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: | 80 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| 81 my_status = CHECKING; | 81 my_status = CHECKING; |
| 82 break; | 82 break; |
| 83 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: | 83 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 108 UpdateEngineClient::UpdateCheckResult result) { | 108 UpdateEngineClient::UpdateCheckResult result) { |
| 109 // If version updating is not implemented, this binary is the most up-to-date | 109 // If version updating is not implemented, this binary is the most up-to-date |
| 110 // possible with respect to automatic updating. | 110 // possible with respect to automatic updating. |
| 111 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) | 111 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) |
| 112 callback_.Run(UPDATED, 0, string16()); | 112 callback_.Run(UPDATED, 0, string16()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) { | 115 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) { |
| 116 channel_callback_.Run(channel); | 116 channel_callback_.Run(channel); |
| 117 } | 117 } |
| OLD | NEW |