OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 case UPDATE_STATUS_REPORTING_ERROR_EVENT: | 177 case UPDATE_STATUS_REPORTING_ERROR_EVENT: |
178 ExitUpdate(REASON_UPDATE_ENDED); | 178 ExitUpdate(REASON_UPDATE_ENDED); |
179 break; | 179 break; |
180 default: | 180 default: |
181 NOTREACHED(); | 181 NOTREACHED(); |
182 break; | 182 break; |
183 } | 183 } |
184 } | 184 } |
185 | 185 |
186 void UpdateScreen::StartUpdate() { | 186 void UpdateScreen::StartUpdate() { |
187 if (!CrosLibrary::Get()->EnsureLoaded()) { | 187 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); |
188 LOG(ERROR) << "Error loading CrosLibrary"; | 188 VLOG(1) << "Initiate update check"; |
189 ExitUpdate(REASON_UPDATE_INIT_FAILED); | 189 CrosLibrary::Get()->GetUpdateLibrary()->RequestUpdateCheck( |
190 } else { | 190 StartUpdateCallback, this); |
191 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); | |
192 VLOG(1) << "Initiate update check"; | |
193 CrosLibrary::Get()->GetUpdateLibrary()->RequestUpdateCheck( | |
194 StartUpdateCallback, this); | |
195 } | |
196 } | 191 } |
197 | 192 |
198 void UpdateScreen::CancelUpdate() { | 193 void UpdateScreen::CancelUpdate() { |
199 VLOG(1) << "Forced update cancel"; | 194 VLOG(1) << "Forced update cancel"; |
200 ExitUpdate(REASON_UPDATE_CANCELED); | 195 ExitUpdate(REASON_UPDATE_CANCELED); |
201 } | 196 } |
202 | 197 |
203 void UpdateScreen::Show() { | 198 void UpdateScreen::Show() { |
204 is_shown_ = true; | 199 is_shown_ = true; |
205 actor_->Show(); | 200 actor_->Show(); |
206 actor_->SetProgress(kBeforeUpdateCheckProgress); | 201 actor_->SetProgress(kBeforeUpdateCheckProgress); |
207 } | 202 } |
208 | 203 |
209 void UpdateScreen::Hide() { | 204 void UpdateScreen::Hide() { |
210 actor_->Hide(); | 205 actor_->Hide(); |
211 is_shown_ = false; | 206 is_shown_ = false; |
212 } | 207 } |
213 | 208 |
214 void UpdateScreen::PrepareToShow() { | 209 void UpdateScreen::PrepareToShow() { |
215 actor_->PrepareToShow(); | 210 actor_->PrepareToShow(); |
216 } | 211 } |
217 | 212 |
218 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { | 213 void UpdateScreen::ExitUpdate(UpdateScreen::ExitReason reason) { |
219 if (CrosLibrary::Get()->EnsureLoaded()) | 214 CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); |
220 CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); | |
221 | 215 |
222 switch (reason) { | 216 switch (reason) { |
223 case REASON_UPDATE_CANCELED: | 217 case REASON_UPDATE_CANCELED: |
224 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); | 218 get_screen_observer()->OnExit(ScreenObserver::UPDATE_NOUPDATE); |
225 break; | 219 break; |
226 case REASON_UPDATE_INIT_FAILED: | 220 case REASON_UPDATE_INIT_FAILED: |
227 get_screen_observer()->OnExit( | 221 get_screen_observer()->OnExit( |
228 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); | 222 ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
229 break; | 223 break; |
230 case REASON_UPDATE_NON_CRITICAL: | 224 case REASON_UPDATE_NON_CRITICAL: |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // if the file exists and not empty, there is critical update. | 293 // if the file exists and not empty, there is critical update. |
300 return true; | 294 return true; |
301 } | 295 } |
302 | 296 |
303 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { | 297 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { |
304 if (actor_ == actor) | 298 if (actor_ == actor) |
305 actor_ = NULL; | 299 actor_ = NULL; |
306 } | 300 } |
307 | 301 |
308 } // namespace chromeos | 302 } // namespace chromeos |
OLD | NEW |