| Index: ash/mus/bridge/wm_shell_mus.cc
|
| diff --git a/ash/mus/bridge/wm_shell_mus.cc b/ash/mus/bridge/wm_shell_mus.cc
|
| index f6aacd9ae83e576c9c766b88bf8ca50358ea7b2f..4e64d2d37fca75096c94ca25c3036911a75896ac 100644
|
| --- a/ash/mus/bridge/wm_shell_mus.cc
|
| +++ b/ash/mus/bridge/wm_shell_mus.cc
|
| @@ -21,11 +21,13 @@
|
| #include "ash/common/wm/window_resizer.h"
|
| #include "ash/common/wm_activation_observer.h"
|
| #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h"
|
| +#include "ash/mus/accelerators/accelerator_controller_registrar.h"
|
| #include "ash/mus/bridge/wm_root_window_controller_mus.h"
|
| #include "ash/mus/bridge/wm_window_mus.h"
|
| #include "ash/mus/container_ids.h"
|
| #include "ash/mus/drag_window_resizer.h"
|
| #include "ash/mus/root_window_controller.h"
|
| +#include "ash/mus/window_manager.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "components/user_manager/user_info_impl.h"
|
| #include "services/ui/common/util.h"
|
| @@ -99,16 +101,24 @@ class SessionStateDelegateStub : public SessionStateDelegate {
|
| } // namespace
|
|
|
| WmShellMus::WmShellMus(std::unique_ptr<ShellDelegate> shell_delegate,
|
| - ::ui::WindowTreeClient* client)
|
| + WindowManager* window_manager)
|
| : WmShell(std::move(shell_delegate)),
|
| - client_(client),
|
| + window_manager_(window_manager),
|
| session_state_delegate_(new SessionStateDelegateStub) {
|
| - client_->AddObserver(this);
|
| + window_tree_client()->AddObserver(this);
|
| WmShell::Set(this);
|
|
|
| + uint16_t accelerator_namespace_id = 0u;
|
| + const bool add_result =
|
| + window_manager->GetNextAcceleratorNamespaceId(&accelerator_namespace_id);
|
| + // WmShellMus is created early on, so that this should always succeed.
|
| + DCHECK(add_result);
|
| accelerator_controller_delegate_.reset(new AcceleratorControllerDelegateMus);
|
| + accelerator_controller_registrar_.reset(new AcceleratorControllerRegistrar(
|
| + window_manager_, accelerator_namespace_id));
|
| SetAcceleratorController(base::MakeUnique<AcceleratorController>(
|
| - accelerator_controller_delegate_.get()));
|
| + accelerator_controller_delegate_.get(),
|
| + accelerator_controller_registrar_.get()));
|
|
|
| CreateMaximizeModeController();
|
|
|
| @@ -132,7 +142,8 @@ WmShellMus::~WmShellMus() {
|
| DeleteWindowCycleController();
|
| DeleteWindowSelectorController();
|
| DeleteMruWindowTracker();
|
| - RemoveClientObserver();
|
| + if (window_tree_client())
|
| + window_tree_client()->RemoveObserver(this);
|
| WmShell::Set(nullptr);
|
| }
|
|
|
| @@ -176,15 +187,15 @@ WmRootWindowControllerMus* WmShellMus::GetRootWindowControllerWithDisplayId(
|
| }
|
|
|
| WmWindow* WmShellMus::NewContainerWindow() {
|
| - return WmWindowMus::Get(client_->NewWindow());
|
| + return WmWindowMus::Get(window_tree_client()->NewWindow());
|
| }
|
|
|
| WmWindow* WmShellMus::GetFocusedWindow() {
|
| - return WmWindowMus::Get(client_->GetFocusedWindow());
|
| + return WmWindowMus::Get(window_tree_client()->GetFocusedWindow());
|
| }
|
|
|
| WmWindow* WmShellMus::GetActiveWindow() {
|
| - return GetToplevelAncestor(client_->GetFocusedWindow());
|
| + return GetToplevelAncestor(window_tree_client()->GetFocusedWindow());
|
| }
|
|
|
| WmWindow* WmShellMus::GetPrimaryRootWindow() {
|
| @@ -328,20 +339,16 @@ void WmShellMus::ToggleIgnoreExternalKeyboard() {
|
| }
|
| #endif // defined(OS_CHROMEOS)
|
|
|
| +::ui::WindowTreeClient* WmShellMus::window_tree_client() {
|
| + return window_manager_->window_tree_client();
|
| +}
|
| +
|
| // static
|
| bool WmShellMus::IsActivationParent(::ui::Window* window) {
|
| return window && IsActivatableShellWindowId(
|
| WmWindowMus::Get(window)->GetShellWindowId());
|
| }
|
|
|
| -void WmShellMus::RemoveClientObserver() {
|
| - if (!client_)
|
| - return;
|
| -
|
| - client_->RemoveObserver(this);
|
| - client_ = nullptr;
|
| -}
|
| -
|
| // TODO: support OnAttemptToReactivateWindow, http://crbug.com/615114.
|
| void WmShellMus::OnWindowTreeFocusChanged(::ui::Window* gained_focus,
|
| ::ui::Window* lost_focus) {
|
| @@ -355,8 +362,8 @@ void WmShellMus::OnWindowTreeFocusChanged(::ui::Window* gained_focus,
|
| }
|
|
|
| void WmShellMus::OnDidDestroyClient(::ui::WindowTreeClient* client) {
|
| - DCHECK_EQ(client, client_);
|
| - RemoveClientObserver();
|
| + DCHECK_EQ(window_tree_client(), client);
|
| + client->RemoveObserver(this);
|
| }
|
|
|
| } // namespace mus
|
|
|