| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 void WebNotificationTray::HideBubbleWithView( | 432 void WebNotificationTray::HideBubbleWithView( |
| 433 const views::TrayBubbleView* bubble_view) { | 433 const views::TrayBubbleView* bubble_view) { |
| 434 if (message_center_bubble() && | 434 if (message_center_bubble() && |
| 435 bubble_view == message_center_bubble()->bubble_view()) { | 435 bubble_view == message_center_bubble()->bubble_view()) { |
| 436 message_center_tray_->HideMessageCenterBubble(); | 436 message_center_tray_->HideMessageCenterBubble(); |
| 437 } else if (popup_collection_.get()) { | 437 } else if (popup_collection_.get()) { |
| 438 message_center_tray_->HidePopupBubble(); | 438 message_center_tray_->HidePopupBubble(); |
| 439 } | 439 } |
| 440 } | 440 } |
| 441 | 441 |
| 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() { | 442 void WebNotificationTray::BubbleViewDestroyed() { |
| 451 if (message_center_bubble()) | 443 if (message_center_bubble()) |
| 452 message_center_bubble()->bubble()->BubbleViewDestroyed(); | 444 message_center_bubble()->bubble()->BubbleViewDestroyed(); |
| 453 } | 445 } |
| 454 | 446 |
| 455 void WebNotificationTray::OnMouseEnteredView() {} | 447 void WebNotificationTray::OnMouseEnteredView() {} |
| 456 | 448 |
| 457 void WebNotificationTray::OnMouseExitedView() {} | 449 void WebNotificationTray::OnMouseExitedView() {} |
| 458 | 450 |
| 459 void WebNotificationTray::RegisterAccelerators( | 451 void WebNotificationTray::RegisterAccelerators( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 473 } | 465 } |
| 474 | 466 |
| 475 bool WebNotificationTray::ShouldEnableExtraKeyboardAccessibility() { | 467 bool WebNotificationTray::ShouldEnableExtraKeyboardAccessibility() { |
| 476 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | 468 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); |
| 477 } | 469 } |
| 478 | 470 |
| 479 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 471 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 480 HideBubbleWithView(bubble_view); | 472 HideBubbleWithView(bubble_view); |
| 481 } | 473 } |
| 482 | 474 |
| 475 bool WebNotificationTray::ProcessGestureEventForBubble( |
| 476 ui::GestureEvent* event) { |
| 477 return drag_controller()->ProcessGestureEvent(*event, this, |
| 478 true /* is_on_bubble */); |
| 479 } |
| 480 |
| 483 bool WebNotificationTray::ShowNotifierSettings() { | 481 bool WebNotificationTray::ShowNotifierSettings() { |
| 484 if (message_center_bubble()) { | 482 if (message_center_bubble()) { |
| 485 static_cast<message_center::MessageCenterBubble*>( | 483 static_cast<message_center::MessageCenterBubble*>( |
| 486 message_center_bubble()->bubble()) | 484 message_center_bubble()->bubble()) |
| 487 ->SetSettingsVisible(); | 485 ->SetSettingsVisible(); |
| 488 return true; | 486 return true; |
| 489 } | 487 } |
| 490 return ShowMessageCenterInternal(true /* show_settings */); | 488 return ShowMessageCenterInternal(true /* show_settings */); |
| 491 } | 489 } |
| 492 | 490 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 594 } |
| 597 | 595 |
| 598 void WebNotificationTray::ClickedOutsideBubble() { | 596 void WebNotificationTray::ClickedOutsideBubble() { |
| 599 // Only hide the message center | 597 // Only hide the message center |
| 600 if (!message_center_bubble()) | 598 if (!message_center_bubble()) |
| 601 return; | 599 return; |
| 602 | 600 |
| 603 message_center_tray_->HideMessageCenterBubble(); | 601 message_center_tray_->HideMessageCenterBubble(); |
| 604 } | 602 } |
| 605 | 603 |
| 604 bool WebNotificationTray::PerformAction(const ui::Event& event) { |
| 605 if (message_center_bubble()) |
| 606 message_center_tray_->HideMessageCenterBubble(); |
| 607 else |
| 608 message_center_tray_->ShowMessageCenterBubble(); |
| 609 return true; |
| 610 } |
| 611 |
| 612 bool WebNotificationTray::HasBubble() { |
| 613 return message_center_bubble_.get() != NULL; |
| 614 } |
| 615 |
| 616 void WebNotificationTray::CloseBubble() { |
| 617 message_center_tray_->HideMessageCenterBubble(); |
| 618 } |
| 619 |
| 620 void WebNotificationTray::ShowBubble() { |
| 621 message_center_tray_->ShowMessageCenterBubble(); |
| 622 } |
| 623 |
| 624 views::TrayBubbleView* WebNotificationTray::GetBubbleView() { |
| 625 if (HasBubble()) |
| 626 return message_center_bubble_->bubble_view(); |
| 627 return nullptr; |
| 628 } |
| 629 |
| 630 void WebNotificationTray::OnGestureEvent(ui::GestureEvent* event) { |
| 631 if (drag_controller()->ProcessGestureEvent(*event, this, |
| 632 false /* is_on_bubble */)) { |
| 633 event->SetHandled(); |
| 634 } else { |
| 635 TrayBackgroundView::OnGestureEvent(event); |
| 636 } |
| 637 } |
| 638 |
| 606 message_center::MessageCenter* WebNotificationTray::message_center() const { | 639 message_center::MessageCenter* WebNotificationTray::message_center() const { |
| 607 return message_center_tray_->message_center(); | 640 return message_center_tray_->message_center(); |
| 608 } | 641 } |
| 609 | 642 |
| 610 // Methods for testing | 643 // Methods for testing |
| 611 | 644 |
| 612 bool WebNotificationTray::IsPopupVisible() const { | 645 bool WebNotificationTray::IsPopupVisible() const { |
| 613 return message_center_tray_->popups_visible(); | 646 return message_center_tray_->popups_visible(); |
| 614 } | 647 } |
| 615 | 648 |
| 616 message_center::MessageCenterBubble* | 649 message_center::MessageCenterBubble* |
| 617 WebNotificationTray::GetMessageCenterBubbleForTest() { | 650 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 618 if (!message_center_bubble()) | 651 if (!message_center_bubble()) |
| 619 return nullptr; | 652 return nullptr; |
| 620 return static_cast<message_center::MessageCenterBubble*>( | 653 return static_cast<message_center::MessageCenterBubble*>( |
| 621 message_center_bubble()->bubble()); | 654 message_center_bubble()->bubble()); |
| 622 } | 655 } |
| 623 | 656 |
| 624 } // namespace ash | 657 } // namespace ash |
| OLD | NEW |