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 "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
11 #include "chrome/browser/ui/browser_otr_state.h" | 11 #include "chrome/browser/ui/browser_otr_state.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 "components/prefs/pref_registry_simple.h" | 14 #include "components/prefs/pref_registry_simple.h" |
15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 17 #include "ui/gfx/color_palette.h" |
| 18 #include "ui/gfx/paint_vector_icon.h" |
| 19 #include "ui/gfx/vector_icons_public.h" |
17 | 20 |
18 // How long to wait between checks for whether the user has been idle. | 21 // How long to wait between checks for whether the user has been idle. |
19 static const int kIdleRepeatingTimerWait = 10; // Minutes (seconds if testing). | 22 static const int kIdleRepeatingTimerWait = 10; // Minutes (seconds if testing). |
20 | 23 |
21 // How much idle time (since last input even was detected) must have passed | 24 // How much idle time (since last input even was detected) must have passed |
22 // until we notify that a critical update has occurred. | 25 // until we notify that a critical update has occurred. |
23 static const int kIdleAmount = 2; // Hours (or seconds, if testing). | 26 static const int kIdleAmount = 2; // Hours (or seconds, if testing). |
24 | 27 |
25 bool UseTestingIntervals() { | 28 bool UseTestingIntervals() { |
26 // If a command line parameter specifying how long the upgrade check should | 29 // If a command line parameter specifying how long the upgrade check should |
27 // be, we assume it is for testing and switch to using seconds instead of | 30 // be, we assume it is for testing and switch to using seconds instead of |
28 // hours. | 31 // hours. |
29 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); | 32 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess(); |
30 return !cmd_line.GetSwitchValueASCII( | 33 return !cmd_line.GetSwitchValueASCII( |
31 switches::kCheckForUpdateIntervalSec).empty(); | 34 switches::kCheckForUpdateIntervalSec).empty(); |
32 } | 35 } |
33 | 36 |
34 // static | 37 // static |
35 void UpgradeDetector::RegisterPrefs(PrefRegistrySimple* registry) { | 38 void UpgradeDetector::RegisterPrefs(PrefRegistrySimple* registry) { |
36 registry->RegisterBooleanPref(prefs::kAttemptedToEnableAutoupdate, false); | 39 registry->RegisterBooleanPref(prefs::kAttemptedToEnableAutoupdate, false); |
37 } | 40 } |
38 | 41 |
39 int UpgradeDetector::GetIconResourceID() { | 42 gfx::Image UpgradeDetector::GetIcon() { |
| 43 SkColor color = gfx::kPlaceholderColor; |
40 switch (upgrade_notification_stage_) { | 44 switch (upgrade_notification_stage_) { |
41 case UPGRADE_ANNOYANCE_NONE: | 45 case UPGRADE_ANNOYANCE_NONE: |
42 return 0; | 46 return gfx::Image(); |
43 case UPGRADE_ANNOYANCE_LOW: | 47 case UPGRADE_ANNOYANCE_LOW: |
44 return IDR_UPDATE_MENU_SEVERITY_LOW; | 48 color = gfx::kGoogleGreen700; |
| 49 break; |
45 case UPGRADE_ANNOYANCE_ELEVATED: | 50 case UPGRADE_ANNOYANCE_ELEVATED: |
46 return IDR_UPDATE_MENU_SEVERITY_MEDIUM; | 51 color = gfx::kGoogleYellow700; |
| 52 break; |
47 case UPGRADE_ANNOYANCE_HIGH: | 53 case UPGRADE_ANNOYANCE_HIGH: |
48 return IDR_UPDATE_MENU_SEVERITY_HIGH; | |
49 case UPGRADE_ANNOYANCE_SEVERE: | 54 case UPGRADE_ANNOYANCE_SEVERE: |
50 return IDR_UPDATE_MENU_SEVERITY_HIGH; | |
51 case UPGRADE_ANNOYANCE_CRITICAL: | 55 case UPGRADE_ANNOYANCE_CRITICAL: |
52 return IDR_UPDATE_MENU_SEVERITY_HIGH; | 56 color = gfx::kGoogleRed700; |
| 57 break; |
53 } | 58 } |
54 NOTREACHED(); | 59 DCHECK_NE(gfx::kPlaceholderColor, color); |
55 return 0; | 60 |
| 61 return gfx::Image( |
| 62 gfx::CreateVectorIcon(gfx::VectorIconId::UPGRADE_MENU_ITEM, 16, color)); |
56 } | 63 } |
57 | 64 |
58 UpgradeDetector::UpgradeDetector() | 65 UpgradeDetector::UpgradeDetector() |
59 : upgrade_available_(UPGRADE_AVAILABLE_NONE), | 66 : upgrade_available_(UPGRADE_AVAILABLE_NONE), |
60 best_effort_experiment_updates_available_(false), | 67 best_effort_experiment_updates_available_(false), |
61 critical_experiment_updates_available_(false), | 68 critical_experiment_updates_available_(false), |
62 critical_update_acknowledged_(false), | 69 critical_update_acknowledged_(false), |
63 is_factory_reset_required_(false), | 70 is_factory_reset_required_(false), |
64 upgrade_notification_stage_(UPGRADE_ANNOYANCE_NONE), | 71 upgrade_notification_stage_(UPGRADE_ANNOYANCE_NONE), |
65 notify_upgrade_(false) { | 72 notify_upgrade_(false) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 break; | 133 break; |
127 case ui::IDLE_STATE_ACTIVE: | 134 case ui::IDLE_STATE_ACTIVE: |
128 case ui::IDLE_STATE_UNKNOWN: | 135 case ui::IDLE_STATE_UNKNOWN: |
129 break; | 136 break; |
130 default: | 137 default: |
131 NOTREACHED(); // Need to add any new value above (either providing | 138 NOTREACHED(); // Need to add any new value above (either providing |
132 // automatic restart or show notification to user). | 139 // automatic restart or show notification to user). |
133 break; | 140 break; |
134 } | 141 } |
135 } | 142 } |
OLD | NEW |