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/common/shelf/shelf_layout_manager.h" | 5 #include "ash/common/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 update_shelf_observer_(nullptr), | 153 update_shelf_observer_(nullptr), |
154 chromevox_panel_height_(0), | 154 chromevox_panel_height_(0), |
155 duration_override_in_ms_(0), | 155 duration_override_in_ms_(0), |
156 shelf_background_type_(SHELF_BACKGROUND_OVERLAP), | 156 shelf_background_type_(SHELF_BACKGROUND_OVERLAP), |
157 keyboard_observer_(this) { | 157 keyboard_observer_(this) { |
158 DCHECK(shelf_widget_); | 158 DCHECK(shelf_widget_); |
159 DCHECK(wm_shelf_); | 159 DCHECK(wm_shelf_); |
160 Shell::GetInstance()->AddShellObserver(this); | 160 Shell::GetInstance()->AddShellObserver(this); |
161 WmShell::Get()->AddLockStateObserver(this); | 161 WmShell::Get()->AddLockStateObserver(this); |
162 Shell::GetInstance()->activation_client()->AddObserver(this); | 162 Shell::GetInstance()->activation_client()->AddObserver(this); |
163 WmShell::Get()->session_controller()->AddSessionStateObserver(this); | 163 Shell::Get()->session_controller()->AddSessionStateObserver(this); |
164 state_.session_state = | 164 state_.session_state = Shell::Get()->session_controller()->GetSessionState(); |
165 WmShell::Get()->session_controller()->GetSessionState(); | |
166 } | 165 } |
167 | 166 |
168 ShelfLayoutManager::~ShelfLayoutManager() { | 167 ShelfLayoutManager::~ShelfLayoutManager() { |
169 if (update_shelf_observer_) | 168 if (update_shelf_observer_) |
170 update_shelf_observer_->Detach(); | 169 update_shelf_observer_->Detach(); |
171 | 170 |
172 for (auto& observer : observers_) | 171 for (auto& observer : observers_) |
173 observer.WillDeleteShelfLayoutManager(); | 172 observer.WillDeleteShelfLayoutManager(); |
174 Shell::GetInstance()->RemoveShellObserver(this); | 173 Shell::GetInstance()->RemoveShellObserver(this); |
175 WmShell::Get()->RemoveLockStateObserver(this); | 174 WmShell::Get()->RemoveLockStateObserver(this); |
176 WmShell::Get()->session_controller()->RemoveSessionStateObserver(this); | 175 Shell::Get()->session_controller()->RemoveSessionStateObserver(this); |
177 } | 176 } |
178 | 177 |
179 void ShelfLayoutManager::PrepareForShutdown() { | 178 void ShelfLayoutManager::PrepareForShutdown() { |
180 in_shutdown_ = true; | 179 in_shutdown_ = true; |
181 // Stop observing changes to avoid updating a partially destructed shelf. | 180 // Stop observing changes to avoid updating a partially destructed shelf. |
182 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 181 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
183 } | 182 } |
184 | 183 |
185 bool ShelfLayoutManager::IsVisible() const { | 184 bool ShelfLayoutManager::IsVisible() const { |
186 // status_area_widget() may be nullptr during the shutdown. | 185 // status_area_widget() may be nullptr during the shutdown. |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 void ShelfLayoutManager::AddObserver(ShelfLayoutManagerObserver* observer) { | 332 void ShelfLayoutManager::AddObserver(ShelfLayoutManagerObserver* observer) { |
334 observers_.AddObserver(observer); | 333 observers_.AddObserver(observer); |
335 } | 334 } |
336 | 335 |
337 void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) { | 336 void ShelfLayoutManager::RemoveObserver(ShelfLayoutManagerObserver* observer) { |
338 observers_.RemoveObserver(observer); | 337 observers_.RemoveObserver(observer); |
339 } | 338 } |
340 | 339 |
341 bool ShelfLayoutManager::ProcessGestureEvent(const ui::GestureEvent& event) { | 340 bool ShelfLayoutManager::ProcessGestureEvent(const ui::GestureEvent& event) { |
342 // The gestures are disabled in the lock/login screen. | 341 // The gestures are disabled in the lock/login screen. |
343 SessionController* controller = WmShell::Get()->session_controller(); | 342 SessionController* controller = Shell::Get()->session_controller(); |
344 if (!controller->NumberOfLoggedInUsers() || controller->IsScreenLocked()) | 343 if (!controller->NumberOfLoggedInUsers() || controller->IsScreenLocked()) |
345 return false; | 344 return false; |
346 | 345 |
347 if (IsShelfHiddenForFullscreen()) | 346 if (IsShelfHiddenForFullscreen()) |
348 return false; | 347 return false; |
349 | 348 |
350 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 349 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
351 StartGestureDrag(event); | 350 StartGestureDrag(event); |
352 return true; | 351 return true; |
353 } | 352 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 429 (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
431 ::switches::kUseNewVirtualKeyboardBehavior) || | 430 ::switches::kUseNewVirtualKeyboardBehavior) || |
432 keyboard::KeyboardController::GetInstance()->keyboard_locked()); | 431 keyboard::KeyboardController::GetInstance()->keyboard_locked()); |
433 | 432 |
434 keyboard_bounds_ = new_bounds; | 433 keyboard_bounds_ = new_bounds; |
435 LayoutShelfAndUpdateBounds(change_work_area); | 434 LayoutShelfAndUpdateBounds(change_work_area); |
436 | 435 |
437 // On login screen if keyboard has been just hidden, update bounds just once | 436 // On login screen if keyboard has been just hidden, update bounds just once |
438 // but ignore target_bounds.work_area_insets since shelf overlaps with login | 437 // but ignore target_bounds.work_area_insets since shelf overlaps with login |
439 // window. | 438 // window. |
440 if (WmShell::Get()->session_controller()->IsUserSessionBlocked() && | 439 if (Shell::Get()->session_controller()->IsUserSessionBlocked() && |
441 keyboard_is_about_to_hide) { | 440 keyboard_is_about_to_hide) { |
442 WmWindow* window = WmWindow::Get(shelf_widget_->GetNativeWindow()); | 441 WmWindow* window = WmWindow::Get(shelf_widget_->GetNativeWindow()); |
443 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets()); | 442 WmShell::Get()->SetDisplayWorkAreaInsets(window, gfx::Insets()); |
444 } | 443 } |
445 } | 444 } |
446 | 445 |
447 void ShelfLayoutManager::OnKeyboardClosed() { | 446 void ShelfLayoutManager::OnKeyboardClosed() { |
448 keyboard_observer_.RemoveAll(); | 447 keyboard_observer_.RemoveAll(); |
449 } | 448 } |
450 | 449 |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1125 gesture_drag_status_ = GESTURE_DRAG_NONE; |
1127 } | 1126 } |
1128 | 1127 |
1129 void ShelfLayoutManager::CancelGestureDrag() { | 1128 void ShelfLayoutManager::CancelGestureDrag() { |
1130 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; | 1129 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
1131 UpdateVisibilityState(); | 1130 UpdateVisibilityState(); |
1132 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1131 gesture_drag_status_ = GESTURE_DRAG_NONE; |
1133 } | 1132 } |
1134 | 1133 |
1135 } // namespace ash | 1134 } // namespace ash |
OLD | NEW |