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/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); | 298 popup_alignment_delegate_.reset(new AshPopupAlignmentDelegate(shelf)); |
299 popup_collection_.reset(new message_center::MessagePopupCollection( | 299 popup_collection_.reset(new message_center::MessagePopupCollection( |
300 message_center(), message_center_tray_.get(), | 300 message_center(), message_center_tray_.get(), |
301 popup_alignment_delegate_.get())); | 301 popup_alignment_delegate_.get())); |
302 display::Screen* screen = display::Screen::GetScreen(); | 302 display::Screen* screen = display::Screen::GetScreen(); |
303 popup_alignment_delegate_->StartObserving( | 303 popup_alignment_delegate_->StartObserving( |
304 screen, screen->GetDisplayNearestWindow(status_area_window_)); | 304 screen, screen->GetDisplayNearestWindow(status_area_window_)); |
305 OnMessageCenterTrayChanged(); | 305 OnMessageCenterTrayChanged(); |
306 | 306 |
307 tray_container()->SetMargin(kTrayMainAxisInset, kTrayCrossAxisInset); | 307 tray_container()->SetMargin(kTrayMainAxisInset, kTrayCrossAxisInset); |
| 308 |
| 309 if (!drag_controller()) |
| 310 set_drag_controller(base::MakeUnique<TrayDragController>(shelf)); |
308 } | 311 } |
309 | 312 |
310 WebNotificationTray::~WebNotificationTray() { | 313 WebNotificationTray::~WebNotificationTray() { |
311 // Release any child views that might have back pointers before ~View(). | 314 // Release any child views that might have back pointers before ~View(). |
312 message_center_bubble_.reset(); | 315 message_center_bubble_.reset(); |
313 popup_alignment_delegate_.reset(); | 316 popup_alignment_delegate_.reset(); |
314 popup_collection_.reset(); | 317 popup_collection_.reset(); |
315 } | 318 } |
316 | 319 |
317 // static | 320 // static |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 bool WebNotificationTray::ShouldShowMessageCenter() const { | 395 bool WebNotificationTray::ShouldShowMessageCenter() const { |
393 // Hidden at login screen, during supervised user creation, etc. | 396 // Hidden at login screen, during supervised user creation, etc. |
394 return Shell::Get()->session_controller()->ShouldShowNotificationTray(); | 397 return Shell::Get()->session_controller()->ShouldShowNotificationTray(); |
395 } | 398 } |
396 | 399 |
397 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { | 400 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { |
398 return (message_center_bubble() && | 401 return (message_center_bubble() && |
399 message_center_bubble()->bubble()->IsVisible()); | 402 message_center_bubble()->bubble()->IsVisible()); |
400 } | 403 } |
401 | 404 |
402 void WebNotificationTray::ShowMessageCenterBubble() { | |
403 if (!IsMessageCenterBubbleVisible()) | |
404 message_center_tray_->ShowMessageCenterBubble(); | |
405 } | |
406 | |
407 void WebNotificationTray::UpdateAfterLoginStatusChange( | 405 void WebNotificationTray::UpdateAfterLoginStatusChange( |
408 LoginStatus login_status) { | 406 LoginStatus login_status) { |
409 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); | 407 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); |
410 OnMessageCenterTrayChanged(); | 408 OnMessageCenterTrayChanged(); |
411 } | 409 } |
412 | 410 |
413 void WebNotificationTray::UpdateAfterShelfAlignmentChange() { | 411 void WebNotificationTray::UpdateAfterShelfAlignmentChange() { |
414 TrayBackgroundView::UpdateAfterShelfAlignmentChange(); | 412 TrayBackgroundView::UpdateAfterShelfAlignmentChange(); |
415 // Destroy any existing bubble so that it will be rebuilt correctly. | 413 // Destroy any existing bubble so that it will be rebuilt correctly. |
416 message_center_tray_->HideMessageCenterBubble(); | 414 message_center_tray_->HideMessageCenterBubble(); |
(...skipping 14 matching lines...) Expand all Loading... |
431 void WebNotificationTray::HideBubbleWithView( | 429 void WebNotificationTray::HideBubbleWithView( |
432 const views::TrayBubbleView* bubble_view) { | 430 const views::TrayBubbleView* bubble_view) { |
433 if (message_center_bubble() && | 431 if (message_center_bubble() && |
434 bubble_view == message_center_bubble()->bubble_view()) { | 432 bubble_view == message_center_bubble()->bubble_view()) { |
435 message_center_tray_->HideMessageCenterBubble(); | 433 message_center_tray_->HideMessageCenterBubble(); |
436 } else if (popup_collection_.get()) { | 434 } else if (popup_collection_.get()) { |
437 message_center_tray_->HidePopupBubble(); | 435 message_center_tray_->HidePopupBubble(); |
438 } | 436 } |
439 } | 437 } |
440 | 438 |
441 bool WebNotificationTray::PerformAction(const ui::Event& event) { | |
442 if (message_center_bubble()) | |
443 message_center_tray_->HideMessageCenterBubble(); | |
444 else | |
445 message_center_tray_->ShowMessageCenterBubble(); | |
446 return true; | |
447 } | |
448 | |
449 void WebNotificationTray::BubbleViewDestroyed() { | 439 void WebNotificationTray::BubbleViewDestroyed() { |
450 if (message_center_bubble()) | 440 if (message_center_bubble()) |
451 message_center_bubble()->bubble()->BubbleViewDestroyed(); | 441 message_center_bubble()->bubble()->BubbleViewDestroyed(); |
452 } | 442 } |
453 | 443 |
454 void WebNotificationTray::OnMouseEnteredView() {} | 444 void WebNotificationTray::OnMouseEnteredView() {} |
455 | 445 |
456 void WebNotificationTray::OnMouseExitedView() {} | 446 void WebNotificationTray::OnMouseExitedView() {} |
457 | 447 |
458 void WebNotificationTray::RegisterAccelerators( | 448 void WebNotificationTray::RegisterAccelerators( |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 } | 585 } |
596 | 586 |
597 void WebNotificationTray::ClickedOutsideBubble() { | 587 void WebNotificationTray::ClickedOutsideBubble() { |
598 // Only hide the message center | 588 // Only hide the message center |
599 if (!message_center_bubble()) | 589 if (!message_center_bubble()) |
600 return; | 590 return; |
601 | 591 |
602 message_center_tray_->HideMessageCenterBubble(); | 592 message_center_tray_->HideMessageCenterBubble(); |
603 } | 593 } |
604 | 594 |
| 595 bool WebNotificationTray::PerformAction(const ui::Event& event) { |
| 596 if (message_center_bubble()) |
| 597 message_center_tray_->HideMessageCenterBubble(); |
| 598 else |
| 599 message_center_tray_->ShowMessageCenterBubble(); |
| 600 return true; |
| 601 } |
| 602 |
| 603 void WebNotificationTray::CloseBubble() { |
| 604 message_center_tray_->HideMessageCenterBubble(); |
| 605 } |
| 606 |
| 607 void WebNotificationTray::ShowBubble() { |
| 608 if (!IsMessageCenterBubbleVisible()) |
| 609 message_center_tray_->ShowMessageCenterBubble(); |
| 610 } |
| 611 |
| 612 views::TrayBubbleView* WebNotificationTray::GetBubbleView() { |
| 613 return message_center_bubble_ ? message_center_bubble_->bubble_view() |
| 614 : nullptr; |
| 615 } |
| 616 |
605 message_center::MessageCenter* WebNotificationTray::message_center() const { | 617 message_center::MessageCenter* WebNotificationTray::message_center() const { |
606 return message_center_tray_->message_center(); | 618 return message_center_tray_->message_center(); |
607 } | 619 } |
608 | 620 |
609 // Methods for testing | 621 // Methods for testing |
610 | 622 |
611 bool WebNotificationTray::IsPopupVisible() const { | 623 bool WebNotificationTray::IsPopupVisible() const { |
612 return message_center_tray_->popups_visible(); | 624 return message_center_tray_->popups_visible(); |
613 } | 625 } |
614 | 626 |
615 message_center::MessageCenterBubble* | 627 message_center::MessageCenterBubble* |
616 WebNotificationTray::GetMessageCenterBubbleForTest() { | 628 WebNotificationTray::GetMessageCenterBubbleForTest() { |
617 if (!message_center_bubble()) | 629 if (!message_center_bubble()) |
618 return nullptr; | 630 return nullptr; |
619 return static_cast<message_center::MessageCenterBubble*>( | 631 return static_cast<message_center::MessageCenterBubble*>( |
620 message_center_bubble()->bubble()); | 632 message_center_bubble()->bubble()); |
621 } | 633 } |
622 | 634 |
623 } // namespace ash | 635 } // namespace ash |
OLD | NEW |