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 "ash/common/focus_cycler.h" | 7 #include "ash/common/focus_cycler.h" |
8 #include "ash/common/keyboard/keyboard_ui.h" | 8 #include "ash/common/keyboard/keyboard_ui.h" |
9 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
10 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 10 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 } | 46 } |
47 | 47 |
48 void WmShell::AddShellObserver(ShellObserver* observer) { | 48 void WmShell::AddShellObserver(ShellObserver* observer) { |
49 shell_observers_.AddObserver(observer); | 49 shell_observers_.AddObserver(observer); |
50 } | 50 } |
51 | 51 |
52 void WmShell::RemoveShellObserver(ShellObserver* observer) { | 52 void WmShell::RemoveShellObserver(ShellObserver* observer) { |
53 shell_observers_.RemoveObserver(observer); | 53 shell_observers_.RemoveObserver(observer); |
54 } | 54 } |
55 | 55 |
56 WmShell::WmShell() | 56 WmShell::WmShell(ShellDelegate* delegate) |
57 : focus_cycler_(new FocusCycler), | 57 : delegate_(delegate), |
| 58 focus_cycler_(new FocusCycler), |
58 system_tray_notifier_(new SystemTrayNotifier), | 59 system_tray_notifier_(new SystemTrayNotifier), |
59 window_selector_controller_(new WindowSelectorController()) {} | 60 window_selector_controller_(new WindowSelectorController()) {} |
60 | 61 |
61 WmShell::~WmShell() {} | 62 WmShell::~WmShell() {} |
62 | 63 |
63 bool WmShell::IsSystemModalWindowOpen() { | 64 bool WmShell::IsSystemModalWindowOpen() { |
64 if (simulate_modal_window_open_for_testing_) | 65 if (simulate_modal_window_open_for_testing_) |
65 return true; | 66 return true; |
66 | 67 |
67 // Traverse all system modal containers, and find its direct child window | 68 // Traverse all system modal containers, and find its direct child window |
68 // with "SystemModal" setting, and visible. | 69 // with "SystemModal" setting, and visible. |
69 for (WmWindow* root : GetAllRootWindows()) { | 70 for (WmWindow* root : GetAllRootWindows()) { |
70 WmWindow* system_modal = | 71 WmWindow* system_modal = |
71 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); | 72 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); |
72 if (!system_modal) | 73 if (!system_modal) |
73 continue; | 74 continue; |
74 for (const WmWindow* child : system_modal->GetChildren()) { | 75 for (const WmWindow* child : system_modal->GetChildren()) { |
75 if (child->IsSystemModal() && child->GetTargetVisibility()) { | 76 if (child->IsSystemModal() && child->GetTargetVisibility()) { |
76 return true; | 77 return true; |
77 } | 78 } |
78 } | 79 } |
79 } | 80 } |
80 return false; | 81 return false; |
81 } | 82 } |
82 | 83 |
83 void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) { | 84 void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) { |
84 keyboard_ui_ = std::move(keyboard_ui); | 85 keyboard_ui_ = std::move(keyboard_ui); |
85 } | 86 } |
86 | 87 |
| 88 void WmShell::DeleteShellDelegate() { |
| 89 delegate_.reset(); |
| 90 } |
| 91 |
87 void WmShell::SetMediaDelegate(std::unique_ptr<MediaDelegate> delegate) { | 92 void WmShell::SetMediaDelegate(std::unique_ptr<MediaDelegate> delegate) { |
88 media_delegate_ = std::move(delegate); | 93 media_delegate_ = std::move(delegate); |
89 } | 94 } |
90 | 95 |
91 void WmShell::SetSystemTrayDelegate( | 96 void WmShell::SetSystemTrayDelegate( |
92 std::unique_ptr<SystemTrayDelegate> delegate) { | 97 std::unique_ptr<SystemTrayDelegate> delegate) { |
93 DCHECK(delegate); | 98 DCHECK(delegate); |
94 DCHECK(!system_tray_delegate_); | 99 DCHECK(!system_tray_delegate_); |
95 // TODO(jamescook): Create via ShellDelegate once it moves to //ash/common. | 100 // TODO(jamescook): Create via ShellDelegate once it moves to //ash/common. |
96 system_tray_delegate_ = std::move(delegate); | 101 system_tray_delegate_ = std::move(delegate); |
(...skipping 27 matching lines...) Expand all Loading... |
124 | 129 |
125 void WmShell::CreateMruWindowTracker() { | 130 void WmShell::CreateMruWindowTracker() { |
126 mru_window_tracker_.reset(new MruWindowTracker); | 131 mru_window_tracker_.reset(new MruWindowTracker); |
127 } | 132 } |
128 | 133 |
129 void WmShell::DeleteMruWindowTracker() { | 134 void WmShell::DeleteMruWindowTracker() { |
130 mru_window_tracker_.reset(); | 135 mru_window_tracker_.reset(); |
131 } | 136 } |
132 | 137 |
133 } // namespace ash | 138 } // namespace ash |
OLD | NEW |