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_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
10 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
11 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 11 #include "ash/common/system/brightness_control_delegate.h" |
12 #include "ash/common/system/keyboard_brightness_control_delegate.h" | |
12 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
13 #include "ash/common/system/tray/system_tray_notifier.h" | 14 #include "ash/common/system/tray/system_tray_notifier.h" |
14 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 15 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
15 #include "ash/common/wm/mru_window_tracker.h" | 16 #include "ash/common/wm/mru_window_tracker.h" |
16 #include "ash/common/wm/overview/window_selector_controller.h" | 17 #include "ash/common/wm/overview/window_selector_controller.h" |
17 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
18 #include "base/bind.h" | 19 #include "base/bind.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 | 21 |
22 #if defined(OS_CHROMEOS) | |
23 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h " | |
24 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" | |
25 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | |
26 #endif | |
27 | |
21 namespace ash { | 28 namespace ash { |
22 | 29 |
23 // static | 30 // static |
24 WmShell* WmShell::instance_ = nullptr; | 31 WmShell* WmShell::instance_ = nullptr; |
25 | 32 |
26 // static | 33 // static |
27 void WmShell::Set(WmShell* instance) { | 34 void WmShell::Set(WmShell* instance) { |
28 instance_ = instance; | 35 instance_ = instance; |
29 } | 36 } |
30 | 37 |
(...skipping 20 matching lines...) Expand all Loading... | |
51 } | 58 } |
52 | 59 |
53 void WmShell::RemoveShellObserver(ShellObserver* observer) { | 60 void WmShell::RemoveShellObserver(ShellObserver* observer) { |
54 shell_observers_.RemoveObserver(observer); | 61 shell_observers_.RemoveObserver(observer); |
55 } | 62 } |
56 | 63 |
57 WmShell::WmShell(ShellDelegate* delegate) | 64 WmShell::WmShell(ShellDelegate* delegate) |
58 : delegate_(delegate), | 65 : delegate_(delegate), |
59 focus_cycler_(new FocusCycler), | 66 focus_cycler_(new FocusCycler), |
60 system_tray_notifier_(new SystemTrayNotifier), | 67 system_tray_notifier_(new SystemTrayNotifier), |
61 window_selector_controller_(new WindowSelectorController()) {} | 68 window_selector_controller_(new WindowSelectorController) { |
69 #if defined(OS_CHROMEOS) | |
70 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); | |
msw
2016/07/08 01:40:48
This seems cleaner than using separate preprocesso
James Cook
2016/07/08 16:29:34
Yeah, I like this better. I hate ifdefs in initial
msw
2016/07/08 17:18:58
Acknowledged.
| |
71 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); | |
72 #endif | |
73 } | |
62 | 74 |
63 WmShell::~WmShell() {} | 75 WmShell::~WmShell() {} |
64 | 76 |
65 bool WmShell::IsSystemModalWindowOpen() { | 77 bool WmShell::IsSystemModalWindowOpen() { |
66 if (simulate_modal_window_open_for_testing_) | 78 if (simulate_modal_window_open_for_testing_) |
67 return true; | 79 return true; |
68 | 80 |
69 // Traverse all system modal containers, and find its direct child window | 81 // Traverse all system modal containers, and find its direct child window |
70 // with "SystemModal" setting, and visible. | 82 // with "SystemModal" setting, and visible. |
71 for (WmWindow* root : GetAllRootWindows()) { | 83 for (WmWindow* root : GetAllRootWindows()) { |
72 WmWindow* system_modal = | 84 WmWindow* system_modal = |
73 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); | 85 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); |
74 if (!system_modal) | 86 if (!system_modal) |
75 continue; | 87 continue; |
76 for (const WmWindow* child : system_modal->GetChildren()) { | 88 for (const WmWindow* child : system_modal->GetChildren()) { |
77 if (child->IsSystemModal() && child->GetTargetVisibility()) { | 89 if (child->IsSystemModal() && child->GetTargetVisibility()) { |
78 return true; | 90 return true; |
79 } | 91 } |
80 } | 92 } |
81 } | 93 } |
82 return false; | 94 return false; |
83 } | 95 } |
84 | 96 |
97 void WmShell::SetBrightnessControlDelegate( | |
98 std::unique_ptr<BrightnessControlDelegate> delegate) { | |
99 brightness_control_delegate_ = std::move(delegate); | |
100 } | |
101 | |
102 void WmShell::SetKeyboardBrightnessControlDelegate( | |
103 std::unique_ptr<KeyboardBrightnessControlDelegate> delegate) { | |
104 keyboard_brightness_control_delegate_ = std::move(delegate); | |
105 } | |
106 | |
85 void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) { | 107 void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) { |
86 keyboard_ui_ = std::move(keyboard_ui); | 108 keyboard_ui_ = std::move(keyboard_ui); |
87 } | 109 } |
88 | 110 |
89 void WmShell::SetMediaDelegate(std::unique_ptr<MediaDelegate> delegate) { | 111 void WmShell::SetMediaDelegate(std::unique_ptr<MediaDelegate> delegate) { |
90 media_delegate_ = std::move(delegate); | 112 media_delegate_ = std::move(delegate); |
91 } | 113 } |
92 | 114 |
93 void WmShell::SetSystemTrayDelegate( | 115 void WmShell::SetSystemTrayDelegate( |
94 std::unique_ptr<SystemTrayDelegate> delegate) { | 116 std::unique_ptr<SystemTrayDelegate> delegate) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 | 148 |
127 void WmShell::CreateMruWindowTracker() { | 149 void WmShell::CreateMruWindowTracker() { |
128 mru_window_tracker_.reset(new MruWindowTracker); | 150 mru_window_tracker_.reset(new MruWindowTracker); |
129 } | 151 } |
130 | 152 |
131 void WmShell::DeleteMruWindowTracker() { | 153 void WmShell::DeleteMruWindowTracker() { |
132 mru_window_tracker_.reset(); | 154 mru_window_tracker_.reset(); |
133 } | 155 } |
134 | 156 |
135 } // namespace ash | 157 } // namespace ash |
OLD | NEW |