| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef ASH_MUS_USER_WINDOW_CONTROLLER_IMPL_H_ | 5 #ifndef ASH_MUS_USER_WINDOW_CONTROLLER_IMPL_H_ |
| 6 #define ASH_MUS_USER_WINDOW_CONTROLLER_IMPL_H_ | 6 #define ASH_MUS_USER_WINDOW_CONTROLLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "ash/public/interfaces/user_window_controller.mojom.h" | 12 #include "ash/public/interfaces/user_window_controller.mojom.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "services/ui/common/types.h" | 14 #include "services/ui/common/types.h" |
| 15 #include "services/ui/public/cpp/window_observer.h" | 15 #include "services/ui/public/cpp/window_observer.h" |
| 16 #include "services/ui/public/cpp/window_tree_client_observer.h" | 16 #include "services/ui/public/cpp/window_tree_client_observer.h" |
| 17 | 17 |
| 18 namespace ash { | 18 namespace ash { |
| 19 namespace mus { | 19 namespace mus { |
| 20 | 20 |
| 21 class RootWindowController; | 21 class RootWindowController; |
| 22 class WindowPropertyObserver; | 22 class WindowPropertyObserver; |
| 23 | 23 |
| 24 class UserWindowControllerImpl : public mojom::UserWindowController, | 24 class UserWindowControllerImpl : public mojom::UserWindowController, |
| 25 public ::ui::WindowObserver, | 25 public ui::WindowObserver, |
| 26 public ::ui::WindowTreeClientObserver { | 26 public ui::WindowTreeClientObserver { |
| 27 public: | 27 public: |
| 28 UserWindowControllerImpl(); | 28 UserWindowControllerImpl(); |
| 29 ~UserWindowControllerImpl() override; | 29 ~UserWindowControllerImpl() override; |
| 30 | 30 |
| 31 mojom::UserWindowObserver* user_window_observer() const { | 31 mojom::UserWindowObserver* user_window_observer() const { |
| 32 return user_window_observer_.get(); | 32 return user_window_observer_.get(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void Initialize(RootWindowController* root_controller); | 35 void Initialize(RootWindowController* root_controller); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 void AssignIdIfNecessary(::ui::Window* window); | 38 void AssignIdIfNecessary(ui::Window* window); |
| 39 | 39 |
| 40 // Removes observers from the window and client. | 40 // Removes observers from the window and client. |
| 41 void RemoveObservers(::ui::Window* user_container); | 41 void RemoveObservers(ui::Window* user_container); |
| 42 | 42 |
| 43 // Returns the window with the specified user id. | 43 // Returns the window with the specified user id. |
| 44 ::ui::Window* GetUserWindowById(uint32_t id); | 44 ui::Window* GetUserWindowById(uint32_t id); |
| 45 | 45 |
| 46 // A helper to get the container for user windows. | 46 // A helper to get the container for user windows. |
| 47 ::ui::Window* GetUserWindowContainer() const; | 47 ui::Window* GetUserWindowContainer() const; |
| 48 | 48 |
| 49 // ui::WindowObserver: | 49 // ui::WindowObserver: |
| 50 void OnTreeChanging(const TreeChangeParams& params) override; | 50 void OnTreeChanging(const TreeChangeParams& params) override; |
| 51 void OnWindowDestroying(::ui::Window* window) override; | 51 void OnWindowDestroying(ui::Window* window) override; |
| 52 | 52 |
| 53 // ui::WindowTreeClientObserver: | 53 // ui::WindowTreeClientObserver: |
| 54 void OnWindowTreeFocusChanged(::ui::Window* gained_focus, | 54 void OnWindowTreeFocusChanged(ui::Window* gained_focus, |
| 55 ::ui::Window* lost_focus) override; | 55 ui::Window* lost_focus) override; |
| 56 | 56 |
| 57 // mojom::UserWindowController: | 57 // mojom::UserWindowController: |
| 58 void AddUserWindowObserver(mojom::UserWindowObserverPtr observer) override; | 58 void AddUserWindowObserver(mojom::UserWindowObserverPtr observer) override; |
| 59 void ActivateUserWindow(uint32_t window_id) override; | 59 void ActivateUserWindow(uint32_t window_id) override; |
| 60 | 60 |
| 61 RootWindowController* root_controller_; | 61 RootWindowController* root_controller_; |
| 62 mojom::UserWindowObserverPtr user_window_observer_; | 62 mojom::UserWindowObserverPtr user_window_observer_; |
| 63 std::unique_ptr<WindowPropertyObserver> window_property_observer_; | 63 std::unique_ptr<WindowPropertyObserver> window_property_observer_; |
| 64 uint32_t next_id_ = 1u; | 64 uint32_t next_id_ = 1u; |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(UserWindowControllerImpl); | 66 DISALLOW_COPY_AND_ASSIGN(UserWindowControllerImpl); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace mus | 69 } // namespace mus |
| 70 } // namespace ash | 70 } // namespace ash |
| 71 | 71 |
| 72 #endif // ASH_MUS_USER_WINDOW_CONTROLLER_IMPL_H_ | 72 #endif // ASH_MUS_USER_WINDOW_CONTROLLER_IMPL_H_ |
| OLD | NEW |