OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_CONTROLLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "chrome/browser/ui/toolbar/app_menu_icon_painter.h" | |
10 #include "content/public/browser/notification_details.h" | 9 #include "content/public/browser/notification_details.h" |
11 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
13 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
14 | 13 |
15 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
16 #include "chrome/browser/win/enumerate_modules_model.h" | 15 #include "chrome/browser/win/enumerate_modules_model.h" |
17 #endif | 16 #endif |
18 | 17 |
19 class Profile; | 18 class Profile; |
20 | 19 |
21 // AppMenuIconController encapsulates the logic for badging the app menu icon | 20 // AppMenuIconController encapsulates the logic for badging the app menu icon |
22 // as a result of various events - such as available updates, errors, etc. | 21 // as a result of various events - such as available updates, errors, etc. |
23 class AppMenuIconController : | 22 class AppMenuIconController : |
24 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
25 public EnumerateModulesModel::Observer, | 24 public EnumerateModulesModel::Observer, |
26 #endif | 25 #endif |
27 public content::NotificationObserver { | 26 public content::NotificationObserver { |
28 public: | 27 public: |
29 enum class IconType { | 28 enum class IconType { |
30 NONE, | 29 NONE, |
31 UPGRADE_NOTIFICATION, | 30 UPGRADE_NOTIFICATION, |
32 GLOBAL_ERROR, | 31 GLOBAL_ERROR, |
33 INCOMPATIBILITY_WARNING, | 32 INCOMPATIBILITY_WARNING, |
34 }; | 33 }; |
| 34 enum class Severity { |
| 35 NONE, |
| 36 LOW, |
| 37 MEDIUM, |
| 38 HIGH, |
| 39 }; |
35 | 40 |
36 // Delegate interface for receiving icon update notifications. | 41 // Delegate interface for receiving icon update notifications. |
37 class Delegate { | 42 class Delegate { |
38 public: | 43 public: |
39 // Notifies the UI to update the icon to have the specified |severity|, as | 44 // Notifies the UI to update the icon to have the specified |severity|, as |
40 // well as specifying whether it should |animate|. The |type| parameter | 45 // well as specifying whether it should |animate|. The |type| parameter |
41 // specifies the type of change (i.e. the source of the notification). | 46 // specifies the type of change (i.e. the source of the notification). |
42 virtual void UpdateSeverity(IconType type, | 47 virtual void UpdateSeverity(IconType type, |
43 AppMenuIconPainter::Severity severity, | 48 Severity severity, |
44 bool animate) = 0; | 49 bool animate) = 0; |
45 | 50 |
46 protected: | 51 protected: |
47 virtual ~Delegate() {} | 52 virtual ~Delegate() {} |
48 }; | 53 }; |
49 | 54 |
50 // Creates an instance of this class for the given |profile| that will notify | 55 // Creates an instance of this class for the given |profile| that will notify |
51 // |delegate| of updates. | 56 // |delegate| of updates. |
52 AppMenuIconController(Profile* profile, Delegate* delegate); | 57 AppMenuIconController(Profile* profile, Delegate* delegate); |
53 ~AppMenuIconController() override; | 58 ~AppMenuIconController() override; |
(...skipping 17 matching lines...) Expand all Loading... |
71 #endif | 76 #endif |
72 | 77 |
73 Profile* profile_; | 78 Profile* profile_; |
74 Delegate* delegate_; | 79 Delegate* delegate_; |
75 content::NotificationRegistrar registrar_; | 80 content::NotificationRegistrar registrar_; |
76 | 81 |
77 DISALLOW_COPY_AND_ASSIGN(AppMenuIconController); | 82 DISALLOW_COPY_AND_ASSIGN(AppMenuIconController); |
78 }; | 83 }; |
79 | 84 |
80 #endif // CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_CONTROLLER_H_ | 85 #endif // CHROME_BROWSER_UI_TOOLBAR_APP_MENU_ICON_CONTROLLER_H_ |
OLD | NEW |