12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/observer_list.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/strings/string16.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/message_center/message_center_export.h"
11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ui/message_center/message_center_observer.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "ui/message_center/message_center_tray_delegate.h"
135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/message_center/notifier_settings.h"
145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ui {
165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class MenuModel;
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace message_center {
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)class MessageCenter;
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class MessageBubbleBase;
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class MessagePopupBubble;
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class QuietModeBubble;
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Implementation found with each supported platform's implementation of
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// MessageCenterTrayDelegate.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)MessageCenterTrayDelegate* CreateMessageCenterTray();
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Class that observes a MessageCenter. Manages the popup and message center
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// bubbles. Tells the MessageCenterTrayHost when the tray is changed, as well
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// as when bubbles are shown and hidden.
33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class MESSAGE_CENTER_EXPORT MessageCenterTray : public MessageCenterObserver {
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  MessageCenterTray(MessageCenterTrayDelegate* delegate,
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                    message_center::MessageCenter* message_center);
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~MessageCenterTray();
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Shows or updates the message center bubble and hides the popup bubble.
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns whether the message center is visible after the call, whether or
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // not it was visible before.
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool ShowMessageCenterBubble();
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
447dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Hides the message center if visible and returns whether the message center
457dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // was visible before.
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool HideMessageCenterBubble();
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
487dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // Marks the message center as "not visible" (this method will not hide the
497dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  // message center).
507dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void MarkMessageCenterHidden();
517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void ToggleMessageCenterBubble();
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Causes an update if the popup bubble is already shown.
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void ShowPopupBubble();
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Returns whether the popup was visible before.
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool HidePopupBubble();
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
60eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // Toggles the visibility of the settings view in the message center bubble.
61eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  void ShowNotifierSettingsBubble();
62eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Creates a model for the context menu for a notification card.
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  scoped_ptr<ui::MenuModel> CreateNotificationMenuModel(
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const NotifierId& notifier_id,
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      const base::string16& display_source);
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool message_center_visible() { return message_center_visible_; }
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool popups_visible() { return popups_visible_; }
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  MessageCenterTrayDelegate* delegate() { return delegate_; }
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const message_center::MessageCenter* message_center() const {
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    return message_center_;
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  }
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  message_center::MessageCenter* message_center() { return message_center_; }
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
76c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  // Overridden from MessageCenterObserver:
77c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnNotificationAdded(const std::string& notification_id) OVERRIDE;
78c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnNotificationRemoved(const std::string& notification_id,
79c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)                                     bool by_user) OVERRIDE;
80c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnNotificationUpdated(
81c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const std::string& notification_id) OVERRIDE;
82c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnNotificationClicked(
83c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const std::string& notification_id) OVERRIDE;
84c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnNotificationButtonClicked(
85c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      const std::string& notification_id,
86c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)      int button_index) OVERRIDE;
87c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  virtual void OnNotificationDisplayed(
88010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)      const std::string& notification_id,
89010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)      const DisplaySource source) OVERRIDE;
90424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  virtual void OnQuietModeChanged(bool in_quiet_mode) OVERRIDE;
91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual void OnBlockingStateChanged(NotificationBlocker* blocker) OVERRIDE;
922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
94c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  void OnMessageCenterChanged();
952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void NotifyMessageCenterTrayChanged();
9658537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)  void HidePopupBubbleInternal();
972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |message_center_| is a weak pointer that must live longer than
992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // MessageCenterTray.
1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  message_center::MessageCenter* message_center_;
1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool message_center_visible_;
1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  bool popups_visible_;
1032a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // |delegate_| is a weak pointer that must live longer than MessageCenterTray.
1042a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  MessageCenterTrayDelegate* delegate_;
1052a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(MessageCenterTray);
1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace message_center
1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // UI_MESSAGE_CENTER_MESSAGE_CENTER_TRAY_H_
112