| 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 #include "chrome/browser/chromeos/login/update_screen.h" | 5 #include "chrome/browser/chromeos/login/update_screen.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/login/screen_observer.h" | 10 #include "chrome/browser/chromeos/login/screen_observer.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 } | 61 } |
| 62 | 62 |
| 63 switch (status) { | 63 switch (status) { |
| 64 case UPDATE_STATUS_CHECKING_FOR_UPDATE: | 64 case UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| 65 // Do nothing in these cases, we don't want to notify the user of the | 65 // Do nothing in these cases, we don't want to notify the user of the |
| 66 // check unless there is an update. | 66 // check unless there is an update. |
| 67 break; | 67 break; |
| 68 case UPDATE_STATUS_UPDATE_AVAILABLE: | 68 case UPDATE_STATUS_UPDATE_AVAILABLE: |
| 69 view()->SetProgress(kBeforeDownloadProgress); | 69 view()->SetProgress(kBeforeDownloadProgress); |
| 70 if (!HasCriticalUpdate()) { | 70 if (!HasCriticalUpdate()) { |
| 71 VLOG(1) << "Noncritical update available: " | 71 LOG(INFO) << "Noncritical update available: " |
| 72 << library->status().new_version; | 72 << library->status().new_version; |
| 73 ExitUpdate(); | 73 ExitUpdate(false); |
| 74 } else { | 74 } else { |
| 75 VLOG(1) << "Critical update available: " | 75 LOG(INFO) << "Critical update available: " |
| 76 << library->status().new_version; | 76 << library->status().new_version; |
| 77 } | 77 } |
| 78 break; | 78 break; |
| 79 case UPDATE_STATUS_DOWNLOADING: | 79 case UPDATE_STATUS_DOWNLOADING: |
| 80 { | 80 { |
| 81 if (!is_downloading_update_) { | 81 if (!is_downloading_update_) { |
| 82 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE | 82 // Because update engine doesn't send UPDATE_STATUS_UPDATE_AVAILABLE |
| 83 // we need to is update critical on first downloading notification. | 83 // we need to is update critical on first downloading notification. |
| 84 is_downloading_update_ = true; | 84 is_downloading_update_ = true; |
| 85 if (!HasCriticalUpdate()) { | 85 if (!HasCriticalUpdate()) { |
| 86 VLOG(1) << "Non-critical update available: " | 86 LOG(INFO) << "Non-critical update available: " |
| 87 << library->status().new_version; | 87 << library->status().new_version; |
| 88 ExitUpdate(); | 88 ExitUpdate(false); |
| 89 } else { | 89 } else { |
| 90 VLOG(1) << "Critical update available: " | 90 LOG(INFO) << "Critical update available: " |
| 91 << library->status().new_version; | 91 << library->status().new_version; |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 view()->ShowCurtain(false); | 94 view()->ShowCurtain(false); |
| 95 int download_progress = static_cast<int>( | 95 int download_progress = static_cast<int>( |
| 96 library->status().download_progress * kDownloadProgressIncrement); | 96 library->status().download_progress * kDownloadProgressIncrement); |
| 97 view()->SetProgress(kBeforeDownloadProgress + download_progress); | 97 view()->SetProgress(kBeforeDownloadProgress + download_progress); |
| 98 } | 98 } |
| 99 break; | 99 break; |
| 100 case UPDATE_STATUS_VERIFYING: | 100 case UPDATE_STATUS_VERIFYING: |
| 101 view()->SetProgress(kBeforeVerifyingProgress); | 101 view()->SetProgress(kBeforeVerifyingProgress); |
| 102 break; | 102 break; |
| 103 case UPDATE_STATUS_FINALIZING: | 103 case UPDATE_STATUS_FINALIZING: |
| 104 view()->SetProgress(kBeforeFinalizingProgress); | 104 view()->SetProgress(kBeforeFinalizingProgress); |
| 105 break; | 105 break; |
| 106 case UPDATE_STATUS_UPDATED_NEED_REBOOT: | 106 case UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| 107 // Make sure that first OOBE stage won't be shown after reboot. | 107 // Make sure that first OOBE stage won't be shown after reboot. |
| 108 WizardController::MarkOobeCompleted(); | 108 WizardController::MarkOobeCompleted(); |
| 109 view()->SetProgress(kProgressComplete); | 109 view()->SetProgress(kProgressComplete); |
| 110 if (HasCriticalUpdate()) { | 110 if (HasCriticalUpdate()) { |
| 111 view()->ShowCurtain(false); | 111 view()->ShowCurtain(false); |
| 112 VLOG(1) << "Initiate reboot after update"; | 112 VLOG(1) << "Initiate reboot after update"; |
| 113 CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); | 113 CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); |
| 114 reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_), | 114 reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_), |
| 115 this, | 115 this, |
| 116 &UpdateScreen::OnWaitForRebootTimeElapsed); | 116 &UpdateScreen::OnWaitForRebootTimeElapsed); |
| 117 } else { | 117 } else { |
| 118 ExitUpdate(); | 118 ExitUpdate(false); |
| 119 } | 119 } |
| 120 break; | 120 break; |
| 121 case UPDATE_STATUS_IDLE: | 121 case UPDATE_STATUS_IDLE: |
| 122 case UPDATE_STATUS_ERROR: | 122 case UPDATE_STATUS_ERROR: |
| 123 case UPDATE_STATUS_REPORTING_ERROR_EVENT: | 123 case UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| 124 ExitUpdate(); | 124 ExitUpdate(false); |
| 125 break; | 125 break; |
| 126 default: | 126 default: |
| 127 NOTREACHED(); | 127 NOTREACHED(); |
| 128 break; | 128 break; |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 void UpdateScreen::StartUpdate() { | 132 void UpdateScreen::StartUpdate() { |
| 133 // Reset view. | 133 // Reset view. |
| 134 view()->Reset(); | 134 view()->Reset(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 view()->SetProgress(kBeforeUpdateCheckProgress); | 148 view()->SetProgress(kBeforeUpdateCheckProgress); |
| 149 | 149 |
| 150 if (!CrosLibrary::Get()->EnsureLoaded()) { | 150 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 151 LOG(ERROR) << "Error loading CrosLibrary"; | 151 LOG(ERROR) << "Error loading CrosLibrary"; |
| 152 } else { | 152 } else { |
| 153 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); | 153 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); |
| 154 VLOG(1) << "Initiate update check"; | 154 VLOG(1) << "Initiate update check"; |
| 155 if (!CrosLibrary::Get()->GetUpdateLibrary()->CheckForUpdate()) { | 155 if (!CrosLibrary::Get()->GetUpdateLibrary()->CheckForUpdate()) { |
| 156 ExitUpdate(); | 156 ExitUpdate(true); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 void UpdateScreen::CancelUpdate() { | 161 void UpdateScreen::CancelUpdate() { |
| 162 // Screen has longer lifetime than it's view. | 162 // Screen has longer lifetime than it's view. |
| 163 // View is deleted after wizard proceeds to the next screen. | 163 // View is deleted after wizard proceeds to the next screen. |
| 164 if (view()) | 164 if (view()) |
| 165 ExitUpdate(); | 165 ExitUpdate(true); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void UpdateScreen::ExitUpdate() { | 168 void UpdateScreen::ExitUpdate(bool forced) { |
| 169 maximal_curtain_time_timer_.Stop(); | 169 maximal_curtain_time_timer_.Stop(); |
| 170 ScreenObserver* observer = delegate()->GetObserver(this); | 170 ScreenObserver* observer = delegate()->GetObserver(this); |
| 171 | 171 |
| 172 if (!CrosLibrary::Get()->EnsureLoaded()) { | 172 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 173 observer->OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); | 173 observer->OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
| 174 return; |
| 175 } |
| 176 |
| 177 if (forced) { |
| 178 observer->OnExit(ScreenObserver::UPDATE_NOUPDATE); |
| 179 return; |
| 174 } | 180 } |
| 175 | 181 |
| 176 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); | 182 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); |
| 177 update_library->RemoveObserver(this); | 183 update_library->RemoveObserver(this); |
| 178 switch (update_library->status().status) { | 184 switch (update_library->status().status) { |
| 179 case UPDATE_STATUS_UPDATE_AVAILABLE: | 185 case UPDATE_STATUS_UPDATE_AVAILABLE: |
| 180 case UPDATE_STATUS_UPDATED_NEED_REBOOT: | 186 case UPDATE_STATUS_UPDATED_NEED_REBOOT: |
| 181 case UPDATE_STATUS_DOWNLOADING: | 187 case UPDATE_STATUS_DOWNLOADING: |
| 188 case UPDATE_STATUS_FINALIZING: |
| 189 case UPDATE_STATUS_VERIFYING: |
| 182 DCHECK(!HasCriticalUpdate()); | 190 DCHECK(!HasCriticalUpdate()); |
| 183 // Noncritical update, just exit screen as if there is no update. | 191 // Noncritical update, just exit screen as if there is no update. |
| 184 // no break | 192 // no break |
| 185 case UPDATE_STATUS_IDLE: | 193 case UPDATE_STATUS_IDLE: |
| 186 observer->OnExit(ScreenObserver::UPDATE_NOUPDATE); | 194 observer->OnExit(ScreenObserver::UPDATE_NOUPDATE); |
| 187 break; | 195 break; |
| 188 case UPDATE_STATUS_ERROR: | 196 case UPDATE_STATUS_ERROR: |
| 189 case UPDATE_STATUS_REPORTING_ERROR_EVENT: | 197 case UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| 190 observer->OnExit(checking_for_update_ ? | 198 observer->OnExit(checking_for_update_ ? |
| 191 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE : | 199 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE : |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // TODO(dpolukhin): Analyze file content. Now we can just assume that | 241 // TODO(dpolukhin): Analyze file content. Now we can just assume that |
| 234 // if the file exists and not empty, there is critical update. | 242 // if the file exists and not empty, there is critical update. |
| 235 return true; | 243 return true; |
| 236 } | 244 } |
| 237 | 245 |
| 238 void UpdateScreen::SetAllUpdatesCritical(bool is_critical) { | 246 void UpdateScreen::SetAllUpdatesCritical(bool is_critical) { |
| 239 is_all_updates_critical_ = is_critical; | 247 is_all_updates_critical_ = is_critical; |
| 240 } | 248 } |
| 241 | 249 |
| 242 } // namespace chromeos | 250 } // namespace chromeos |
| OLD | NEW |