OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_ |
6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_ | 6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_ |
7 | 7 |
8 #import <AppKit/AppKit.h> | 8 #import <AppKit/AppKit.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
15 #include "ui/message_center/message_center.h" | 15 #include "ui/message_center/message_center.h" |
16 #include "ui/message_center/message_center_tray_delegate.h" | 16 #include "ui/message_center/message_center_tray_delegate.h" |
17 | 17 |
18 @class MCPopupCollection; | 18 @class MCPopupCollection; |
19 @class MCStatusItemView; | |
20 @class MCTrayController; | |
21 | 19 |
22 namespace message_center { | 20 namespace message_center { |
23 class MessageCenter; | 21 class MessageCenter; |
24 class MessageCenterTray; | 22 class MessageCenterTray; |
25 } | 23 } |
26 | 24 |
27 // MessageCenterTrayBridge is the owner of all the Cocoa UI objects for the | 25 // MessageCenterTrayBridge is the owner of all the Cocoa UI objects for the |
28 // message_center. It bridges C++ notifications from the MessageCenterTray to | 26 // message_center. It bridges C++ notifications from the MessageCenterTray to |
29 // the various UI objects. | 27 // the various UI objects. |
30 class MessageCenterTrayBridge : | 28 class MessageCenterTrayBridge : |
(...skipping 11 matching lines...) Expand all Loading... | |
42 void HideMessageCenter() override; | 40 void HideMessageCenter() override; |
43 bool ShowNotifierSettings() override; | 41 bool ShowNotifierSettings() override; |
44 bool IsContextMenuEnabled() const override; | 42 bool IsContextMenuEnabled() const override; |
45 message_center::MessageCenterTray* GetMessageCenterTray() override; | 43 message_center::MessageCenterTray* GetMessageCenterTray() override; |
46 | 44 |
47 message_center::MessageCenter* message_center() { return message_center_; } | 45 message_center::MessageCenter* message_center() { return message_center_; } |
48 | 46 |
49 private: | 47 private: |
50 friend class MessageCenterTrayBridgeTest; | 48 friend class MessageCenterTrayBridgeTest; |
51 | 49 |
52 // Updates the unread count on the status item. | |
53 void UpdateStatusItem(); | |
54 | |
55 // Opens the message center tray. | |
56 void OpenTrayWindow(); | |
57 | |
58 // Returns whether the status item allowed based on the preference value. | |
59 bool CanShowStatusItem() const; | |
60 | |
61 // Returns whether the status item should be shown if allowed. | |
62 bool NeedsStatusItem() const; | |
63 | |
64 // Constructs the status item view and registers its callback. | |
65 void ShowStatusItem(); | |
66 | |
67 // Destroys the status item view. | |
68 void HideStatusItem(); | |
69 | |
70 // Called after returning to the event loop from the | |
71 // OnMessageCenterTrayChanged event to prevent multiple updates from being | |
72 // rendered as the message center is modified. | |
73 void HandleMessageCenterTrayChanged(); | |
74 | |
75 // Notifies that the user has changed the show menubar item preference. | |
76 void OnShowStatusItemChanged(); | |
77 | |
78 // The global, singleton message center model object. Weak. | 50 // The global, singleton message center model object. Weak. |
79 message_center::MessageCenter* message_center_; | 51 message_center::MessageCenter* message_center_; |
80 | 52 |
81 // C++ controller for the notification tray UI. | 53 // C++ controller for the notification tray UI. |
82 scoped_ptr<message_center::MessageCenterTray> tray_; | 54 scoped_ptr<message_center::MessageCenterTray> tray_; |
Robert Sesek
2015/09/15 22:07:08
I assume we still need |tray_| per the CL descript
dewittj
2015/09/15 22:52:22
I was assuming so, but now that I look it's only u
| |
83 | 55 |
84 // Obj-C window controller for the notification tray. | |
85 base::scoped_nsobject<MCTrayController> tray_controller_; | |
86 | |
87 // View that is displayed on the system menu bar item. | |
88 base::scoped_nsobject<MCStatusItemView> status_item_view_; | |
89 | |
90 // Obj-C controller for the on-screen popup notifications. | 56 // Obj-C controller for the on-screen popup notifications. |
91 base::scoped_nsobject<MCPopupCollection> popup_collection_; | 57 base::scoped_nsobject<MCPopupCollection> popup_collection_; |
92 | 58 |
93 // Used to ensure only one status item update happens in a given call stack. | |
94 bool status_item_update_pending_; | |
95 | |
96 // A PrefMember that calls OnShowStatusItemChanged when the pref is updated | |
97 // by the user's selection in the main menu. | |
98 BooleanPrefMember show_status_item_; | |
99 | |
100 // Weak pointer factory to posts tasks to self. | |
101 base::WeakPtrFactory<MessageCenterTrayBridge> weak_ptr_factory_; | |
102 | |
103 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayBridge); | 59 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayBridge); |
104 }; | 60 }; |
105 | 61 |
106 #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_ | 62 #endif // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_ |
OLD | NEW |