| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/shelf/wm_shelf.h" | 5 #include "ash/shelf/wm_shelf.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/config.h" |
| 7 #include "ash/public/cpp/shelf_item_delegate.h" | 8 #include "ash/public/cpp/shelf_item_delegate.h" |
| 8 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 9 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_bezel_event_handler.h" | 11 #include "ash/shelf/shelf_bezel_event_handler.h" |
| 11 #include "ash/shelf/shelf_controller.h" | 12 #include "ash/shelf/shelf_controller.h" |
| 12 #include "ash/shelf/shelf_delegate.h" | 13 #include "ash/shelf/shelf_delegate.h" |
| 13 #include "ash/shelf/shelf_layout_manager.h" | 14 #include "ash/shelf/shelf_layout_manager.h" |
| 14 #include "ash/shelf/shelf_locking_manager.h" | 15 #include "ash/shelf/shelf_locking_manager.h" |
| 15 #include "ash/shelf/shelf_model.h" | 16 #include "ash/shelf/shelf_model.h" |
| 16 #include "ash/shelf/shelf_widget.h" | 17 #include "ash/shelf/shelf_widget.h" |
| 17 #include "ash/shelf/wm_shelf_observer.h" | 18 #include "ash/shelf/wm_shelf_observer.h" |
| 18 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 19 #include "ash/shell_port.h" | |
| 20 #include "ash/system/tray/system_tray_delegate.h" | 20 #include "ash/system/tray/system_tray_delegate.h" |
| 21 #include "ash/wm_window.h" | 21 #include "ash/wm_window.h" |
| 22 #include "base/logging.h" | 22 #include "base/logging.h" |
| 23 #include "base/memory/ptr_util.h" | 23 #include "base/memory/ptr_util.h" |
| 24 #include "ui/display/types/display_constants.h" | 24 #include "ui/display/types/display_constants.h" |
| 25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 26 | 26 |
| 27 namespace ash { | 27 namespace ash { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // Must occur after |shelf_widget_| is constructed because the system tray | 115 // Must occur after |shelf_widget_| is constructed because the system tray |
| 116 // constructors call back into WmShelf::shelf_widget(). | 116 // constructors call back into WmShelf::shelf_widget(). |
| 117 DCHECK(!shelf_widget_->status_area_widget()); | 117 DCHECK(!shelf_widget_->status_area_widget()); |
| 118 WmWindow* status_container = | 118 WmWindow* status_container = |
| 119 root->GetChildByShellWindowId(kShellWindowId_StatusContainer); | 119 root->GetChildByShellWindowId(kShellWindowId_StatusContainer); |
| 120 shelf_widget_->CreateStatusAreaWidget(status_container); | 120 shelf_widget_->CreateStatusAreaWidget(status_container); |
| 121 | 121 |
| 122 // TODO: ShelfBezelEventHandler needs to work with mus too. | 122 // TODO: ShelfBezelEventHandler needs to work with mus too. |
| 123 // http://crbug.com/636647 | 123 // http://crbug.com/636647 |
| 124 if (!ShellPort::Get()->IsRunningInMash()) | 124 if (Shell::GetAshConfig() != Config::MASH) |
| 125 bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this); | 125 bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WmShelf::ShutdownShelfWidget() { | 128 void WmShelf::ShutdownShelfWidget() { |
| 129 if (shelf_widget_) | 129 if (shelf_widget_) |
| 130 shelf_widget_->Shutdown(); | 130 shelf_widget_->Shutdown(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void WmShelf::DestroyShelfWidget() { | 133 void WmShelf::DestroyShelfWidget() { |
| 134 shelf_widget_.reset(); | 134 shelf_widget_.reset(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { | 336 ShelfLockingManager* WmShelf::GetShelfLockingManagerForTesting() { |
| 337 return shelf_locking_manager_.get(); | 337 return shelf_locking_manager_.get(); |
| 338 } | 338 } |
| 339 | 339 |
| 340 ShelfView* WmShelf::GetShelfViewForTesting() { | 340 ShelfView* WmShelf::GetShelfViewForTesting() { |
| 341 return shelf_view_; | 341 return shelf_view_; |
| 342 } | 342 } |
| 343 | 343 |
| 344 void WmShelf::WillDeleteShelfLayoutManager() { | 344 void WmShelf::WillDeleteShelfLayoutManager() { |
| 345 if (ShellPort::Get()->IsRunningInMash()) { | 345 if (Shell::GetAshConfig() == Config::MASH) { |
| 346 // TODO(sky): this should be removed once Shell is used everywhere. | 346 // TODO(sky): this should be removed once Shell is used everywhere. |
| 347 ShutdownShelfWidget(); | 347 ShutdownShelfWidget(); |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Clear event handlers that might forward events to the destroyed instance. | 350 // Clear event handlers that might forward events to the destroyed instance. |
| 351 auto_hide_event_handler_.reset(); | 351 auto_hide_event_handler_.reset(); |
| 352 bezel_event_handler_.reset(); | 352 bezel_event_handler_.reset(); |
| 353 | 353 |
| 354 DCHECK(shelf_layout_manager_); | 354 DCHECK(shelf_layout_manager_); |
| 355 shelf_layout_manager_->RemoveObserver(this); | 355 shelf_layout_manager_->RemoveObserver(this); |
| 356 shelf_layout_manager_ = nullptr; | 356 shelf_layout_manager_ = nullptr; |
| 357 } | 357 } |
| 358 | 358 |
| 359 void WmShelf::WillChangeVisibilityState(ShelfVisibilityState new_state) { | 359 void WmShelf::WillChangeVisibilityState(ShelfVisibilityState new_state) { |
| 360 for (auto& observer : observers_) | 360 for (auto& observer : observers_) |
| 361 observer.WillChangeVisibilityState(new_state); | 361 observer.WillChangeVisibilityState(new_state); |
| 362 if (new_state != SHELF_AUTO_HIDE) { | 362 if (new_state != SHELF_AUTO_HIDE) { |
| 363 auto_hide_event_handler_.reset(); | 363 auto_hide_event_handler_.reset(); |
| 364 } else if (!auto_hide_event_handler_ && | 364 } else if (!auto_hide_event_handler_ && |
| 365 !ShellPort::Get()->IsRunningInMash()) { | 365 Shell::GetAshConfig() != Config::MASH) { |
| 366 auto_hide_event_handler_ = | 366 auto_hide_event_handler_ = |
| 367 base::MakeUnique<AutoHideEventHandler>(shelf_layout_manager()); | 367 base::MakeUnique<AutoHideEventHandler>(shelf_layout_manager()); |
| 368 } | 368 } |
| 369 } | 369 } |
| 370 | 370 |
| 371 void WmShelf::OnAutoHideStateChanged(ShelfAutoHideState new_state) { | 371 void WmShelf::OnAutoHideStateChanged(ShelfAutoHideState new_state) { |
| 372 for (auto& observer : observers_) | 372 for (auto& observer : observers_) |
| 373 observer.OnAutoHideStateChanged(new_state); | 373 observer.OnAutoHideStateChanged(new_state); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, | 376 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, |
| 377 AnimationChangeType change_type) { | 377 AnimationChangeType change_type) { |
| 378 if (background_type == GetBackgroundType()) | 378 if (background_type == GetBackgroundType()) |
| 379 return; | 379 return; |
| 380 for (auto& observer : observers_) | 380 for (auto& observer : observers_) |
| 381 observer.OnBackgroundTypeChanged(background_type, change_type); | 381 observer.OnBackgroundTypeChanged(background_type, change_type); |
| 382 } | 382 } |
| 383 | 383 |
| 384 } // namespace ash | 384 } // namespace ash |
| OLD | NEW |