Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 depends on the specific |
|
whywhat
2011/05/20 09:29:50
nit: depends -> depend
altimofeev
2011/05/20 12:00:32
Done.
| |
| 25 public UpdateLibrary::Observer, | 23 // realization of the screen showing (Views of WebUI based), it delegates it to |
|
whywhat
2011/05/20 09:29:50
nit: realization -> implementation, it delegates i
altimofeev
2011/05/20 12:00:32
Done.
| |
| 26 public UpdateController { | 24 // 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 updates if needed. Made virtual to simplify mocking. |
|
whywhat
2011/05/20 09:29:50
nit: second "updates" -> performs an update
altimofeev
2011/05/20 12:00:32
Done.
| |
| 35 virtual void StartUpdate(); | 37 virtual void StartUpdate(); |
| 38 | |
| 39 // Force udpate cancel. Made virtual to simplify mocking. | |
|
whywhat
2011/05/20 09:29:50
nit: Force cancel update (udpate -> update and can
altimofeev
2011/05/20 12:00:32
Done.
nit: cancel is a noun too.
| |
| 36 virtual void CancelUpdate(); | 40 virtual void CancelUpdate(); |
| 37 | 41 |
| 38 // Overridden from ViewScreen. | 42 // Reboot check delay get/set, in seconds. |
| 39 virtual void Show(); | 43 int reboot_check_delay() const { return reboot_check_delay_; } |
| 44 void SetRebootCheckDelay(int seconds); | |
| 45 | |
| 46 // Set flag to treat all updates as critical (for test purpose mainly). | |
| 47 // Default value is false. | |
| 48 void SetAllUpdatesCritical(bool is_critical); | |
|
whywhat
2011/05/20 09:29:50
If it's only for tests, why not make it private an
altimofeev
2011/05/20 12:00:32
Then I can completely remove it - done.
| |
| 49 | |
| 50 // Returns true if this instance is still active (i.e. has not been deleted). | |
| 51 static bool HasInstance(UpdateScreen* inst); | |
| 40 | 52 |
| 41 enum ExitReason { | 53 enum ExitReason { |
| 42 REASON_UPDATE_CANCELED, | 54 REASON_UPDATE_CANCELED, |
| 43 REASON_UPDATE_INIT_FAILED, | 55 REASON_UPDATE_INIT_FAILED, |
| 44 REASON_UPDATE_NON_CRITICAL, | 56 REASON_UPDATE_NON_CRITICAL, |
| 45 REASON_UPDATE_ENDED | 57 REASON_UPDATE_ENDED |
| 46 }; | 58 }; |
| 47 | |
| 48 // Reports update results to the ScreenObserver. | 59 // Reports update results to the ScreenObserver. |
| 49 virtual void ExitUpdate(ExitReason reason); | 60 virtual void ExitUpdate(ExitReason reason); |
| 50 | 61 |
| 51 // Reboot check delay get/set, in seconds. | 62 private: |
| 52 int reboot_check_delay() const { return reboot_check_delay_; } | 63 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic); |
| 53 void SetRebootCheckDelay(int seconds); | 64 |
| 65 // UpdateLibrary::Observer implementation: | |
| 66 virtual void UpdateStatusChanged(UpdateLibrary* library); | |
| 54 | 67 |
| 55 // Returns true if there is critical system update that requires installation | 68 // Returns true if there is critical system update that requires installation |
| 56 // and immediate reboot. | 69 // and immediate reboot. |
| 57 bool HasCriticalUpdate(); | 70 bool HasCriticalUpdate(); |
| 58 | 71 |
| 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. | 72 // Timer notification handlers. |
| 68 void OnWaitForRebootTimeElapsed(); | 73 void OnWaitForRebootTimeElapsed(); |
| 69 | 74 |
| 70 // Checks that screen is shown, shows if not. | 75 // Checks that screen is shown, shows if not. |
| 71 void MakeSureScreenIsShown(); | 76 void MakeSureScreenIsShown(); |
| 72 | 77 |
| 73 // Timer for the interval to wait for the reboot. | 78 // Timer for the interval to wait for the reboot. |
| 74 // If reboot didn't happen - ask user to reboot manually. | 79 // If reboot didn't happen - ask user to reboot manually. |
| 75 base::OneShotTimer<UpdateScreen> reboot_timer_; | 80 base::OneShotTimer<UpdateScreen> reboot_timer_; |
| 76 | 81 |
| 77 // Returns a static InstanceSet. | 82 // Returns a static InstanceSet. |
| 78 typedef std::set<UpdateScreen*> InstanceSet; | 83 typedef std::set<UpdateScreen*> InstanceSet; |
| 79 static InstanceSet& GetInstanceSet(); | 84 static InstanceSet& GetInstanceSet(); |
| 80 | 85 |
| 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 | 86 // 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 | 87 // automatically. If reboot didn't happen during this interval, ask user to |
| 86 // reboot device manually. | 88 // reboot device manually. |
| 87 int reboot_check_delay_; | 89 int reboot_check_delay_; |
| 88 | 90 |
| 91 // Is all updates critical? If true, update deadlines are ignored. | |
|
whywhat
2011/05/20 09:29:50
nit: Is -> Are
altimofeev
2011/05/20 12:00:32
Done.
| |
| 92 bool is_all_updates_critical_; | |
|
whywhat
2011/05/20 09:29:50
optional: there too. or maybe rename to ignore_upd
altimofeev
2011/05/20 12:00:32
Done.
| |
| 93 // True if in the process of checking for update. | |
| 94 bool is_checking_for_update_; | |
| 89 // Flag that is used to detect when update download has just started. | 95 // Flag that is used to detect when update download has just started. |
| 90 bool is_downloading_update_; | 96 bool is_downloading_update_; |
| 97 // Whether the update screen is shown. | |
| 98 bool is_shown_; | |
| 91 | 99 |
| 92 // Is all updates critical? If true, update deadlines are ignored. | 100 // Keeps actor which is delegated with all showing operations. |
| 93 bool is_all_updates_critical_; | 101 scoped_ptr<UpdateScreenActor> actor_; |
| 94 | 102 |
| 95 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); | 103 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); |
| 96 }; | 104 }; |
| 97 | 105 |
| 98 } // namespace chromeos | 106 } // namespace chromeos |
| 99 | 107 |
| 100 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ | 108 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UPDATE_SCREEN_H_ |
| OLD | NEW |