| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 9 #include "chrome/browser/chromeos/login/screen_observer.h" | 9 #include "chrome/browser/chromeos/login/screen_observer.h" |
| 10 #include "chrome/browser/chromeos/login/update_view.h" | 10 #include "chrome/browser/chromeos/login/update_view.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 view()->ShowCurtain(false); | 85 view()->ShowCurtain(false); |
| 86 CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); | 86 CrosLibrary::Get()->GetUpdateLibrary()->RebootAfterUpdate(); |
| 87 LOG(INFO) << "Reboot API was called. Waiting for reboot."; | 87 LOG(INFO) << "Reboot API was called. Waiting for reboot."; |
| 88 reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_), | 88 reboot_timer_.Start(base::TimeDelta::FromSeconds(reboot_check_delay_), |
| 89 this, | 89 this, |
| 90 &UpdateScreen::OnWaitForRebootTimeElapsed); | 90 &UpdateScreen::OnWaitForRebootTimeElapsed); |
| 91 break; | 91 break; |
| 92 case UPDATE_STATUS_IDLE: | 92 case UPDATE_STATUS_IDLE: |
| 93 case UPDATE_STATUS_ERROR: | 93 case UPDATE_STATUS_ERROR: |
| 94 case UPDATE_STATUS_REPORTING_ERROR_EVENT: | 94 case UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| 95 ExitUpdate(); | 95 ExitUpdate(false); |
| 96 break; | 96 break; |
| 97 default: | 97 default: |
| 98 NOTREACHED(); | 98 NOTREACHED(); |
| 99 break; | 99 break; |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 void UpdateScreen::StartUpdate() { | 103 void UpdateScreen::StartUpdate() { |
| 104 // Reset view. | 104 // Reset view. |
| 105 view()->Reset(); | 105 view()->Reset(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 view()->SetProgress(kBeforeUpdateCheckProgress); | 118 view()->SetProgress(kBeforeUpdateCheckProgress); |
| 119 | 119 |
| 120 if (!CrosLibrary::Get()->EnsureLoaded()) { | 120 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 121 LOG(ERROR) << "Error loading CrosLibrary"; | 121 LOG(ERROR) << "Error loading CrosLibrary"; |
| 122 } else { | 122 } else { |
| 123 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); | 123 CrosLibrary::Get()->GetUpdateLibrary()->AddObserver(this); |
| 124 LOG(INFO) << "Checking for update"; | 124 LOG(INFO) << "Checking for update"; |
| 125 if (!CrosLibrary::Get()->GetUpdateLibrary()->CheckForUpdate()) { | 125 if (!CrosLibrary::Get()->GetUpdateLibrary()->CheckForUpdate()) { |
| 126 ExitUpdate(); | 126 ExitUpdate(true); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 void UpdateScreen::CancelUpdate() { | 131 void UpdateScreen::CancelUpdate() { |
| 132 // Screen has longer lifetime than it's view. | 132 // Screen has longer lifetime than it's view. |
| 133 // View is deleted after wizard proceeds to the next screen. | 133 // View is deleted after wizard proceeds to the next screen. |
| 134 if (view()) | 134 if (view()) |
| 135 ExitUpdate(); | 135 ExitUpdate(true); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void UpdateScreen::ExitUpdate() { | 138 void UpdateScreen::ExitUpdate(bool forced) { |
| 139 maximal_curtain_time_timer_.Stop(); | 139 maximal_curtain_time_timer_.Stop(); |
| 140 ScreenObserver* observer = delegate()->GetObserver(this); | 140 ScreenObserver* observer = delegate()->GetObserver(this); |
| 141 | 141 |
| 142 if (!CrosLibrary::Get()->EnsureLoaded()) { | 142 if (!CrosLibrary::Get()->EnsureLoaded()) { |
| 143 observer->OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); | 143 observer->OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE); |
| 144 return; |
| 145 } |
| 146 |
| 147 if (forced) { |
| 148 observer->OnExit(ScreenObserver::UPDATE_NOUPDATE); |
| 149 return; |
| 144 } | 150 } |
| 145 | 151 |
| 146 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); | 152 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); |
| 147 update_library->RemoveObserver(this); | 153 update_library->RemoveObserver(this); |
| 148 switch (update_library->status().status) { | 154 switch (update_library->status().status) { |
| 149 case UPDATE_STATUS_IDLE: | 155 case UPDATE_STATUS_IDLE: |
| 150 observer->OnExit(ScreenObserver::UPDATE_NOUPDATE); | 156 observer->OnExit(ScreenObserver::UPDATE_NOUPDATE); |
| 151 break; | 157 break; |
| 152 case UPDATE_STATUS_ERROR: | 158 case UPDATE_STATUS_ERROR: |
| 153 case UPDATE_STATUS_REPORTING_ERROR_EVENT: | 159 case UPDATE_STATUS_REPORTING_ERROR_EVENT: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 177 } | 183 } |
| 178 | 184 |
| 179 void UpdateScreen::SetRebootCheckDelay(int seconds) { | 185 void UpdateScreen::SetRebootCheckDelay(int seconds) { |
| 180 if (seconds <= 0) | 186 if (seconds <= 0) |
| 181 reboot_timer_.Stop(); | 187 reboot_timer_.Stop(); |
| 182 DCHECK(!reboot_timer_.IsRunning()); | 188 DCHECK(!reboot_timer_.IsRunning()); |
| 183 reboot_check_delay_ = seconds; | 189 reboot_check_delay_ = seconds; |
| 184 } | 190 } |
| 185 | 191 |
| 186 } // namespace chromeos | 192 } // namespace chromeos |
| OLD | NEW |