| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 StopObserving(); | 117 StopObserving(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void WorkAreaObserver::SetSystemTrayHeight(int height) { | 120 void WorkAreaObserver::SetSystemTrayHeight(int height) { |
| 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_ -= kShelfSize - ShelfLayoutManager::kAutoHideSize; | 127 system_tray_height_ -= ShelfLayoutManager::GetPreferredShelfSize() - |
| 128 ShelfLayoutManager::kAutoHideSize; |
| 128 } | 129 } |
| 129 | 130 |
| 130 if (system_tray_height_ > 0) | 131 if (system_tray_height_ > 0 && ash::switches::UseAlternateShelfLayout()) |
| 131 system_tray_height_ += message_center::kMarginBetweenItems; | 132 system_tray_height_ += message_center::kMarginBetweenItems; |
| 132 | 133 |
| 133 if (!shelf_) | 134 if (!shelf_) |
| 134 return; | 135 return; |
| 135 | 136 |
| 136 OnAutoHideStateChanged(shelf_->auto_hide_state()); | 137 OnAutoHideStateChanged(shelf_->auto_hide_state()); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void WorkAreaObserver::StartObserving( | 140 void WorkAreaObserver::StartObserving( |
| 140 message_center::MessagePopupCollection* collection, | 141 message_center::MessagePopupCollection* collection, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 166 | 167 |
| 167 void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) { | 168 void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
| 168 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | 169 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( |
| 169 shelf_->shelf_widget()->GetNativeView()); | 170 shelf_->shelf_widget()->GetNativeView()); |
| 170 gfx::Rect work_area = display.work_area(); | 171 gfx::Rect work_area = display.work_area(); |
| 171 int width = 0; | 172 int width = 0; |
| 172 if ((shelf_->visibility_state() == SHELF_AUTO_HIDE) && | 173 if ((shelf_->visibility_state() == SHELF_AUTO_HIDE) && |
| 173 new_state == SHELF_AUTO_HIDE_SHOWN) { | 174 new_state == SHELF_AUTO_HIDE_SHOWN) { |
| 174 // Since the work_area is already reduced by kAutoHideSize, the inset width | 175 // Since the work_area is already reduced by kAutoHideSize, the inset width |
| 175 // should be just the difference. | 176 // should be just the difference. |
| 176 width = kShelfSize - ShelfLayoutManager::kAutoHideSize; | 177 width = ShelfLayoutManager::GetPreferredShelfSize() - |
| 178 ShelfLayoutManager::kAutoHideSize; |
| 177 } | 179 } |
| 178 work_area.Inset(shelf_->SelectValueForShelfAlignment( | 180 work_area.Inset(shelf_->SelectValueForShelfAlignment( |
| 179 gfx::Insets(0, 0, width, 0), | 181 gfx::Insets(0, 0, width, 0), |
| 180 gfx::Insets(0, width, 0, 0), | 182 gfx::Insets(0, width, 0, 0), |
| 181 gfx::Insets(0, 0, 0, width), | 183 gfx::Insets(0, 0, 0, width), |
| 182 gfx::Insets(width, 0, 0, 0))); | 184 gfx::Insets(width, 0, 0, 0))); |
| 183 if (system_tray_height_ > 0) { | 185 if (system_tray_height_ > 0) { |
| 184 work_area.set_height( | 186 work_area.set_height( |
| 185 std::max(0, work_area.height() - system_tray_height_)); | 187 std::max(0, work_area.height() - system_tray_height_)); |
| 186 if (shelf_->GetAlignment() == SHELF_ALIGNMENT_TOP) | 188 if (shelf_->GetAlignment() == SHELF_ALIGNMENT_TOP) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 211 views::TrayBubbleView::InitParams init_params = | 213 views::TrayBubbleView::InitParams init_params = |
| 212 bubble->GetInitParams(anchor_alignment); | 214 bubble->GetInitParams(anchor_alignment); |
| 213 views::View* anchor = tray->tray_container(); | 215 views::View* anchor = tray->tray_container(); |
| 214 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { | 216 if (anchor_alignment == views::TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) { |
| 215 gfx::Point bounds(anchor->width() / 2, 0); | 217 gfx::Point bounds(anchor->width() / 2, 0); |
| 216 views::View::ConvertPointToWidget(anchor, &bounds); | 218 views::View::ConvertPointToWidget(anchor, &bounds); |
| 217 init_params.arrow_offset = bounds.x(); | 219 init_params.arrow_offset = bounds.x(); |
| 218 } | 220 } |
| 219 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( | 221 views::TrayBubbleView* bubble_view = views::TrayBubbleView::Create( |
| 220 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); | 222 tray->GetBubbleWindowContainer(), anchor, tray, &init_params); |
| 221 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 223 if (ash::switches::UseAlternateShelfLayout()) |
| 224 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| 222 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); | 225 bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_view)); |
| 223 bubble->InitializeContents(bubble_view); | 226 bubble->InitializeContents(bubble_view); |
| 224 } | 227 } |
| 225 | 228 |
| 226 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } | 229 message_center::MessageBubbleBase* bubble() const { return bubble_.get(); } |
| 227 | 230 |
| 228 // Convenience accessors. | 231 // Convenience accessors. |
| 229 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } | 232 views::TrayBubbleView* bubble_view() const { return bubble_->bubble_view(); } |
| 230 | 233 |
| 231 private: | 234 private: |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 341 |
| 339 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { | 342 bool WebNotificationTray::ShowMessageCenterInternal(bool show_settings) { |
| 340 if (!ShouldShowMessageCenter()) | 343 if (!ShouldShowMessageCenter()) |
| 341 return false; | 344 return false; |
| 342 | 345 |
| 343 should_block_shelf_auto_hide_ = true; | 346 should_block_shelf_auto_hide_ = true; |
| 344 message_center::MessageCenterBubble* message_center_bubble = | 347 message_center::MessageCenterBubble* message_center_bubble = |
| 345 new message_center::MessageCenterBubble( | 348 new message_center::MessageCenterBubble( |
| 346 message_center(), | 349 message_center(), |
| 347 message_center_tray_.get(), | 350 message_center_tray_.get(), |
| 348 true); | 351 ash::switches::UseAlternateShelfLayout()); |
| 349 | 352 |
| 350 int max_height = 0; | 353 int max_height = 0; |
| 351 aura::Window* status_area_window = status_area_widget()->GetNativeView(); | 354 aura::Window* status_area_window = status_area_widget()->GetNativeView(); |
| 352 switch (GetShelfLayoutManager()->GetAlignment()) { | 355 switch (GetShelfLayoutManager()->GetAlignment()) { |
| 353 case SHELF_ALIGNMENT_BOTTOM: { | 356 case SHELF_ALIGNMENT_BOTTOM: { |
| 354 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); | 357 gfx::Rect shelf_bounds = GetShelfLayoutManager()->GetIdealBounds(); |
| 355 max_height = shelf_bounds.y(); | 358 max_height = shelf_bounds.y(); |
| 356 break; | 359 break; |
| 357 } | 360 } |
| 358 case SHELF_ALIGNMENT_TOP: { | 361 case SHELF_ALIGNMENT_TOP: { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 620 |
| 618 message_center::MessageCenterBubble* | 621 message_center::MessageCenterBubble* |
| 619 WebNotificationTray::GetMessageCenterBubbleForTest() { | 622 WebNotificationTray::GetMessageCenterBubbleForTest() { |
| 620 if (!message_center_bubble()) | 623 if (!message_center_bubble()) |
| 621 return NULL; | 624 return NULL; |
| 622 return static_cast<message_center::MessageCenterBubble*>( | 625 return static_cast<message_center::MessageCenterBubble*>( |
| 623 message_center_bubble()->bubble()); | 626 message_center_bubble()->bubble()); |
| 624 } | 627 } |
| 625 | 628 |
| 626 } // namespace ash | 629 } // namespace ash |
| OLD | NEW |