Chromium Code Reviews| Index: chrome/browser/chromeos/login/screens/update_screen.cc |
| diff --git a/chrome/browser/chromeos/login/screens/update_screen.cc b/chrome/browser/chromeos/login/screens/update_screen.cc |
| index 8fc167be844d91c0e7f441fa911563615e6847e6..8281a264142550f149540ab3699d6f4918efb2e4 100644 |
| --- a/chrome/browser/chromeos/login/screens/update_screen.cc |
| +++ b/chrome/browser/chromeos/login/screens/update_screen.cc |
| @@ -35,6 +35,17 @@ namespace chromeos { |
| namespace { |
| +constexpr const char kUserActionCancelUpdateShortcut[] = "cancel-update"; |
| +constexpr const char kContextKeyEstimatedTimeLeftSec[] = "time-left-sec"; |
| +constexpr const char kContextKeyShowEstimatedTimeLeft[] = "show-time-left"; |
| +constexpr const char kContextKeyUpdateMessage[] = "update-msg"; |
| +constexpr const char kContextKeyShowCurtain[] = "show-curtain"; |
| +constexpr const char kContextKeyShowProgressMessage[] = "show-progress-msg"; |
| +constexpr const char kContextKeyProgress[] = "progress"; |
| +constexpr const char kContextKeyProgressMessage[] = "progress-msg"; |
| +constexpr const char kContextKeyCancelUpdateShortcutEnabled[] = |
| + "cancel-update-enabled"; |
| + |
| // If reboot didn't happen, ask user to reboot device manually. |
| const int kWaitForRebootTimeSec = 3; |
| @@ -110,22 +121,14 @@ UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { |
| UpdateScreen::UpdateScreen(BaseScreenDelegate* base_screen_delegate, |
| UpdateView* view, |
| HostPairingController* remora_controller) |
| - : UpdateModel(base_screen_delegate), |
| - state_(STATE_IDLE), |
| + : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_UPDATE), |
| reboot_check_delay_(kWaitForRebootTimeSec), |
| - is_checking_for_update_(true), |
| - is_downloading_update_(false), |
| - is_ignore_update_deadlines_(false), |
| - is_shown_(false), |
| - ignore_idle_status_(true), |
| view_(view), |
| remora_controller_(remora_controller), |
| - is_first_detection_notification_(true), |
| - is_first_portal_notification_(true), |
| histogram_helper_(new ErrorScreensHistogramHelper("Update")), |
| weak_factory_(this) { |
| if (view_) |
| - view_->Bind(*this); |
| + view_->Bind(this); |
| GetInstanceSet().insert(this); |
| } |
| @@ -139,6 +142,74 @@ UpdateScreen::~UpdateScreen() { |
| GetInstanceSet().erase(this); |
| } |
| +void UpdateScreen::OnViewDestroyed(UpdateView* view) { |
| + if (view_ == view) |
| + view_ = nullptr; |
| +} |
| + |
| +void UpdateScreen::StartNetworkCheck() { |
| + // If portal detector is enabled and portal detection before AU is |
| + // allowed, initiate network state check. Otherwise, directly |
| + // proceed to update. |
| + if (!network_portal_detector::GetInstance()->IsEnabled()) { |
| + StartUpdateCheck(); |
| + return; |
| + } |
| + state_ = STATE_FIRST_PORTAL_CHECK; |
| + is_first_detection_notification_ = true; |
| + is_first_portal_notification_ = true; |
| + network_portal_detector::GetInstance()->AddAndFireObserver(this); |
| +} |
| + |
| +void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { |
| + ignore_idle_status_ = ignore_idle_status; |
| +} |
| + |
| +void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { |
| + DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
| + network_portal_detector::GetInstance()->RemoveObserver(this); |
| + SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); |
| + |
| + switch (reason) { |
| + case REASON_UPDATE_CANCELED: |
| + Finish(BaseScreenDelegate::UPDATE_NOUPDATE); |
| + break; |
| + case REASON_UPDATE_INIT_FAILED: |
| + Finish(BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
| + break; |
| + case REASON_UPDATE_NON_CRITICAL: |
| + case REASON_UPDATE_ENDED: { |
| + UpdateEngineClient* update_engine_client = |
| + DBusThreadManager::Get()->GetUpdateEngineClient(); |
| + switch (update_engine_client->GetLastStatus().status) { |
| + case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: |
| + break; |
| + case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: |
| + case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| + case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| + case UpdateEngineClient::UPDATE_STATUS_FINALIZING: |
| + case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
| + DCHECK(!HasCriticalUpdate()); |
| + // Noncritical update, just exit screen as if there is no update. |
| + // no break |
| + case UpdateEngineClient::UPDATE_STATUS_IDLE: |
| + Finish(BaseScreenDelegate::UPDATE_NOUPDATE); |
| + break; |
| + case UpdateEngineClient::UPDATE_STATUS_ERROR: |
| + case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| + Finish(is_checking_for_update_ |
| + ? BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE |
| + : BaseScreenDelegate::UPDATE_ERROR_UPDATING); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| + } break; |
| + default: |
| + NOTREACHED(); |
| + } |
| +} |
| + |
| void UpdateScreen::UpdateStatusChanged( |
| const UpdateEngineClient::Status& status) { |
| if (is_checking_for_update_ && |
| @@ -307,18 +378,13 @@ void UpdateScreen::OnPortalDetectionCompleted( |
| } |
| } |
| -void UpdateScreen::StartNetworkCheck() { |
| - // If portal detector is enabled and portal detection before AU is |
| - // allowed, initiate network state check. Otherwise, directly |
| - // proceed to update. |
| - if (!network_portal_detector::GetInstance()->IsEnabled()) { |
| - StartUpdateCheck(); |
| - return; |
| - } |
| - state_ = STATE_FIRST_PORTAL_CHECK; |
| - is_first_detection_notification_ = true; |
| - is_first_portal_notification_ = true; |
| - network_portal_detector::GetInstance()->AddAndFireObserver(this); |
| +void UpdateScreen::CancelUpdate() { |
| + VLOG(1) << "Forced update cancel"; |
| + ExitUpdate(REASON_UPDATE_CANCELED); |
| +} |
| + |
| +base::OneShotTimer& UpdateScreen::GetErrorMessageTimerForTesting() { |
|
achuithb
2017/02/03 22:36:43
This should return a pointer, but let's not change
jdufault
2017/02/06 22:30:48
Added TODO
|
| + return error_message_timer_; |
| } |
| void UpdateScreen::Show() { |
| @@ -341,11 +407,6 @@ void UpdateScreen::Hide() { |
| is_shown_ = false; |
| } |
| -void UpdateScreen::OnViewDestroyed(UpdateView* view) { |
| - if (view_ == view) |
| - view_ = nullptr; |
| -} |
| - |
| void UpdateScreen::OnUserAction(const std::string& action_id) { |
| #if !defined(OFFICIAL_BUILD) |
| if (action_id == kUserActionCancelUpdateShortcut) |
| @@ -355,80 +416,6 @@ void UpdateScreen::OnUserAction(const std::string& action_id) { |
| BaseScreen::OnUserAction(action_id); |
| } |
| -void UpdateScreen::OnContextKeyUpdated( |
| - const ::login::ScreenContext::KeyType& key) { |
| - UpdateModel::OnContextKeyUpdated(key); |
| -} |
| - |
| -void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { |
| - DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
| - network_portal_detector::GetInstance()->RemoveObserver(this); |
| - SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); |
| - |
| - |
| - switch (reason) { |
| - case REASON_UPDATE_CANCELED: |
| - Finish(BaseScreenDelegate::UPDATE_NOUPDATE); |
| - break; |
| - case REASON_UPDATE_INIT_FAILED: |
| - Finish(BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
| - break; |
| - case REASON_UPDATE_NON_CRITICAL: |
| - case REASON_UPDATE_ENDED: |
| - { |
| - UpdateEngineClient* update_engine_client = |
| - DBusThreadManager::Get()->GetUpdateEngineClient(); |
| - switch (update_engine_client->GetLastStatus().status) { |
| - case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: |
| - break; |
| - case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: |
| - case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| - case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| - case UpdateEngineClient::UPDATE_STATUS_FINALIZING: |
| - case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
| - DCHECK(!HasCriticalUpdate()); |
| - // Noncritical update, just exit screen as if there is no update. |
| - // no break |
| - case UpdateEngineClient::UPDATE_STATUS_IDLE: |
| - Finish(BaseScreenDelegate::UPDATE_NOUPDATE); |
| - break; |
| - case UpdateEngineClient::UPDATE_STATUS_ERROR: |
| - case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| - Finish(is_checking_for_update_ |
| - ? BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE |
| - : BaseScreenDelegate::UPDATE_ERROR_UPDATING); |
| - break; |
| - default: |
| - NOTREACHED(); |
| - } |
| - } |
| - break; |
| - default: |
| - NOTREACHED(); |
| - } |
| -} |
| - |
| -void UpdateScreen::OnWaitForRebootTimeElapsed() { |
| - LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; |
| - MakeSureScreenIsShown(); |
| - GetContextEditor().SetString(kContextKeyUpdateMessage, |
| - l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); |
| -} |
| - |
| -void UpdateScreen::MakeSureScreenIsShown() { |
| - if (!is_shown_) |
| - get_base_screen_delegate()->ShowCurrentScreen(); |
| -} |
| - |
| -void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { |
| - ignore_idle_status_ = ignore_idle_status; |
| -} |
| - |
| -void UpdateScreen::CancelUpdate() { |
| - VLOG(1) << "Forced update cancel"; |
| - ExitUpdate(REASON_UPDATE_CANCELED); |
| -} |
| - |
| void UpdateScreen::UpdateDownloadingStats( |
| const UpdateEngineClient::Status& status) { |
| base::Time download_current_time = base::Time::Now(); |
| @@ -499,6 +486,25 @@ bool UpdateScreen::HasCriticalUpdate() { |
| return true; |
| } |
| +void UpdateScreen::OnWaitForRebootTimeElapsed() { |
| + LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; |
| + MakeSureScreenIsShown(); |
| + GetContextEditor().SetString(kContextKeyUpdateMessage, |
| + l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); |
| +} |
| + |
| +void UpdateScreen::MakeSureScreenIsShown() { |
| + if (!is_shown_) |
| + get_base_screen_delegate()->ShowCurrentScreen(); |
| +} |
| + |
| +void UpdateScreen::SetHostPairingControllerStatus( |
| + HostPairingController::UpdateStatus update_status) { |
| + if (remora_controller_) { |
| + remora_controller_->OnUpdateStatusChanged(update_status); |
| + } |
| +} |
| + |
| ErrorScreen* UpdateScreen::GetErrorScreen() { |
| return get_base_screen_delegate()->GetErrorScreen(); |
| } |
| @@ -569,13 +575,6 @@ void UpdateScreen::UpdateErrorMessage( |
| } |
| } |
| -void UpdateScreen::SetHostPairingControllerStatus( |
| - HostPairingController::UpdateStatus update_status) { |
| - if (remora_controller_) { |
| - remora_controller_->OnUpdateStatusChanged(update_status); |
| - } |
| -} |
| - |
| void UpdateScreen::DelayErrorMessage() { |
| if (error_message_timer_.IsRunning()) |
| return; |
| @@ -586,10 +585,6 @@ void UpdateScreen::DelayErrorMessage() { |
| &UpdateScreen::ShowErrorMessage); |
| } |
| -base::OneShotTimer& UpdateScreen::GetErrorMessageTimerForTesting() { |
| - return error_message_timer_; |
| -} |
| - |
| void UpdateScreen::OnConnectRequested() { |
| if (state_ == STATE_ERROR) { |
| LOG(WARNING) << "Hiding error message since AP was reselected"; |