Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / toolbar / wrench_menu_badge_controller.h
blobc75b371421fa9f44bfe7aacbcb0084387f03cdaa
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_BADGE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_BADGE_CONTROLLER_H_
8 #include "base/macros.h"
9 #include "chrome/browser/ui/toolbar/wrench_icon_painter.h"
10 #include "content/public/browser/notification_details.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/notification_service.h"
15 class Profile;
17 // WrenchMenuBadgeController encapsulates the logic for badging the wrench menu
18 // icon as a result of various events - such as available updates, errors, etc.
19 class WrenchMenuBadgeController : public content::NotificationObserver {
20 public:
21 enum BadgeType {
22 BADGE_TYPE_NONE,
23 BADGE_TYPE_UPGRADE_NOTIFICATION,
24 BADGE_TYPE_GLOBAL_ERROR,
25 BADGE_TYPE_INCOMPATIBILITY_WARNING,
28 // Delegate interface for receiving badge update notifications.
29 class Delegate {
30 public:
31 // Notifies the UI to update the badge to have the specified |severity|, as
32 // well as specifying whether it should |animate|. The |type| parameter
33 // specifies the type of change (i.e. the source of the notification).
34 virtual void UpdateBadgeSeverity(BadgeType type,
35 WrenchIconPainter::Severity severity,
36 bool animate) = 0;
38 protected:
39 virtual ~Delegate() {}
42 // Creates an instance of this class for the given |profile| that will notify
43 // |delegate| of updates.
44 WrenchMenuBadgeController(Profile* profile, Delegate* delegate);
45 ~WrenchMenuBadgeController() override;
47 // Forces an update of the UI based on the current state of the world. This
48 // will check whether there are any current pending updates, global errors,
49 // etc. and based on that information trigger an appropriate call to the
50 // delegate.
51 void UpdateDelegate();
53 // Sets |overflowed_toolbar_action_wants_to_run_| and updates the delegate.
54 void SetOverflowedToolbarActionWantsToRun(bool wants_to_run);
56 bool overflowed_toolbar_action_wants_to_run() const {
57 return overflowed_toolbar_action_wants_to_run_;
60 private:
61 // content::NotificationObserver:
62 void Observe(int type,
63 const content::NotificationSource& source,
64 const content::NotificationDetails& details) override;
66 Profile* profile_;
67 Delegate* delegate_;
68 content::NotificationRegistrar registrar_;
69 bool overflowed_toolbar_action_wants_to_run_;
71 DISALLOW_COPY_AND_ASSIGN(WrenchMenuBadgeController);
74 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_BADGE_CONTROLLER_H_