| 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 "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/lifetime/application_lifetime.h" | 11 #include "chrome/browser/lifetime/application_lifetime.h" |
| 12 #include "chrome/browser/ui/browser_otr_state.h" | 12 #include "chrome/browser/ui/browser_otr_state.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 | 17 |
| 18 // How long to wait between checks for whether the user has been idle. | 18 // How long to wait between checks for whether the user has been idle. |
| 19 static const int kIdleRepeatingTimerWait = 10; // Minutes (seconds if testing). | 19 static const int kIdleRepeatingTimerWait = 10; // Minutes (seconds if testing). |
| 20 | 20 |
| 21 // How much idle time (since last input even was detected) must have passed | 21 // How much idle time (since last input even was detected) must have passed |
| 22 // until we notify that a critical update has occurred. | 22 // until we notify that a critical update has occurred. |
| 23 static const int kIdleAmount = 2; // Hours (or seconds, if testing). | 23 static const int kIdleAmount = 2; // Hours (or seconds, if testing). |
| 24 | 24 |
| 25 bool UseTestingIntervals() { | 25 bool UseTestingIntervals() { |
| 26 // If a command line parameter specifying how long the upgrade check should | 26 // If a command line parameter specifying how long the upgrade check should |
| 27 // be, we assume it is for testing and switch to using seconds instead of | 27 // be, we assume it is for testing and switch to using seconds instead of |
| 28 // hours. | 28 // hours. |
| 29 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 29 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); |
| 30 return !cmd_line.GetSwitchValueASCII( | 30 return !cmd_line.GetSwitchValueASCII( |
| 31 switches::kCheckForUpdateIntervalSec).empty(); | 31 switches::kCheckForUpdateIntervalSec).empty(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 void UpgradeDetector::RegisterPrefs(PrefRegistrySimple* registry) { | 35 void UpgradeDetector::RegisterPrefs(PrefRegistrySimple* registry) { |
| 36 registry->RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, false); | 36 registry->RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, false); |
| 37 registry->RegisterBooleanPref(prefs::kWasRestarted, false); | 37 registry->RegisterBooleanPref(prefs::kWasRestarted, false); |
| 38 registry->RegisterBooleanPref(prefs::kAttemptedToEnableAutoupdate, false); | 38 registry->RegisterBooleanPref(prefs::kAttemptedToEnableAutoupdate, false); |
| 39 } | 39 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 break; | 128 break; |
| 129 case IDLE_STATE_ACTIVE: | 129 case IDLE_STATE_ACTIVE: |
| 130 case IDLE_STATE_UNKNOWN: | 130 case IDLE_STATE_UNKNOWN: |
| 131 break; | 131 break; |
| 132 default: | 132 default: |
| 133 NOTREACHED(); // Need to add any new value above (either providing | 133 NOTREACHED(); // Need to add any new value above (either providing |
| 134 // automatic restart or show notification to user). | 134 // automatic restart or show notification to user). |
| 135 break; | 135 break; |
| 136 } | 136 } |
| 137 } | 137 } |
| OLD | NEW |