[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / notifications / message_center_tray_bridge.h
blob77da69f86fa78cbb18f891b18c1c79a48b84b207
1 // Copyright (c) 2013 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_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
8 #import <AppKit/AppKit.h>
10 #include "base/basictypes.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/prefs/pref_member.h"
15 #include "ui/message_center/message_center.h"
16 #include "ui/message_center/message_center_tray_delegate.h"
18 @class MCPopupCollection;
19 @class MCStatusItemView;
20 @class MCTrayController;
22 namespace message_center {
23 class MessageCenter;
24 class MessageCenterTray;
27 // MessageCenterTrayBridge is the owner of all the Cocoa UI objects for the
28 // message_center. It bridges C++ notifications from the MessageCenterTray to
29 // the various UI objects.
30 class MessageCenterTrayBridge :
31 public message_center::MessageCenterTrayDelegate {
32 public:
33 explicit MessageCenterTrayBridge(
34 message_center::MessageCenter* message_center);
35 virtual ~MessageCenterTrayBridge();
37 // message_center::MessageCenterTrayDelegate:
38 virtual void OnMessageCenterTrayChanged() OVERRIDE;
39 virtual bool ShowPopups() OVERRIDE;
40 virtual void HidePopups() OVERRIDE;
41 virtual bool ShowMessageCenter() OVERRIDE;
42 virtual void HideMessageCenter() OVERRIDE;
43 virtual bool ShowNotifierSettings() OVERRIDE;
44 virtual bool IsContextMenuEnabled() const OVERRIDE;
45 virtual message_center::MessageCenterTray* GetMessageCenterTray() OVERRIDE;
47 message_center::MessageCenter* message_center() { return message_center_; }
49 private:
50 friend class MessageCenterTrayBridgeTest;
52 // Updates the unread count on the status item.
53 void UpdateStatusItem();
55 // Opens the message center tray.
56 void OpenTrayWindow();
58 // Uses the pref controlled by the main menu to determine whether the status
59 // item should be shown.
60 bool ShouldShowStatusItem() const;
62 // Notifies that the user has changed the show menubar item preference.
63 void OnShowStatusItemChanged();
65 // The global, singleton message center model object. Weak.
66 message_center::MessageCenter* message_center_;
68 // C++ controller for the notification tray UI.
69 scoped_ptr<message_center::MessageCenterTray> tray_;
71 // Obj-C window controller for the notification tray.
72 base::scoped_nsobject<MCTrayController> tray_controller_;
74 // View that is displayed on the system menu bar item.
75 base::scoped_nsobject<MCStatusItemView> status_item_view_;
77 // Obj-C controller for the on-screen popup notifications.
78 base::scoped_nsobject<MCPopupCollection> popup_collection_;
80 // Weak pointer factory to posts tasks to self.
81 base::WeakPtrFactory<MessageCenterTrayBridge> weak_ptr_factory_;
83 // A PrefMember that calls OnShowStatusItemChanged when the pref is updated
84 // by the user's selection in the main menu.
85 BooleanPrefMember show_status_item_;
87 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayBridge);
90 #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_