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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
16 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 16 #include "chrome/browser/chromeos/login/screens/update_model.h" |
17 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" | |
18 #include "chromeos/dbus/update_engine_client.h" | 17 #include "chromeos/dbus/update_engine_client.h" |
19 #include "chromeos/network/portal_detector/network_portal_detector.h" | 18 #include "chromeos/network/portal_detector/network_portal_detector.h" |
20 #include "components/pairing/host_pairing_controller.h" | 19 #include "components/pairing/host_pairing_controller.h" |
21 | 20 |
22 namespace chromeos { | 21 namespace chromeos { |
23 | 22 |
24 class BaseScreenDelegate; | 23 class BaseScreenDelegate; |
25 class ErrorScreen; | 24 class ErrorScreen; |
26 class ErrorScreensHistogramHelper; | 25 class ErrorScreensHistogramHelper; |
27 class NetworkState; | 26 class NetworkState; |
28 class ScreenManager; | 27 class ScreenManager; |
| 28 class UpdateView; |
29 | 29 |
30 // Controller for the update screen. It does not depend on the specific | 30 // Controller for the update screen. |
31 // implementation of the screen showing (Views of WebUI based), the dependency | 31 class UpdateScreen : public UpdateModel, |
32 // is moved to the UpdateScreenActor instead. | 32 public UpdateEngineClient::Observer, |
33 class UpdateScreen : public UpdateEngineClient::Observer, | |
34 public UpdateScreenActor::Delegate, | |
35 public BaseScreen, | |
36 public NetworkPortalDetector::Observer { | 33 public NetworkPortalDetector::Observer { |
37 public: | 34 public: |
38 UpdateScreen(BaseScreenDelegate* base_screen_delegate, | 35 UpdateScreen(BaseScreenDelegate* base_screen_delegate, |
39 UpdateScreenActor* actor, | 36 UpdateView* view, |
40 pairing_chromeos::HostPairingController* remora_controller); | 37 pairing_chromeos::HostPairingController* remora_controller); |
41 ~UpdateScreen() override; | 38 ~UpdateScreen() override; |
42 | 39 |
43 static UpdateScreen* Get(ScreenManager* manager); | 40 static UpdateScreen* Get(ScreenManager* manager); |
44 | 41 |
45 // Overridden from BaseScreen. | 42 // UpdateModel: |
46 void PrepareToShow() override; | 43 void PrepareToShow() override; |
47 void Show() override; | 44 void Show() override; |
48 void Hide() override; | 45 void Hide() override; |
49 std::string GetName() const override; | 46 void Initialize(::login::ScreenContext* context) override; |
50 | 47 void OnViewDestroyed(UpdateView* view) override; |
51 // UpdateScreenActor::Delegate implementation: | 48 void OnUserAction(const std::string& action_id) override; |
52 void CancelUpdate() override; | 49 void OnContextKeyUpdated(const ::login::ScreenContext::KeyType& key) override; |
53 void OnActorDestroyed(UpdateScreenActor* actor) override; | |
54 void OnConnectToNetworkRequested() override; | 50 void OnConnectToNetworkRequested() override; |
55 | 51 |
56 // Starts network check. Made virtual to simplify mocking. | 52 // Starts network check. Made virtual to simplify mocking. |
57 virtual void StartNetworkCheck(); | 53 virtual void StartNetworkCheck(); |
58 | 54 |
59 // Reboot check delay get/set, in seconds. | |
60 int reboot_check_delay() const { return reboot_check_delay_; } | |
61 void SetRebootCheckDelay(int seconds); | |
62 | |
63 // Returns true if this instance is still active (i.e. has not been deleted). | 55 // Returns true if this instance is still active (i.e. has not been deleted). |
64 static bool HasInstance(UpdateScreen* inst); | 56 static bool HasInstance(UpdateScreen* inst); |
65 | 57 |
66 void SetIgnoreIdleStatus(bool ignore_idle_status); | 58 void SetIgnoreIdleStatus(bool ignore_idle_status); |
67 | 59 |
68 enum ExitReason { | 60 enum ExitReason { |
69 REASON_UPDATE_CANCELED = 0, | 61 REASON_UPDATE_CANCELED = 0, |
70 REASON_UPDATE_INIT_FAILED, | 62 REASON_UPDATE_INIT_FAILED, |
71 REASON_UPDATE_NON_CRITICAL, | 63 REASON_UPDATE_NON_CRITICAL, |
72 REASON_UPDATE_ENDED | 64 REASON_UPDATE_ENDED |
73 }; | 65 }; |
74 // Reports update results to the BaseScreenDelegate. | 66 // Reports update results to the BaseScreenDelegate. |
75 virtual void ExitUpdate(ExitReason reason); | 67 virtual void ExitUpdate(ExitReason reason); |
76 | 68 |
77 // UpdateEngineClient::Observer implementation: | 69 // UpdateEngineClient::Observer implementation: |
78 void UpdateStatusChanged(const UpdateEngineClient::Status& status) override; | 70 void UpdateStatusChanged(const UpdateEngineClient::Status& status) override; |
79 | 71 |
80 // NetworkPortalDetector::Observer implementation: | 72 // NetworkPortalDetector::Observer implementation: |
81 void OnPortalDetectionCompleted( | 73 void OnPortalDetectionCompleted( |
82 const NetworkState* network, | 74 const NetworkState* network, |
83 const NetworkPortalDetector::CaptivePortalState& state) override; | 75 const NetworkPortalDetector::CaptivePortalState& state) override; |
84 | 76 |
| 77 // Skip update UI, usually used only in debug builds/tests. |
| 78 void CancelUpdate(); |
| 79 |
85 private: | 80 private: |
86 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic); | 81 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestBasic); |
87 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestUpdateAvailable); | 82 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestUpdateAvailable); |
88 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestAPReselection); | 83 FRIEND_TEST_ALL_PREFIXES(UpdateScreenTest, TestAPReselection); |
89 | 84 |
90 enum State { | 85 enum State { |
91 STATE_IDLE = 0, | 86 STATE_IDLE = 0, |
92 STATE_FIRST_PORTAL_CHECK, | 87 STATE_FIRST_PORTAL_CHECK, |
93 STATE_UPDATE, | 88 STATE_UPDATE, |
94 STATE_ERROR | 89 STATE_ERROR |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // Flag that is used to detect when update download has just started. | 137 // Flag that is used to detect when update download has just started. |
143 bool is_downloading_update_; | 138 bool is_downloading_update_; |
144 // If true, update deadlines are ignored. | 139 // If true, update deadlines are ignored. |
145 // Note, this is false by default. | 140 // Note, this is false by default. |
146 bool is_ignore_update_deadlines_; | 141 bool is_ignore_update_deadlines_; |
147 // Whether the update screen is shown. | 142 // Whether the update screen is shown. |
148 bool is_shown_; | 143 bool is_shown_; |
149 // Ignore fist IDLE status that is sent before update screen initiated check. | 144 // Ignore fist IDLE status that is sent before update screen initiated check. |
150 bool ignore_idle_status_; | 145 bool ignore_idle_status_; |
151 | 146 |
152 // Keeps actor which is delegated with all showing operations. | 147 UpdateView* view_; |
153 UpdateScreenActor* actor_; | |
154 | 148 |
155 // Used to track updates over Bluetooth. | 149 // Used to track updates over Bluetooth. |
156 pairing_chromeos::HostPairingController* remora_controller_; | 150 pairing_chromeos::HostPairingController* remora_controller_; |
157 | 151 |
158 // Time of the first notification from the downloading stage. | 152 // Time of the first notification from the downloading stage. |
159 base::Time download_start_time_; | 153 base::Time download_start_time_; |
160 double download_start_progress_; | 154 double download_start_progress_; |
161 | 155 |
162 // Time of the last notification from the downloading stage. | 156 // Time of the last notification from the downloading stage. |
163 base::Time download_last_time_; | 157 base::Time download_last_time_; |
(...skipping 13 matching lines...) Expand all Loading... |
177 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_; | 171 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_; |
178 | 172 |
179 base::WeakPtrFactory<UpdateScreen> weak_factory_; | 173 base::WeakPtrFactory<UpdateScreen> weak_factory_; |
180 | 174 |
181 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); | 175 DISALLOW_COPY_AND_ASSIGN(UpdateScreen); |
182 }; | 176 }; |
183 | 177 |
184 } // namespace chromeos | 178 } // namespace chromeos |
185 | 179 |
186 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ | 180 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_UPDATE_SCREEN_H_ |
OLD | NEW |