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_constants.h" | 11 #include "ash/shelf/shelf_constants.h" |
11 #include "ash/shelf/wm_shelf.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 // substracted 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(WmShelf* 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 |
40 AshPopupAlignmentDelegate::~AshPopupAlignmentDelegate() { | 40 AshPopupAlignmentDelegate::~AshPopupAlignmentDelegate() { |
41 if (screen_) | 41 if (screen_) |
42 screen_->RemoveObserver(this); | 42 screen_->RemoveObserver(this); |
43 Shell::Get()->RemoveShellObserver(this); | 43 Shell::Get()->RemoveShellObserver(this); |
44 shelf_->RemoveObserver(this); | 44 shelf_->RemoveObserver(this); |
45 } | 45 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 ->ConfigureWidgetInitParamsForContainer( | 121 ->ConfigureWidgetInitParamsForContainer( |
122 widget, kShellWindowId_StatusContainer, init_params); | 122 widget, kShellWindowId_StatusContainer, init_params); |
123 } | 123 } |
124 | 124 |
125 bool AshPopupAlignmentDelegate::IsPrimaryDisplayForNotification() const { | 125 bool AshPopupAlignmentDelegate::IsPrimaryDisplayForNotification() const { |
126 return screen_ && | 126 return screen_ && |
127 GetCurrentDisplay().id() == screen_->GetPrimaryDisplay().id(); | 127 GetCurrentDisplay().id() == screen_->GetPrimaryDisplay().id(); |
128 } | 128 } |
129 | 129 |
130 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const { | 130 ShelfAlignment AshPopupAlignmentDelegate::GetAlignment() const { |
131 return shelf_->GetAlignment(); | 131 return shelf_->alignment(); |
132 } | 132 } |
133 | 133 |
134 display::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { | 134 display::Display AshPopupAlignmentDelegate::GetCurrentDisplay() const { |
135 return shelf_->GetWindow()->GetDisplayNearestWindow(); | 135 return shelf_->GetWindow()->GetDisplayNearestWindow(); |
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 // WmShelfObserver: | 144 // ShelfObserver: |
145 | 145 |
146 void AshPopupAlignmentDelegate::WillChangeVisibilityState( | 146 void AshPopupAlignmentDelegate::WillChangeVisibilityState( |
147 ShelfVisibilityState new_state) { | 147 ShelfVisibilityState new_state) { |
148 UpdateWorkArea(); | 148 UpdateWorkArea(); |
149 } | 149 } |
150 | 150 |
151 void AshPopupAlignmentDelegate::OnAutoHideStateChanged( | 151 void AshPopupAlignmentDelegate::OnAutoHideStateChanged( |
152 ShelfAutoHideState new_state) { | 152 ShelfAutoHideState new_state) { |
153 UpdateWorkArea(); | 153 UpdateWorkArea(); |
154 } | 154 } |
155 | 155 |
156 /////////////////////////////////////////////////////////////////////////////// | 156 /////////////////////////////////////////////////////////////////////////////// |
157 // display::DisplayObserver: | 157 // display::DisplayObserver: |
158 | 158 |
159 void AshPopupAlignmentDelegate::OnDisplayAdded( | 159 void AshPopupAlignmentDelegate::OnDisplayAdded( |
160 const display::Display& new_display) {} | 160 const display::Display& new_display) {} |
161 | 161 |
162 void AshPopupAlignmentDelegate::OnDisplayRemoved( | 162 void AshPopupAlignmentDelegate::OnDisplayRemoved( |
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 |