| 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/mus/bridge/wm_shell_mus.h" | 5 #include "ash/mus/bridge/wm_shell_mus.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/default_accessibility_delegate.h" | |
| 10 #include "ash/common/display/display_info.h" | 9 #include "ash/common/display/display_info.h" |
| 11 #include "ash/common/keyboard/keyboard_ui.h" | 10 #include "ash/common/keyboard/keyboard_ui.h" |
| 12 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
| 13 #include "ash/common/shell_delegate.h" | 12 #include "ash/common/shell_delegate.h" |
| 14 #include "ash/common/shell_observer.h" | 13 #include "ash/common/shell_observer.h" |
| 15 #include "ash/common/shell_window_ids.h" | 14 #include "ash/common/shell_window_ids.h" |
| 16 #include "ash/common/system/tray/default_system_tray_delegate.h" | 15 #include "ash/common/system/tray/default_system_tray_delegate.h" |
| 17 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" | 16 #include "ash/common/wm/maximize_mode/maximize_mode_event_handler.h" |
| 18 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard
.h" | 17 #include "ash/common/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard
.h" |
| 19 #include "ash/common/wm/mru_window_tracker.h" | 18 #include "ash/common/wm/mru_window_tracker.h" |
| 20 #include "ash/common/wm/window_resizer.h" | 19 #include "ash/common/wm/window_resizer.h" |
| 21 #include "ash/common/wm_activation_observer.h" | 20 #include "ash/common/wm_activation_observer.h" |
| 22 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 21 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 23 #include "ash/mus/bridge/wm_window_mus.h" | 22 #include "ash/mus/bridge/wm_window_mus.h" |
| 24 #include "ash/mus/container_ids.h" | 23 #include "ash/mus/container_ids.h" |
| 25 #include "ash/mus/drag_window_resizer.h" | 24 #include "ash/mus/drag_window_resizer.h" |
| 26 #include "ash/mus/root_window_controller.h" | 25 #include "ash/mus/root_window_controller.h" |
| 27 #include "base/memory/ptr_util.h" | 26 #include "base/memory/ptr_util.h" |
| 28 #include "components/user_manager/user_info_impl.h" | 27 #include "components/user_manager/user_info_impl.h" |
| 29 #include "services/shell/public/cpp/connector.h" | |
| 30 #include "services/ui/common/util.h" | 28 #include "services/ui/common/util.h" |
| 31 #include "services/ui/public/cpp/window.h" | 29 #include "services/ui/public/cpp/window.h" |
| 32 #include "services/ui/public/cpp/window_tree_client.h" | 30 #include "services/ui/public/cpp/window_tree_client.h" |
| 33 #include "services/ui/public/interfaces/accessibility_manager.mojom.h" | |
| 34 | 31 |
| 35 namespace ash { | 32 namespace ash { |
| 36 namespace mus { | 33 namespace mus { |
| 37 | 34 |
| 38 namespace { | 35 namespace { |
| 39 | 36 |
| 40 // TODO(jamescook): After ShellDelegate is ported to ash/common use | 37 // TODO(jamescook): After ShellDelegate is ported to ash/common use |
| 41 // ShellDelegate::CreateSessionStateDelegate() to construct the mus version | 38 // ShellDelegate::CreateSessionStateDelegate() to construct the mus version |
| 42 // of SessionStateDelegate. | 39 // of SessionStateDelegate. |
| 43 class SessionStateDelegateStub : public SessionStateDelegate { | 40 class SessionStateDelegateStub : public SessionStateDelegate { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 86 |
| 90 private: | 87 private: |
| 91 bool screen_locked_; | 88 bool screen_locked_; |
| 92 | 89 |
| 93 // A pseudo user info. | 90 // A pseudo user info. |
| 94 std::unique_ptr<user_manager::UserInfo> user_info_; | 91 std::unique_ptr<user_manager::UserInfo> user_info_; |
| 95 | 92 |
| 96 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); | 93 DISALLOW_COPY_AND_ASSIGN(SessionStateDelegateStub); |
| 97 }; | 94 }; |
| 98 | 95 |
| 99 class AccessibilityDelegateMus : public DefaultAccessibilityDelegate { | |
| 100 public: | |
| 101 explicit AccessibilityDelegateMus(shell::Connector* connector) | |
| 102 : connector_(connector) {} | |
| 103 ~AccessibilityDelegateMus() override {} | |
| 104 | |
| 105 private: | |
| 106 ui::mojom::AccessibilityManager* GetAccessibilityManager() { | |
| 107 if (!accessibility_manager_ptr_.is_bound()) | |
| 108 connector_->ConnectToInterface("mojo:ui", &accessibility_manager_ptr_); | |
| 109 return accessibility_manager_ptr_.get(); | |
| 110 } | |
| 111 | |
| 112 // DefaultAccessibilityDelegate: | |
| 113 void ToggleHighContrast() override { | |
| 114 DefaultAccessibilityDelegate::ToggleHighContrast(); | |
| 115 GetAccessibilityManager()->SetHighContrastMode(IsHighContrastEnabled()); | |
| 116 } | |
| 117 | |
| 118 ui::mojom::AccessibilityManagerPtr accessibility_manager_ptr_; | |
| 119 shell::Connector* connector_; | |
| 120 | |
| 121 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateMus); | |
| 122 }; | |
| 123 | |
| 124 } // namespace | 96 } // namespace |
| 125 | 97 |
| 126 WmShellMus::WmShellMus(std::unique_ptr<ShellDelegate> shell_delegate, | 98 WmShellMus::WmShellMus(std::unique_ptr<ShellDelegate> shell_delegate, |
| 127 ::ui::WindowTreeClient* client, | 99 ::ui::WindowTreeClient* client) |
| 128 shell::Connector* connector) | |
| 129 : WmShell(std::move(shell_delegate)), | 100 : WmShell(std::move(shell_delegate)), |
| 130 client_(client), | 101 client_(client), |
| 131 connector_(connector), | |
| 132 session_state_delegate_(new SessionStateDelegateStub) { | 102 session_state_delegate_(new SessionStateDelegateStub) { |
| 133 client_->AddObserver(this); | 103 client_->AddObserver(this); |
| 134 WmShell::Set(this); | 104 WmShell::Set(this); |
| 135 | 105 |
| 136 CreateMaximizeModeController(); | 106 CreateMaximizeModeController(); |
| 137 | 107 |
| 138 CreateMruWindowTracker(); | 108 CreateMruWindowTracker(); |
| 139 | 109 |
| 140 accessibility_delegate_.reset(new AccessibilityDelegateMus(connector_)); | |
| 141 SetSystemTrayDelegate(base::WrapUnique(new DefaultSystemTrayDelegate)); | 110 SetSystemTrayDelegate(base::WrapUnique(new DefaultSystemTrayDelegate)); |
| 142 | 111 |
| 143 // TODO(jamescook): Port ash::sysui::KeyboardUIMus and use it here. | 112 // TODO(jamescook): Port ash::sysui::KeyboardUIMus and use it here. |
| 144 SetKeyboardUI(KeyboardUI::Create()); | 113 SetKeyboardUI(KeyboardUI::Create()); |
| 145 } | 114 } |
| 146 | 115 |
| 147 WmShellMus::~WmShellMus() { | 116 WmShellMus::~WmShellMus() { |
| 148 // This order mirrors that of Shell. | 117 // This order mirrors that of Shell. |
| 149 | 118 |
| 150 // Destroy maximize mode controller early on since it has some observers which | 119 // Destroy maximize mode controller early on since it has some observers which |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 264 |
| 296 void WmShellMus::OnOverviewModeStarting() { | 265 void WmShellMus::OnOverviewModeStarting() { |
| 297 FOR_EACH_OBSERVER(ShellObserver, *shell_observers(), | 266 FOR_EACH_OBSERVER(ShellObserver, *shell_observers(), |
| 298 OnOverviewModeStarting()); | 267 OnOverviewModeStarting()); |
| 299 } | 268 } |
| 300 | 269 |
| 301 void WmShellMus::OnOverviewModeEnded() { | 270 void WmShellMus::OnOverviewModeEnded() { |
| 302 FOR_EACH_OBSERVER(ShellObserver, *shell_observers(), OnOverviewModeEnded()); | 271 FOR_EACH_OBSERVER(ShellObserver, *shell_observers(), OnOverviewModeEnded()); |
| 303 } | 272 } |
| 304 | 273 |
| 305 AccessibilityDelegate* WmShellMus::GetAccessibilityDelegate() { | |
| 306 return accessibility_delegate_.get(); | |
| 307 } | |
| 308 | |
| 309 SessionStateDelegate* WmShellMus::GetSessionStateDelegate() { | 274 SessionStateDelegate* WmShellMus::GetSessionStateDelegate() { |
| 310 return session_state_delegate_.get(); | 275 return session_state_delegate_.get(); |
| 311 } | 276 } |
| 312 | 277 |
| 313 void WmShellMus::AddActivationObserver(WmActivationObserver* observer) { | 278 void WmShellMus::AddActivationObserver(WmActivationObserver* observer) { |
| 314 activation_observers_.AddObserver(observer); | 279 activation_observers_.AddObserver(observer); |
| 315 } | 280 } |
| 316 | 281 |
| 317 void WmShellMus::RemoveActivationObserver(WmActivationObserver* observer) { | 282 void WmShellMus::RemoveActivationObserver(WmActivationObserver* observer) { |
| 318 activation_observers_.RemoveObserver(observer); | 283 activation_observers_.RemoveObserver(observer); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 OnWindowActivated(gained_active, lost_active)); | 332 OnWindowActivated(gained_active, lost_active)); |
| 368 } | 333 } |
| 369 | 334 |
| 370 void WmShellMus::OnDidDestroyClient(::ui::WindowTreeClient* client) { | 335 void WmShellMus::OnDidDestroyClient(::ui::WindowTreeClient* client) { |
| 371 DCHECK_EQ(client, client_); | 336 DCHECK_EQ(client, client_); |
| 372 RemoveClientObserver(); | 337 RemoveClientObserver(); |
| 373 } | 338 } |
| 374 | 339 |
| 375 } // namespace mus | 340 } // namespace mus |
| 376 } // namespace ash | 341 } // namespace ash |
| OLD | NEW |