update_screen.h revision 201ade2fbba22bfb27ae029f4d23fca6ded109a0
1// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ 6#define CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ 7#pragma once 8 9#include "base/timer.h" 10#include "chrome/browser/chromeos/cros/update_library.h" 11#include "chrome/browser/chromeos/login/update_view.h" 12#include "chrome/browser/chromeos/login/view_screen.h" 13 14namespace chromeos { 15 16class UpdateController { 17 public: 18 // Starts update. 19 virtual void StartUpdate() = 0; 20 // Cancels pending update without error. 21 virtual void CancelUpdate() = 0; 22}; 23 24class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView>, 25 public UpdateLibrary::Observer, 26 public UpdateController { 27 public: 28 explicit UpdateScreen(WizardScreenDelegate* delegate); 29 virtual ~UpdateScreen(); 30 31 // UpdateLibrary::Observer implementation: 32 virtual void UpdateStatusChanged(UpdateLibrary* library); 33 34 // Overridden from UpdateController: 35 virtual void StartUpdate(); 36 virtual void CancelUpdate(); 37 38 // Reports update results to the ScreenObserver. 39 // |forced| should be set to true when calling this method and update status 40 // is not one of UPDATE_STATUS_IDLE, UPDATE_STATUS_ERROR, 41 // UPDATE_STATUS_REPORTING_ERROR_EVENT. 42 virtual void ExitUpdate(bool forced); 43 44 // Reboot check delay get/set, in seconds. 45 int reboot_check_delay() const { return reboot_check_delay_; } 46 void SetRebootCheckDelay(int seconds); 47 48 // Returns true if there is critical system update that requires installation 49 // and immediate reboot. 50 bool HasCriticalUpdate(); 51 52 // Set flag to treat all updates as critical (for test purpose mainly). 53 // Default value is false. 54 void SetAllUpdatesCritical(bool is_critical); 55 56 private: 57 // Timer notification handlers. 58 void OnWaitForRebootTimeElapsed(); 59 60 // Timer for the interval to wait for the reboot. 61 // If reboot didn't happen - ask user to reboot manually. 62 base::OneShotTimer<UpdateScreen> reboot_timer_; 63 64 // True if in the process of checking for update. 65 bool checking_for_update_; 66 67 // Time in seconds after which we decide that the device has not rebooted 68 // automatically. If reboot didn't happen during this interval, ask user to 69 // reboot device manually. 70 int reboot_check_delay_; 71 72 // Flag that is used to detect when update download has just started. 73 bool is_downloading_update_; 74 75 // Is all updates critical? If true, update deadlines are ignored. 76 bool is_all_updates_critical_; 77 78 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); 79}; 80 81} // namespace chromeos 82 83#endif // CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ 84