| 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/public/cpp/shell_window_ids.h" | |
| 8 #include "ash/resources/vector_icons/vector_icons.h" | 7 #include "ash/resources/vector_icons/vector_icons.h" |
| 9 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_controller.h" | 9 #include "ash/session/session_controller.h" |
| 11 #include "ash/shelf/shelf_constants.h" | 10 #include "ash/shelf/shelf_constants.h" |
| 12 #include "ash/shelf/wm_shelf.h" | 11 #include "ash/shelf/wm_shelf.h" |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "ash/strings/grit/ash_strings.h" | 13 #include "ash/strings/grit/ash_strings.h" |
| 15 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
| 16 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
| 17 #include "ash/system/tray/system_tray_delegate.h" | 16 #include "ash/system/tray/system_tray_delegate.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 public: | 80 public: |
| 82 // Takes ownership of |bubble| and creates |bubble_wrapper_|. | 81 // Takes ownership of |bubble| and creates |bubble_wrapper_|. |
| 83 WebNotificationBubbleWrapper(WebNotificationTray* tray, | 82 WebNotificationBubbleWrapper(WebNotificationTray* tray, |
| 84 TrayBackgroundView* anchor_tray, | 83 TrayBackgroundView* anchor_tray, |
| 85 message_center::MessageBubbleBase* bubble) { | 84 message_center::MessageBubbleBase* bubble) { |
| 86 bubble_.reset(bubble); | 85 bubble_.reset(bubble); |
| 87 views::TrayBubbleView::AnchorAlignment anchor_alignment = | 86 views::TrayBubbleView::AnchorAlignment anchor_alignment = |
| 88 tray->GetAnchorAlignment(); | 87 tray->GetAnchorAlignment(); |
| 89 views::TrayBubbleView::InitParams init_params = | 88 views::TrayBubbleView::InitParams init_params = |
| 90 bubble->GetInitParams(anchor_alignment); | 89 bubble->GetInitParams(anchor_alignment); |
| 91 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( | 90 views::TrayBubbleView* bubble_view = new views::TrayBubbleView( |
| 92 anchor_tray->GetBubbleAnchor(), tray, &init_params); | 91 anchor_tray->GetBubbleWindowContainer(), anchor_tray->GetBubbleAnchor(), |
| 92 tray, init_params); |
| 93 bubble_view->set_anchor_view_insets(anchor_tray->GetBubbleAnchorInsets()); | 93 bubble_view->set_anchor_view_insets(anchor_tray->GetBubbleAnchorInsets()); |
| 94 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); | 94 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); |
| 95 bubble->InitializeContents(bubble_view); | 95 bubble->InitializeContents(bubble_view); |
| 96 } | 96 } |
| 97 | 97 |
| 98 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } | 98 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } |
| 99 | 99 |
| 100 // Convenience accessors. | 100 // Convenience accessors. |
| 101 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } | 101 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } |
| 102 | 102 |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 } | 446 } |
| 447 | 447 |
| 448 void WebNotificationTray::OnMouseEnteredView() {} | 448 void WebNotificationTray::OnMouseEnteredView() {} |
| 449 | 449 |
| 450 void WebNotificationTray::OnMouseExitedView() {} | 450 void WebNotificationTray::OnMouseExitedView() {} |
| 451 | 451 |
| 452 base::string16 WebNotificationTray::GetAccessibleNameForBubble() { | 452 base::string16 WebNotificationTray::GetAccessibleNameForBubble() { |
| 453 return GetAccessibleNameForTray(); | 453 return GetAccessibleNameForTray(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 void WebNotificationTray::OnBeforeBubbleWidgetInit( | |
| 457 views::Widget* anchor_widget, | |
| 458 views::Widget* bubble_widget, | |
| 459 views::Widget::InitParams* params) const { | |
| 460 // Place the bubble in the same root window as |anchor_widget|. | |
| 461 RootWindowController::ForWindow(anchor_widget->GetNativeWindow()) | |
| 462 ->ConfigureWidgetInitParamsForContainer( | |
| 463 bubble_widget, kShellWindowId_SettingBubbleContainer, params); | |
| 464 } | |
| 465 | |
| 466 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 456 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 467 HideBubbleWithView(bubble_view); | 457 HideBubbleWithView(bubble_view); |
| 468 } | 458 } |
| 469 | 459 |
| 470 bool WebNotificationTray::ShowNotifierSettings() { | 460 bool WebNotificationTray::ShowNotifierSettings() { |
| 471 if (message_center_bubble()) { | 461 if (message_center_bubble()) { |
| 472 static_cast<message_center::MessageCenterBubble*>( | 462 static_cast<message_center::MessageCenterBubble*>( |
| 473 message_center_bubble()->bubble()) | 463 message_center_bubble()->bubble()) |
| 474 ->SetSettingsVisible(); | 464 ->SetSettingsVisible(); |
| 475 return true; | 465 return true; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 592 |
| 603 message_center::MessageCenterBubble* | 593 message_center::MessageCenterBubble* |
| 604 WebNotificationTray::GetMessageCenterBubbleForTest() { | 594 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 605 if (!message_center_bubble()) | 595 if (!message_center_bubble()) |
| 606 return nullptr; | 596 return nullptr; |
| 607 return static_cast<message_center::MessageCenterBubble*>( | 597 return static_cast<message_center::MessageCenterBubble*>( |
| 608 message_center_bubble()->bubble()); | 598 message_center_bubble()->bubble()); |
| 609 } | 599 } |
| 610 | 600 |
| 611 } // namespace ash | 601 } // namespace ash |
| OLD | NEW |