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 if (max_height > kTraySpacing) | |
148 max_height -= kTraySpacing; | |
stevenjb
2013/02/13 18:54:45
We should just subtract kTraySpacing when appropri
Jun Mukai
2013/02/13 19:42:27
used std::max(0, ...)
| |
131 message_center_bubble->SetMaxHeight(max_height); | 149 message_center_bubble->SetMaxHeight(max_height); |
132 message_center_bubble_.reset( | 150 message_center_bubble_.reset( |
133 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); | 151 new internal::WebNotificationBubbleWrapper(this, message_center_bubble)); |
134 | 152 |
135 status_area_widget()->SetHideSystemNotifications(true); | 153 status_area_widget()->SetHideSystemNotifications(true); |
136 GetShelfLayoutManager()->UpdateAutoHideState(); | 154 GetShelfLayoutManager()->UpdateAutoHideState(); |
137 return true; | 155 return true; |
138 } | 156 } |
139 | 157 |
140 void WebNotificationTray::UpdateMessageCenter() { | 158 void WebNotificationTray::UpdateMessageCenter() { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 | 432 |
415 message_center::MessagePopupBubble* | 433 message_center::MessagePopupBubble* |
416 WebNotificationTray::GetPopupBubbleForTest() { | 434 WebNotificationTray::GetPopupBubbleForTest() { |
417 if (!popup_bubble()) | 435 if (!popup_bubble()) |
418 return NULL; | 436 return NULL; |
419 return static_cast<message_center::MessagePopupBubble*>( | 437 return static_cast<message_center::MessagePopupBubble*>( |
420 popup_bubble()->bubble()); | 438 popup_bubble()->bubble()); |
421 } | 439 } |
422 | 440 |
423 } // namespace ash | 441 } // namespace ash |
OLD | NEW |