blob: 994f75c496de270b509f13f32002db872c837d45 [file] [log] [blame]
[email protected]7f070d42011-03-09 20:25:321// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]b1b73942010-05-26 20:11:542// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/upgrade_detector.h"
6
[email protected]37858e52010-08-26 00:22:027#include "chrome/browser/prefs/pref_service.h"
[email protected]432115822011-07-10 15:52:278#include "chrome/common/chrome_notification_types.h"
[email protected]8fcec3c72010-06-03 00:17:229#include "chrome/common/pref_names.h"
[email protected]7f070d42011-03-09 20:25:3210#include "content/common/notification_service.h"
[email protected]21788142011-05-03 10:38:3511#include "grit/theme_resources.h"
[email protected]8fcec3c72010-06-03 00:17:2212
13// static
14void UpgradeDetector::RegisterPrefs(PrefService* prefs) {
15 prefs->RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, false);
16}
17
[email protected]21788142011-05-03 10:38:3518int UpgradeDetector::GetIconResourceID(UpgradeNotificationIconType type) {
19 bool badge = type == UPGRADE_ICON_TYPE_BADGE;
20 switch (upgrade_notification_stage_) {
21 case UPGRADE_ANNOYANCE_SEVERE:
22 return badge ? IDR_UPDATE_BADGE4 : IDR_UPDATE_MENU4;
23 case UPGRADE_ANNOYANCE_HIGH:
24 return badge ? IDR_UPDATE_BADGE3 : IDR_UPDATE_MENU3;
25 case UPGRADE_ANNOYANCE_ELEVATED:
26 return badge ? IDR_UPDATE_BADGE2 : IDR_UPDATE_MENU2;
27 case UPGRADE_ANNOYANCE_LOW:
28 return badge ? IDR_UPDATE_BADGE : IDR_UPDATE_MENU;
29 default:
30 return 0;
31 }
32}
33
[email protected]8fcec3c72010-06-03 00:17:2234UpgradeDetector::UpgradeDetector()
[email protected]ceff8402011-06-12 23:27:1235 : upgrade_notification_stage_(UPGRADE_ANNOYANCE_NONE),
[email protected]8fcec3c72010-06-03 00:17:2236 notify_upgrade_(false) {
[email protected]b1b73942010-05-26 20:11:5437}
38
39UpgradeDetector::~UpgradeDetector() {
40}
41
[email protected]ceff8402011-06-12 23:27:1242void UpgradeDetector::NotifyUpgradeDetected() {
[email protected]3bed26a2011-04-14 16:05:0443 upgrade_detected_time_ = base::Time::Now();
44
[email protected]8fcec3c72010-06-03 00:17:2245 NotificationService::current()->Notify(
[email protected]432115822011-07-10 15:52:2746 chrome::NOTIFICATION_UPGRADE_DETECTED,
[email protected]8fcec3c72010-06-03 00:17:2247 Source<UpgradeDetector>(this),
48 NotificationService::NoDetails());
[email protected]b1b73942010-05-26 20:11:5449}
50
[email protected]ceff8402011-06-12 23:27:1251void UpgradeDetector::NotifyUpgradeRecommended() {
[email protected]b1b73942010-05-26 20:11:5452 notify_upgrade_ = true;
53
54 NotificationService::current()->Notify(
[email protected]432115822011-07-10 15:52:2755 chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
[email protected]b1b73942010-05-26 20:11:5456 Source<UpgradeDetector>(this),
57 NotificationService::NoDetails());
58}