Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: chrome/browser/upgrade_detector.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/browser_list.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/common/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
21 // until we notify that a critical update has occurred. 21 // until we notify that a critical update has occurred.
22 static const int kIdleAmount = 2; // Hours (or seconds, if testing). 22 static const int kIdleAmount = 2; // Hours (or seconds, if testing).
23 23
24 bool UseTestingIntervals() { 24 bool UseTestingIntervals() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 void UpgradeDetector::NotifyUpgradeDetected() { 71 void UpgradeDetector::NotifyUpgradeDetected() {
72 upgrade_detected_time_ = base::Time::Now(); 72 upgrade_detected_time_ = base::Time::Now();
73 critical_update_acknowledged_ = false; 73 critical_update_acknowledged_ = false;
74 } 74 }
75 75
76 void UpgradeDetector::NotifyUpgradeRecommended() { 76 void UpgradeDetector::NotifyUpgradeRecommended() {
77 notify_upgrade_ = true; 77 notify_upgrade_ = true;
78 78
79 NotificationService::current()->Notify( 79 content::NotificationService::current()->Notify(
80 chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 80 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
81 content::Source<UpgradeDetector>(this), 81 content::Source<UpgradeDetector>(this),
82 NotificationService::NoDetails()); 82 content::NotificationService::NoDetails());
83 83
84 if (is_critical_upgrade_) { 84 if (is_critical_upgrade_) {
85 int idle_timer = UseTestingIntervals() ? 85 int idle_timer = UseTestingIntervals() ?
86 kIdleRepeatingTimerWait : 86 kIdleRepeatingTimerWait :
87 kIdleRepeatingTimerWait * 60; // To minutes. 87 kIdleRepeatingTimerWait * 60; // To minutes.
88 idle_check_timer_.Start(FROM_HERE, 88 idle_check_timer_.Start(FROM_HERE,
89 base::TimeDelta::FromSeconds(idle_timer), 89 base::TimeDelta::FromSeconds(idle_timer),
90 this, &UpgradeDetector::CheckIdle); 90 this, &UpgradeDetector::CheckIdle);
91 } 91 }
92 } 92 }
(...skipping 11 matching lines...) Expand all
104 void UpgradeDetector::IdleCallback(IdleState state) { 104 void UpgradeDetector::IdleCallback(IdleState state) {
105 switch (state) { 105 switch (state) {
106 case IDLE_STATE_LOCKED: 106 case IDLE_STATE_LOCKED:
107 // Computer is locked, auto-restart. 107 // Computer is locked, auto-restart.
108 idle_check_timer_.Stop(); 108 idle_check_timer_.Stop();
109 BrowserList::AttemptRestart(); 109 BrowserList::AttemptRestart();
110 break; 110 break;
111 case IDLE_STATE_IDLE: 111 case IDLE_STATE_IDLE:
112 // Computer has been idle for long enough, show warning. 112 // Computer has been idle for long enough, show warning.
113 idle_check_timer_.Stop(); 113 idle_check_timer_.Stop();
114 NotificationService::current()->Notify( 114 content::NotificationService::current()->Notify(
115 chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED, 115 chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED,
116 content::Source<UpgradeDetector>(this), 116 content::Source<UpgradeDetector>(this),
117 NotificationService::NoDetails()); 117 content::NotificationService::NoDetails());
118 break; 118 break;
119 case IDLE_STATE_ACTIVE: 119 case IDLE_STATE_ACTIVE:
120 case IDLE_STATE_UNKNOWN: 120 case IDLE_STATE_UNKNOWN:
121 break; 121 break;
122 default: 122 default:
123 NOTREACHED(); // Need to add any new value above (either providing 123 NOTREACHED(); // Need to add any new value above (either providing
124 // automatic restart or show notification to user). 124 // automatic restart or show notification to user).
125 break; 125 break;
126 } 126 }
127 } 127 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/task_manager_handler.cc ('k') | chrome/browser/user_style_sheet_watcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698