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