[email protected] | 7f070d4 | 2011-03-09 20:25:32 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | b1b7394 | 2010-05-26 20:11:54 | [diff] [blame] | 2 | // 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] | 37858e5 | 2010-08-26 00:22:02 | [diff] [blame] | 7 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame^] | 8 | #include "chrome/common/chrome_notification_types.h" |
[email protected] | 8fcec3c7 | 2010-06-03 00:17:22 | [diff] [blame] | 9 | #include "chrome/common/pref_names.h" |
[email protected] | 7f070d4 | 2011-03-09 20:25:32 | [diff] [blame] | 10 | #include "content/common/notification_service.h" |
[email protected] | 2178814 | 2011-05-03 10:38:35 | [diff] [blame] | 11 | #include "grit/theme_resources.h" |
[email protected] | 8fcec3c7 | 2010-06-03 00:17:22 | [diff] [blame] | 12 | |
13 | // static | ||||
14 | void UpgradeDetector::RegisterPrefs(PrefService* prefs) { | ||||
15 | prefs->RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, false); | ||||
16 | } | ||||
17 | |||||
[email protected] | 2178814 | 2011-05-03 10:38:35 | [diff] [blame] | 18 | int 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] | 8fcec3c7 | 2010-06-03 00:17:22 | [diff] [blame] | 34 | UpgradeDetector::UpgradeDetector() |
[email protected] | ceff840 | 2011-06-12 23:27:12 | [diff] [blame] | 35 | : upgrade_notification_stage_(UPGRADE_ANNOYANCE_NONE), |
[email protected] | 8fcec3c7 | 2010-06-03 00:17:22 | [diff] [blame] | 36 | notify_upgrade_(false) { |
[email protected] | b1b7394 | 2010-05-26 20:11:54 | [diff] [blame] | 37 | } |
38 | |||||
39 | UpgradeDetector::~UpgradeDetector() { | ||||
40 | } | ||||
41 | |||||
[email protected] | ceff840 | 2011-06-12 23:27:12 | [diff] [blame] | 42 | void UpgradeDetector::NotifyUpgradeDetected() { |
[email protected] | 3bed26a | 2011-04-14 16:05:04 | [diff] [blame] | 43 | upgrade_detected_time_ = base::Time::Now(); |
44 | |||||
[email protected] | 8fcec3c7 | 2010-06-03 00:17:22 | [diff] [blame] | 45 | NotificationService::current()->Notify( |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame^] | 46 | chrome::NOTIFICATION_UPGRADE_DETECTED, |
[email protected] | 8fcec3c7 | 2010-06-03 00:17:22 | [diff] [blame] | 47 | Source<UpgradeDetector>(this), |
48 | NotificationService::NoDetails()); | ||||
[email protected] | b1b7394 | 2010-05-26 20:11:54 | [diff] [blame] | 49 | } |
50 | |||||
[email protected] | ceff840 | 2011-06-12 23:27:12 | [diff] [blame] | 51 | void UpgradeDetector::NotifyUpgradeRecommended() { |
[email protected] | b1b7394 | 2010-05-26 20:11:54 | [diff] [blame] | 52 | notify_upgrade_ = true; |
53 | |||||
54 | NotificationService::current()->Notify( | ||||
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame^] | 55 | chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
[email protected] | b1b7394 | 2010-05-26 20:11:54 | [diff] [blame] | 56 | Source<UpgradeDetector>(this), |
57 | NotificationService::NoDetails()); | ||||
58 | } |