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/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/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
11 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
16 | 16 |
17 // How long to wait between checks for whether the user has been idle. | 17 // How long to wait between checks for whether the user has been idle. |
18 static const int kIdleRepeatingTimerWait = 10; // Minutes (seconds if testing). | 18 static const int kIdleRepeatingTimerWait = 10; // Minutes (seconds if testing). |
19 | 19 |
20 // How much idle time (since last input even was detected) must have passed | 20 // How much idle time (since last input even was detected) must have passed |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 CalculateIdleState( | 100 CalculateIdleState( |
101 idle_time_allowed, base::Bind(&UpgradeDetector::IdleCallback, | 101 idle_time_allowed, base::Bind(&UpgradeDetector::IdleCallback, |
102 base::Unretained(this))); | 102 base::Unretained(this))); |
103 } | 103 } |
104 | 104 |
105 void UpgradeDetector::IdleCallback(IdleState state) { | 105 void UpgradeDetector::IdleCallback(IdleState state) { |
106 switch (state) { | 106 switch (state) { |
107 case IDLE_STATE_LOCKED: | 107 case IDLE_STATE_LOCKED: |
108 // Computer is locked, auto-restart. | 108 // Computer is locked, auto-restart. |
109 idle_check_timer_.Stop(); | 109 idle_check_timer_.Stop(); |
110 BrowserList::AttemptRestart(); | 110 browser::AttemptRestart(); |
111 break; | 111 break; |
112 case IDLE_STATE_IDLE: | 112 case IDLE_STATE_IDLE: |
113 // Computer has been idle for long enough, show warning. | 113 // Computer has been idle for long enough, show warning. |
114 idle_check_timer_.Stop(); | 114 idle_check_timer_.Stop(); |
115 content::NotificationService::current()->Notify( | 115 content::NotificationService::current()->Notify( |
116 chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, | 116 chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, |
117 content::Source<UpgradeDetector>(this), | 117 content::Source<UpgradeDetector>(this), |
118 content::NotificationService::NoDetails()); | 118 content::NotificationService::NoDetails()); |
119 break; | 119 break; |
120 case IDLE_STATE_ACTIVE: | 120 case IDLE_STATE_ACTIVE: |
121 case IDLE_STATE_UNKNOWN: | 121 case IDLE_STATE_UNKNOWN: |
122 break; | 122 break; |
123 default: | 123 default: |
124 NOTREACHED(); // Need to add any new value above (either providing | 124 NOTREACHED(); // Need to add any new value above (either providing |
125 // automatic restart or show notification to user). | 125 // automatic restart or show notification to user). |
126 break; | 126 break; |
127 } | 127 } |
128 } | 128 } |
OLD | NEW |