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

Side by Side Diff: chrome/browser/chromeos/login/screens/update_screen.cc

Issue 1018523007: ChromeOS: Do not show the error dialog when captive portal is detected in OOBE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed browser tests. Created 5 years, 9 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 unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // estimation. 59 // estimation.
60 // avg_speed = smooth_factor * cur_speed + (1.0 - smooth_factor) * avg_speed. 60 // avg_speed = smooth_factor * cur_speed + (1.0 - smooth_factor) * avg_speed.
61 const double kDownloadSpeedSmoothFactor = 0.1; 61 const double kDownloadSpeedSmoothFactor = 0.1;
62 62
63 // Minumum allowed value for the average downloading speed. 63 // Minumum allowed value for the average downloading speed.
64 const double kDownloadAverageSpeedDropBound = 1e-8; 64 const double kDownloadAverageSpeedDropBound = 1e-8;
65 65
66 // An upper bound for possible downloading time left estimations. 66 // An upper bound for possible downloading time left estimations.
67 const double kMaxTimeLeft = 24 * 60 * 60; 67 const double kMaxTimeLeft = 24 * 60 * 60;
68 68
69 // Delay before showing error message if captive portal is detected.
70 // We wait for this delay to let captive portal to perform redirect and show
71 // its login page before error message appears.
72 const int kDelayErrorMessageSec = 10;
73
69 // Invoked from call to RequestUpdateCheck upon completion of the DBus call. 74 // Invoked from call to RequestUpdateCheck upon completion of the DBus call.
70 void StartUpdateCallback(UpdateScreen* screen, 75 void StartUpdateCallback(UpdateScreen* screen,
71 UpdateEngineClient::UpdateCheckResult result) { 76 UpdateEngineClient::UpdateCheckResult result) {
72 VLOG(1) << "Callback from RequestUpdateCheck, result " << result; 77 VLOG(1) << "Callback from RequestUpdateCheck, result " << result;
73 if (UpdateScreen::HasInstance(screen)) { 78 if (UpdateScreen::HasInstance(screen)) {
74 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS) 79 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS)
75 screen->SetIgnoreIdleStatus(false); 80 screen->SetIgnoreIdleStatus(false);
76 else 81 else
77 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); 82 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED);
78 } 83 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 break; 249 break;
245 default: 250 default:
246 NOTREACHED(); 251 NOTREACHED();
247 break; 252 break;
248 } 253 }
249 } 254 }
250 255
251 void UpdateScreen::OnPortalDetectionCompleted( 256 void UpdateScreen::OnPortalDetectionCompleted(
252 const NetworkState* network, 257 const NetworkState* network,
253 const NetworkPortalDetector::CaptivePortalState& state) { 258 const NetworkPortalDetector::CaptivePortalState& state) {
254 LOG(WARNING) << "UpdateScreen::PortalDetectionCompleted(): " 259 LOG(WARNING) << "UpdateScreen::OnPortalDetectionCompleted(): "
255 << "network=" << (network ? network->path() : "") << ", " 260 << "network=" << (network ? network->path() : "") << ", "
256 << "state.status=" << state.status << ", " 261 << "state.status=" << state.status << ", "
257 << "state.response_code=" << state.response_code; 262 << "state.response_code=" << state.response_code;
258 263
259 // Wait for the sane detection results. 264 // Wait for the sane detection results.
260 if (network && 265 if (network &&
261 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) { 266 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) {
262 return; 267 return;
263 } 268 }
264 269
(...skipping 19 matching lines...) Expand all
284 StartUpdateCheck(); 289 StartUpdateCheck();
285 else 290 else
286 UpdateErrorMessage(network, status); 291 UpdateErrorMessage(network, status);
287 } else if (state_ == STATE_FIRST_PORTAL_CHECK) { 292 } else if (state_ == STATE_FIRST_PORTAL_CHECK) {
288 // In the case of online state immediately proceed to the update 293 // In the case of online state immediately proceed to the update
289 // stage. Otherwise, prepare and show error message. 294 // stage. Otherwise, prepare and show error message.
290 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) { 295 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) {
291 StartUpdateCheck(); 296 StartUpdateCheck();
292 } else { 297 } else {
293 UpdateErrorMessage(network, status); 298 UpdateErrorMessage(network, status);
294 ShowErrorMessage(); 299
300 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL)
301 DelayErrorMessage();
302 else
303 ShowErrorMessage();
295 } 304 }
296 } 305 }
297 } 306 }
298 307
299 void UpdateScreen::StartNetworkCheck() { 308 void UpdateScreen::StartNetworkCheck() {
300 // If portal detector is enabled and portal detection before AU is 309 // If portal detector is enabled and portal detection before AU is
301 // allowed, initiate network state check. Otherwise, directly 310 // allowed, initiate network state check. Otherwise, directly
302 // proceed to update. 311 // proceed to update.
303 if (!NetworkPortalDetector::Get()->IsEnabled()) { 312 if (!NetworkPortalDetector::Get()->IsEnabled()) {
304 StartUpdateCheck(); 313 StartUpdateCheck();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 // TODO(dpolukhin): Analyze file content. Now we can just assume that 511 // TODO(dpolukhin): Analyze file content. Now we can just assume that
503 // if the file exists and not empty, there is critical update. 512 // if the file exists and not empty, there is critical update.
504 return true; 513 return true;
505 } 514 }
506 515
507 ErrorScreen* UpdateScreen::GetErrorScreen() { 516 ErrorScreen* UpdateScreen::GetErrorScreen() {
508 return get_base_screen_delegate()->GetErrorScreen(); 517 return get_base_screen_delegate()->GetErrorScreen();
509 } 518 }
510 519
511 void UpdateScreen::StartUpdateCheck() { 520 void UpdateScreen::StartUpdateCheck() {
521 error_message_timer_.Stop();
522 GetErrorScreen()->HideCaptivePortal();
523
512 NetworkPortalDetector::Get()->RemoveObserver(this); 524 NetworkPortalDetector::Get()->RemoveObserver(this);
513 if (state_ == STATE_ERROR) 525 if (state_ == STATE_ERROR)
514 HideErrorMessage(); 526 HideErrorMessage();
515 state_ = STATE_UPDATE; 527 state_ = STATE_UPDATE;
516 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this); 528 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this);
517 VLOG(1) << "Initiate update check"; 529 VLOG(1) << "Initiate update check";
518 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck( 530 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck(
519 base::Bind(StartUpdateCallback, this)); 531 base::Bind(StartUpdateCallback, this));
520 } 532 }
521 533
522 void UpdateScreen::ShowErrorMessage() { 534 void UpdateScreen::ShowErrorMessage() {
523 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()"; 535 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()";
536
537 error_message_timer_.Stop();
538
524 state_ = STATE_ERROR; 539 state_ = STATE_ERROR;
525 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_UPDATE); 540 GetErrorScreen()->SetUIState(NetworkError::UI_STATE_UPDATE);
526 get_base_screen_delegate()->ShowErrorScreen(); 541 get_base_screen_delegate()->ShowErrorScreen();
527 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState()); 542 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState());
528 } 543 }
529 544
530 void UpdateScreen::HideErrorMessage() { 545 void UpdateScreen::HideErrorMessage() {
531 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; 546 LOG(WARNING) << "UpdateScreen::HideErrorMessage()";
532 get_base_screen_delegate()->HideErrorScreen(this); 547 get_base_screen_delegate()->HideErrorScreen(this);
533 histogram_helper_->OnErrorHide(); 548 histogram_helper_->OnErrorHide();
(...skipping 30 matching lines...) Expand all
564 } 579 }
565 } 580 }
566 581
567 void UpdateScreen::SetHostPairingControllerStatus( 582 void UpdateScreen::SetHostPairingControllerStatus(
568 HostPairingController::UpdateStatus update_status) { 583 HostPairingController::UpdateStatus update_status) {
569 if (remora_controller_) { 584 if (remora_controller_) {
570 remora_controller_->OnUpdateStatusChanged(update_status); 585 remora_controller_->OnUpdateStatusChanged(update_status);
571 } 586 }
572 } 587 }
573 588
589 void UpdateScreen::DelayErrorMessage() {
590 if (error_message_timer_.IsRunning())
591 return;
592
593 state_ = STATE_ERROR;
594 error_message_timer_.Start(
595 FROM_HERE, base::TimeDelta::FromSeconds(kDelayErrorMessageSec), this,
596 &UpdateScreen::ShowErrorMessage);
597 }
598
599 base::OneShotTimer<UpdateScreen>&
600 UpdateScreen::GetErrorMessageTimerForTesting() {
601 return error_message_timer_;
602 }
603
574 } // namespace chromeos 604 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698