| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 UpdateEngineClient::UpdateCheckResult result) { | 63 UpdateEngineClient::UpdateCheckResult result) { |
| 64 VLOG(1) << "Callback from RequestUpdateCheck, result " << result; | 64 VLOG(1) << "Callback from RequestUpdateCheck, result " << result; |
| 65 if (UpdateScreen::HasInstance(screen)) { | 65 if (UpdateScreen::HasInstance(screen)) { |
| 66 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS) | 66 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS) |
| 67 screen->SetIgnoreIdleStatus(false); | 67 screen->SetIgnoreIdleStatus(false); |
| 68 else | 68 else |
| 69 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); | 69 screen->ExitUpdate(UpdateScreen::REASON_UPDATE_INIT_FAILED); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Returns true if blocking AU is enabled in command line. | |
| 74 bool IsBlockingUpdateEnabledInCommandLine() { | |
| 75 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 76 chromeos::switches::kDisableOOBEBlockingUpdate); | |
| 77 } | |
| 78 | |
| 79 } // anonymous namespace | 73 } // anonymous namespace |
| 80 | 74 |
| 81 // static | 75 // static |
| 82 UpdateScreen::InstanceSet& UpdateScreen::GetInstanceSet() { | 76 UpdateScreen::InstanceSet& UpdateScreen::GetInstanceSet() { |
| 83 CR_DEFINE_STATIC_LOCAL(std::set<UpdateScreen*>, instance_set, ()); | 77 CR_DEFINE_STATIC_LOCAL(std::set<UpdateScreen*>, instance_set, ()); |
| 84 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // not threadsafe. | 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); // not threadsafe. |
| 85 return instance_set; | 79 return instance_set; |
| 86 } | 80 } |
| 87 | 81 |
| 88 // static | 82 // static |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 switch (status.status) { | 132 switch (status.status) { |
| 139 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: | 133 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| 140 // Do nothing in these cases, we don't want to notify the user of the | 134 // Do nothing in these cases, we don't want to notify the user of the |
| 141 // check unless there is an update. | 135 // check unless there is an update. |
| 142 break; | 136 break; |
| 143 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: | 137 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: |
| 144 MakeSureScreenIsShown(); | 138 MakeSureScreenIsShown(); |
| 145 actor_->SetProgress(kBeforeDownloadProgress); | 139 actor_->SetProgress(kBeforeDownloadProgress); |
| 146 actor_->ShowEstimatedTimeLeft(false); | 140 actor_->ShowEstimatedTimeLeft(false); |
| 147 if (!HasCriticalUpdate()) { | 141 if (!HasCriticalUpdate()) { |
| 148 LOG(INFO) << "Noncritical update available: " | 142 VLOG(1) << "Noncritical update available: " << status.new_version; |
| 149 << status.new_version; | |
| 150 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 143 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
| 151 } else { | 144 } else { |
| 152 LOG(INFO) << "Critical update available: " | 145 VLOG(1) << "Critical update available: " << status.new_version; |
| 153 << status.new_version; | |
| 154 actor_->SetProgressMessage( | 146 actor_->SetProgressMessage( |
| 155 UpdateScreenActor::PROGRESS_MESSAGE_UPDATE_AVAILABLE); | 147 UpdateScreenActor::PROGRESS_MESSAGE_UPDATE_AVAILABLE); |
| 156 actor_->ShowProgressMessage(true); | 148 actor_->ShowProgressMessage(true); |
| 157 actor_->ShowCurtain(false); | 149 actor_->ShowCurtain(false); |
| 158 } | 150 } |
| 159 break; | 151 break; |
| 160 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: | 152 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: |
| 161 { | 153 { |
| 162 MakeSureScreenIsShown(); | 154 MakeSureScreenIsShown(); |
| 163 if (!is_downloading_update_) { | 155 if (!is_downloading_update_) { |
| 164 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE | 156 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE |
| 165 // we need to is update critical on first downloading notification. | 157 // we need to is update critical on first downloading notification. |
| 166 is_downloading_update_ = true; | 158 is_downloading_update_ = true; |
| 167 download_start_time_ = download_last_time_ = base::Time::Now(); | 159 download_start_time_ = download_last_time_ = base::Time::Now(); |
| 168 download_start_progress_ = status.download_progress; | 160 download_start_progress_ = status.download_progress; |
| 169 download_last_progress_ = status.download_progress; | 161 download_last_progress_ = status.download_progress; |
| 170 is_download_average_speed_computed_ = false; | 162 is_download_average_speed_computed_ = false; |
| 171 download_average_speed_ = 0.0; | 163 download_average_speed_ = 0.0; |
| 172 if (!HasCriticalUpdate()) { | 164 if (!HasCriticalUpdate()) { |
| 173 LOG(INFO) << "Non-critical update available: " | 165 VLOG(1) << "Non-critical update available: " << status.new_version; |
| 174 << status.new_version; | |
| 175 ExitUpdate(REASON_UPDATE_NON_CRITICAL); | 166 ExitUpdate(REASON_UPDATE_NON_CRITICAL); |
| 176 } else { | 167 } else { |
| 177 LOG(INFO) << "Critical update available: " | 168 VLOG(1) << "Critical update available: " << status.new_version; |
| 178 << status.new_version; | |
| 179 actor_->SetProgressMessage( | 169 actor_->SetProgressMessage( |
| 180 UpdateScreenActor::PROGRESS_MESSAGE_INSTALLING_UPDATE); | 170 UpdateScreenActor::PROGRESS_MESSAGE_INSTALLING_UPDATE); |
| 181 actor_->ShowProgressMessage(true); | 171 actor_->ShowProgressMessage(true); |
| 182 actor_->ShowCurtain(false); | 172 actor_->ShowCurtain(false); |
| 183 } | 173 } |
| 184 } | 174 } |
| 185 UpdateDownloadingStats(status); | 175 UpdateDownloadingStats(status); |
| 186 } | 176 } |
| 187 break; | 177 break; |
| 188 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: | 178 case UpdateEngineClient::UPDATE_STATUS_VERIFYING: |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 UpdateErrorMessage(network, status); | 268 UpdateErrorMessage(network, status); |
| 279 ShowErrorMessage(); | 269 ShowErrorMessage(); |
| 280 } | 270 } |
| 281 } | 271 } |
| 282 } | 272 } |
| 283 | 273 |
| 284 void UpdateScreen::StartNetworkCheck() { | 274 void UpdateScreen::StartNetworkCheck() { |
| 285 // If portal detector is enabled and portal detection before AU is | 275 // If portal detector is enabled and portal detection before AU is |
| 286 // allowed, initiate network state check. Otherwise, directly | 276 // allowed, initiate network state check. Otherwise, directly |
| 287 // proceed to update. | 277 // proceed to update. |
| 288 if (!NetworkPortalDetector::Get()->IsEnabled() || | 278 if (!NetworkPortalDetector::Get()->IsEnabled()) { |
| 289 !IsBlockingUpdateEnabledInCommandLine()) { | |
| 290 StartUpdateCheck(); | 279 StartUpdateCheck(); |
| 291 return; | 280 return; |
| 292 } | 281 } |
| 293 state_ = STATE_FIRST_PORTAL_CHECK; | 282 state_ = STATE_FIRST_PORTAL_CHECK; |
| 294 is_first_detection_notification_ = true; | 283 is_first_detection_notification_ = true; |
| 295 is_first_portal_notification_ = true; | 284 is_first_portal_notification_ = true; |
| 296 NetworkPortalDetector::Get()->AddAndFireObserver(this); | 285 NetworkPortalDetector::Get()->AddAndFireObserver(this); |
| 297 } | 286 } |
| 298 | 287 |
| 299 void UpdateScreen::CancelUpdate() { | 288 void UpdateScreen::CancelUpdate() { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, | 514 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
| 526 std::string()); | 515 std::string()); |
| 527 break; | 516 break; |
| 528 default: | 517 default: |
| 529 NOTREACHED(); | 518 NOTREACHED(); |
| 530 break; | 519 break; |
| 531 } | 520 } |
| 532 } | 521 } |
| 533 | 522 |
| 534 } // namespace chromeos | 523 } // namespace chromeos |
| OLD | NEW |