Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / message_center / web_notification_tray.cc
blob0e7a396be18a3e3f3ac9b29f293e02a1f488957e
1 // Copyright 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 #include "chrome/browser/ui/views/message_center/web_notification_tray.h"
7 #include "chrome/browser/browser_process.h"
8 #include "ui/gfx/screen.h"
9 #include "ui/message_center/message_center_tray.h"
10 #include "ui/message_center/message_center_tray_delegate.h"
11 #include "ui/message_center/views/desktop_popup_alignment_delegate.h"
12 #include "ui/message_center/views/message_popup_collection.h"
14 namespace message_center {
16 MessageCenterTrayDelegate* CreateMessageCenterTray() {
17 return new WebNotificationTray();
20 WebNotificationTray::WebNotificationTray() {
21 message_center_tray_.reset(
22 new MessageCenterTray(this, g_browser_process->message_center()));
23 alignment_delegate_.reset(new message_center::DesktopPopupAlignmentDelegate);
24 popup_collection_.reset(new message_center::MessagePopupCollection(
25 NULL, message_center(), message_center_tray_.get(),
26 alignment_delegate_.get()));
29 WebNotificationTray::~WebNotificationTray() {
30 // Reset this early so that delegated events during destruction don't cause
31 // problems.
32 popup_collection_.reset();
33 message_center_tray_.reset();
36 message_center::MessageCenter* WebNotificationTray::message_center() {
37 return message_center_tray_->message_center();
40 bool WebNotificationTray::ShowPopups() {
41 alignment_delegate_->StartObserving(gfx::Screen::GetNativeScreen());
42 popup_collection_->DoUpdateIfPossible();
43 return true;
46 void WebNotificationTray::HidePopups() {
47 DCHECK(popup_collection_.get());
48 popup_collection_->MarkAllPopupsShown();
51 bool WebNotificationTray::ShowMessageCenter() {
52 // Message center not available on Windows/Linux.
53 return false;
56 void WebNotificationTray::HideMessageCenter() {
59 bool WebNotificationTray::ShowNotifierSettings() {
60 // Message center settings not available on Windows/Linux.
61 return false;
64 bool WebNotificationTray::IsContextMenuEnabled() const {
65 // It can always return true because the notifications are invisible if
66 // the context menu shouldn't be enabled, such as in the lock screen.
67 return true;
70 void WebNotificationTray::OnMessageCenterTrayChanged() {
73 MessageCenterTray* WebNotificationTray::GetMessageCenterTray() {
74 return message_center_tray_.get();
77 } // namespace message_center