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/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
12 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/shell_window_ids.h" |
13 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
14 #include "ash/common/system/tray/tray_utils.h" | 15 #include "ash/common/system/tray/tray_utils.h" |
15 #include "ash/common/wm_lookup.h" | 16 #include "ash/common/wm_lookup.h" |
16 #include "ash/common/wm_root_window_controller.h" | 17 #include "ash/common/wm_root_window_controller.h" |
17 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
18 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
19 #include "ash/system/status_area_widget.h" | 20 #include "ash/system/status_area_widget.h" |
20 #include "ash/system/tray/system_tray.h" | 21 #include "ash/system/tray/system_tray.h" |
21 #include "ash/system/tray/tray_background_view.h" | 22 #include "ash/system/tray/tray_background_view.h" |
22 #include "ash/system/tray/tray_bubble_wrapper.h" | 23 #include "ash/system/tray/tray_bubble_wrapper.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 views::TrayBubbleView::AnchorAlignment anchor_alignment = | 88 views::TrayBubbleView::AnchorAlignment anchor_alignment = |
88 tray->GetAnchorAlignment(); | 89 tray->GetAnchorAlignment(); |
89 views::TrayBubbleView::InitParams init_params = | 90 views::TrayBubbleView::InitParams init_params = |
90 bubble->GetInitParams(anchor_alignment); | 91 bubble->GetInitParams(anchor_alignment); |
91 views::View* anchor = tray->tray_container(); | 92 views::View* anchor = tray->tray_container(); |
92 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 93 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
93 gfx::Point bounds(anchor->width() / 2, 0); | 94 gfx::Point bounds(anchor->width() / 2, 0); |
94 views::View::ConvertPointToWidget(anchor, &bounds); | 95 views::View::ConvertPointToWidget(anchor, &bounds); |
95 init_params.arrow_offset = bounds.x(); | 96 init_params.arrow_offset = bounds.x(); |
96 } | 97 } |
97 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( | 98 DCHECK(anchor); |
98 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); | 99 // TrayBubbleView uses |anchor| and |tray| to determine the parent |
| 100 // container. See WebNotificationTray::OnBeforeBubbleWidgetInit(). |
| 101 views::TrayBubbleView* bubble_view = |
| 102 views::TrayBubbleView::Create(anchor, tray, &init_params); |
99 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); | 103 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); |
100 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 104 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
101 bubble->InitializeContents(bubble_view); | 105 bubble->InitializeContents(bubble_view); |
102 } | 106 } |
103 | 107 |
104 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } | 108 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } |
105 | 109 |
106 // Convenience accessors. | 110 // Convenience accessors. |
107 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } | 111 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } |
108 | 112 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 return GetAccessibleNameForTray(); | 404 return GetAccessibleNameForTray(); |
401 } | 405 } |
402 | 406 |
403 gfx::Rect WebNotificationTray::GetAnchorRect( | 407 gfx::Rect WebNotificationTray::GetAnchorRect( |
404 views::Widget* anchor_widget, | 408 views::Widget* anchor_widget, |
405 views::TrayBubbleView::AnchorType anchor_type, | 409 views::TrayBubbleView::AnchorType anchor_type, |
406 views::TrayBubbleView::AnchorAlignment anchor_alignment) const { | 410 views::TrayBubbleView::AnchorAlignment anchor_alignment) const { |
407 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); | 411 return GetBubbleAnchorRect(anchor_widget, anchor_type, anchor_alignment); |
408 } | 412 } |
409 | 413 |
| 414 void WebNotificationTray::OnBeforeBubbleWidgetInit( |
| 415 views::Widget* anchor_widget, |
| 416 views::Widget* bubble_widget, |
| 417 views::Widget::InitParams* params) const { |
| 418 // Place the bubble in the same root window as |anchor_widget|. |
| 419 WmLookup::Get() |
| 420 ->GetWindowForWidget(anchor_widget) |
| 421 ->GetRootWindowController() |
| 422 ->ConfigureWidgetInitParamsForContainer( |
| 423 bubble_widget, kShellWindowId_SettingBubbleContainer, params); |
| 424 } |
| 425 |
410 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 426 void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
411 HideBubbleWithView(bubble_view); | 427 HideBubbleWithView(bubble_view); |
412 } | 428 } |
413 | 429 |
414 bool WebNotificationTray::ShowNotifierSettings() { | 430 bool WebNotificationTray::ShowNotifierSettings() { |
415 if (message_center_bubble()) { | 431 if (message_center_bubble()) { |
416 static_cast<message_center::MessageCenterBubble*>( | 432 static_cast<message_center::MessageCenterBubble*>( |
417 message_center_bubble()->bubble())->SetSettingsVisible(); | 433 message_center_bubble()->bubble())->SetSettingsVisible(); |
418 return true; | 434 return true; |
419 } | 435 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 531 |
516 message_center::MessageCenterBubble* | 532 message_center::MessageCenterBubble* |
517 WebNotificationTray::GetMessageCenterBubbleForTest() { | 533 WebNotificationTray::GetMessageCenterBubbleForTest() { |
518 if (!message_center_bubble()) | 534 if (!message_center_bubble()) |
519 return NULL; | 535 return NULL; |
520 return static_cast<message_center::MessageCenterBubble*>( | 536 return static_cast<message_center::MessageCenterBubble*>( |
521 message_center_bubble()->bubble()); | 537 message_center_bubble()->bubble()); |
522 } | 538 } |
523 | 539 |
524 } // namespace ash | 540 } // namespace ash |
OLD | NEW |