| 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" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // hours. | 28 // hours. |
| 29 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); | 29 const CommandLine& cmd_line = *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 } | 39 } |
| 39 | 40 |
| 40 int UpgradeDetector::GetIconResourceID(UpgradeNotificationIconType type) { | 41 int UpgradeDetector::GetIconResourceID(UpgradeNotificationIconType type) { |
| 41 if (type == UPGRADE_ICON_TYPE_BADGE) { | 42 if (type == UPGRADE_ICON_TYPE_BADGE) { |
| 42 // Badges do not exist on Views and Mac OS X. | 43 // Badges do not exist on Views and Mac OS X. |
| 43 #if !defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) | 44 #if !defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 44 switch (upgrade_notification_stage_) { | 45 switch (upgrade_notification_stage_) { |
| 45 case UPGRADE_ANNOYANCE_NONE: | 46 case UPGRADE_ANNOYANCE_NONE: |
| 46 return 0; | 47 return 0; |
| 47 case UPGRADE_ANNOYANCE_LOW: | 48 case UPGRADE_ANNOYANCE_LOW: |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 content::NotificationService::NoDetails()); | 103 content::NotificationService::NoDetails()); |
| 103 | 104 |
| 104 switch (upgrade_available_) { | 105 switch (upgrade_available_) { |
| 105 case UPGRADE_NEEDED_OUTDATED_INSTALL: { | 106 case UPGRADE_NEEDED_OUTDATED_INSTALL: { |
| 106 content::NotificationService::current()->Notify( | 107 content::NotificationService::current()->Notify( |
| 107 chrome::NOTIFICATION_OUTDATED_INSTALL, | 108 chrome::NOTIFICATION_OUTDATED_INSTALL, |
| 108 content::Source<UpgradeDetector>(this), | 109 content::Source<UpgradeDetector>(this), |
| 109 content::NotificationService::NoDetails()); | 110 content::NotificationService::NoDetails()); |
| 110 break; | 111 break; |
| 111 } | 112 } |
| 113 case UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU: { |
| 114 content::NotificationService::current()->Notify( |
| 115 chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU, |
| 116 content::Source<UpgradeDetector>(this), |
| 117 content::NotificationService::NoDetails()); |
| 118 break; |
| 119 } |
| 112 case UPGRADE_AVAILABLE_CRITICAL: { | 120 case UPGRADE_AVAILABLE_CRITICAL: { |
| 113 int idle_timer = UseTestingIntervals() ? | 121 int idle_timer = UseTestingIntervals() ? |
| 114 kIdleRepeatingTimerWait : | 122 kIdleRepeatingTimerWait : |
| 115 kIdleRepeatingTimerWait * 60; // To minutes. | 123 kIdleRepeatingTimerWait * 60; // To minutes. |
| 116 idle_check_timer_.Start(FROM_HERE, | 124 idle_check_timer_.Start(FROM_HERE, |
| 117 base::TimeDelta::FromSeconds(idle_timer), | 125 base::TimeDelta::FromSeconds(idle_timer), |
| 118 this, &UpgradeDetector::CheckIdle); | 126 this, &UpgradeDetector::CheckIdle); |
| 119 break; | 127 break; |
| 120 } | 128 } |
| 121 default: | 129 default: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 break; | 163 break; |
| 156 case IDLE_STATE_ACTIVE: | 164 case IDLE_STATE_ACTIVE: |
| 157 case IDLE_STATE_UNKNOWN: | 165 case IDLE_STATE_UNKNOWN: |
| 158 break; | 166 break; |
| 159 default: | 167 default: |
| 160 NOTREACHED(); // Need to add any new value above (either providing | 168 NOTREACHED(); // Need to add any new value above (either providing |
| 161 // automatic restart or show notification to user). | 169 // automatic restart or show notification to user). |
| 162 break; | 170 break; |
| 163 } | 171 } |
| 164 } | 172 } |
| OLD | NEW |