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

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

Issue 578293002: Fixed channel switch when user decides to switch to another channel in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Commend is added to overriden EnsureCanUpdate() method. Created 6 years, 3 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
index f0d8179d6ae38294c85ba1c0b9c1d114eb14f32d..4a9151f006a044b4c21dcdfbe6f20dde6b80d355 100644
--- a/chrome/browser/ui/webui/help/version_updater_chromeos.cc
+++ b/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -72,39 +72,6 @@ bool IsAutoUpdateDisabled() {
return update_disabled;
}
-// Returns whether an update is allowed. If not, it calls the callback with
-// the appropriate status.
-bool EnsureCanUpdate(const VersionUpdater::StatusCallback& callback) {
- if (IsAutoUpdateDisabled()) {
- callback.Run(VersionUpdater::FAILED, 0,
- l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY));
- return false;
- }
-
- chromeos::NetworkStateHandler* network_state_handler =
- chromeos::NetworkHandler::Get()->network_state_handler();
- const chromeos::NetworkState* network =
- network_state_handler->DefaultNetwork();
-
- // Don't allow an update if we're currently offline or connected
- // to a network for which updates are disallowed.
- NetworkStatus status = GetNetworkStatus(network);
- if (status == NETWORK_STATUS_OFFLINE) {
- callback.Run(VersionUpdater::FAILED_OFFLINE, 0,
- l10n_util::GetStringUTF16(IDS_UPGRADE_OFFLINE));
- return false;
- } else if (status == NETWORK_STATUS_DISALLOWED) {
- base::string16 message =
- l10n_util::GetStringFUTF16(
- IDS_UPGRADE_DISALLOWED,
- help_utils_chromeos::GetConnectionTypeAsUTF16(network->type()));
- callback.Run(VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED, 0, message);
- return false;
- }
-
- return true;
-}
-
} // namespace
VersionUpdater* VersionUpdater::Create() {
@@ -136,12 +103,18 @@ void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback) {
if (!update_engine_client->HasObserver(this))
update_engine_client->AddObserver(this);
+ if (update_engine_client->GetLastStatus().status !=
+ UpdateEngineClient::UPDATE_STATUS_IDLE) {
+ check_for_update_when_idle_ = true;
+ return;
+ }
+ check_for_update_when_idle_ = false;
+
// Make sure that libcros is loaded and OOBE is complete.
if (!WizardController::default_controller() ||
chromeos::StartupUtils::IsDeviceRegistered()) {
- update_engine_client->RequestUpdateCheck(
- base::Bind(&VersionUpdaterCros::OnUpdateCheck,
- weak_ptr_factory_.GetWeakPtr()));
+ update_engine_client->RequestUpdateCheck(base::Bind(
+ &VersionUpdaterCros::OnUpdateCheck, weak_ptr_factory_.GetWeakPtr()));
}
}
@@ -170,6 +143,7 @@ void VersionUpdaterCros::GetChannel(bool get_current_channel,
VersionUpdaterCros::VersionUpdaterCros()
: last_operation_(UpdateEngineClient::UPDATE_STATUS_IDLE),
+ check_for_update_when_idle_(false),
weak_ptr_factory_(this) {
}
@@ -179,6 +153,37 @@ VersionUpdaterCros::~VersionUpdaterCros() {
update_engine_client->RemoveObserver(this);
}
+bool VersionUpdaterCros::EnsureCanUpdate(const StatusCallback& callback) {
+ if (IsAutoUpdateDisabled()) {
+ callback.Run(VersionUpdater::FAILED, 0,
+ l10n_util::GetStringUTF16(IDS_UPGRADE_DISABLED_BY_POLICY));
+ return false;
+ }
+
+ chromeos::NetworkStateHandler* network_state_handler =
+ chromeos::NetworkHandler::Get()->network_state_handler();
+ const chromeos::NetworkState* network =
+ network_state_handler->DefaultNetwork();
+
+ // Don't allow an update if we're currently offline or connected
+ // to a network for which updates are disallowed.
+ NetworkStatus status = GetNetworkStatus(network);
+ if (status == NETWORK_STATUS_OFFLINE) {
+ callback.Run(VersionUpdater::FAILED_OFFLINE, 0,
+ l10n_util::GetStringUTF16(IDS_UPGRADE_OFFLINE));
+ return false;
+ } else if (status == NETWORK_STATUS_DISALLOWED) {
+ base::string16 message =
+ l10n_util::GetStringFUTF16(
+ IDS_UPGRADE_DISALLOWED,
+ help_utils_chromeos::GetConnectionTypeAsUTF16(network->type()));
+ callback.Run(VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED, 0, message);
+ return false;
+ }
+
+ return true;
+}
+
void VersionUpdaterCros::UpdateStatusChanged(
const UpdateEngineClient::Status& status) {
Status my_status = UPDATED;
@@ -229,6 +234,11 @@ void VersionUpdaterCros::UpdateStatusChanged(
callback_.Run(my_status, progress, message);
last_operation_ = status.status;
+
+ if (check_for_update_when_idle_ &&
+ status.status == UpdateEngineClient::UPDATE_STATUS_IDLE) {
+ CheckForUpdate(callback_);
+ }
}
void VersionUpdaterCros::OnUpdateCheck(

Powered by Google App Engine
This is Rietveld 408576698