OLD | NEW |
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/system/status_area_widget.h" | 8 #include "ash/system/status_area_widget.h" |
9 #include "ash/system/tray/tray_bubble_view.h" | 9 #include "ash/system/tray/tray_bubble_view.h" |
10 #include "ash/system/tray/tray_bubble_wrapper.h" | 10 #include "ash/system/tray/tray_bubble_wrapper.h" |
11 #include "ash/system/tray/tray_constants.h" | 11 #include "ash/system/tray/tray_constants.h" |
12 #include "ash/system/tray/tray_views.h" | 12 #include "ash/system/tray/tray_views.h" |
13 #include "ash/system/web_notification/message_center_bubble.h" | 13 #include "ash/system/web_notification/message_center_bubble.h" |
14 #include "ash/system/web_notification/popup_bubble.h" | 14 #include "ash/system/web_notification/popup_bubble.h" |
15 #include "ash/system/web_notification/web_notification.h" | 15 #include "ash/system/web_notification/web_notification.h" |
16 #include "ash/system/web_notification/web_notification_bubble.h" | 16 #include "ash/system/web_notification/web_notification_bubble.h" |
17 #include "ash/system/web_notification/web_notification_list.h" | |
18 #include "ash/wm/shelf_layout_manager.h" | 17 #include "ash/wm/shelf_layout_manager.h" |
19 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
20 #include "base/stringprintf.h" | 19 #include "base/stringprintf.h" |
21 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
22 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
23 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
26 #include "ui/views/widget/widget_observer.h" | 25 #include "ui/views/widget/widget_observer.h" |
27 | 26 |
28 namespace { | 27 namespace { |
29 | 28 |
30 // Tray constants | 29 // Tray constants |
31 const int kTrayContainerVerticalPaddingBottomAlignment = 3; | 30 const int kTrayContainerVerticalPaddingBottomAlignment = 3; |
32 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; | 31 const int kTrayContainerHorizontalPaddingBottomAlignment = 1; |
33 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; | 32 const int kTrayContainerVerticalPaddingVerticalAlignment = 1; |
34 const int kTrayContainerHorizontalPaddingVerticalAlignment = 0; | 33 const int kTrayContainerHorizontalPaddingVerticalAlignment = 0; |
35 const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8; | 34 const int kPaddingFromLeftEdgeOfSystemTrayBottomAlignment = 8; |
36 const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10; | 35 const int kPaddingFromTopEdgeOfSystemTrayVerticalAlignment = 10; |
37 | 36 |
38 std::string GetNotificationText(int notification_count) { | |
39 if (notification_count >= 100) | |
40 return "99+"; | |
41 return base::StringPrintf("%d", notification_count); | |
42 } | |
43 | |
44 } // namespace | 37 } // namespace |
45 | 38 |
46 using message_center::MessageCenterBubble; | 39 using message_center::MessageCenterBubble; |
47 using message_center::PopupBubble; | 40 using message_center::PopupBubble; |
48 using message_center::TrayBubbleView; | 41 using message_center::TrayBubbleView; |
49 using message_center::WebNotification; | 42 using message_center::WebNotification; |
50 using message_center::WebNotificationBubble; | 43 using message_center::WebNotificationBubble; |
51 using message_center::WebNotificationList; | |
52 | 44 |
53 namespace ash { | 45 namespace ash { |
54 | 46 |
55 namespace internal { | 47 namespace internal { |
56 | 48 |
57 // Class to initialize and manage the WebNotificationBubble and | 49 // Class to initialize and manage the WebNotificationBubble and |
58 // TrayBubbleWrapper instances for a bubble. | 50 // TrayBubbleWrapper instances for a bubble. |
59 | 51 |
60 class WebNotificationBubbleWrapper { | 52 class WebNotificationBubbleWrapper { |
61 public: | 53 public: |
(...skipping 26 matching lines...) Expand all Loading... |
88 scoped_ptr<WebNotificationBubble> bubble_; | 80 scoped_ptr<WebNotificationBubble> bubble_; |
89 scoped_ptr<internal::TrayBubbleWrapper> bubble_wrapper_; | 81 scoped_ptr<internal::TrayBubbleWrapper> bubble_wrapper_; |
90 }; | 82 }; |
91 | 83 |
92 } // namespace internal | 84 } // namespace internal |
93 | 85 |
94 WebNotificationTray::WebNotificationTray( | 86 WebNotificationTray::WebNotificationTray( |
95 internal::StatusAreaWidget* status_area_widget) | 87 internal::StatusAreaWidget* status_area_widget) |
96 : internal::TrayBackgroundView(status_area_widget), | 88 : internal::TrayBackgroundView(status_area_widget), |
97 button_(NULL), | 89 button_(NULL), |
98 delegate_(NULL), | |
99 show_message_center_on_unlock_(false) { | 90 show_message_center_on_unlock_(false) { |
100 notification_list_.reset(new WebNotificationList(this)); | 91 message_center_.reset(new message_center::MessageCenter(this)); |
101 | |
102 button_ = new views::ImageButton(this); | 92 button_ = new views::ImageButton(this); |
103 tray_container()->AddChildView(button_); | 93 tray_container()->AddChildView(button_); |
104 | |
105 UpdateTray(); | 94 UpdateTray(); |
106 } | 95 } |
107 | 96 |
108 WebNotificationTray::~WebNotificationTray() { | 97 WebNotificationTray::~WebNotificationTray() { |
| 98 // message_center_ has a weak pointer to this; destroy it early. |
| 99 message_center_.reset(); |
109 // Release any child views that might have back pointers before ~View(). | 100 // Release any child views that might have back pointers before ~View(). |
110 notification_list_.reset(); | |
111 message_center_bubble_.reset(); | 101 message_center_bubble_.reset(); |
112 popup_bubble_.reset(); | 102 popup_bubble_.reset(); |
113 } | 103 } |
114 | 104 |
115 void WebNotificationTray::SetDelegate(Delegate* delegate) { | |
116 DCHECK(!delegate_); | |
117 delegate_ = delegate; | |
118 } | |
119 | |
120 // Add/Update/RemoveNotification are called by the client code, i.e the | |
121 // Delegate implementation or its proxy. | |
122 | |
123 void WebNotificationTray::AddNotification(const std::string& id, | |
124 const string16& title, | |
125 const string16& message, | |
126 const string16& display_source, | |
127 const std::string& extension_id) { | |
128 notification_list_->AddNotification( | |
129 id, title, message, display_source, extension_id); | |
130 UpdateTrayAndBubble(); | |
131 ShowPopupBubble(); | |
132 } | |
133 | |
134 void WebNotificationTray::UpdateNotification(const std::string& old_id, | |
135 const std::string& new_id, | |
136 const string16& title, | |
137 const string16& message) { | |
138 notification_list_->UpdateNotificationMessage(old_id, new_id, title, message); | |
139 UpdateTrayAndBubble(); | |
140 ShowPopupBubble(); | |
141 } | |
142 | |
143 void WebNotificationTray::RemoveNotification(const std::string& id) { | |
144 if (!notification_list_->RemoveNotification(id)) | |
145 return; | |
146 if (!notification_list_->HasPopupNotifications()) | |
147 HidePopupBubble(); | |
148 UpdateTrayAndBubble(); | |
149 } | |
150 | |
151 void WebNotificationTray::SetNotificationImage(const std::string& id, | |
152 const gfx::ImageSkia& image) { | |
153 if (!notification_list_->SetNotificationImage(id, image)) | |
154 return; | |
155 UpdateTrayAndBubble(); | |
156 ShowPopupBubble(); | |
157 } | |
158 | |
159 void WebNotificationTray::ShowMessageCenterBubble() { | 105 void WebNotificationTray::ShowMessageCenterBubble() { |
160 if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED) | 106 if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED) |
161 return; | 107 return; |
162 if (message_center_bubble()) { | 108 if (message_center_bubble()) { |
163 UpdateTray(); | 109 UpdateTray(); |
164 return; | 110 return; |
165 } | 111 } |
166 // Indicate that the message center is visible. Clears the unread count. | 112 // Indicate that the message center is visible. Clears the unread count. |
167 notification_list_->SetMessageCenterVisible(true); | 113 message_center_->SetMessageCenterVisible(true); |
168 UpdateTray(); | 114 UpdateTray(); |
169 HidePopupBubble(); | 115 HidePopupBubble(); |
170 MessageCenterBubble* bubble = new MessageCenterBubble(this); | 116 MessageCenterBubble* bubble = new MessageCenterBubble(message_center_.get()); |
171 message_center_bubble_.reset( | 117 message_center_bubble_.reset( |
172 new internal::WebNotificationBubbleWrapper(this, bubble)); | 118 new internal::WebNotificationBubbleWrapper(this, bubble)); |
173 | 119 |
174 status_area_widget()->SetHideSystemNotifications(true); | 120 status_area_widget()->SetHideSystemNotifications(true); |
175 GetShelfLayoutManager()->UpdateAutoHideState(); | 121 GetShelfLayoutManager()->UpdateAutoHideState(); |
176 } | 122 } |
177 | 123 |
178 void WebNotificationTray::HideMessageCenterBubble() { | 124 void WebNotificationTray::HideMessageCenterBubble() { |
179 if (!message_center_bubble()) | 125 if (!message_center_bubble()) |
180 return; | 126 return; |
181 message_center_bubble_.reset(); | 127 message_center_bubble_.reset(); |
182 show_message_center_on_unlock_ = false; | 128 show_message_center_on_unlock_ = false; |
183 notification_list_->SetMessageCenterVisible(false); | 129 message_center_->SetMessageCenterVisible(false); |
184 UpdateTray(); | 130 UpdateTray(); |
185 status_area_widget()->SetHideSystemNotifications(false); | 131 status_area_widget()->SetHideSystemNotifications(false); |
186 GetShelfLayoutManager()->UpdateAutoHideState(); | 132 GetShelfLayoutManager()->UpdateAutoHideState(); |
187 } | 133 } |
188 | 134 |
189 void WebNotificationTray::SetHidePopupBubble(bool hide) { | 135 void WebNotificationTray::SetHidePopupBubble(bool hide) { |
190 if (hide) | 136 if (hide) |
191 HidePopupBubble(); | 137 HidePopupBubble(); |
192 else | 138 else |
193 ShowPopupBubble(); | 139 ShowPopupBubble(); |
194 } | 140 } |
195 | 141 |
196 void WebNotificationTray::ShowPopupBubble() { | 142 void WebNotificationTray::ShowPopupBubble() { |
197 if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED) | 143 if (status_area_widget()->login_status() == user::LOGGED_IN_LOCKED) |
198 return; | 144 return; |
199 if (message_center_bubble()) | 145 if (message_center_bubble()) |
200 return; | 146 return; |
201 if (!status_area_widget()->ShouldShowWebNotifications()) | 147 if (!status_area_widget()->ShouldShowWebNotifications()) |
202 return; | 148 return; |
203 UpdateTray(); | 149 UpdateTray(); |
204 if (popup_bubble()) { | 150 if (popup_bubble()) { |
205 popup_bubble()->bubble()->ScheduleUpdate(); | 151 popup_bubble()->bubble()->ScheduleUpdate(); |
206 } else if (notification_list_->HasPopupNotifications()) { | 152 } else if (message_center_->HasPopupNotifications()) { |
207 popup_bubble_.reset( | 153 popup_bubble_.reset( |
208 new internal::WebNotificationBubbleWrapper( | 154 new internal::WebNotificationBubbleWrapper( |
209 this, new PopupBubble(this))); | 155 this, new PopupBubble(message_center_.get()))); |
210 } | 156 } |
211 } | 157 } |
212 | 158 |
213 void WebNotificationTray::HidePopupBubble() { | 159 void WebNotificationTray::HidePopupBubble() { |
214 popup_bubble_.reset(); | 160 popup_bubble_.reset(); |
215 } | 161 } |
216 | 162 |
217 void WebNotificationTray::UpdateAfterLoginStatusChange( | 163 void WebNotificationTray::UpdateAfterLoginStatusChange( |
218 user::LoginStatus login_status) { | 164 user::LoginStatus login_status) { |
219 if (login_status == user::LOGGED_IN_LOCKED) { | 165 if (login_status == user::LOGGED_IN_LOCKED) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 } | 205 } |
260 if (message_center_bubble_.get()) | 206 if (message_center_bubble_.get()) |
261 message_center_bubble_->bubble_view()->UpdateBubble(); | 207 message_center_bubble_->bubble_view()->UpdateBubble(); |
262 } | 208 } |
263 | 209 |
264 string16 WebNotificationTray::GetAccessibleNameForTray() { | 210 string16 WebNotificationTray::GetAccessibleNameForTray() { |
265 return l10n_util::GetStringUTF16( | 211 return l10n_util::GetStringUTF16( |
266 IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME); | 212 IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME); |
267 } | 213 } |
268 | 214 |
269 void WebNotificationTray::SendRemoveNotification(const std::string& id) { | |
270 // If this is the only notification in the list, close the bubble. | |
271 if (notification_list_->notifications().size() == 1 && | |
272 notification_list_->HasNotification(id)) { | |
273 HideMessageCenterBubble(); | |
274 } | |
275 if (delegate_) | |
276 delegate_->NotificationRemoved(id); | |
277 } | |
278 | |
279 void WebNotificationTray::SendRemoveAllNotifications() { | |
280 HideMessageCenterBubble(); | |
281 if (delegate_) { | |
282 const WebNotificationList::Notifications& notifications = | |
283 notification_list_->notifications(); | |
284 for (WebNotificationList::Notifications::const_iterator loopiter = | |
285 notifications.begin(); | |
286 loopiter != notifications.end(); ) { | |
287 WebNotificationList::Notifications::const_iterator curiter = loopiter++; | |
288 std::string notification_id = curiter->id; | |
289 // May call RemoveNotification and erase curiter. | |
290 delegate_->NotificationRemoved(notification_id); | |
291 } | |
292 } | |
293 } | |
294 | |
295 // When we disable notifications, we remove any existing matching | |
296 // notifications to avoid adding complicated UI to re-enable the source. | |
297 void WebNotificationTray::DisableNotificationByExtension( | |
298 const std::string& id) { | |
299 if (delegate_) | |
300 delegate_->DisableExtension(id); | |
301 // Will call SendRemoveNotification for each matching notification. | |
302 notification_list_->SendRemoveNotificationsByExtension(id); | |
303 } | |
304 | |
305 void WebNotificationTray::DisableNotificationByUrl(const std::string& id) { | |
306 if (delegate_) | |
307 delegate_->DisableNotificationsFromSource(id); | |
308 // Will call SendRemoveNotification for each matching notification. | |
309 notification_list_->SendRemoveNotificationsBySource(id); | |
310 } | |
311 | |
312 void WebNotificationTray::ShowNotificationSettings(const std::string& id) { | |
313 if (delegate_) | |
314 delegate_->ShowSettings(id); | |
315 } | |
316 | |
317 void WebNotificationTray::OnNotificationClicked(const std::string& id) { | |
318 if (delegate_) | |
319 delegate_->OnClicked(id); | |
320 } | |
321 | |
322 WebNotificationList* WebNotificationTray::GetNotificationList() { | |
323 return notification_list_.get(); | |
324 } | |
325 | |
326 void WebNotificationTray::HideBubbleWithView( | 215 void WebNotificationTray::HideBubbleWithView( |
327 const TrayBubbleView* bubble_view) { | 216 const TrayBubbleView* bubble_view) { |
328 if (message_center_bubble() && | 217 if (message_center_bubble() && |
329 bubble_view == message_center_bubble()->bubble_view()) { | 218 bubble_view == message_center_bubble()->bubble_view()) { |
330 HideMessageCenterBubble(); | 219 HideMessageCenterBubble(); |
331 } else if (popup_bubble() && bubble_view == popup_bubble()->bubble_view()) { | 220 } else if (popup_bubble() && bubble_view == popup_bubble()->bubble_view()) { |
332 HidePopupBubble(); | 221 HidePopupBubble(); |
333 } | 222 } |
334 } | 223 } |
335 | 224 |
(...skipping 26 matching lines...) Expand all Loading... |
362 gfx::Rect WebNotificationTray::GetAnchorRect(views::Widget* anchor_widget, | 251 gfx::Rect WebNotificationTray::GetAnchorRect(views::Widget* anchor_widget, |
363 AnchorType anchor_type, | 252 AnchorType anchor_type, |
364 AnchorAlignment anchor_alignment) { | 253 AnchorAlignment anchor_alignment) { |
365 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); | 254 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); |
366 } | 255 } |
367 | 256 |
368 void WebNotificationTray::HideBubble(const TrayBubbleView* bubble_view) { | 257 void WebNotificationTray::HideBubble(const TrayBubbleView* bubble_view) { |
369 HideBubbleWithView(bubble_view); | 258 HideBubbleWithView(bubble_view); |
370 } | 259 } |
371 | 260 |
| 261 void WebNotificationTray::MessageCenterChanged(bool new_notification) { |
| 262 if (message_center_bubble()) { |
| 263 if (message_center_->NotificationCount() == 0) |
| 264 HideMessageCenterBubble(); |
| 265 else |
| 266 message_center_bubble()->bubble()->ScheduleUpdate(); |
| 267 } |
| 268 if (popup_bubble()) { |
| 269 if (message_center_->NotificationCount() == 0) |
| 270 HidePopupBubble(); |
| 271 else |
| 272 popup_bubble()->bubble()->ScheduleUpdate(); |
| 273 } |
| 274 UpdateTray(); |
| 275 if (new_notification) |
| 276 ShowPopupBubble(); |
| 277 } |
| 278 |
372 void WebNotificationTray::ButtonPressed(views::Button* sender, | 279 void WebNotificationTray::ButtonPressed(views::Button* sender, |
373 const ui::Event& event) { | 280 const ui::Event& event) { |
374 DCHECK(sender == button_); | 281 DCHECK(sender == button_); |
375 ToggleMessageCenterBubble(); | 282 ToggleMessageCenterBubble(); |
376 } | 283 } |
377 | 284 |
378 // Private methods | 285 // Private methods |
379 | 286 |
380 void WebNotificationTray::ToggleMessageCenterBubble() { | 287 void WebNotificationTray::ToggleMessageCenterBubble() { |
381 if (message_center_bubble()) | 288 if (message_center_bubble()) |
382 HideMessageCenterBubble(); | 289 HideMessageCenterBubble(); |
383 else | 290 else |
384 ShowMessageCenterBubble(); | 291 ShowMessageCenterBubble(); |
385 UpdateTray(); | 292 UpdateTray(); |
386 } | 293 } |
387 | 294 |
388 void WebNotificationTray::UpdateTray() { | 295 void WebNotificationTray::UpdateTray() { |
389 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 296 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
390 if (notification_list()->unread_count() > 0) { | 297 if (message_center_->UnreadNotificationCount() > 0) { |
391 button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetImageSkiaNamed( | 298 button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetImageSkiaNamed( |
392 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_ACTIVE_NORMAL)); | 299 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_ACTIVE_NORMAL)); |
393 button_->SetImage(views::CustomButton::BS_HOT, rb.GetImageSkiaNamed( | 300 button_->SetImage(views::CustomButton::BS_HOT, rb.GetImageSkiaNamed( |
394 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_ACTIVE_HOVER)); | 301 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_ACTIVE_HOVER)); |
395 button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetImageSkiaNamed( | 302 button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetImageSkiaNamed( |
396 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_ACTIVE_PRESSED)); | 303 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_ACTIVE_PRESSED)); |
397 } else { | 304 } else { |
398 button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetImageSkiaNamed( | 305 button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetImageSkiaNamed( |
399 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_INACTIVE_NORMAL)); | 306 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_INACTIVE_NORMAL)); |
400 button_->SetImage(views::CustomButton::BS_HOT, rb.GetImageSkiaNamed( | 307 button_->SetImage(views::CustomButton::BS_HOT, rb.GetImageSkiaNamed( |
401 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_INACTIVE_HOVER)); | 308 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_INACTIVE_HOVER)); |
402 button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetImageSkiaNamed( | 309 button_->SetImage(views::CustomButton::BS_PUSHED, rb.GetImageSkiaNamed( |
403 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_INACTIVE_PRESSED)); | 310 IDR_AURA_UBER_TRAY_NOTIFY_BUTTON_INACTIVE_PRESSED)); |
404 } | 311 } |
405 if (message_center_bubble()) | 312 if (message_center_bubble()) |
406 button_->SetState(views::CustomButton::BS_PUSHED); | 313 button_->SetState(views::CustomButton::BS_PUSHED); |
407 else | 314 else |
408 button_->SetState(views::CustomButton::BS_NORMAL); | 315 button_->SetState(views::CustomButton::BS_NORMAL); |
409 bool is_visible = | 316 bool is_visible = |
410 (status_area_widget()->login_status() != user::LOGGED_IN_NONE) && | 317 (status_area_widget()->login_status() != user::LOGGED_IN_NONE) && |
411 (status_area_widget()->login_status() != user::LOGGED_IN_LOCKED) && | 318 (status_area_widget()->login_status() != user::LOGGED_IN_LOCKED) && |
412 (!notification_list()->notifications().empty()); | 319 (message_center_->NotificationCount() > 0); |
413 SetVisible(is_visible); | 320 SetVisible(is_visible); |
414 Layout(); | 321 Layout(); |
415 SchedulePaint(); | 322 SchedulePaint(); |
416 } | 323 } |
417 | 324 |
418 void WebNotificationTray::UpdateTrayAndBubble() { | |
419 if (message_center_bubble()) { | |
420 if (notification_list_->notifications().size() == 0) | |
421 HideMessageCenterBubble(); | |
422 else | |
423 message_center_bubble()->bubble()->ScheduleUpdate(); | |
424 } | |
425 if (popup_bubble()) { | |
426 if (notification_list_->notifications().size() == 0) | |
427 HidePopupBubble(); | |
428 else | |
429 popup_bubble()->bubble()->ScheduleUpdate(); | |
430 } | |
431 UpdateTray(); | |
432 } | |
433 | |
434 bool WebNotificationTray::ClickedOutsideBubble() { | 325 bool WebNotificationTray::ClickedOutsideBubble() { |
435 // Only hide the message center. | 326 // Only hide the message center. |
436 if (!message_center_bubble()) | 327 if (!message_center_bubble()) |
437 return false; | 328 return false; |
438 HideMessageCenterBubble(); | 329 HideMessageCenterBubble(); |
439 return true; | 330 return true; |
440 } | 331 } |
441 | 332 |
442 // Methods for testing | 333 // Methods for testing |
443 | 334 |
444 MessageCenterBubble* WebNotificationTray::GetMessageCenterBubbleForTest() { | 335 MessageCenterBubble* WebNotificationTray::GetMessageCenterBubbleForTest() { |
445 if (!message_center_bubble_.get()) | 336 if (!message_center_bubble_.get()) |
446 return NULL; | 337 return NULL; |
447 return static_cast<MessageCenterBubble*>(message_center_bubble_->bubble()); | 338 return static_cast<MessageCenterBubble*>(message_center_bubble_->bubble()); |
448 } | 339 } |
449 | 340 |
450 PopupBubble* WebNotificationTray::GetPopupBubbleForTest() { | 341 PopupBubble* WebNotificationTray::GetPopupBubbleForTest() { |
451 if (!popup_bubble_.get()) | 342 if (!popup_bubble_.get()) |
452 return NULL; | 343 return NULL; |
453 return static_cast<PopupBubble*>(popup_bubble_->bubble()); | 344 return static_cast<PopupBubble*>(popup_bubble_->bubble()); |
454 } | 345 } |
455 | 346 |
456 } // namespace ash | 347 } // namespace ash |
OLD | NEW |