| 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/common/wm_shell.h" | 5 #include "ash/common/wm_shell.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/accelerators/accelerator_controller.h" | 9 #include "ash/common/accelerators/accelerator_controller.h" |
| 10 #include "ash/common/accessibility_delegate.h" | 10 #include "ash/common/accessibility_delegate.h" |
| 11 #include "ash/common/focus_cycler.h" | 11 #include "ash/common/focus_cycler.h" |
| 12 #include "ash/common/keyboard/keyboard_ui.h" | 12 #include "ash/common/keyboard/keyboard_ui.h" |
| 13 #include "ash/common/shelf/app_list_shelf_item_delegate.h" |
| 13 #include "ash/common/shelf/shelf_model.h" | 14 #include "ash/common/shelf/shelf_model.h" |
| 14 #include "ash/common/shell_delegate.h" | 15 #include "ash/common/shell_delegate.h" |
| 15 #include "ash/common/shell_window_ids.h" | 16 #include "ash/common/shell_window_ids.h" |
| 16 #include "ash/common/system/brightness_control_delegate.h" | 17 #include "ash/common/system/brightness_control_delegate.h" |
| 17 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 18 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 18 #include "ash/common/system/toast/toast_manager.h" | 19 #include "ash/common/system/toast/toast_manager.h" |
| 19 #include "ash/common/system/tray/system_tray_delegate.h" | 20 #include "ash/common/system/tray/system_tray_delegate.h" |
| 20 #include "ash/common/system/tray/system_tray_notifier.h" | 21 #include "ash/common/system/tray/system_tray_notifier.h" |
| 21 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 22 #include "ash/common/wm/mru_window_tracker.h" | 23 #include "ash/common/wm/mru_window_tracker.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 48 WmShell* WmShell::Get() { | 49 WmShell* WmShell::Get() { |
| 49 return instance_; | 50 return instance_; |
| 50 } | 51 } |
| 51 | 52 |
| 52 void WmShell::Initialize() { | 53 void WmShell::Initialize() { |
| 53 // Some delegates access WmShell during their construction. Create them here | 54 // Some delegates access WmShell during their construction. Create them here |
| 54 // instead of the WmShell constructor. | 55 // instead of the WmShell constructor. |
| 55 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); | 56 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); |
| 56 media_delegate_.reset(delegate_->CreateMediaDelegate()); | 57 media_delegate_.reset(delegate_->CreateMediaDelegate()); |
| 57 toast_manager_.reset(new ToastManager); | 58 toast_manager_.reset(new ToastManager); |
| 59 |
| 60 // Create the app list item in the shelf data model. |
| 61 AppListShelfItemDelegate::CreateAppListItemAndDelegate(shelf_model_.get()); |
| 58 } | 62 } |
| 59 | 63 |
| 60 void WmShell::Shutdown() { | 64 void WmShell::Shutdown() { |
| 61 // Accesses WmShell in its destructor. | 65 // Accesses WmShell in its destructor. |
| 62 accessibility_delegate_.reset(); | 66 accessibility_delegate_.reset(); |
| 67 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
| 68 // shelf items in Chrome) so explicitly shutdown early. |
| 69 shelf_model_->DestroyItemDelegates(); |
| 63 } | 70 } |
| 64 | 71 |
| 65 void WmShell::OnMaximizeModeStarted() { | 72 void WmShell::OnMaximizeModeStarted() { |
| 66 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeStarted()); | 73 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeStarted()); |
| 67 } | 74 } |
| 68 | 75 |
| 69 void WmShell::OnMaximizeModeEnded() { | 76 void WmShell::OnMaximizeModeEnded() { |
| 70 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeEnded()); | 77 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeEnded()); |
| 71 } | 78 } |
| 72 | 79 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 lock_state_observers_.AddObserver(observer); | 104 lock_state_observers_.AddObserver(observer); |
| 98 } | 105 } |
| 99 | 106 |
| 100 void WmShell::RemoveLockStateObserver(LockStateObserver* observer) { | 107 void WmShell::RemoveLockStateObserver(LockStateObserver* observer) { |
| 101 lock_state_observers_.RemoveObserver(observer); | 108 lock_state_observers_.RemoveObserver(observer); |
| 102 } | 109 } |
| 103 | 110 |
| 104 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate) | 111 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate) |
| 105 : delegate_(std::move(shell_delegate)), | 112 : delegate_(std::move(shell_delegate)), |
| 106 focus_cycler_(new FocusCycler), | 113 focus_cycler_(new FocusCycler), |
| 107 shelf_model_(new ShelfModel), | 114 shelf_model_(new ShelfModel), // Must create before ShelfDelegate. |
| 108 system_tray_notifier_(new SystemTrayNotifier), | 115 system_tray_notifier_(new SystemTrayNotifier), |
| 116 window_cycle_controller_(new WindowCycleController), |
| 109 window_selector_controller_(new WindowSelectorController) { | 117 window_selector_controller_(new WindowSelectorController) { |
| 110 #if defined(OS_CHROMEOS) | 118 #if defined(OS_CHROMEOS) |
| 111 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); | 119 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); |
| 112 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); | 120 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); |
| 113 #endif | 121 #endif |
| 114 window_cycle_controller_.reset(new WindowCycleController()); | |
| 115 } | 122 } |
| 116 | 123 |
| 117 WmShell::~WmShell() {} | 124 WmShell::~WmShell() {} |
| 118 | 125 |
| 119 bool WmShell::IsSystemModalWindowOpen() { | 126 bool WmShell::IsSystemModalWindowOpen() { |
| 120 if (simulate_modal_window_open_for_testing_) | 127 if (simulate_modal_window_open_for_testing_) |
| 121 return true; | 128 return true; |
| 122 | 129 |
| 123 // Traverse all system modal containers, and find its direct child window | 130 // Traverse all system modal containers, and find its direct child window |
| 124 // with "SystemModal" setting, and visible. | 131 // with "SystemModal" setting, and visible. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void WmShell::DeleteToastManager() { | 222 void WmShell::DeleteToastManager() { |
| 216 toast_manager_.reset(); | 223 toast_manager_.reset(); |
| 217 } | 224 } |
| 218 | 225 |
| 219 void WmShell::SetAcceleratorController( | 226 void WmShell::SetAcceleratorController( |
| 220 std::unique_ptr<AcceleratorController> accelerator_controller) { | 227 std::unique_ptr<AcceleratorController> accelerator_controller) { |
| 221 accelerator_controller_ = std::move(accelerator_controller); | 228 accelerator_controller_ = std::move(accelerator_controller); |
| 222 } | 229 } |
| 223 | 230 |
| 224 } // namespace ash | 231 } // namespace ash |
| OLD | NEW |