| 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" |
| 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/screen_manager.h" | 15 #include "chrome/browser/chromeos/login/screen_manager.h" |
| 15 #include "chrome/browser/chromeos/login/screens/error_screen.h" | 16 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
| 16 #include "chrome/browser/chromeos/login/screens/screen_observer.h" | 17 #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
| 17 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" | 18 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" |
| 18 #include "chrome/browser/chromeos/login/startup_utils.h" | 19 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 19 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 20 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
| 21 #include "chromeos/network/network_state.h" | 22 #include "chromeos/network/network_state.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 | 24 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 InstanceSet::iterator found = instance_set.find(inst); | 85 InstanceSet::iterator found = instance_set.find(inst); |
| 85 return (found != instance_set.end()); | 86 return (found != instance_set.end()); |
| 86 } | 87 } |
| 87 | 88 |
| 88 // static | 89 // static |
| 89 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { | 90 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { |
| 90 return static_cast<UpdateScreen*>( | 91 return static_cast<UpdateScreen*>( |
| 91 manager->GetScreen(WizardController::kUpdateScreenName)); | 92 manager->GetScreen(WizardController::kUpdateScreenName)); |
| 92 } | 93 } |
| 93 | 94 |
| 94 UpdateScreen::UpdateScreen( | 95 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, |
| 95 ScreenObserver* screen_observer, | 96 UpdateScreenActor* actor) |
| 96 UpdateScreenActor* actor) | |
| 97 : WizardScreen(screen_observer), | 97 : WizardScreen(screen_observer), |
| 98 state_(STATE_IDLE), | 98 state_(STATE_IDLE), |
| 99 reboot_check_delay_(0), | 99 reboot_check_delay_(0), |
| 100 is_checking_for_update_(true), | 100 is_checking_for_update_(true), |
| 101 is_downloading_update_(false), | 101 is_downloading_update_(false), |
| 102 is_ignore_update_deadlines_(false), | 102 is_ignore_update_deadlines_(false), |
| 103 is_shown_(false), | 103 is_shown_(false), |
| 104 ignore_idle_status_(true), | 104 ignore_idle_status_(true), |
| 105 actor_(actor), | 105 actor_(actor), |
| 106 is_first_detection_notification_(true), | 106 is_first_detection_notification_(true), |
| 107 is_first_portal_notification_(true), | 107 is_first_portal_notification_(true), |
| 108 histogram_helper_(new ErrorScreensHistogramHelper("Update")), |
| 108 weak_factory_(this) { | 109 weak_factory_(this) { |
| 109 DCHECK(actor_); | 110 DCHECK(actor_); |
| 110 if (actor_) | 111 if (actor_) |
| 111 actor_->SetDelegate(this); | 112 actor_->SetDelegate(this); |
| 112 GetInstanceSet().insert(this); | 113 GetInstanceSet().insert(this); |
| 113 } | 114 } |
| 114 | 115 |
| 115 UpdateScreen::~UpdateScreen() { | 116 UpdateScreen::~UpdateScreen() { |
| 116 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); | 117 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
| 117 NetworkPortalDetector::Get()->RemoveObserver(this); | 118 NetworkPortalDetector::Get()->RemoveObserver(this); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 NetworkPortalDetector::Get()->AddAndFireObserver(this); | 291 NetworkPortalDetector::Get()->AddAndFireObserver(this); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void UpdateScreen::CancelUpdate() { | 294 void UpdateScreen::CancelUpdate() { |
| 294 VLOG(1) << "Forced update cancel"; | 295 VLOG(1) << "Forced update cancel"; |
| 295 ExitUpdate(REASON_UPDATE_CANCELED); | 296 ExitUpdate(REASON_UPDATE_CANCELED); |
| 296 } | 297 } |
| 297 | 298 |
| 298 void UpdateScreen::Show() { | 299 void UpdateScreen::Show() { |
| 299 is_shown_ = true; | 300 is_shown_ = true; |
| 301 histogram_helper_->OnScreenShow(); |
| 300 if (actor_) { | 302 if (actor_) { |
| 301 actor_->Show(); | 303 actor_->Show(); |
| 302 actor_->SetProgress(kBeforeUpdateCheckProgress); | 304 actor_->SetProgress(kBeforeUpdateCheckProgress); |
| 303 } | 305 } |
| 304 } | 306 } |
| 305 | 307 |
| 306 void UpdateScreen::Hide() { | 308 void UpdateScreen::Hide() { |
| 307 if (actor_) | 309 if (actor_) |
| 308 actor_->Hide(); | 310 actor_->Hide(); |
| 309 is_shown_ = false; | 311 is_shown_ = false; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 VLOG(1) << "Initiate update check"; | 483 VLOG(1) << "Initiate update check"; |
| 482 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck( | 484 DBusThreadManager::Get()->GetUpdateEngineClient()->RequestUpdateCheck( |
| 483 base::Bind(StartUpdateCallback, this)); | 485 base::Bind(StartUpdateCallback, this)); |
| 484 } | 486 } |
| 485 | 487 |
| 486 void UpdateScreen::ShowErrorMessage() { | 488 void UpdateScreen::ShowErrorMessage() { |
| 487 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()"; | 489 LOG(WARNING) << "UpdateScreen::ShowErrorMessage()"; |
| 488 state_ = STATE_ERROR; | 490 state_ = STATE_ERROR; |
| 489 GetErrorScreen()->SetUIState(ErrorScreen::UI_STATE_UPDATE); | 491 GetErrorScreen()->SetUIState(ErrorScreen::UI_STATE_UPDATE); |
| 490 get_screen_observer()->ShowErrorScreen(); | 492 get_screen_observer()->ShowErrorScreen(); |
| 493 histogram_helper_->OnErrorShow(GetErrorScreen()->GetErrorState()); |
| 491 } | 494 } |
| 492 | 495 |
| 493 void UpdateScreen::HideErrorMessage() { | 496 void UpdateScreen::HideErrorMessage() { |
| 494 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; | 497 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; |
| 495 get_screen_observer()->HideErrorScreen(this); | 498 get_screen_observer()->HideErrorScreen(this); |
| 499 histogram_helper_->OnErrorHide(); |
| 496 } | 500 } |
| 497 | 501 |
| 498 void UpdateScreen::UpdateErrorMessage( | 502 void UpdateScreen::UpdateErrorMessage( |
| 499 const NetworkState* network, | 503 const NetworkState* network, |
| 500 const NetworkPortalDetector::CaptivePortalStatus status) { | 504 const NetworkPortalDetector::CaptivePortalStatus status) { |
| 501 switch (status) { | 505 switch (status) { |
| 502 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | 506 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: |
| 503 NOTREACHED(); | 507 NOTREACHED(); |
| 504 break; | 508 break; |
| 505 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | 509 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 520 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, | 524 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
| 521 std::string()); | 525 std::string()); |
| 522 break; | 526 break; |
| 523 default: | 527 default: |
| 524 NOTREACHED(); | 528 NOTREACHED(); |
| 525 break; | 529 break; |
| 526 } | 530 } |
| 527 } | 531 } |
| 528 | 532 |
| 529 } // namespace chromeos | 533 } // namespace chromeos |
| OLD | NEW |