| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> |
| 10 |
| 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/timer.h" | 13 #include "base/timer.h" |
| 10 #include "chrome/browser/chromeos/cros/update_library.h" | 14 #include "chrome/browser/chromeos/cros/update_library.h" |
| 11 #include "chrome/browser/chromeos/login/update_view.h" | 15 #include "chrome/browser/chromeos/login/wizard_screen.h" |
| 12 #include "chrome/browser/chromeos/login/view_screen.h" | |
| 13 | 16 |
| 14 namespace chromeos { | 17 namespace chromeos { |
| 15 | 18 |
| 16 class UpdateController { | 19 // Forward declaration. |
| 17 public: | 20 class UpdateScreenActor; |
| 18 // Starts update. | |
| 19 virtual void StartUpdate() = 0; | |
| 20 // Cancels pending update without error. | |
| 21 virtual void CancelUpdate() = 0; | |
| 22 }; | |
| 23 | 21 |
| 24 class UpdateScreen: public DefaultViewScreen<chromeos::UpdateView>, | 22 // Controller for the update screen. It does not depend on the specific |
| 25 public UpdateLibrary::Observer, | 23 // implementation of the screen showing (Views of WebUI based), the dependency |
| 26 public UpdateController { | 24 // is moved to the UpdateScreenActor instead. |
| 25 class UpdateScreen: public UpdateLibrary::Observer, |
| 26 public WizardScreen { |
| 27 public: | 27 public: |
| 28 explicit UpdateScreen(WizardScreenDelegate* delegate); | 28 explicit UpdateScreen(WizardScreenDelegate* delegate); |
| 29 virtual ~UpdateScreen(); | 29 virtual ~UpdateScreen(); |
| 30 | 30 |
| 31 // UpdateLibrary::Observer implementation: | 31 // Overridden from WizardScreen. |
| 32 virtual void UpdateStatusChanged(UpdateLibrary* library); | 32 virtual void Show(); |
| 33 virtual void Hide(); |
| 34 virtual gfx::Size GetScreenSize() const; |
| 33 | 35 |
| 34 // Overridden from UpdateController: | 36 // Checks for updates and performs an update if needed. Made virtual to |
| 37 // simplify mocking. |
| 35 virtual void StartUpdate(); | 38 virtual void StartUpdate(); |
| 39 |
| 40 // Force cancel update. Made virtual to simplify mocking. |
| 36 virtual void CancelUpdate(); | 41 virtual void CancelUpdate(); |
| 37 | 42 |
| 38 // Overridden from ViewScreen. | 43 // Reboot check delay get/set, in seconds. |
| 39 virtual void Show(); | 44 int reboot_check_delay() const { return reboot_check_delay_; } |
| 45 void SetRebootCheckDelay(int seconds); |
| 46 |
| 47 // Returns true if this instance is still active (i.e. has not been deleted). |
| 48 static bool HasInstance(UpdateScreen* inst); |
| 40 | 49 |
| 41 enum ExitReason { | 50 enum ExitReason { |
| 42 REASON_UPDATE_CANCELED, | 51 REASON_UPDATE_CANCELED, |
| 43 REASON_UPDATE_INIT_FAILED, | 52 REASON_UPDATE_INIT_FAILED, |
| 44 REASON_UPDATE_NON_CRITICAL, | 53 REASON_UPDATE_NON_CRITICAL, |
| 45 REASON_UPDATE_ENDED | 54 REASON_UPDATE_ENDED |
| 46 }; | 55 }; |
| 47 | |
| 48 // Reports update results to the ScreenObserver. | 56 // Reports update results to the ScreenObserver. |
| 49 virtual void ExitUpdate(ExitReason reason); | 57 virtual void ExitUpdate(ExitReason reason); |
| 50 | 58 |
| 51 // Reboot check delay get/set, in seconds. | 59 // UpdateLibrary::Observer implementation: |
| 52 int reboot_check_delay() const { return reboot_check_delay_; } | 60 virtual void UpdateStatusChanged(UpdateLibrary* library); |
| 53 void SetRebootCheckDelay(int seconds); | 61 |
| 62 private: |
| 63 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic); |
| 64 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestUpdateAvailable); |
| 54 | 65 |
| 55 // Returns true if there is critical system update that requires installation | 66 // Returns true if there is critical system update that requires installation |
| 56 // and immediate reboot. | 67 // and immediate reboot. |
| 57 bool HasCriticalUpdate(); | 68 bool HasCriticalUpdate(); |
| 58 | 69 |
| 59 // Set flag to treat all updates as critical (for test purpose mainly). | |
| 60 // Default value is false. | |
| 61 void SetAllUpdatesCritical(bool is_critical); | |
| 62 | |
| 63 // Returns true if this instance is still active (i.e. has not been deleted). | |
| 64 static bool HasInstance(UpdateScreen* inst); | |
| 65 | |
| 66 private: | |
| 67 // Timer notification handlers. | 70 // Timer notification handlers. |
| 68 void OnWaitForRebootTimeElapsed(); | 71 void OnWaitForRebootTimeElapsed(); |
| 69 | 72 |
| 70 // Checks that screen is shown, shows if not. | 73 // Checks that screen is shown, shows if not. |
| 71 void MakeSureScreenIsShown(); | 74 void MakeSureScreenIsShown(); |
| 72 | 75 |
| 73 // Timer for the interval to wait for the reboot. | 76 // Timer for the interval to wait for the reboot. |
| 74 // If reboot didn't happen - ask user to reboot manually. | 77 // If reboot didn't happen - ask user to reboot manually. |
| 75 base::OneShotTimer<UpdateScreen> reboot_timer_; | 78 base::OneShotTimer<UpdateScreen> reboot_timer_; |
| 76 | 79 |
| 77 // Returns a static InstanceSet. | 80 // Returns a static InstanceSet. |
| 78 typedef std::set<UpdateScreen*> InstanceSet; | 81 typedef std::set<UpdateScreen*> InstanceSet; |
| 79 static InstanceSet& GetInstanceSet(); | 82 static InstanceSet& GetInstanceSet(); |
| 80 | 83 |
| 81 // True if in the process of checking for update. | |
| 82 bool checking_for_update_; | |
| 83 | |
| 84 // Time in seconds after which we decide that the device has not rebooted | 84 // Time in seconds after which we decide that the device has not rebooted |
| 85 // automatically. If reboot didn't happen during this interval, ask user to | 85 // automatically. If reboot didn't happen during this interval, ask user to |
| 86 // reboot device manually. | 86 // reboot device manually. |
| 87 int reboot_check_delay_; | 87 int reboot_check_delay_; |
| 88 | 88 |
| 89 // True if in the process of checking for update. |
| 90 bool is_checking_for_update_; |
| 89 // Flag that is used to detect when update download has just started. | 91 // Flag that is used to detect when update download has just started. |
| 90 bool is_downloading_update_; | 92 bool is_downloading_update_; |
| 93 // If true, update deadlines are ignored. |
| 94 // Note, this is true by default. See "http://crosbug.com/10068". |
| 95 bool is_ignore_update_deadlines_; |
| 96 // Whether the update screen is shown. |
| 97 bool is_shown_; |
| 91 | 98 |
| 92 // Is all updates critical? If true, update deadlines are ignored. | 99 // Keeps actor which is delegated with all showing operations. |
| 93 bool is_all_updates_critical_; | 100 scoped_ptr<UpdateScreenActor> actor_; |
| 94 | 101 |
| 95 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); | 102 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); |
| 96 }; | 103 }; |
| 97 | 104 |
| 98 } // namespace chromeos | 105 } // namespace chromeos |
| 99 | 106 |
| 100 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ | 107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ |
| OLD | NEW |