blob: f4a7e68ce54a32484ad3258be5f96cdebb2b3e1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/upgrade_detector.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/common/notification_service.h"
#include "grit/theme_resources.h"
// static
void UpgradeDetector::RegisterPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, false);
}
int UpgradeDetector::GetIconResourceID(UpgradeNotificationIconType type) {
bool badge = type == UPGRADE_ICON_TYPE_BADGE;
switch (upgrade_notification_stage_) {
case UPGRADE_ANNOYANCE_SEVERE:
return badge ? IDR_UPDATE_BADGE4 : IDR_UPDATE_MENU4;
case UPGRADE_ANNOYANCE_HIGH:
return badge ? IDR_UPDATE_BADGE3 : IDR_UPDATE_MENU3;
case UPGRADE_ANNOYANCE_ELEVATED:
return badge ? IDR_UPDATE_BADGE2 : IDR_UPDATE_MENU2;
case UPGRADE_ANNOYANCE_LOW:
return badge ? IDR_UPDATE_BADGE : IDR_UPDATE_MENU;
default:
return 0;
}
}
UpgradeDetector::UpgradeDetector()
: upgrade_notification_stage_(UPGRADE_ANNOYANCE_NONE),
notify_upgrade_(false) {
}
UpgradeDetector::~UpgradeDetector() {
}
void UpgradeDetector::NotifyUpgradeDetected() {
upgrade_detected_time_ = base::Time::Now();
}
void UpgradeDetector::NotifyUpgradeRecommended() {
notify_upgrade_ = true;
NotificationService::current()->Notify(
chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
Source<UpgradeDetector>(this),
NotificationService::NoDetails());
}
|