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/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
11 #include "ash/system/tray/tray_background_view.h" | 11 #include "ash/system/tray/tray_background_view.h" |
12 #include "ash/system/tray/tray_bubble_wrapper.h" | 12 #include "ash/system/tray/tray_bubble_wrapper.h" |
| 13 #include "ash/system/tray/tray_constants.h" |
13 #include "ash/wm/shelf_layout_manager.h" | 14 #include "ash/wm/shelf_layout_manager.h" |
14 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
15 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 17 #include "ui/aura/root_window.h" |
16 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/screen.h" | 21 #include "ui/gfx/screen.h" |
20 #include "ui/message_center/message_bubble_base.h" | 22 #include "ui/message_center/message_bubble_base.h" |
21 #include "ui/message_center/message_center_bubble.h" | 23 #include "ui/message_center/message_center_bubble.h" |
22 #include "ui/message_center/message_center_tray_delegate.h" | 24 #include "ui/message_center/message_center_tray_delegate.h" |
23 #include "ui/message_center/message_center_util.h" | 25 #include "ui/message_center/message_center_util.h" |
24 #include "ui/message_center/message_popup_bubble.h" | 26 #include "ui/message_center/message_popup_bubble.h" |
25 #include "ui/message_center/quiet_mode_bubble.h" | 27 #include "ui/message_center/quiet_mode_bubble.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 bool WebNotificationTray::ShowMessageCenter() { | 114 bool WebNotificationTray::ShowMessageCenter() { |
113 if (!ShouldShowMessageCenter()) | 115 if (!ShouldShowMessageCenter()) |
114 return false; | 116 return false; |
115 | 117 |
116 message_center::MessageCenterBubble* message_center_bubble = | 118 message_center::MessageCenterBubble* message_center_bubble = |
117 new message_center::MessageCenterBubble(message_center()); | 119 new message_center::MessageCenterBubble(message_center()); |
118 | 120 |
119 // TODO(mukai): move this to WebNotificationBubbleWrapper if it's safe | 121 // TODO(mukai): move this to WebNotificationBubbleWrapper if it's safe |
120 // to set the height of the popup. | 122 // to set the height of the popup. |
121 int max_height = 0; | 123 int max_height = 0; |
122 if (GetShelfLayoutManager()->GetAlignment() == SHELF_ALIGNMENT_BOTTOM) { | 124 aura::Window* status_area_window = status_area_widget()->GetNativeWindow(); |
123 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); | 125 switch (GetShelfLayoutManager()->GetAlignment()) { |
124 max_height = shelf_bounds.y(); | 126 case SHELF_ALIGNMENT_BOTTOM: { |
125 } else { | 127 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); |
126 // Assume that the bottom line of the status area widget and the bubble are | 128 max_height = shelf_bounds.y(); |
127 // aligned. | 129 break; |
128 aura::Window* status_area_window = status_area_widget()->GetNativeWindow(); | 130 } |
129 max_height = status_area_window->GetBoundsInRootWindow().bottom(); | 131 case SHELF_ALIGNMENT_TOP: { |
| 132 aura::RootWindow* root = status_area_window->GetRootWindow(); |
| 133 max_height = |
| 134 root->bounds().height() - status_area_window->bounds().height(); |
| 135 break; |
| 136 } |
| 137 case SHELF_ALIGNMENT_LEFT: |
| 138 case SHELF_ALIGNMENT_RIGHT: { |
| 139 // Assume that the bottom line of the status area widget and the bubble |
| 140 // are aligned. |
| 141 max_height = status_area_window->GetBoundsInRootWindow().bottom(); |
| 142 break; |
| 143 } |
| 144 default: |
| 145 NOTREACHED(); |
130 } | 146 } |
| 147 max_height = std::max(0, max_height - kTraySpacing); |
131 message_center_bubble->SetMaxHeight(max_height); | 148 message_center_bubble->SetMaxHeight(max_height); |
132 message_center_bubble_.reset( | 149 message_center_bubble_.reset( |
133 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); | 150 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); |
134 | 151 |
135 status_area_widget()->SetHideSystemNotifications(true); | 152 status_area_widget()->SetHideSystemNotifications(true); |
136 GetShelfLayoutManager()->UpdateAutoHideState(); | 153 GetShelfLayoutManager()->UpdateAutoHideState(); |
137 return true; | 154 return true; |
138 } | 155 } |
139 | 156 |
140 void WebNotificationTray::UpdateMessageCenter() { | 157 void WebNotificationTray::UpdateMessageCenter() { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 436 |
420 message_center::MessagePopupBubble* | 437 message_center::MessagePopupBubble* |
421 WebNotificationTray::GetPopupBubbleForTest() { | 438 WebNotificationTray::GetPopupBubbleForTest() { |
422 if (!popup_bubble()) | 439 if (!popup_bubble()) |
423 return NULL; | 440 return NULL; |
424 return static_cast<message_center::MessagePopupBubble*>( | 441 return static_cast<message_center::MessagePopupBubble*>( |
425 popup_bubble()->bubble()); | 442 popup_bubble()->bubble()); |
426 } | 443 } |
427 | 444 |
428 } // namespace ash | 445 } // namespace ash |
OLD | NEW |