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.h" | 10 #include "ash/shelf/shelf.h" |
12 #include "ash/shelf/shelf_constants.h" | 11 #include "ash/shelf/shelf_constants.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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 76 |
78 // Class to initialize and manage the WebNotificationBubble and | 77 // Class to initialize and manage the WebNotificationBubble and |
79 // TrayBubbleWrapper instances for a bubble. | 78 // TrayBubbleWrapper instances for a bubble. |
80 class WebNotificationBubbleWrapper { | 79 class WebNotificationBubbleWrapper { |
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::InitParams init_params; |
88 tray->GetAnchorAlignment(); | 87 init_params.delegate = tray; |
89 views::TrayBubbleView::InitParams init_params = | 88 init_params.parent_window = anchor_tray->GetBubbleWindowContainer(); |
90 bubble->GetInitParams(anchor_alignment); | 89 init_params.anchor_view = anchor_tray->GetBubbleAnchor(); |
91 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( | 90 init_params.anchor_alignment = tray->GetAnchorAlignment(); |
92 anchor_tray->GetBubbleAnchor(), tray, &init_params); | 91 const int width = message_center::kNotificationWidth + |
| 92 message_center::kMarginBetweenItems * 2; |
| 93 init_params.min_width = width; |
| 94 init_params.max_width = width; |
| 95 init_params.max_height = bubble->max_height(); |
| 96 init_params.can_activate = true; |
| 97 init_params.bg_color = message_center::kBackgroundDarkColor; |
| 98 |
| 99 views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params); |
93 bubble_view->set_anchor_view_insets(anchor_tray->GetBubbleAnchorInsets()); | 100 bubble_view->set_anchor_view_insets(anchor_tray->GetBubbleAnchorInsets()); |
94 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); | 101 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); |
95 bubble->InitializeContents(bubble_view); | 102 bubble->InitializeContents(bubble_view); |
96 } | 103 } |
97 | 104 |
98 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } | 105 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } |
99 | 106 |
100 // Convenience accessors. | 107 // Convenience accessors. |
101 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } | 108 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } |
102 | 109 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 453 } |
447 | 454 |
448 void WebNotificationTray::OnMouseEnteredView() {} | 455 void WebNotificationTray::OnMouseEnteredView() {} |
449 | 456 |
450 void WebNotificationTray::OnMouseExitedView() {} | 457 void WebNotificationTray::OnMouseExitedView() {} |
451 | 458 |
452 base::string16 WebNotificationTray::GetAccessibleNameForBubble() { | 459 base::string16 WebNotificationTray::GetAccessibleNameForBubble() { |
453 return GetAccessibleNameForTray(); | 460 return GetAccessibleNameForTray(); |
454 } | 461 } |
455 | 462 |
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) { | 463 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
467 HideBubbleWithView(bubble_view); | 464 HideBubbleWithView(bubble_view); |
468 } | 465 } |
469 | 466 |
470 bool WebNotificationTray::ShowNotifierSettings() { | 467 bool WebNotificationTray::ShowNotifierSettings() { |
471 if (message_center_bubble()) { | 468 if (message_center_bubble()) { |
472 static_cast<message_center::MessageCenterBubble*>( | 469 static_cast<message_center::MessageCenterBubble*>( |
473 message_center_bubble()->bubble()) | 470 message_center_bubble()->bubble()) |
474 ->SetSettingsVisible(); | 471 ->SetSettingsVisible(); |
475 return true; | 472 return true; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 | 599 |
603 message_center::MessageCenterBubble* | 600 message_center::MessageCenterBubble* |
604 WebNotificationTray::GetMessageCenterBubbleForTest() { | 601 WebNotificationTray::GetMessageCenterBubbleForTest() { |
605 if (!message_center_bubble()) | 602 if (!message_center_bubble()) |
606 return nullptr; | 603 return nullptr; |
607 return static_cast<message_center::MessageCenterBubble*>( | 604 return static_cast<message_center::MessageCenterBubble*>( |
608 message_center_bubble()->bubble()); | 605 message_center_bubble()->bubble()); |
609 } | 606 } |
610 | 607 |
611 } // namespace ash | 608 } // namespace ash |
OLD | NEW |