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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, | 70 UpdateScreen::UpdateScreen(ScreenObserver* screen_observer, |
71 UpdateScreenActor* actor) | 71 UpdateScreenActor* actor) |
72 : WizardScreen(screen_observer), | 72 : WizardScreen(screen_observer), |
73 reboot_check_delay_(0), | 73 reboot_check_delay_(0), |
74 is_checking_for_update_(true), | 74 is_checking_for_update_(true), |
75 is_downloading_update_(false), | 75 is_downloading_update_(false), |
76 is_ignore_update_deadlines_(false), | 76 is_ignore_update_deadlines_(false), |
77 is_shown_(false), | 77 is_shown_(false), |
78 ignore_idle_status_(true), | 78 ignore_idle_status_(true), |
79 actor_(actor) { | 79 actor_(actor) { |
| 80 actor_->SetDelegate(this); |
80 GetInstanceSet().insert(this); | 81 GetInstanceSet().insert(this); |
81 } | 82 } |
82 | 83 |
83 UpdateScreen::~UpdateScreen() { | 84 UpdateScreen::~UpdateScreen() { |
84 CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); | 85 CrosLibrary::Get()->GetUpdateLibrary()->RemoveObserver(this); |
85 GetInstanceSet().erase(this); | 86 GetInstanceSet().erase(this); |
| 87 if (actor_) |
| 88 actor_->SetDelegate(NULL); |
86 } | 89 } |
87 | 90 |
88 void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { | 91 void UpdateScreen::UpdateStatusChanged(UpdateLibrary* library) { |
89 UpdateStatusOperation status = library->status().status; | 92 UpdateStatusOperation status = library->status().status; |
90 if (is_checking_for_update_ && status > UPDATE_STATUS_CHECKING_FOR_UPDATE) { | 93 if (is_checking_for_update_ && status > UPDATE_STATUS_CHECKING_FOR_UPDATE) { |
91 is_checking_for_update_ = false; | 94 is_checking_for_update_ = false; |
92 } | 95 } |
93 if (ignore_idle_status_ && status > UPDATE_STATUS_IDLE) { | 96 if (ignore_idle_status_ && status > UPDATE_STATUS_IDLE) { |
94 ignore_idle_status_ = false; | 97 ignore_idle_status_ = false; |
95 } | 98 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 ExitUpdate(REASON_UPDATE_INIT_FAILED); | 186 ExitUpdate(REASON_UPDATE_INIT_FAILED); |
184 } else { | 187 } else { |
185 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); | 188 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); |
186 VLOG(1) << "Initiate update check"; | 189 VLOG(1) << "Initiate update check"; |
187 CrosLibrary::Get()->GetUpdateLibrary()->RequestUpdateCheck( | 190 CrosLibrary::Get()->GetUpdateLibrary()->RequestUpdateCheck( |
188 StartUpdateCallback, this); | 191 StartUpdateCallback, this); |
189 } | 192 } |
190 } | 193 } |
191 | 194 |
192 void UpdateScreen::CancelUpdate() { | 195 void UpdateScreen::CancelUpdate() { |
| 196 VLOG(1) << "Forced update cancel"; |
193 ExitUpdate(REASON_UPDATE_CANCELED); | 197 ExitUpdate(REASON_UPDATE_CANCELED); |
194 } | 198 } |
195 | 199 |
196 void UpdateScreen::Show() { | 200 void UpdateScreen::Show() { |
197 is_shown_ = true; | 201 is_shown_ = true; |
198 actor_->Show(); | 202 actor_->Show(); |
199 actor_->SetProgress(kBeforeUpdateCheckProgress); | 203 actor_->SetProgress(kBeforeUpdateCheckProgress); |
200 } | 204 } |
201 | 205 |
202 void UpdateScreen::Hide() { | 206 void UpdateScreen::Hide() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 if (!file_util::ReadFileToString(update_deadline_file_path, &deadline) || | 290 if (!file_util::ReadFileToString(update_deadline_file_path, &deadline) || |
287 deadline.empty()) { | 291 deadline.empty()) { |
288 return false; | 292 return false; |
289 } | 293 } |
290 | 294 |
291 // TODO(dpolukhin): Analyze file content. Now we can just assume that | 295 // TODO(dpolukhin): Analyze file content. Now we can just assume that |
292 // if the file exists and not empty, there is critical update. | 296 // if the file exists and not empty, there is critical update. |
293 return true; | 297 return true; |
294 } | 298 } |
295 | 299 |
| 300 void UpdateScreen::OnActorDestroyed(UpdateScreenActor* actor) { |
| 301 if (actor_ == actor) |
| 302 actor_ = NULL; |
| 303 } |
| 304 |
296 } // namespace chromeos | 305 } // namespace chromeos |
OLD | NEW |