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/screen_manager.h" | 14 #include "chrome/browser/chromeos/login/screen_manager.h" |
15 #include "chrome/browser/chromeos/login/screens/error_screen.h" | 15 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
16 #include "chrome/browser/chromeos/login/screens/screen_observer.h" | 16 #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
17 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" | 17 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" |
18 #include "chrome/browser/chromeos/login/startup_utils.h" | 18 #include "chrome/browser/chromeos/login/startup_utils.h" |
19 #include "chrome/browser/chromeos/login/wizard_controller.h" | 19 #include "chrome/browser/chromeos/login/wizard_controller.h" |
20 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
21 #include "chromeos/network/network_state.h" | 21 #include "chromeos/network/network_state.h" |
22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
| 25 using pairing_chromeos::HostPairingController; |
25 | 26 |
26 namespace chromeos { | 27 namespace chromeos { |
27 | 28 |
28 namespace { | 29 namespace { |
29 | 30 |
30 // Progress bar stages. Each represents progress bar value | 31 // Progress bar stages. Each represents progress bar value |
31 // at the beginning of each stage. | 32 // at the beginning of each stage. |
32 // TODO(nkostylev): Base stage progress values on approximate time. | 33 // TODO(nkostylev): Base stage progress values on approximate time. |
33 // TODO(nkostylev): Animate progress during each state. | 34 // TODO(nkostylev): Animate progress during each state. |
34 const int kBeforeUpdateCheckProgress = 7; | 35 const int kBeforeUpdateCheckProgress = 7; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( |
95 ScreenObserver* screen_observer, | 96 ScreenObserver* screen_observer, |
96 UpdateScreenActor* actor) | 97 UpdateScreenActor* actor, |
| 98 HostPairingController* remora_controller) |
97 : WizardScreen(screen_observer), | 99 : WizardScreen(screen_observer), |
98 state_(STATE_IDLE), | 100 state_(STATE_IDLE), |
99 reboot_check_delay_(0), | 101 reboot_check_delay_(0), |
100 is_checking_for_update_(true), | 102 is_checking_for_update_(true), |
101 is_downloading_update_(false), | 103 is_downloading_update_(false), |
102 is_ignore_update_deadlines_(false), | 104 is_ignore_update_deadlines_(false), |
103 is_shown_(false), | 105 is_shown_(false), |
104 ignore_idle_status_(true), | 106 ignore_idle_status_(true), |
105 actor_(actor), | 107 actor_(actor), |
| 108 remora_controller_(remora_controller), |
106 is_first_detection_notification_(true), | 109 is_first_detection_notification_(true), |
107 is_first_portal_notification_(true), | 110 is_first_portal_notification_(true), |
108 weak_factory_(this) { | 111 weak_factory_(this) { |
109 DCHECK(actor_); | 112 DCHECK(actor_); |
110 if (actor_) | 113 if (actor_) |
111 actor_->SetDelegate(this); | 114 actor_->SetDelegate(this); |
112 GetInstanceSet().insert(this); | 115 GetInstanceSet().insert(this); |
113 } | 116 } |
114 | 117 |
115 UpdateScreen::~UpdateScreen() { | 118 UpdateScreen::~UpdateScreen() { |
(...skipping 15 matching lines...) Expand all Loading... |
131 } | 134 } |
132 if (ignore_idle_status_ && status.status > | 135 if (ignore_idle_status_ && status.status > |
133 UpdateEngineClient::UPDATE_STATUS_IDLE) { | 136 UpdateEngineClient::UPDATE_STATUS_IDLE) { |
134 ignore_idle_status_ = false; | 137 ignore_idle_status_ = false; |
135 } | 138 } |
136 | 139 |
137 switch (status.status) { | 140 switch (status.status) { |
138 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: | 141 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: |
139 // Do nothing in these cases, we don't want to notify the user of the | 142 // Do nothing in these cases, we don't want to notify the user of the |
140 // check unless there is an update. | 143 // check unless there is an update. |
| 144 SetHostPairingControllerStatus( |
| 145 HostPairingController::UPDATE_STATUS_UPDATING); |
141 break; | 146 break; |
142 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: | 147 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: |
143 MakeSureScreenIsShown(); | 148 MakeSureScreenIsShown(); |
144 actor_->SetProgress(kBeforeDownloadProgress); | 149 actor_->SetProgress(kBeforeDownloadProgress); |
145 actor_->ShowEstimatedTimeLeft(false); | 150 actor_->ShowEstimatedTimeLeft(false); |
146 if (!HasCriticalUpdate()) { | 151 if (!HasCriticalUpdate()) { |
147 VLOG(1) << "Noncritical update available: " << status.new_version; | 152 VLOG(1) << "Noncritical update available: " << status.new_version; |
148 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 153 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
149 } else { | 154 } else { |
150 VLOG(1) << "Critical update available: " << status.new_version; | 155 VLOG(1) << "Critical update available: " << status.new_version; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 UpdateScreenActor::PROGRESS_MESSAGE_FINALIZING); | 198 UpdateScreenActor::PROGRESS_MESSAGE_FINALIZING); |
194 actor_->ShowProgressMessage(true); | 199 actor_->ShowProgressMessage(true); |
195 break; | 200 break; |
196 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: | 201 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
197 MakeSureScreenIsShown(); | 202 MakeSureScreenIsShown(); |
198 actor_->SetProgress(kProgressComplete); | 203 actor_->SetProgress(kProgressComplete); |
199 actor_->ShowEstimatedTimeLeft(false); | 204 actor_->ShowEstimatedTimeLeft(false); |
200 if (HasCriticalUpdate()) { | 205 if (HasCriticalUpdate()) { |
201 actor_->ShowCurtain(false); | 206 actor_->ShowCurtain(false); |
202 VLOG(1) << "Initiate reboot after update"; | 207 VLOG(1) << "Initiate reboot after update"; |
| 208 SetHostPairingControllerStatus( |
| 209 HostPairingController::UPDATE_STATUS_REBOOTING); |
203 DBusThreadManager::Get()->GetUpdateEngineClient()->RebootAfterUpdate(); | 210 DBusThreadManager::Get()->GetUpdateEngineClient()->RebootAfterUpdate(); |
204 reboot_timer_.Start(FROM_HERE, | 211 reboot_timer_.Start(FROM_HERE, |
205 base::TimeDelta::FromSeconds(reboot_check_delay_), | 212 base::TimeDelta::FromSeconds(reboot_check_delay_), |
206 this, | 213 this, |
207 &UpdateScreen::OnWaitForRebootTimeElapsed); | 214 &UpdateScreen::OnWaitForRebootTimeElapsed); |
208 } else { | 215 } else { |
209 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 216 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
210 } | 217 } |
211 break; | 218 break; |
212 case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: | 219 case UpdateEngineClient::UPDATE_STATUS_ATTEMPTING_ROLLBACK: |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 321 } |
315 | 322 |
316 void UpdateScreen::PrepareToShow() { | 323 void UpdateScreen::PrepareToShow() { |
317 if (actor_) | 324 if (actor_) |
318 actor_->PrepareToShow(); | 325 actor_->PrepareToShow(); |
319 } | 326 } |
320 | 327 |
321 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { | 328 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { |
322 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); | 329 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); |
323 NetworkPortalDetector::Get()->RemoveObserver(this); | 330 NetworkPortalDetector::Get()->RemoveObserver(this); |
| 331 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); |
| 332 |
324 | 333 |
325 switch (reason) { | 334 switch (reason) { |
326 case REASON_UPDATE_CANCELED: | 335 case REASON_UPDATE_CANCELED: |
327 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); | 336 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); |
328 break; | 337 break; |
329 case REASON_UPDATE_INIT_FAILED: | 338 case REASON_UPDATE_INIT_FAILED: |
330 get_screen_observer()->OnExit( | 339 get_screen_observer()->OnExit( |
331 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); | 340 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
332 break; | 341 break; |
333 case REASON_UPDATE_NON_CRITICAL: | 342 case REASON_UPDATE_NON_CRITICAL: |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | 528 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
520 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, | 529 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
521 std::string()); | 530 std::string()); |
522 break; | 531 break; |
523 default: | 532 default: |
524 NOTREACHED(); | 533 NOTREACHED(); |
525 break; | 534 break; |
526 } | 535 } |
527 } | 536 } |
528 | 537 |
| 538 void UpdateScreen::SetHostPairingControllerStatus( |
| 539 HostPairingController::UpdateStatus update_status) { |
| 540 if (remora_controller_) { |
| 541 remora_controller_->OnUpdateStatusChanged(update_status); |
| 542 } |
| 543 } |
| 544 |
529 } // namespace chromeos | 545 } // namespace chromeos |
OLD | NEW |