| 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/upgrade_detector.h" | 5 #include "chrome/browser/upgrade_detector.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/app/vector_icons/vector_icons.h" | 9 #include "chrome/app/vector_icons/vector_icons.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL) { | 80 if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL) { |
| 81 TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL); | 81 TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL); |
| 82 } else if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU) { | 82 } else if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU) { |
| 83 TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU); | 83 TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU); |
| 84 } else if (upgrade_available_ == UPGRADE_AVAILABLE_CRITICAL || | 84 } else if (upgrade_available_ == UPGRADE_AVAILABLE_CRITICAL || |
| 85 critical_experiment_updates_available_) { | 85 critical_experiment_updates_available_) { |
| 86 TriggerCriticalUpdate(); | 86 TriggerCriticalUpdate(); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 void UpgradeDetector::NotifyUpdateOverCellularAvailable() { |
| 91 for (auto& observer : observer_list_) |
| 92 observer.OnUpdateOverCellularAvailable(); |
| 93 } |
| 94 |
| 90 void UpgradeDetector::TriggerCriticalUpdate() { | 95 void UpgradeDetector::TriggerCriticalUpdate() { |
| 91 const base::TimeDelta idle_timer = UseTestingIntervals() ? | 96 const base::TimeDelta idle_timer = UseTestingIntervals() ? |
| 92 base::TimeDelta::FromSeconds(kIdleRepeatingTimerWait) : | 97 base::TimeDelta::FromSeconds(kIdleRepeatingTimerWait) : |
| 93 base::TimeDelta::FromMinutes(kIdleRepeatingTimerWait); | 98 base::TimeDelta::FromMinutes(kIdleRepeatingTimerWait); |
| 94 idle_check_timer_.Start(FROM_HERE, idle_timer, this, | 99 idle_check_timer_.Start(FROM_HERE, idle_timer, this, |
| 95 &UpgradeDetector::CheckIdle); | 100 &UpgradeDetector::CheckIdle); |
| 96 } | 101 } |
| 97 | 102 |
| 98 void UpgradeDetector::CheckIdle() { | 103 void UpgradeDetector::CheckIdle() { |
| 99 // CalculateIdleState expects an interval in seconds. | 104 // CalculateIdleState expects an interval in seconds. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 break; | 136 break; |
| 132 case ui::IDLE_STATE_ACTIVE: | 137 case ui::IDLE_STATE_ACTIVE: |
| 133 case ui::IDLE_STATE_UNKNOWN: | 138 case ui::IDLE_STATE_UNKNOWN: |
| 134 break; | 139 break; |
| 135 default: | 140 default: |
| 136 NOTREACHED(); // Need to add any new value above (either providing | 141 NOTREACHED(); // Need to add any new value above (either providing |
| 137 // automatic restart or show notification to user). | 142 // automatic restart or show notification to user). |
| 138 break; | 143 break; |
| 139 } | 144 } |
| 140 } | 145 } |
| 146 |
| 147 void UpgradeDetector::AddObserver(UpgradeObserver* observer) { |
| 148 observer_list_.AddObserver(observer); |
| 149 } |
| 150 |
| 151 void UpgradeDetector::RemoveObserver(UpgradeObserver* observer) { |
| 152 observer_list_.RemoveObserver(observer); |
| 153 } |
| OLD | NEW |