| 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/chromeos/login/screens/update_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/update_screen.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 | 30 |
| 31 using content::BrowserThread; | 31 using content::BrowserThread; |
| 32 using pairing_chromeos::HostPairingController; | 32 using pairing_chromeos::HostPairingController; |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 constexpr const char kContextKeyEstimatedTimeLeftSec[] = "time-left-sec"; |
| 39 constexpr const char kContextKeyShowEstimatedTimeLeft[] = "show-time-left"; |
| 40 constexpr const char kContextKeyUpdateMessage[] = "update-msg"; |
| 41 constexpr const char kContextKeyShowCurtain[] = "show-curtain"; |
| 42 constexpr const char kContextKeyShowProgressMessage[] = "show-progress-msg"; |
| 43 constexpr const char kContextKeyProgress[] = "progress"; |
| 44 constexpr const char kContextKeyProgressMessage[] = "progress-msg"; |
| 45 |
| 46 #if !defined(OFFICIAL_BUILD) |
| 47 constexpr const char kUserActionCancelUpdateShortcut[] = "cancel-update"; |
| 48 constexpr const char kContextKeyCancelUpdateShortcutEnabled[] = |
| 49 "cancel-update-enabled"; |
| 50 #endif |
| 51 |
| 38 // If reboot didn't happen, ask user to reboot device manually. | 52 // If reboot didn't happen, ask user to reboot device manually. |
| 39 const int kWaitForRebootTimeSec = 3; | 53 const int kWaitForRebootTimeSec = 3; |
| 40 | 54 |
| 41 // Progress bar stages. Each represents progress bar value | 55 // Progress bar stages. Each represents progress bar value |
| 42 // at the beginning of each stage. | 56 // at the beginning of each stage. |
| 43 // TODO(nkostylev): Base stage progress values on approximate time. | 57 // TODO(nkostylev): Base stage progress values on approximate time. |
| 44 // TODO(nkostylev): Animate progress during each state. | 58 // TODO(nkostylev): Animate progress during each state. |
| 45 const int kBeforeUpdateCheckProgress = 7; | 59 const int kBeforeUpdateCheckProgress = 7; |
| 46 const int kBeforeDownloadProgress = 14; | 60 const int kBeforeDownloadProgress = 14; |
| 47 const int kBeforeVerifyingProgress = 74; | 61 const int kBeforeVerifyingProgress = 74; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 117 |
| 104 // static | 118 // static |
| 105 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { | 119 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { |
| 106 return static_cast<UpdateScreen*>( | 120 return static_cast<UpdateScreen*>( |
| 107 manager->GetScreen(OobeScreen::SCREEN_OOBE_UPDATE)); | 121 manager->GetScreen(OobeScreen::SCREEN_OOBE_UPDATE)); |
| 108 } | 122 } |
| 109 | 123 |
| 110 UpdateScreen::UpdateScreen(BaseScreenDelegate* base_screen_delegate, | 124 UpdateScreen::UpdateScreen(BaseScreenDelegate* base_screen_delegate, |
| 111 UpdateView* view, | 125 UpdateView* view, |
| 112 HostPairingController* remora_controller) | 126 HostPairingController* remora_controller) |
| 113 : UpdateModel(base_screen_delegate), | 127 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_UPDATE), |
| 114 state_(STATE_IDLE), | |
| 115 reboot_check_delay_(kWaitForRebootTimeSec), | 128 reboot_check_delay_(kWaitForRebootTimeSec), |
| 116 is_checking_for_update_(true), | |
| 117 is_downloading_update_(false), | |
| 118 is_ignore_update_deadlines_(false), | |
| 119 is_shown_(false), | |
| 120 ignore_idle_status_(true), | |
| 121 view_(view), | 129 view_(view), |
| 122 remora_controller_(remora_controller), | 130 remora_controller_(remora_controller), |
| 123 is_first_detection_notification_(true), | |
| 124 is_first_portal_notification_(true), | |
| 125 histogram_helper_(new ErrorScreensHistogramHelper("Update")), | 131 histogram_helper_(new ErrorScreensHistogramHelper("Update")), |
| 126 weak_factory_(this) { | 132 weak_factory_(this) { |
| 127 if (view_) | 133 if (view_) |
| 128 view_->Bind(*this); | 134 view_->Bind(this); |
| 129 | 135 |
| 130 GetInstanceSet().insert(this); | 136 GetInstanceSet().insert(this); |
| 131 } | 137 } |
| 132 | 138 |
| 133 UpdateScreen::~UpdateScreen() { | 139 UpdateScreen::~UpdateScreen() { |
| 134 if (view_) | 140 if (view_) |
| 135 view_->Unbind(); | 141 view_->Unbind(); |
| 136 | 142 |
| 137 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); | 143 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
| 138 network_portal_detector::GetInstance()->RemoveObserver(this); | 144 network_portal_detector::GetInstance()->RemoveObserver(this); |
| 139 GetInstanceSet().erase(this); | 145 GetInstanceSet().erase(this); |
| 140 } | 146 } |
| 141 | 147 |
| 148 void UpdateScreen::OnViewDestroyed(UpdateView* view) { |
| 149 if (view_ == view) |
| 150 view_ = nullptr; |
| 151 } |
| 152 |
| 153 void UpdateScreen::StartNetworkCheck() { |
| 154 // If portal detector is enabled and portal detection before AU is |
| 155 // allowed, initiate network state check. Otherwise, directly |
| 156 // proceed to update. |
| 157 if (!network_portal_detector::GetInstance()->IsEnabled()) { |
| 158 StartUpdateCheck(); |
| 159 return; |
| 160 } |
| 161 state_ = State::STATE_FIRST_PORTAL_CHECK; |
| 162 is_first_detection_notification_ = true; |
| 163 is_first_portal_notification_ = true; |
| 164 network_portal_detector::GetInstance()->AddAndFireObserver(this); |
| 165 } |
| 166 |
| 167 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { |
| 168 ignore_idle_status_ = ignore_idle_status; |
| 169 } |
| 170 |
| 171 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { |
| 172 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
| 173 network_portal_detector::GetInstance()->RemoveObserver(this); |
| 174 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); |
| 175 |
| 176 switch (reason) { |
| 177 case REASON_UPDATE_CANCELED: |
| 178 Finish(BaseScreenDelegate::UPDATE_NOUPDATE); |
| 179 break; |
| 180 case REASON_UPDATE_INIT_FAILED: |
| 181 Finish(BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
| 182 break; |
| 183 case REASON_UPDATE_NON_CRITICAL: |
| 184 case REASON_UPDATE_ENDED: { |
| 185 UpdateEngineClient* update_engine_client = |
| 186 DBusThreadManager::Get()->GetUpdateEngineClient(); |
| 187 switch (update_engine_client->GetLastStatus().status) { |
| 188 case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: |
| 189 break; |
| 190 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: |
| 191 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| 192 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| 193 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: |
| 194 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
| 195 DCHECK(!HasCriticalUpdate()); |
| 196 // Noncritical update, just exit screen as if there is no update. |
| 197 // no break |
| 198 case UpdateEngineClient::UPDATE_STATUS_IDLE: |
| 199 Finish(BaseScreenDelegate::UPDATE_NOUPDATE); |
| 200 break; |
| 201 case UpdateEngineClient::UPDATE_STATUS_ERROR: |
| 202 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| 203 if (is_checking_for_update_) { |
| 204 Finish(BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
| 205 } else if (HasCriticalUpdate()) { |
| 206 Finish(BaseScreenDelegate::UPDATE_ERROR_UPDATING_CRITICAL_UPDATE); |
| 207 } else { |
| 208 Finish(BaseScreenDelegate::UPDATE_ERROR_UPDATING); |
| 209 } |
| 210 break; |
| 211 default: |
| 212 NOTREACHED(); |
| 213 } |
| 214 } break; |
| 215 default: |
| 216 NOTREACHED(); |
| 217 } |
| 218 } |
| 219 |
| 142 void UpdateScreen::UpdateStatusChanged( | 220 void UpdateScreen::UpdateStatusChanged( |
| 143 const UpdateEngineClient::Status& status) { | 221 const UpdateEngineClient::Status& status) { |
| 144 if (is_checking_for_update_ && | 222 if (is_checking_for_update_ && |
| 145 status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) { | 223 status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) { |
| 146 is_checking_for_update_ = false; | 224 is_checking_for_update_ = false; |
| 147 } | 225 } |
| 148 if (ignore_idle_status_ && status.status > | 226 if (ignore_idle_status_ && status.status > |
| 149 UpdateEngineClient::UPDATE_STATUS_IDLE) { | 227 UpdateEngineClient::UPDATE_STATUS_IDLE) { |
| 150 ignore_idle_status_ = false; | 228 ignore_idle_status_ = false; |
| 151 } | 229 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 base::ThreadTaskRunnerHandle::Get()->PostTask( | 355 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 278 FROM_HERE, | 356 FROM_HERE, |
| 279 base::Bind( | 357 base::Bind( |
| 280 base::IgnoreResult(&NetworkPortalDetector::StartDetectionIfIdle), | 358 base::IgnoreResult(&NetworkPortalDetector::StartDetectionIfIdle), |
| 281 base::Unretained(network_portal_detector::GetInstance()))); | 359 base::Unretained(network_portal_detector::GetInstance()))); |
| 282 return; | 360 return; |
| 283 } | 361 } |
| 284 is_first_detection_notification_ = false; | 362 is_first_detection_notification_ = false; |
| 285 | 363 |
| 286 NetworkPortalDetector::CaptivePortalStatus status = state.status; | 364 NetworkPortalDetector::CaptivePortalStatus status = state.status; |
| 287 if (state_ == STATE_ERROR) { | 365 if (state_ == State::STATE_ERROR) { |
| 288 // In the case of online state hide error message and proceed to | 366 // In the case of online state hide error message and proceed to |
| 289 // the update stage. Otherwise, update error message content. | 367 // the update stage. Otherwise, update error message content. |
| 290 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) | 368 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) |
| 291 StartUpdateCheck(); | 369 StartUpdateCheck(); |
| 292 else | 370 else |
| 293 UpdateErrorMessage(network, status); | 371 UpdateErrorMessage(network, status); |
| 294 } else if (state_ == STATE_FIRST_PORTAL_CHECK) { | 372 } else if (state_ == State::STATE_FIRST_PORTAL_CHECK) { |
| 295 // In the case of online state immediately proceed to the update | 373 // In the case of online state immediately proceed to the update |
| 296 // stage. Otherwise, prepare and show error message. | 374 // stage. Otherwise, prepare and show error message. |
| 297 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) { | 375 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) { |
| 298 StartUpdateCheck(); | 376 StartUpdateCheck(); |
| 299 } else { | 377 } else { |
| 300 UpdateErrorMessage(network, status); | 378 UpdateErrorMessage(network, status); |
| 301 | 379 |
| 302 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) | 380 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL) |
| 303 DelayErrorMessage(); | 381 DelayErrorMessage(); |
| 304 else | 382 else |
| 305 ShowErrorMessage(); | 383 ShowErrorMessage(); |
| 306 } | 384 } |
| 307 } | 385 } |
| 308 } | 386 } |
| 309 | 387 |
| 310 void UpdateScreen::StartNetworkCheck() { | 388 void UpdateScreen::CancelUpdate() { |
| 311 // If portal detector is enabled and portal detection before AU is | 389 VLOG(1) << "Forced update cancel"; |
| 312 // allowed, initiate network state check. Otherwise, directly | 390 ExitUpdate(REASON_UPDATE_CANCELED); |
| 313 // proceed to update. | 391 } |
| 314 if (!network_portal_detector::GetInstance()->IsEnabled()) { | 392 |
| 315 StartUpdateCheck(); | 393 // TODO(jdufault): This should return a pointer. See crbug.com/672142. |
| 316 return; | 394 base::OneShotTimer& UpdateScreen::GetErrorMessageTimerForTesting() { |
| 317 } | 395 return error_message_timer_; |
| 318 state_ = STATE_FIRST_PORTAL_CHECK; | |
| 319 is_first_detection_notification_ = true; | |
| 320 is_first_portal_notification_ = true; | |
| 321 network_portal_detector::GetInstance()->AddAndFireObserver(this); | |
| 322 } | 396 } |
| 323 | 397 |
| 324 void UpdateScreen::Show() { | 398 void UpdateScreen::Show() { |
| 325 is_shown_ = true; | 399 is_shown_ = true; |
| 326 histogram_helper_->OnScreenShow(); | 400 histogram_helper_->OnScreenShow(); |
| 327 | 401 |
| 328 #if !defined(OFFICIAL_BUILD) | 402 #if !defined(OFFICIAL_BUILD) |
| 329 GetContextEditor().SetBoolean(kContextKeyCancelUpdateShortcutEnabled, true); | 403 GetContextEditor().SetBoolean(kContextKeyCancelUpdateShortcutEnabled, true); |
| 330 #endif | 404 #endif |
| 331 GetContextEditor().SetInteger(kContextKeyProgress, | 405 GetContextEditor().SetInteger(kContextKeyProgress, |
| 332 kBeforeUpdateCheckProgress); | 406 kBeforeUpdateCheckProgress); |
| 333 | 407 |
| 334 if (view_) | 408 if (view_) |
| 335 view_->Show(); | 409 view_->Show(); |
| 336 } | 410 } |
| 337 | 411 |
| 338 void UpdateScreen::Hide() { | 412 void UpdateScreen::Hide() { |
| 339 if (view_) | 413 if (view_) |
| 340 view_->Hide(); | 414 view_->Hide(); |
| 341 is_shown_ = false; | 415 is_shown_ = false; |
| 342 } | 416 } |
| 343 | 417 |
| 344 void UpdateScreen::OnViewDestroyed(UpdateView* view) { | |
| 345 if (view_ == view) | |
| 346 view_ = nullptr; | |
| 347 } | |
| 348 | |
| 349 void UpdateScreen::OnUserAction(const std::string& action_id) { | 418 void UpdateScreen::OnUserAction(const std::string& action_id) { |
| 350 #if !defined(OFFICIAL_BUILD) | 419 #if !defined(OFFICIAL_BUILD) |
| 351 if (action_id == kUserActionCancelUpdateShortcut) | 420 if (action_id == kUserActionCancelUpdateShortcut) |
| 352 CancelUpdate(); | 421 CancelUpdate(); |
| 353 else | 422 else |
| 354 #endif | 423 #endif |
| 355 BaseScreen::OnUserAction(action_id); | 424 BaseScreen::OnUserAction(action_id); |
| 356 } | 425 } |
| 357 | 426 |
| 358 void UpdateScreen::OnContextKeyUpdated( | |
| 359 const ::login::ScreenContext::KeyType& key) { | |
| 360 UpdateModel::OnContextKeyUpdated(key); | |
| 361 } | |
| 362 | |
| 363 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { | |
| 364 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); | |
| 365 network_portal_detector::GetInstance()->RemoveObserver(this); | |
| 366 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); | |
| 367 | |
| 368 | |
| 369 switch (reason) { | |
| 370 case REASON_UPDATE_CANCELED: | |
| 371 Finish(BaseScreenDelegate::UPDATE_NOUPDATE); | |
| 372 break; | |
| 373 case REASON_UPDATE_INIT_FAILED: | |
| 374 Finish(BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE); | |
| 375 break; | |
| 376 case REASON_UPDATE_NON_CRITICAL: | |
| 377 case REASON_UPDATE_ENDED: | |
| 378 { | |
| 379 UpdateEngineClient* update_engine_client = | |
| 380 DBusThreadManager::Get()->GetUpdateEngineClient(); | |
| 381 switch (update_engine_client->GetLastStatus().status) { | |
| 382 case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: | |
| 383 break; | |
| 384 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: | |
| 385 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: | |
| 386 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: | |
| 387 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: | |
| 388 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: | |
| 389 DCHECK(!HasCriticalUpdate()); | |
| 390 // Noncritical update, just exit screen as if there is no update. | |
| 391 // no break | |
| 392 case UpdateEngineClient::UPDATE_STATUS_IDLE: | |
| 393 Finish(BaseScreenDelegate::UPDATE_NOUPDATE); | |
| 394 break; | |
| 395 case UpdateEngineClient::UPDATE_STATUS_ERROR: | |
| 396 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: | |
| 397 if (is_checking_for_update_) { | |
| 398 Finish(BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE); | |
| 399 } else if (HasCriticalUpdate()) { | |
| 400 Finish(BaseScreenDelegate::UPDATE_ERROR_UPDATING_CRITICAL_UPDATE); | |
| 401 } else { | |
| 402 Finish(BaseScreenDelegate::UPDATE_ERROR_UPDATING); | |
| 403 } | |
| 404 break; | |
| 405 default: | |
| 406 NOTREACHED(); | |
| 407 } | |
| 408 } | |
| 409 break; | |
| 410 default: | |
| 411 NOTREACHED(); | |
| 412 } | |
| 413 } | |
| 414 | |
| 415 void UpdateScreen::OnWaitForRebootTimeElapsed() { | |
| 416 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; | |
| 417 MakeSureScreenIsShown(); | |
| 418 GetContextEditor().SetString(kContextKeyUpdateMessage, | |
| 419 l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); | |
| 420 } | |
| 421 | |
| 422 void UpdateScreen::MakeSureScreenIsShown() { | |
| 423 if (!is_shown_) | |
| 424 get_base_screen_delegate()->ShowCurrentScreen(); | |
| 425 } | |
| 426 | |
| 427 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { | |
| 428 ignore_idle_status_ = ignore_idle_status; | |
| 429 } | |
| 430 | |
| 431 void UpdateScreen::CancelUpdate() { | |
| 432 VLOG(1) << "Forced update cancel"; | |
| 433 ExitUpdate(REASON_UPDATE_CANCELED); | |
| 434 } | |
| 435 | |
| 436 void UpdateScreen::UpdateDownloadingStats( | 427 void UpdateScreen::UpdateDownloadingStats( |
| 437 const UpdateEngineClient::Status& status) { | 428 const UpdateEngineClient::Status& status) { |
| 438 base::Time download_current_time = base::Time::Now(); | 429 base::Time download_current_time = base::Time::Now(); |
| 439 if (download_current_time >= | 430 if (download_current_time >= |
| 440 download_last_time_ + | 431 download_last_time_ + |
| 441 base::TimeDelta::FromSeconds(kMinTimeStepInSeconds)) { | 432 base::TimeDelta::FromSeconds(kMinTimeStepInSeconds)) { |
| 442 // Estimate downloading rate. | 433 // Estimate downloading rate. |
| 443 double progress_delta = | 434 double progress_delta = |
| 444 std::max(status.download_progress - download_last_progress_, 0.0); | 435 std::max(status.download_progress - download_last_progress_, 0.0); |
| 445 double time_delta = | 436 double time_delta = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 if (!base::ReadFileToString(update_deadline_file_path, &deadline) || | 487 if (!base::ReadFileToString(update_deadline_file_path, &deadline) || |
| 497 deadline.empty()) { | 488 deadline.empty()) { |
| 498 return false; | 489 return false; |
| 499 } | 490 } |
| 500 | 491 |
| 501 // TODO(dpolukhin): Analyze file content. Now we can just assume that | 492 // TODO(dpolukhin): Analyze file content. Now we can just assume that |
| 502 // if the file exists and not empty, there is critical update. | 493 // if the file exists and not empty, there is critical update. |
| 503 return true; | 494 return true; |
| 504 } | 495 } |
| 505 | 496 |
| 497 void UpdateScreen::OnWaitForRebootTimeElapsed() { |
| 498 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; |
| 499 MakeSureScreenIsShown(); |
| 500 GetContextEditor().SetString(kContextKeyUpdateMessage, |
| 501 l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED)); |
| 502 } |
| 503 |
| 504 void UpdateScreen::MakeSureScreenIsShown() { |
| 505 if (!is_shown_) |
| 506 get_base_screen_delegate()->ShowCurrentScreen(); |
| 507 } |
| 508 |
| 509 void UpdateScreen::SetHostPairingControllerStatus( |
| 510 HostPairingController::UpdateStatus update_status) { |
| 511 if (remora_controller_) { |
| 512 remora_controller_->OnUpdateStatusChanged(update_status); |
| 513 } |
| 514 } |
| 515 |
| 506 ErrorScreen* UpdateScreen::GetErrorScreen() { | 516 ErrorScreen* UpdateScreen::GetErrorScreen() { |
| 507 return get_base_screen_delegate()->GetErrorScreen(); | 517 return get_base_screen_delegate()->GetErrorScreen(); |
| 508 } | 518 } |
| 509 | 519 |
| 510 void UpdateScreen::StartUpdateCheck() { | 520 void UpdateScreen::StartUpdateCheck() { |
| 511 error_message_timer_.Stop(); | 521 error_message_timer_.Stop(); |
| 512 GetErrorScreen()->HideCaptivePortal(); | 522 GetErrorScreen()->HideCaptivePortal(); |
| 513 | 523 |
| 514 network_portal_detector::GetInstance()->RemoveObserver(this); | 524 network_portal_detector::GetInstance()->RemoveObserver(this); |
| 515 connect_request_subscription_.reset(); | 525 connect_request_subscription_.reset(); |
| 516 if (state_ == STATE_ERROR) | 526 if (state_ == State::STATE_ERROR) |
| 517 HideErrorMessage(); | 527 HideErrorMessage(); |
| 518 state_ = STATE_UPDATE; | 528 state_ = State::STATE_UPDATE; |
| 519 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this); | 529 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this); |
| 520 VLOG(1) << "Initiate update check"; | 530 VLOG(1) << "Initiate update check"; |
| 521 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck( | 531 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck( |
| 522 base::Bind(StartUpdateCallback, this)); | 532 base::Bind(StartUpdateCallback, this)); |
| 523 } | 533 } |
| 524 | 534 |
| 525 void UpdateScreen::ShowErrorMessage() { | 535 void UpdateScreen::ShowErrorMessage() { |
| 526 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()"; | 536 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()"; |
| 527 | 537 |
| 528 error_message_timer_.Stop(); | 538 error_message_timer_.Stop(); |
| 529 | 539 |
| 530 state_ = STATE_ERROR; | 540 state_ = State::STATE_ERROR; |
| 531 connect_request_subscription_ = | 541 connect_request_subscription_ = |
| 532 GetErrorScreen()->RegisterConnectRequestCallback(base::Bind( | 542 GetErrorScreen()->RegisterConnectRequestCallback(base::Bind( |
| 533 &UpdateScreen::OnConnectRequested, base::Unretained(this))); | 543 &UpdateScreen::OnConnectRequested, base::Unretained(this))); |
| 534 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_UPDATE); | 544 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_UPDATE); |
| 535 get_base_screen_delegate()->ShowErrorScreen(); | 545 get_base_screen_delegate()->ShowErrorScreen(); |
| 536 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState()); | 546 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState()); |
| 537 } | 547 } |
| 538 | 548 |
| 539 void UpdateScreen::HideErrorMessage() { | 549 void UpdateScreen::HideErrorMessage() { |
| 540 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; | 550 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 566 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | 576 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
| 567 GetErrorScreen()->SetErrorState(NetworkError::ERROR_STATE_PROXY, | 577 GetErrorScreen()->SetErrorState(NetworkError::ERROR_STATE_PROXY, |
| 568 std::string()); | 578 std::string()); |
| 569 break; | 579 break; |
| 570 default: | 580 default: |
| 571 NOTREACHED(); | 581 NOTREACHED(); |
| 572 break; | 582 break; |
| 573 } | 583 } |
| 574 } | 584 } |
| 575 | 585 |
| 576 void UpdateScreen::SetHostPairingControllerStatus( | |
| 577 HostPairingController::UpdateStatus update_status) { | |
| 578 if (remora_controller_) { | |
| 579 remora_controller_->OnUpdateStatusChanged(update_status); | |
| 580 } | |
| 581 } | |
| 582 | |
| 583 void UpdateScreen::DelayErrorMessage() { | 586 void UpdateScreen::DelayErrorMessage() { |
| 584 if (error_message_timer_.IsRunning()) | 587 if (error_message_timer_.IsRunning()) |
| 585 return; | 588 return; |
| 586 | 589 |
| 587 state_ = STATE_ERROR; | 590 state_ = State::STATE_ERROR; |
| 588 error_message_timer_.Start( | 591 error_message_timer_.Start( |
| 589 FROM_HERE, base::TimeDelta::FromSeconds(kDelayErrorMessageSec), this, | 592 FROM_HERE, base::TimeDelta::FromSeconds(kDelayErrorMessageSec), this, |
| 590 &UpdateScreen::ShowErrorMessage); | 593 &UpdateScreen::ShowErrorMessage); |
| 591 } | 594 } |
| 592 | 595 |
| 593 base::OneShotTimer& UpdateScreen::GetErrorMessageTimerForTesting() { | |
| 594 return error_message_timer_; | |
| 595 } | |
| 596 | |
| 597 void UpdateScreen::OnConnectRequested() { | 596 void UpdateScreen::OnConnectRequested() { |
| 598 if (state_ == STATE_ERROR) { | 597 if (state_ == State::STATE_ERROR) { |
| 599 LOG(WARNING) << "Hiding error message since AP was reselected"; | 598 LOG(WARNING) << "Hiding error message since AP was reselected"; |
| 600 StartUpdateCheck(); | 599 StartUpdateCheck(); |
| 601 } | 600 } |
| 602 } | 601 } |
| 603 | 602 |
| 604 } // namespace chromeos | 603 } // namespace chromeos |
| OLD | NEW |