OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ash_popup_alignment_delegate.h" | 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
6 | 6 |
7 #include "ash/public/cpp/shelf_types.h" | 7 #include "ash/public/cpp/shelf_types.h" |
8 #include "ash/public/cpp/shell_window_ids.h" | 8 #include "ash/public/cpp/shell_window_ids.h" |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
11 #include "ash/shelf/shelf_constants.h" | 11 #include "ash/shelf/shelf_constants.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/wm_window.h" | 13 #include "ash/wm_window.h" |
14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
15 #include "ui/display/display.h" | 15 #include "ui/display/display.h" |
16 #include "ui/display/screen.h" | 16 #include "ui/display/screen.h" |
17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
18 #include "ui/message_center/message_center_style.h" | 18 #include "ui/message_center/message_center_style.h" |
19 #include "ui/message_center/views/message_popup_collection.h" | 19 #include "ui/message_center/views/message_popup_collection.h" |
20 #include "ui/wm/core/shadow_types.h" | 20 #include "ui/wm/core/shadow_types.h" |
21 | 21 |
22 namespace ash { | 22 namespace ash { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 const int kToastMarginX = 7; | 26 const int kToastMarginX = 7; |
27 | 27 |
28 // If there should be no margin for the first item, this value needs to be | 28 // If there should be no margin for the first item, this value needs to be |
29 // substracted to flush the message to the shelf (the width of the border + | 29 // subtracted to flush the message to the shelf (the width of the border + |
30 // shadow). | 30 // shadow). |
31 const int kNoToastMarginBorderAndShadowOffset = 2; | 31 const int kNoToastMarginBorderAndShadowOffset = 2; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 AshPopupAlignmentDelegate::AshPopupAlignmentDelegate(Shelf* shelf) | 35 AshPopupAlignmentDelegate::AshPopupAlignmentDelegate(Shelf* shelf) |
36 : screen_(NULL), shelf_(shelf), tray_bubble_height_(0) { | 36 : screen_(NULL), shelf_(shelf), tray_bubble_height_(0) { |
37 shelf_->AddObserver(this); | 37 shelf_->AddObserver(this); |
38 } | 38 } |
39 | 39 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 const display::Display& display) { | 109 const display::Display& display) { |
110 // Nothing needs to be done. | 110 // Nothing needs to be done. |
111 } | 111 } |
112 | 112 |
113 void AshPopupAlignmentDelegate::ConfigureWidgetInitParamsForContainer( | 113 void AshPopupAlignmentDelegate::ConfigureWidgetInitParamsForContainer( |
114 views::Widget* widget, | 114 views::Widget* widget, |
115 views::Widget::InitParams* init_params) { | 115 views::Widget::InitParams* init_params) { |
116 init_params->shadow_type = views::Widget::InitParams::SHADOW_TYPE_DROP; | 116 init_params->shadow_type = views::Widget::InitParams::SHADOW_TYPE_DROP; |
117 init_params->shadow_elevation = ::wm::ShadowElevation::MEDIUM; | 117 init_params->shadow_elevation = ::wm::ShadowElevation::MEDIUM; |
118 // On ash, popups go in the status container. | 118 // On ash, popups go in the status container. |
119 shelf_->GetWindow() | 119 RootWindowController::ForWindow(shelf_->GetWindow()) |
120 ->GetRootWindowController() | |
121 ->ConfigureWidgetInitParamsForContainer( | 120 ->ConfigureWidgetInitParamsForContainer( |
122 widget, kShellWindowId_StatusContainer, init_params); | 121 widget, kShellWindowId_StatusContainer, init_params); |
123 } | 122 } |
124 | 123 |
125 bool AshPopupAlignmentDelegate::IsPrimaryDisplayForNotification() const { | 124 bool AshPopupAlignmentDelegate::IsPrimaryDisplayForNotification() const { |
126 return screen_ && | 125 return screen_ && |
127 GetCurrentDisplay().id() == screen_->GetPrimaryDisplay().id(); | 126 GetCurrentDisplay().id() == screen_->GetPrimaryDisplay().id(); |
128 } | 127 } |
129 | 128 |
130 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const { | 129 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const { |
131 return shelf_->alignment(); | 130 return shelf_->alignment(); |
132 } | 131 } |
133 | 132 |
134 display::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { | 133 display::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { |
135 return shelf_->GetWindow()->GetDisplayNearestWindow(); | 134 return display::Screen::GetScreen()->GetDisplayNearestWindow( |
| 135 shelf_->GetWindow()); |
136 } | 136 } |
137 | 137 |
138 void AshPopupAlignmentDelegate::UpdateWorkArea() { | 138 void AshPopupAlignmentDelegate::UpdateWorkArea() { |
139 work_area_ = shelf_->GetUserWorkAreaBounds(); | 139 work_area_ = shelf_->GetUserWorkAreaBounds(); |
140 DoUpdateIfPossible(); | 140 DoUpdateIfPossible(); |
141 } | 141 } |
142 | 142 |
143 /////////////////////////////////////////////////////////////////////////////// | 143 /////////////////////////////////////////////////////////////////////////////// |
144 // ShelfObserver: | 144 // ShelfObserver: |
145 | 145 |
(...skipping 17 matching lines...) Expand all Loading... |
163 const display::Display& old_display) {} | 163 const display::Display& old_display) {} |
164 | 164 |
165 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( | 165 void AshPopupAlignmentDelegate::OnDisplayMetricsChanged( |
166 const display::Display& display, | 166 const display::Display& display, |
167 uint32_t metrics) { | 167 uint32_t metrics) { |
168 if (GetCurrentDisplay().id() == display.id()) | 168 if (GetCurrentDisplay().id() == display.id()) |
169 UpdateWorkArea(); | 169 UpdateWorkArea(); |
170 } | 170 } |
171 | 171 |
172 } // namespace ash | 172 } // namespace ash |
OLD | NEW |