Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/chromeos/login/screens/update_screen.cc

Issue 863263006: Migrating UpdateScreen to ScreenContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: refactor Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/error_screens_histogram_helper.h" 14 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
15 #include "chrome/browser/chromeos/login/screen_manager.h" 15 #include "chrome/browser/chromeos/login/screen_manager.h"
16 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" 16 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
17 #include "chrome/browser/chromeos/login/screens/error_screen.h" 17 #include "chrome/browser/chromeos/login/screens/error_screen.h"
18 #include "chrome/browser/chromeos/login/screens/update_screen_actor.h" 18 #include "chrome/browser/chromeos/login/screens/update_view.h"
19 #include "chrome/browser/chromeos/login/startup_utils.h" 19 #include "chrome/browser/chromeos/login/startup_utils.h"
20 #include "chrome/browser/chromeos/login/wizard_controller.h" 20 #include "chrome/browser/chromeos/login/wizard_controller.h"
21 #include "chrome/grit/chromium_strings.h"
22 #include "chrome/grit/generated_resources.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 23 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/network/network_state.h" 24 #include "chromeos/network/network_state.h"
23 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "ui/base/l10n/l10n_util.h"
24 27
25 using content::BrowserThread; 28 using content::BrowserThread;
26 using pairing_chromeos::HostPairingController; 29 using pairing_chromeos::HostPairingController;
27 30
28 namespace chromeos { 31 namespace chromeos {
29 32
30 namespace { 33 namespace {
31 34
35 // If reboot didn't happen, ask user to reboot device manually.
36 const int kWaitForRebootTimeSec = 3;
37
32 // Progress bar stages. Each represents progress bar value 38 // Progress bar stages. Each represents progress bar value
33 // at the beginning of each stage. 39 // at the beginning of each stage.
34 // TODO(nkostylev): Base stage progress values on approximate time. 40 // TODO(nkostylev): Base stage progress values on approximate time.
35 // TODO(nkostylev): Animate progress during each state. 41 // TODO(nkostylev): Animate progress during each state.
36 const int kBeforeUpdateCheckProgress = 7; 42 const int kBeforeUpdateCheckProgress = 7;
37 const int kBeforeDownloadProgress = 14; 43 const int kBeforeDownloadProgress = 14;
38 const int kBeforeVerifyingProgress = 74; 44 const int kBeforeVerifyingProgress = 74;
39 const int kBeforeFinalizingProgress = 81; 45 const int kBeforeFinalizingProgress = 81;
40 const int kProgressComplete = 100; 46 const int kProgressComplete = 100;
41 47
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 return (found != instance_set.end()); 93 return (found != instance_set.end());
88 } 94 }
89 95
90 // static 96 // static
91 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) { 97 UpdateScreen* UpdateScreen::Get(ScreenManager* manager) {
92 return static_cast<UpdateScreen*>( 98 return static_cast<UpdateScreen*>(
93 manager->GetScreen(WizardController::kUpdateScreenName)); 99 manager->GetScreen(WizardController::kUpdateScreenName));
94 } 100 }
95 101
96 UpdateScreen::UpdateScreen(BaseScreenDelegate* base_screen_delegate, 102 UpdateScreen::UpdateScreen(BaseScreenDelegate* base_screen_delegate,
97 UpdateScreenActor* actor, 103 UpdateView* view,
98 HostPairingController* remora_controller) 104 HostPairingController* remora_controller)
99 : BaseScreen(base_screen_delegate), 105 : UpdateModel(base_screen_delegate),
100 state_(STATE_IDLE), 106 state_(STATE_IDLE),
101 reboot_check_delay_(0), 107 reboot_check_delay_(kWaitForRebootTimeSec),
102 is_checking_for_update_(true), 108 is_checking_for_update_(true),
103 is_downloading_update_(false), 109 is_downloading_update_(false),
104 is_ignore_update_deadlines_(false), 110 is_ignore_update_deadlines_(true),
105 is_shown_(false), 111 is_shown_(false),
106 ignore_idle_status_(true), 112 ignore_idle_status_(true),
107 actor_(actor), 113 view_(view),
108 remora_controller_(remora_controller), 114 remora_controller_(remora_controller),
109 is_first_detection_notification_(true), 115 is_first_detection_notification_(true),
110 is_first_portal_notification_(true), 116 is_first_portal_notification_(true),
111 histogram_helper_(new ErrorScreensHistogramHelper("Update")), 117 histogram_helper_(new ErrorScreensHistogramHelper("Update")),
112 weak_factory_(this) { 118 weak_factory_(this) {
113 DCHECK(actor_); 119 if (view_)
114 if (actor_) 120 view_->Bind(*this);
115 actor_->SetDelegate(this); 121
116 GetInstanceSet().insert(this); 122 GetInstanceSet().insert(this);
117 } 123 }
118 124
119 UpdateScreen::~UpdateScreen() { 125 UpdateScreen::~UpdateScreen() {
126 if (view_)
127 view_->Unbind();
128
120 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 129 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
121 NetworkPortalDetector::Get()->RemoveObserver(this); 130 NetworkPortalDetector::Get()->RemoveObserver(this);
122 GetInstanceSet().erase(this); 131 GetInstanceSet().erase(this);
123 if (actor_)
124 actor_->SetDelegate(NULL);
125 } 132 }
126 133
127 void UpdateScreen::UpdateStatusChanged( 134 void UpdateScreen::UpdateStatusChanged(
128 const UpdateEngineClient::Status& status) { 135 const UpdateEngineClient::Status& status) {
129 if (!actor_)
130 return;
131
132 if (is_checking_for_update_ && 136 if (is_checking_for_update_ &&
133 status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) { 137 status.status > UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE) {
134 is_checking_for_update_ = false; 138 is_checking_for_update_ = false;
135 } 139 }
136 if (ignore_idle_status_ && status.status > 140 if (ignore_idle_status_ && status.status >
137 UpdateEngineClient::UPDATE_STATUS_IDLE) { 141 UpdateEngineClient::UPDATE_STATUS_IDLE) {
138 ignore_idle_status_ = false; 142 ignore_idle_status_ = false;
139 } 143 }
140 144
141 switch (status.status) { 145 switch (status.status) {
142 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: 146 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
143 // Do nothing in these cases, we don't want to notify the user of the 147 // Do nothing in these cases, we don't want to notify the user of the
144 // check unless there is an update. 148 // check unless there is an update.
145 SetHostPairingControllerStatus( 149 SetHostPairingControllerStatus(
146 HostPairingController::UPDATE_STATUS_UPDATING); 150 HostPairingController::UPDATE_STATUS_UPDATING);
147 break; 151 break;
148 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: 152 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
149 MakeSureScreenIsShown(); 153 MakeSureScreenIsShown();
150 actor_->SetProgress(kBeforeDownloadProgress); 154 GetContextEditor()
151 actor_->ShowEstimatedTimeLeft(false); 155 .SetInteger(kContextKeyProgress, kBeforeDownloadProgress)
156 .SetBoolean(kContextKeyShowEstimatedTimeLeft, false);
152 if (!HasCriticalUpdate()) { 157 if (!HasCriticalUpdate()) {
153 VLOG(1) << "Noncritical update available: " << status.new_version; 158 VLOG(1) << "Noncritical update available: " << status.new_version;
154 ExitUpdate(REASON_UPDATE_NON_CRITICAL); 159 ExitUpdate(REASON_UPDATE_NON_CRITICAL);
155 } else { 160 } else {
156 VLOG(1) << "Critical update available: " << status.new_version; 161 VLOG(1) << "Critical update available: " << status.new_version;
157 actor_->SetProgressMessage( 162 GetContextEditor()
158 UpdateScreenActor::PROGRESS_MESSAGE_UPDATE_AVAILABLE); 163 .SetString(kContextKeyProgressMessage,
159 actor_->ShowProgressMessage(true); 164 l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE))
160 actor_->ShowCurtain(false); 165 .SetBoolean(kContextKeyShowProgressMessage, true)
166 .SetBoolean(kContextKeyShowCurtain, false);
161 } 167 }
162 break; 168 break;
163 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: 169 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
164 { 170 {
165 MakeSureScreenIsShown(); 171 MakeSureScreenIsShown();
166 if (!is_downloading_update_) { 172 if (!is_downloading_update_) {
167 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE 173 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE
168 // we need to is update critical on first downloading notification. 174 // we need to is update critical on first downloading notification.
169 is_downloading_update_ = true; 175 is_downloading_update_ = true;
170 download_start_time_ = download_last_time_ = base::Time::Now(); 176 download_start_time_ = download_last_time_ = base::Time::Now();
171 download_start_progress_ = status.download_progress; 177 download_start_progress_ = status.download_progress;
172 download_last_progress_ = status.download_progress; 178 download_last_progress_ = status.download_progress;
173 is_download_average_speed_computed_ = false; 179 is_download_average_speed_computed_ = false;
174 download_average_speed_ = 0.0; 180 download_average_speed_ = 0.0;
175 if (!HasCriticalUpdate()) { 181 if (!HasCriticalUpdate()) {
176 VLOG(1) << "Non-critical update available: " << status.new_version; 182 VLOG(1) << "Non-critical update available: " << status.new_version;
177 ExitUpdate(REASON_UPDATE_NON_CRITICAL); 183 ExitUpdate(REASON_UPDATE_NON_CRITICAL);
178 } else { 184 } else {
179 VLOG(1) << "Critical update available: " << status.new_version; 185 VLOG(1) << "Critical update available: " << status.new_version;
180 actor_->SetProgressMessage( 186 GetContextEditor()
181 UpdateScreenActor::PROGRESS_MESSAGE_INSTALLING_UPDATE); 187 .SetString(kContextKeyProgressMessage,
182 actor_->ShowProgressMessage(true); 188 l10n_util::GetStringUTF16(IDS_INSTALLING_UPDATE))
183 actor_->ShowCurtain(false); 189 .SetBoolean(kContextKeyShowProgressMessage, true)
190 .SetBoolean(kContextKeyShowCurtain, false);
184 } 191 }
185 } 192 }
186 UpdateDownloadingStats(status); 193 UpdateDownloadingStats(status);
187 } 194 }
188 break; 195 break;
189 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: 196 case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
190 MakeSureScreenIsShown(); 197 MakeSureScreenIsShown();
191 actor_->SetProgress(kBeforeVerifyingProgress); 198 GetContextEditor()
192 actor_->SetProgressMessage(UpdateScreenActor::PROGRESS_MESSAGE_VERIFYING); 199 .SetInteger(kContextKeyProgress, kBeforeVerifyingProgress)
193 actor_->ShowProgressMessage(true); 200 .SetString(kContextKeyProgressMessage,
201 l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING))
202 .SetBoolean(kContextKeyShowProgressMessage, true);
194 break; 203 break;
195 case UpdateEngineClient::UPDATE_STATUS_FINALIZING: 204 case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
196 MakeSureScreenIsShown(); 205 MakeSureScreenIsShown();
197 actor_->SetProgress(kBeforeFinalizingProgress); 206 GetContextEditor()
198 actor_->SetProgressMessage( 207 .SetInteger(kContextKeyProgress, kBeforeFinalizingProgress)
199 UpdateScreenActor::PROGRESS_MESSAGE_FINALIZING); 208 .SetString(kContextKeyProgressMessage,
200 actor_->ShowProgressMessage(true); 209 l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING))
210 .SetBoolean(kContextKeyShowProgressMessage, true);
201 break; 211 break;
202 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: 212 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
203 MakeSureScreenIsShown(); 213 MakeSureScreenIsShown();
204 actor_->SetProgress(kProgressComplete); 214 GetContextEditor()
205 actor_->ShowEstimatedTimeLeft(false); 215 .SetInteger(kContextKeyProgress, kProgressComplete)
216 .SetBoolean(kContextKeyShowEstimatedTimeLeft, false);
206 if (HasCriticalUpdate()) { 217 if (HasCriticalUpdate()) {
207 actor_->ShowCurtain(false); 218 GetContextEditor().SetBoolean(kContextKeyShowCurtain, false);
208 VLOG(1) << "Initiate reboot after update"; 219 VLOG(1) << "Initiate reboot after update";
209 SetHostPairingControllerStatus( 220 SetHostPairingControllerStatus(
210 HostPairingController::UPDATE_STATUS_REBOOTING); 221 HostPairingController::UPDATE_STATUS_REBOOTING);
211 DBusThreadManager::Get()->GetUpdateEngineClient()->RebootAfterUpdate(); 222 DBusThreadManager::Get()->GetUpdateEngineClient()->RebootAfterUpdate();
212 reboot_timer_.Start(FROM_HERE, 223 reboot_timer_.Start(FROM_HERE,
213 base::TimeDelta::FromSeconds(reboot_check_delay_), 224 base::TimeDelta::FromSeconds(reboot_check_delay_),
214 this, 225 this,
215 &UpdateScreen::OnWaitForRebootTimeElapsed); 226 &UpdateScreen::OnWaitForRebootTimeElapsed);
216 } else { 227 } else {
217 ExitUpdate(REASON_UPDATE_NON_CRITICAL); 228 ExitUpdate(REASON_UPDATE_NON_CRITICAL);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (!NetworkPortalDetector::Get()->IsEnabled()) { 302 if (!NetworkPortalDetector::Get()->IsEnabled()) {
292 StartUpdateCheck(); 303 StartUpdateCheck();
293 return; 304 return;
294 } 305 }
295 state_ = STATE_FIRST_PORTAL_CHECK; 306 state_ = STATE_FIRST_PORTAL_CHECK;
296 is_first_detection_notification_ = true; 307 is_first_detection_notification_ = true;
297 is_first_portal_notification_ = true; 308 is_first_portal_notification_ = true;
298 NetworkPortalDetector::Get()->AddAndFireObserver(this); 309 NetworkPortalDetector::Get()->AddAndFireObserver(this);
299 } 310 }
300 311
301 void UpdateScreen::CancelUpdate() { 312 void UpdateScreen::PrepareToShow() {
302 VLOG(1) << "Forced update cancel"; 313 if (!view_)
303 ExitUpdate(REASON_UPDATE_CANCELED); 314 return;
315
316 view_->PrepareToShow();
304 } 317 }
305 318
306 void UpdateScreen::Show() { 319 void UpdateScreen::Show() {
307 is_shown_ = true; 320 is_shown_ = true;
308 histogram_helper_->OnScreenShow(); 321 histogram_helper_->OnScreenShow();
309 if (actor_) { 322
310 actor_->Show(); 323 #if !defined(OFFICIAL_BUILD)
311 actor_->SetProgress(kBeforeUpdateCheckProgress); 324 GetContextEditor().SetBoolean(kContextKeyCancelUpdateShortcutEnabled, true);
325 #endif
326 GetContextEditor().SetInteger(kContextKeyProgress,
327 kBeforeUpdateCheckProgress);
328
329 if (view_)
330 view_->Show();
331 }
332
333 void UpdateScreen::Hide() {
334 if (view_)
335 view_->Hide();
336 is_shown_ = false;
337 }
338
339 void UpdateScreen::Initialize(::login::ScreenContext* context) {
340 UpdateModel::Initialize(context);
341 }
342
343 void UpdateScreen::OnViewDestroyed(UpdateView* view) {
344 if (view_ == view)
345 view_ = nullptr;
346 }
347
348 void UpdateScreen::OnUserAction(const std::string& action_id) {
349 #if !defined(OFFICIAL_BUILD)
350 if (action_id == kUserActionCancelUpdateShortcut)
351 CancelUpdate();
352 #endif
353 }
354
355 void UpdateScreen::OnContextKeyUpdated(
356 const ::login::ScreenContext::KeyType& key) {
357 UpdateModel::OnContextKeyUpdated(key);
358 }
359
360 void UpdateScreen::OnConnectToNetworkRequested() {
361 if (state_ == STATE_ERROR) {
362 LOG(WARNING) << "Hiding error message since AP was reselected";
363 StartUpdateCheck();
312 } 364 }
313 } 365 }
314 366
315 void UpdateScreen::Hide() {
316 if (actor_)
317 actor_->Hide();
318 is_shown_ = false;
319 }
320
321 std::string UpdateScreen::GetName() const {
322 return WizardController::kUpdateScreenName;
323 }
324
325 void UpdateScreen::PrepareToShow() {
326 if (actor_)
327 actor_->PrepareToShow();
328 }
329
330 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { 367 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) {
331 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this); 368 DBusThreadManager::Get()->GetUpdateEngineClient()->RemoveObserver(this);
332 NetworkPortalDetector::Get()->RemoveObserver(this); 369 NetworkPortalDetector::Get()->RemoveObserver(this);
333 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED); 370 SetHostPairingControllerStatus(HostPairingController::UPDATE_STATUS_UPDATED);
334 371
335 372
336 switch (reason) { 373 switch (reason) {
337 case REASON_UPDATE_CANCELED: 374 case REASON_UPDATE_CANCELED:
338 Finish(BaseScreenDelegate::UPDATE_NOUPDATE); 375 Finish(BaseScreenDelegate::UPDATE_NOUPDATE);
339 break; 376 break;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 408 }
372 break; 409 break;
373 default: 410 default:
374 NOTREACHED(); 411 NOTREACHED();
375 } 412 }
376 } 413 }
377 414
378 void UpdateScreen::OnWaitForRebootTimeElapsed() { 415 void UpdateScreen::OnWaitForRebootTimeElapsed() {
379 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot."; 416 LOG(ERROR) << "Unable to reboot - asking user for a manual reboot.";
380 MakeSureScreenIsShown(); 417 MakeSureScreenIsShown();
381 if (actor_) 418 GetContextEditor().SetString(kContextKeyUpdateMessage,
382 actor_->ShowManualRebootInfo(); 419 l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED));
383 } 420 }
384 421
385 void UpdateScreen::MakeSureScreenIsShown() { 422 void UpdateScreen::MakeSureScreenIsShown() {
386 if (!is_shown_) 423 if (!is_shown_)
387 get_base_screen_delegate()->ShowCurrentScreen(); 424 get_base_screen_delegate()->ShowCurrentScreen();
388 } 425 }
389 426
390 void UpdateScreen::SetRebootCheckDelay(int seconds) {
391 if (seconds <= 0)
392 reboot_timer_.Stop();
393 DCHECK(!reboot_timer_.IsRunning());
394 reboot_check_delay_ = seconds;
395 }
396
397 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) { 427 void UpdateScreen::SetIgnoreIdleStatus(bool ignore_idle_status) {
398 ignore_idle_status_ = ignore_idle_status; 428 ignore_idle_status_ = ignore_idle_status;
399 } 429 }
400 430
431 void UpdateScreen::CancelUpdate() {
432 VLOG(1) << "Forced update cancel";
433 ExitUpdate(REASON_UPDATE_CANCELED);
434 }
435
401 void UpdateScreen::UpdateDownloadingStats( 436 void UpdateScreen::UpdateDownloadingStats(
402 const UpdateEngineClient::Status& status) { 437 const UpdateEngineClient::Status& status) {
403 if (!actor_)
404 return;
405 base::Time download_current_time = base::Time::Now(); 438 base::Time download_current_time = base::Time::Now();
406 if (download_current_time >= download_last_time_ + kMinTimeStep) { 439 if (download_current_time >= download_last_time_ + kMinTimeStep) {
407 // Estimate downloading rate. 440 // Estimate downloading rate.
408 double progress_delta = 441 double progress_delta =
409 std::max(status.download_progress - download_last_progress_, 0.0); 442 std::max(status.download_progress - download_last_progress_, 0.0);
410 double time_delta = 443 double time_delta =
411 (download_current_time - download_last_time_).InSecondsF(); 444 (download_current_time - download_last_time_).InSecondsF();
412 double download_rate = status.new_size * progress_delta / time_delta; 445 double download_rate = status.new_size * progress_delta / time_delta;
413 446
414 download_last_time_ = download_current_time; 447 download_last_time_ = download_current_time;
(...skipping 15 matching lines...) Expand all
430 status.new_size * 463 status.new_size *
431 (status.download_progress - download_start_progress_) / 464 (status.download_progress - download_start_progress_) /
432 time_delta; 465 time_delta;
433 } 466 }
434 double work_left = progress_left * status.new_size; 467 double work_left = progress_left * status.new_size;
435 double time_left = work_left / download_average_speed_; 468 double time_left = work_left / download_average_speed_;
436 // |time_left| may be large enough or even +infinity. So we must 469 // |time_left| may be large enough or even +infinity. So we must
437 // |bound possible estimations. 470 // |bound possible estimations.
438 time_left = std::min(time_left, kMaxTimeLeft); 471 time_left = std::min(time_left, kMaxTimeLeft);
439 472
440 actor_->ShowEstimatedTimeLeft(true); 473 GetContextEditor()
441 actor_->SetEstimatedTimeLeft( 474 .SetBoolean(kContextKeyShowEstimatedTimeLeft, true)
442 base::TimeDelta::FromSeconds(static_cast<int64>(time_left))); 475 .SetInteger(kContextKeyEstimatedTimeLeftSec,
476 static_cast<int>(time_left));
443 } 477 }
444 478
445 int download_progress = static_cast<int>( 479 int download_progress = static_cast<int>(
446 status.download_progress * kDownloadProgressIncrement); 480 status.download_progress * kDownloadProgressIncrement);
447 actor_->SetProgress(kBeforeDownloadProgress + download_progress); 481 GetContextEditor().SetInteger(kContextKeyProgress,
482 kBeforeDownloadProgress + download_progress);
448 } 483 }
449 484
450 bool UpdateScreen::HasCriticalUpdate() { 485 bool UpdateScreen::HasCriticalUpdate() {
451 if (is_ignore_update_deadlines_) 486 if (is_ignore_update_deadlines_)
452 return true; 487 return true;
453 488
454 std::string deadline; 489 std::string deadline;
455 // Checking for update flag file causes us to do blocking IO on UI thread. 490 // Checking for update flag file causes us to do blocking IO on UI thread.
456 // Temporarily allow it until we fix http://crosbug.com/11106 491 // Temporarily allow it until we fix http://crosbug.com/11106
457 base::ThreadRestrictions::ScopedAllowIO allow_io; 492 base::ThreadRestrictions::ScopedAllowIO allow_io;
458 base::FilePath update_deadline_file_path(kUpdateDeadlineFile); 493 base::FilePath update_deadline_file_path(kUpdateDeadlineFile);
459 if (!base::ReadFileToString(update_deadline_file_path, &deadline) || 494 if (!base::ReadFileToString(update_deadline_file_path, &deadline) ||
460 deadline.empty()) { 495 deadline.empty()) {
461 return false; 496 return false;
462 } 497 }
463 498
464 // TODO(dpolukhin): Analyze file content. Now we can just assume that 499 // TODO(dpolukhin): Analyze file content. Now we can just assume that
465 // if the file exists and not empty, there is critical update. 500 // if the file exists and not empty, there is critical update.
466 return true; 501 return true;
467 } 502 }
468 503
469 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) {
470 if (actor_ == actor)
471 actor_ = NULL;
472 }
473
474 void UpdateScreen::OnConnectToNetworkRequested() {
475 if (state_ == STATE_ERROR) {
476 LOG(WARNING) << "Hiding error message since AP was reselected";
477 StartUpdateCheck();
478 }
479 }
480
481 ErrorScreen* UpdateScreen::GetErrorScreen() { 504 ErrorScreen* UpdateScreen::GetErrorScreen() {
482 return get_base_screen_delegate()->GetErrorScreen(); 505 return get_base_screen_delegate()->GetErrorScreen();
483 } 506 }
484 507
485 void UpdateScreen::StartUpdateCheck() { 508 void UpdateScreen::StartUpdateCheck() {
486 NetworkPortalDetector::Get()->RemoveObserver(this); 509 NetworkPortalDetector::Get()->RemoveObserver(this);
487 if (state_ == STATE_ERROR) 510 if (state_ == STATE_ERROR)
488 HideErrorMessage(); 511 HideErrorMessage();
489 state_ = STATE_UPDATE; 512 state_ = STATE_UPDATE;
490 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this); 513 DBusThreadManager::Get()->GetUpdateEngineClient()->AddObserver(this);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 } 562 }
540 563
541 void UpdateScreen::SetHostPairingControllerStatus( 564 void UpdateScreen::SetHostPairingControllerStatus(
542 HostPairingController::UpdateStatus update_status) { 565 HostPairingController::UpdateStatus update_status) {
543 if (remora_controller_) { 566 if (remora_controller_) {
544 remora_controller_->OnUpdateStatusChanged(update_status); 567 remora_controller_->OnUpdateStatusChanged(update_status);
545 } 568 }
546 } 569 }
547 570
548 } // namespace chromeos 571 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screens/update_screen.h ('k') | chrome/browser/chromeos/login/screens/update_screen_actor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698