Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / notifications / message_center_tray_bridge.h
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.
4
5 #ifndef CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
6 #define CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_
7
8 #import <AppKit/AppKit.h>
9
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"
17
18 @class MCPopupCollection;
19 @class MCStatusItemView;
20 @class MCTrayController;
21
22 namespace message_center {
23 class MessageCenter;
24 class MessageCenterTray;
25 }
26
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();
36
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;
46
47   message_center::MessageCenter* message_center() { return message_center_; }
48
49  private:
50   friend class MessageCenterTrayBridgeTest;
51
52   // Updates the unread count on the status item.
53   void UpdateStatusItem();
54
55   // Opens the message center tray.
56   void OpenTrayWindow();
57
58   // Uses the pref controlled by the main menu to determine whether the status
59   // item should be shown.
60   bool ShouldShowStatusItem() const;
61
62   // Notifies that the user has changed the show menubar item preference.
63   void OnShowStatusItemChanged();
64
65   // The global, singleton message center model object. Weak.
66   message_center::MessageCenter* message_center_;
67
68   // C++ controller for the notification tray UI.
69   scoped_ptr<message_center::MessageCenterTray> tray_;
70
71   // Obj-C window controller for the notification tray.
72   base::scoped_nsobject<MCTrayController> tray_controller_;
73
74   // View that is displayed on the system menu bar item.
75   base::scoped_nsobject<MCStatusItemView> status_item_view_;
76
77   // Obj-C controller for the on-screen popup notifications.
78   base::scoped_nsobject<MCPopupCollection> popup_collection_;
79
80   // A PrefMember that calls OnShowStatusItemChanged when the pref is updated
81   // by the user's selection in the main menu.
82   BooleanPrefMember show_status_item_;
83
84   // Weak pointer factory to posts tasks to self.
85   base::WeakPtrFactory<MessageCenterTrayBridge> weak_ptr_factory_;
86
87   DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayBridge);
88 };
89
90 #endif  // CHROME_BROWSER_UI_COCOA_NOTIFICATIONS_MESSAGE_CENTER_TRAY_BRIDGE_H_