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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/root_window_controller.h" | 8 #include "ash/root_window_controller.h" |
9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
10 #include "ash/shelf/shelf_layout_manager_observer.h" | 10 #include "ash/shelf/shelf_layout_manager_observer.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 system_tray_height_ = height; | 121 system_tray_height_ = height; |
122 | 122 |
123 // If the shelf is shown during auto-hide state, the distance from the edge | 123 // If the shelf is shown during auto-hide state, the distance from the edge |
124 // should be reduced by the height of shelf's shown height. | 124 // should be reduced by the height of shelf's shown height. |
125 if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && | 125 if (shelf_ && shelf_->visibility_state() == SHELF_AUTO_HIDE && |
126 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { | 126 shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) { |
127 system_tray_height_ -= ShelfLayoutManager::GetPreferredShelfSize() - | 127 system_tray_height_ -= ShelfLayoutManager::GetPreferredShelfSize() - |
128 ShelfLayoutManager::kAutoHideSize; | 128 ShelfLayoutManager::kAutoHideSize; |
129 } | 129 } |
130 | 130 |
131 if (system_tray_height_ > 0 && ash::switches::UseAlternateShelfLayout()) | 131 if (system_tray_height_ > 0) |
132 system_tray_height_ += message_center::kMarginBetweenItems; | 132 system_tray_height_ += message_center::kMarginBetweenItems; |
133 | 133 |
134 if (!shelf_) | 134 if (!shelf_) |
135 return; | 135 return; |
136 | 136 |
137 OnAutoHideStateChanged(shelf_->auto_hide_state()); | 137 OnAutoHideStateChanged(shelf_->auto_hide_state()); |
138 } | 138 } |
139 | 139 |
140 void WorkAreaObserver::StartObserving( | 140 void WorkAreaObserver::StartObserving( |
141 message_center::MessagePopupCollection* collection, | 141 message_center::MessagePopupCollection* collection, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
213 views::TrayBubbleView::InitParams init_params = | 213 views::TrayBubbleView::InitParams init_params = |
214 bubble->GetInitParams(anchor_alignment); | 214 bubble->GetInitParams(anchor_alignment); |
215 views::View* anchor = tray->tray_container(); | 215 views::View* anchor = tray->tray_container(); |
216 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 216 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
217 gfx::Point bounds(anchor->width() / 2, 0); | 217 gfx::Point bounds(anchor->width() / 2, 0); |
218 views::View::ConvertPointToWidget(anchor, &bounds); | 218 views::View::ConvertPointToWidget(anchor, &bounds); |
219 init_params.arrow_offset = bounds.x(); | 219 init_params.arrow_offset = bounds.x(); |
220 } | 220 } |
221 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( | 221 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( |
222 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); | 222 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); |
223 if (ash::switches::UseAlternateShelfLayout()) | 223 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
224 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | |
225 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); | 224 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); |
226 bubble->InitializeContents(bubble_view); | 225 bubble->InitializeContents(bubble_view); |
227 } | 226 } |
228 | 227 |
229 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } | 228 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } |
230 | 229 |
231 // Convenience accessors. | 230 // Convenience accessors. |
232 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } | 231 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } |
233 | 232 |
234 private: | 233 private: |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 | 330 |
332 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { | 331 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { |
333 if (!ShouldShowMessageCenter()) | 332 if (!ShouldShowMessageCenter()) |
334 return false; | 333 return false; |
335 | 334 |
336 should_block_shelf_auto_hide_ = true; | 335 should_block_shelf_auto_hide_ = true; |
337 message_center::MessageCenterBubble* message_center_bubble = | 336 message_center::MessageCenterBubble* message_center_bubble = |
338 new message_center::MessageCenterBubble( | 337 new message_center::MessageCenterBubble( |
339 message_center(), | 338 message_center(), |
340 message_center_tray_.get(), | 339 message_center_tray_.get(), |
341 ash::switches::UseAlternateShelfLayout()); | 340 true); |
James Cook
2014/01/23 18:02:35
same question about first_item_has_no_margin
Harry McCleave
2014/01/24 22:48:47
.
| |
342 | 341 |
343 int max_height = 0; | 342 int max_height = 0; |
344 aura::Window* status_area_window = status_area_widget()->GetNativeView(); | 343 aura::Window* status_area_window = status_area_widget()->GetNativeView(); |
345 switch (GetShelfLayoutManager()->GetAlignment()) { | 344 switch (GetShelfLayoutManager()->GetAlignment()) { |
346 case SHELF_ALIGNMENT_BOTTOM: { | 345 case SHELF_ALIGNMENT_BOTTOM: { |
347 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); | 346 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); |
348 max_height = shelf_bounds.y(); | 347 max_height = shelf_bounds.y(); |
349 break; | 348 break; |
350 } | 349 } |
351 case SHELF_ALIGNMENT_TOP: { | 350 case SHELF_ALIGNMENT_TOP: { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 bool WebNotificationTray::ShowPopups() { | 401 bool WebNotificationTray::ShowPopups() { |
403 if (message_center_bubble()) | 402 if (message_center_bubble()) |
404 return false; | 403 return false; |
405 | 404 |
406 popup_collection_.reset(new message_center::MessagePopupCollection( | 405 popup_collection_.reset(new message_center::MessagePopupCollection( |
407 ash::Shell::GetContainer( | 406 ash::Shell::GetContainer( |
408 GetWidget()->GetNativeView()->GetRootWindow(), | 407 GetWidget()->GetNativeView()->GetRootWindow(), |
409 internal::kShellWindowId_StatusContainer), | 408 internal::kShellWindowId_StatusContainer), |
410 message_center(), | 409 message_center(), |
411 message_center_tray_.get(), | 410 message_center_tray_.get(), |
412 ash::switches::UseAlternateShelfLayout())); | 411 true)); |
413 work_area_observer_->StartObserving( | 412 work_area_observer_->StartObserving( |
414 popup_collection_.get(), GetWidget()->GetNativeView()->GetRootWindow()); | 413 popup_collection_.get(), GetWidget()->GetNativeView()->GetRootWindow()); |
415 return true; | 414 return true; |
416 } | 415 } |
417 | 416 |
418 void WebNotificationTray::HidePopups() { | 417 void WebNotificationTray::HidePopups() { |
419 DCHECK(popup_collection_.get()); | 418 DCHECK(popup_collection_.get()); |
420 | 419 |
421 popup_collection_->MarkAllPopupsShown(); | 420 popup_collection_->MarkAllPopupsShown(); |
422 popup_collection_.reset(); | 421 popup_collection_.reset(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 | 620 |
622 message_center::MessageCenterBubble* | 621 message_center::MessageCenterBubble* |
623 WebNotificationTray::GetMessageCenterBubbleForTest() { | 622 WebNotificationTray::GetMessageCenterBubbleForTest() { |
624 if (!message_center_bubble()) | 623 if (!message_center_bubble()) |
625 return NULL; | 624 return NULL; |
626 return static_cast<message_center::MessageCenterBubble*>( | 625 return static_cast<message_center::MessageCenterBubble*>( |
627 message_center_bubble()->bubble()); | 626 message_center_bubble()->bubble()); |
628 } | 627 } |
629 | 628 |
630 } // namespace ash | 629 } // namespace ash |
OLD | NEW |