| 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/login/user_manager.h" | 11 #include "chrome/browser/chromeos/login/user_manager.h" |
| 12 #include "chrome/browser/chromeos/login/wizard_controller.h" | 12 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" | 13 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "chromeos/dbus/power_manager_client.h" | 14 #include "chromeos/dbus/power_manager_client.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 21 matching lines...) Expand all Loading... |
| 57 UpdateEngineClient* update_engine_client = | 65 UpdateEngineClient* update_engine_client = |
| 58 DBusThreadManager::Get()->GetUpdateEngineClient(); | 66 DBusThreadManager::Get()->GetUpdateEngineClient(); |
| 59 | 67 |
| 60 // Request the channel information. Use the observer to track the help page | 68 // Request the channel information. Use the observer to track the help page |
| 61 // handler and ensure it does not get deleted before the callback. | 69 // handler and ensure it does not get deleted before the callback. |
| 62 update_engine_client->GetReleaseTrack( | 70 update_engine_client->GetReleaseTrack( |
| 63 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel, | 71 base::Bind(&VersionUpdaterCros::UpdateSelectedChannel, |
| 64 weak_ptr_factory_.GetWeakPtr())); | 72 weak_ptr_factory_.GetWeakPtr())); |
| 65 } | 73 } |
| 66 | 74 |
| 75 <<<<<<< HEAD |
| 67 VersionUpdaterCros::VersionUpdaterCros() : weak_ptr_factory_(this) {} | 76 VersionUpdaterCros::VersionUpdaterCros() : weak_ptr_factory_(this) {} |
| 68 | 77 |
| 69 VersionUpdaterCros::~VersionUpdaterCros() { | 78 VersionUpdaterCros::~VersionUpdaterCros() { |
| 70 UpdateEngineClient* update_engine_client = | 79 UpdateEngineClient* update_engine_client = |
| 71 DBusThreadManager::Get()->GetUpdateEngineClient(); | 80 DBusThreadManager::Get()->GetUpdateEngineClient(); |
| 72 update_engine_client->RemoveObserver(this); | 81 update_engine_client->RemoveObserver(this); |
| 73 } | 82 } |
| 74 | 83 |
| 84 ======= |
| 85 >>>>>>> patch from issue 9700049 |
| 75 void VersionUpdaterCros::UpdateStatusChanged( | 86 void VersionUpdaterCros::UpdateStatusChanged( |
| 76 const UpdateEngineClient::Status& status) { | 87 const UpdateEngineClient::Status& status) { |
| 77 Status my_status = UPDATED; | 88 Status my_status = UPDATED; |
| 78 int progress = 0; | 89 int progress = 0; |
| 79 | 90 |
| 80 switch (status.status) { | 91 switch (status.status) { |
| 81 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: | 92 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| 82 my_status = CHECKING; | 93 my_status = CHECKING; |
| 83 break; | 94 break; |
| 84 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: | 95 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 109 UpdateEngineClient::UpdateCheckResult result) { | 120 UpdateEngineClient::UpdateCheckResult result) { |
| 110 // If version updating is not implemented, this binary is the most up-to-date | 121 // If version updating is not implemented, this binary is the most up-to-date |
| 111 // possible with respect to automatic updating. | 122 // possible with respect to automatic updating. |
| 112 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) | 123 if (result == UpdateEngineClient::UPDATE_RESULT_NOTIMPLEMENTED) |
| 113 callback_.Run(UPDATED, 0, string16()); | 124 callback_.Run(UPDATED, 0, string16()); |
| 114 } | 125 } |
| 115 | 126 |
| 116 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) { | 127 void VersionUpdaterCros::UpdateSelectedChannel(const std::string& channel) { |
| 117 channel_callback_.Run(channel); | 128 channel_callback_.Run(channel); |
| 118 } | 129 } |
| OLD | NEW |