Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: ash/system/web_notification/web_notification_tray.cc

Issue 11958025: Start delegating notifications to MessageCenter on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another build fix Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | chrome/browser/browser_process.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ash/system/web_notification/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/system/status_area_widget.h" 9 #include "ash/system/status_area_widget.h"
10 #include "ash/system/tray/tray_bubble_wrapper.h" 10 #include "ash/system/tray/tray_bubble_wrapper.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 scoped_ptr<internal::TrayBubbleWrapper> bubble_wrapper_; 76 scoped_ptr<internal::TrayBubbleWrapper> bubble_wrapper_;
77 }; 77 };
78 78
79 } // namespace internal 79 } // namespace internal
80 80
81 WebNotificationTray::WebNotificationTray( 81 WebNotificationTray::WebNotificationTray(
82 internal::StatusAreaWidget* status_area_widget) 82 internal::StatusAreaWidget* status_area_widget)
83 : internal::TrayBackgroundView(status_area_widget), 83 : internal::TrayBackgroundView(status_area_widget),
84 button_(NULL), 84 button_(NULL),
85 show_message_center_on_unlock_(false) { 85 show_message_center_on_unlock_(false) {
86 message_center_ = message_center::MessageCenter::GetInstance(); 86 message_center_ = ash::Shell::GetInstance()->message_center();
87 message_center_->AddObserver(this); 87 message_center_->AddObserver(this);
88 button_ = new views::ImageButton(this); 88 button_ = new views::ImageButton(this);
89 button_->set_triggerable_event_flags( 89 button_->set_triggerable_event_flags(
90 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON); 90 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON);
91 tray_container()->AddChildView(button_); 91 tray_container()->AddChildView(button_);
92 SetVisible(false); 92 SetVisible(false);
93 UpdateTray(); 93 UpdateTray();
94 } 94 }
95 95
96 WebNotificationTray::~WebNotificationTray() { 96 WebNotificationTray::~WebNotificationTray() {
97 // Ensure the message center doesn't notify a destroyed object. 97 // Ensure the message center doesn't notify an object under destruction.
98 message_center_->RemoveObserver(this); 98 message_center_->RemoveObserver(this);
99 // Release any child views that might have back pointers before ~View(). 99 // Release any child views that might have back pointers before ~View().
100 message_center_bubble_.reset(); 100 message_center_bubble_.reset();
101 popup_bubble_.reset(); 101 popup_bubble_.reset();
102 if (quiet_mode_bubble() && quiet_mode_bubble_->GetBubbleWidget()) 102 if (quiet_mode_bubble() && quiet_mode_bubble_->GetBubbleWidget())
103 quiet_mode_bubble_->GetBubbleWidget()->RemoveObserver(this); 103 quiet_mode_bubble_->GetBubbleWidget()->RemoveObserver(this);
104 quiet_mode_bubble_.reset(); 104 quiet_mode_bubble_.reset();
105 } 105 }
106 106
107 void WebNotificationTray::ShowMessageCenterBubble() { 107 void WebNotificationTray::ShowMessageCenterBubble() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if (message_center_bubble()) 164 if (message_center_bubble())
165 return; 165 return;
166 if (!status_area_widget()->ShouldShowWebNotifications()) 166 if (!status_area_widget()->ShouldShowWebNotifications())
167 return; 167 return;
168 UpdateTray(); 168 UpdateTray();
169 if (popup_bubble()) { 169 if (popup_bubble()) {
170 popup_bubble()->bubble()->ScheduleUpdate(); 170 popup_bubble()->bubble()->ScheduleUpdate();
171 } else if (message_center_->HasPopupNotifications()) { 171 } else if (message_center_->HasPopupNotifications()) {
172 popup_bubble_.reset( 172 popup_bubble_.reset(
173 new internal::WebNotificationBubbleWrapper( 173 new internal::WebNotificationBubbleWrapper(
174 this, new message_center::MessagePopupBubble( 174 this, new message_center::MessagePopupBubble(message_center_)));
175 message_center_)));
176 } 175 }
177 } 176 }
178 177
179 void WebNotificationTray::HidePopupBubble() { 178 void WebNotificationTray::HidePopupBubble() {
180 popup_bubble_.reset(); 179 popup_bubble_.reset();
181 } 180 }
182 181
183 bool WebNotificationTray::ShouldShowQuietModeBubble(const ui::Event& event) { 182 bool WebNotificationTray::ShouldShowQuietModeBubble(const ui::Event& event) {
184 // TODO(mukai): Add keyboard event handler. 183 // TODO(mukai): Add keyboard event handler.
185 if (!event.IsMouseEvent()) 184 if (!event.IsMouseEvent())
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 404
406 message_center::MessagePopupBubble* 405 message_center::MessagePopupBubble*
407 WebNotificationTray::GetPopupBubbleForTest() { 406 WebNotificationTray::GetPopupBubbleForTest() {
408 if (!popup_bubble_.get()) 407 if (!popup_bubble_.get())
409 return NULL; 408 return NULL;
410 return static_cast<message_center::MessagePopupBubble*>( 409 return static_cast<message_center::MessagePopupBubble*>(
411 popup_bubble_->bubble()); 410 popup_bubble_->bubble());
412 } 411 }
413 412
414 } // namespace ash 413 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | chrome/browser/browser_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698