| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 bool WebNotificationTray::ShouldShowMessageCenter() const { | 393 bool WebNotificationTray::ShouldShowMessageCenter() const { |
| 394 // Hidden at login screen, during supervised user creation, etc. | 394 // Hidden at login screen, during supervised user creation, etc. |
| 395 return Shell::Get()->session_controller()->ShouldShowNotificationTray(); | 395 return Shell::Get()->session_controller()->ShouldShowNotificationTray(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { | 398 bool WebNotificationTray::IsMessageCenterBubbleVisible() const { |
| 399 return (message_center_bubble() && | 399 return (message_center_bubble() && |
| 400 message_center_bubble()->bubble()->IsVisible()); | 400 message_center_bubble()->bubble()->IsVisible()); |
| 401 } | 401 } |
| 402 | 402 |
| 403 void WebNotificationTray::ShowMessageCenterBubble() { | |
| 404 if (!IsMessageCenterBubbleVisible()) | |
| 405 message_center_tray_->ShowMessageCenterBubble(); | |
| 406 } | |
| 407 | |
| 408 void WebNotificationTray::UpdateAfterLoginStatusChange( | 403 void WebNotificationTray::UpdateAfterLoginStatusChange( |
| 409 LoginStatus login_status) { | 404 LoginStatus login_status) { |
| 410 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); | 405 message_center()->SetLockedState(login_status == LoginStatus::LOCKED); |
| 411 OnMessageCenterTrayChanged(); | 406 OnMessageCenterTrayChanged(); |
| 412 } | 407 } |
| 413 | 408 |
| 414 void WebNotificationTray::UpdateAfterShelfAlignmentChange() { | 409 void WebNotificationTray::UpdateAfterShelfAlignmentChange() { |
| 415 TrayBackgroundView::UpdateAfterShelfAlignmentChange(); | 410 TrayBackgroundView::UpdateAfterShelfAlignmentChange(); |
| 416 // Destroy any existing bubble so that it will be rebuilt correctly. | 411 // Destroy any existing bubble so that it will be rebuilt correctly. |
| 417 message_center_tray_->HideMessageCenterBubble(); | 412 message_center_tray_->HideMessageCenterBubble(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 432 void WebNotificationTray::HideBubbleWithView( | 427 void WebNotificationTray::HideBubbleWithView( |
| 433 const views::TrayBubbleView* bubble_view) { | 428 const views::TrayBubbleView* bubble_view) { |
| 434 if (message_center_bubble() && | 429 if (message_center_bubble() && |
| 435 bubble_view == message_center_bubble()->bubble_view()) { | 430 bubble_view == message_center_bubble()->bubble_view()) { |
| 436 message_center_tray_->HideMessageCenterBubble(); | 431 message_center_tray_->HideMessageCenterBubble(); |
| 437 } else if (popup_collection_.get()) { | 432 } else if (popup_collection_.get()) { |
| 438 message_center_tray_->HidePopupBubble(); | 433 message_center_tray_->HidePopupBubble(); |
| 439 } | 434 } |
| 440 } | 435 } |
| 441 | 436 |
| 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() { | 437 void WebNotificationTray::BubbleViewDestroyed() { |
| 451 if (message_center_bubble()) | 438 if (message_center_bubble()) |
| 452 message_center_bubble()->bubble()->BubbleViewDestroyed(); | 439 message_center_bubble()->bubble()->BubbleViewDestroyed(); |
| 453 } | 440 } |
| 454 | 441 |
| 455 void WebNotificationTray::OnMouseEnteredView() {} | 442 void WebNotificationTray::OnMouseEnteredView() {} |
| 456 | 443 |
| 457 void WebNotificationTray::OnMouseExitedView() {} | 444 void WebNotificationTray::OnMouseExitedView() {} |
| 458 | 445 |
| 459 void WebNotificationTray::RegisterAccelerators( | 446 void WebNotificationTray::RegisterAccelerators( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 473 } | 460 } |
| 474 | 461 |
| 475 bool WebNotificationTray::ShouldEnableExtraKeyboardAccessibility() { | 462 bool WebNotificationTray::ShouldEnableExtraKeyboardAccessibility() { |
| 476 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 463 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
| 477 } | 464 } |
| 478 | 465 |
| 479 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 466 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 480 HideBubbleWithView(bubble_view); | 467 HideBubbleWithView(bubble_view); |
| 481 } | 468 } |
| 482 | 469 |
| 470 bool WebNotificationTray::ProcessGestureEventForBubble( |
| 471 ui::GestureEvent* event) { |
| 472 return drag_controller()->ProcessGestureEvent(event, this); |
| 473 } |
| 474 |
| 483 bool WebNotificationTray::ShowNotifierSettings() { | 475 bool WebNotificationTray::ShowNotifierSettings() { |
| 484 if (message_center_bubble()) { | 476 if (message_center_bubble()) { |
| 485 static_cast<message_center::MessageCenterBubble*>( | 477 static_cast<message_center::MessageCenterBubble*>( |
| 486 message_center_bubble()->bubble()) | 478 message_center_bubble()->bubble()) |
| 487 ->SetSettingsVisible(); | 479 ->SetSettingsVisible(); |
| 488 return true; | 480 return true; |
| 489 } | 481 } |
| 490 return ShowMessageCenterInternal(true /* show_settings */); | 482 return ShowMessageCenterInternal(true /* show_settings */); |
| 491 } | 483 } |
| 492 | 484 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 588 } |
| 597 | 589 |
| 598 void WebNotificationTray::ClickedOutsideBubble() { | 590 void WebNotificationTray::ClickedOutsideBubble() { |
| 599 // Only hide the message center | 591 // Only hide the message center |
| 600 if (!message_center_bubble()) | 592 if (!message_center_bubble()) |
| 601 return; | 593 return; |
| 602 | 594 |
| 603 message_center_tray_->HideMessageCenterBubble(); | 595 message_center_tray_->HideMessageCenterBubble(); |
| 604 } | 596 } |
| 605 | 597 |
| 598 bool WebNotificationTray::PerformAction(const ui::Event& event) { |
| 599 if (message_center_bubble()) |
| 600 message_center_tray_->HideMessageCenterBubble(); |
| 601 else |
| 602 message_center_tray_->ShowMessageCenterBubble(); |
| 603 return true; |
| 604 } |
| 605 |
| 606 void WebNotificationTray::CloseBubble() { |
| 607 message_center_tray_->HideMessageCenterBubble(); |
| 608 } |
| 609 |
| 610 void WebNotificationTray::ShowBubble() { |
| 611 if (!IsMessageCenterBubbleVisible()) |
| 612 message_center_tray_->ShowMessageCenterBubble(); |
| 613 } |
| 614 |
| 615 views::TrayBubbleView* WebNotificationTray::GetBubbleView() { |
| 616 return message_center_bubble_ ? message_center_bubble_->bubble_view() |
| 617 : nullptr; |
| 618 } |
| 619 |
| 620 void WebNotificationTray::OnGestureEvent(ui::GestureEvent* event) { |
| 621 if (!drag_controller()->ProcessGestureEvent(event, this)) |
| 622 TrayBackgroundView::OnGestureEvent(event); |
| 623 } |
| 624 |
| 606 message_center::MessageCenter* WebNotificationTray::message_center() const { | 625 message_center::MessageCenter* WebNotificationTray::message_center() const { |
| 607 return message_center_tray_->message_center(); | 626 return message_center_tray_->message_center(); |
| 608 } | 627 } |
| 609 | 628 |
| 610 // Methods for testing | 629 // Methods for testing |
| 611 | 630 |
| 612 bool WebNotificationTray::IsPopupVisible() const { | 631 bool WebNotificationTray::IsPopupVisible() const { |
| 613 return message_center_tray_->popups_visible(); | 632 return message_center_tray_->popups_visible(); |
| 614 } | 633 } |
| 615 | 634 |
| 616 message_center::MessageCenterBubble* | 635 message_center::MessageCenterBubble* |
| 617 WebNotificationTray::GetMessageCenterBubbleForTest() { | 636 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 618 if (!message_center_bubble()) | 637 if (!message_center_bubble()) |
| 619 return nullptr; | 638 return nullptr; |
| 620 return static_cast<message_center::MessageCenterBubble*>( | 639 return static_cast<message_center::MessageCenterBubble*>( |
| 621 message_center_bubble()->bubble()); | 640 message_center_bubble()->bubble()); |
| 622 } | 641 } |
| 623 | 642 |
| 624 } // namespace ash | 643 } // namespace ash |
| OLD | NEW |