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

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

Issue 679133002: ScreenObserver is renamed to BaseScreenDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 6 years, 1 month 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/threading/thread_restrictions.h" 13 #include "base/threading/thread_restrictions.h"
14 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" 14 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
15 #include "chrome/browser/chromeos/login/screen_manager.h" 15 #include "chrome/browser/chromeos/login/screen_manager.h"
16 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
16 #include "chrome/browser/chromeos/login/screens/error_screen.h" 17 #include "chrome/browser/chromeos/login/screens/error_screen.h"
17 #include "chrome/browser/chromeos/login/screens/screen_observer.h"
18 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" 18 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h"
19 #include "chrome/browser/chromeos/login/startup_utils.h" 19 #include "chrome/browser/chromeos/login/startup_utils.h"
20 #include "chrome/browser/chromeos/login/wizard_controller.h" 20 #include "chrome/browser/chromeos/login/wizard_controller.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/network/network_state.h" 22 #include "chromeos/network/network_state.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 24
25 using content::BrowserThread; 25 using content::BrowserThread;
26 using pairing_chromeos::HostPairingController; 26 using pairing_chromeos::HostPairingController;
27 27
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 InstanceSet::iterator found = instance_set.find(inst); 86 InstanceSet::iterator found = instance_set.find(inst);
87 return (found != instance_set.end()); 87 return (found != instance_set.end());
88 } 88 }
89 89
90 // static 90 // static
91 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { 91 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) {
92 return static_cast<UpdateScreen*>( 92 return static_cast<UpdateScreen*>(
93 manager->GetScreen(WizardController::kUpdateScreenName)); 93 manager->GetScreen(WizardController::kUpdateScreenName));
94 } 94 }
95 95
96 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, 96 UpdateScreen::UpdateScreen(BaseScreenDelegate* base_screen_delegate,
97 UpdateScreenActor* actor, 97 UpdateScreenActor* actor,
98 HostPairingController* remora_controller) 98 HostPairingController* remora_controller)
99 : BaseScreen(screen_observer), 99 : BaseScreen(base_screen_delegate),
100 state_(STATE_IDLE), 100 state_(STATE_IDLE),
101 reboot_check_delay_(0), 101 reboot_check_delay_(0),
102 is_checking_for_update_(true), 102 is_checking_for_update_(true),
103 is_downloading_update_(false), 103 is_downloading_update_(false),
104 is_ignore_update_deadlines_(false), 104 is_ignore_update_deadlines_(false),
105 is_shown_(false), 105 is_shown_(false),
106 ignore_idle_status_(true), 106 ignore_idle_status_(true),
107 actor_(actor), 107 actor_(actor),
108 remora_controller_(remora_controller), 108 remora_controller_(remora_controller),
109 is_first_detection_notification_(true), 109 is_first_detection_notification_(true),
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { 330 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) {
331 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 331 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
332 NetworkPortalDetector::Get()->RemoveObserver(this); 332 NetworkPortalDetector::Get()->RemoveObserver(this);
333 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); 333 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED);
334 334
335 335
336 switch (reason) { 336 switch (reason) {
337 case REASON_UPDATE_CANCELED: 337 case REASON_UPDATE_CANCELED:
338 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); 338 get_base_screen_delegate()->OnExit(BaseScreenDelegate::UPDATE_NOUPDATE);
339 break; 339 break;
340 case REASON_UPDATE_INIT_FAILED: 340 case REASON_UPDATE_INIT_FAILED:
341 get_screen_observer()->OnExit( 341 get_base_screen_delegate()->OnExit(
342 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); 342 BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE);
343 break; 343 break;
344 case REASON_UPDATE_NON_CRITICAL: 344 case REASON_UPDATE_NON_CRITICAL:
345 case REASON_UPDATE_ENDED: 345 case REASON_UPDATE_ENDED:
346 { 346 {
347 UpdateEngineClient* update_engine_client = 347 UpdateEngineClient* update_engine_client =
348 DBusThreadManager::Get()->GetUpdateEngineClient(); 348 DBusThreadManager::Get()->GetUpdateEngineClient();
349 switch (update_engine_client->GetLastStatus().status) { 349 switch (update_engine_client->GetLastStatus().status) {
350 case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: 350 case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK:
351 break; 351 break;
352 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: 352 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
353 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: 353 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
354 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: 354 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
355 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: 355 case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
356 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: 356 case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
357 DCHECK(!HasCriticalUpdate()); 357 DCHECK(!HasCriticalUpdate());
358 // Noncritical update, just exit screen as if there is no update. 358 // Noncritical update, just exit screen as if there is no update.
359 // no break 359 // no break
360 case UpdateEngineClient::UPDATE_STATUS_IDLE: 360 case UpdateEngineClient::UPDATE_STATUS_IDLE:
361 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); 361 get_base_screen_delegate()->OnExit(
362 BaseScreenDelegate::UPDATE_NOUPDATE);
362 break; 363 break;
363 case UpdateEngineClient::UPDATE_STATUS_ERROR: 364 case UpdateEngineClient::UPDATE_STATUS_ERROR:
364 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: 365 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
365 get_screen_observer()->OnExit(is_checking_for_update_ ? 366 get_base_screen_delegate()->OnExit(
366 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE : 367 is_checking_for_update_
367 ScreenObserver::UPDATE_ERROR_UPDATING); 368 ? BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE
369 : BaseScreenDelegate::UPDATE_ERROR_UPDATING);
368 break; 370 break;
369 default: 371 default:
370 NOTREACHED(); 372 NOTREACHED();
371 } 373 }
372 } 374 }
373 break; 375 break;
374 default: 376 default:
375 NOTREACHED(); 377 NOTREACHED();
376 } 378 }
377 } 379 }
378 380
379 void UpdateScreen::OnWaitForRebootTimeElapsed() { 381 void UpdateScreen::OnWaitForRebootTimeElapsed() {
380 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; 382 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot.";
381 MakeSureScreenIsShown(); 383 MakeSureScreenIsShown();
382 if (actor_) 384 if (actor_)
383 actor_->ShowManualRebootInfo(); 385 actor_->ShowManualRebootInfo();
384 } 386 }
385 387
386 void UpdateScreen::MakeSureScreenIsShown() { 388 void UpdateScreen::MakeSureScreenIsShown() {
387 if (!is_shown_) 389 if (!is_shown_)
388 get_screen_observer()->ShowCurrentScreen(); 390 get_base_screen_delegate()->ShowCurrentScreen();
389 } 391 }
390 392
391 void UpdateScreen::SetRebootCheckDelay(int seconds) { 393 void UpdateScreen::SetRebootCheckDelay(int seconds) {
392 if (seconds <= 0) 394 if (seconds <= 0)
393 reboot_timer_.Stop(); 395 reboot_timer_.Stop();
394 DCHECK(!reboot_timer_.IsRunning()); 396 DCHECK(!reboot_timer_.IsRunning());
395 reboot_check_delay_ = seconds; 397 reboot_check_delay_ = seconds;
396 } 398 }
397 399
398 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { 400 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 475 }
474 476
475 void UpdateScreen::OnConnectToNetworkRequested() { 477 void UpdateScreen::OnConnectToNetworkRequested() {
476 if (state_ == STATE_ERROR) { 478 if (state_ == STATE_ERROR) {
477 LOG(WARNING) << "Hiding error message since AP was reselected"; 479 LOG(WARNING) << "Hiding error message since AP was reselected";
478 StartUpdateCheck(); 480 StartUpdateCheck();
479 } 481 }
480 } 482 }
481 483
482 ErrorScreen* UpdateScreen::GetErrorScreen() { 484 ErrorScreen* UpdateScreen::GetErrorScreen() {
483 return get_screen_observer()->GetErrorScreen(); 485 return get_base_screen_delegate()->GetErrorScreen();
484 } 486 }
485 487
486 void UpdateScreen::StartUpdateCheck() { 488 void UpdateScreen::StartUpdateCheck() {
487 NetworkPortalDetector::Get()->RemoveObserver(this); 489 NetworkPortalDetector::Get()->RemoveObserver(this);
488 if (state_ == STATE_ERROR) 490 if (state_ == STATE_ERROR)
489 HideErrorMessage(); 491 HideErrorMessage();
490 state_ = STATE_UPDATE; 492 state_ = STATE_UPDATE;
491 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this); 493 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this);
492 VLOG(1) << "Initiate update check"; 494 VLOG(1) << "Initiate update check";
493 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck( 495 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck(
494 base::Bind(StartUpdateCallback, this)); 496 base::Bind(StartUpdateCallback, this));
495 } 497 }
496 498
497 void UpdateScreen::ShowErrorMessage() { 499 void UpdateScreen::ShowErrorMessage() {
498 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()"; 500 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()";
499 state_ = STATE_ERROR; 501 state_ = STATE_ERROR;
500 GetErrorScreen()->SetUIState(ErrorScreen::UI_STATE_UPDATE); 502 GetErrorScreen()->SetUIState(ErrorScreen::UI_STATE_UPDATE);
501 get_screen_observer()->ShowErrorScreen(); 503 get_base_screen_delegate()->ShowErrorScreen();
502 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState()); 504 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState());
503 } 505 }
504 506
505 void UpdateScreen::HideErrorMessage() { 507 void UpdateScreen::HideErrorMessage() {
506 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; 508 LOG(WARNING) << "UpdateScreen::HideErrorMessage()";
507 get_screen_observer()->HideErrorScreen(this); 509 get_base_screen_delegate()->HideErrorScreen(this);
508 histogram_helper_->OnErrorHide(); 510 histogram_helper_->OnErrorHide();
509 } 511 }
510 512
511 void UpdateScreen::UpdateErrorMessage( 513 void UpdateScreen::UpdateErrorMessage(
512 const NetworkState* network, 514 const NetworkState* network,
513 const NetworkPortalDetector::CaptivePortalStatus status) { 515 const NetworkPortalDetector::CaptivePortalStatus status) {
514 switch (status) { 516 switch (status) {
515 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: 517 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE:
516 NOTREACHED(); 518 NOTREACHED();
517 break; 519 break;
(...skipping 22 matching lines...) Expand all
540 } 542 }
541 543
542 void UpdateScreen::SetHostPairingControllerStatus( 544 void UpdateScreen::SetHostPairingControllerStatus(
543 HostPairingController::UpdateStatus update_status) { 545 HostPairingController::UpdateStatus update_status) {
544 if (remora_controller_) { 546 if (remora_controller_) {
545 remora_controller_->OnUpdateStatusChanged(update_status); 547 remora_controller_->OnUpdateStatusChanged(update_status);
546 } 548 }
547 } 549 }
548 550
549 } // namespace chromeos 551 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698