Index: components/mus/ws/focus_controller.h |
diff --git a/components/mus/ws/focus_controller.h b/components/mus/ws/focus_controller.h |
index d63f5655b144078600c206e05e5063f132503577..8567f63c1055a3cf13e064f7ac8a9390e557f56e 100644 |
--- a/components/mus/ws/focus_controller.h |
+++ b/components/mus/ws/focus_controller.h |
@@ -6,21 +6,28 @@ |
#define COMPONENTS_MUS_WS_FOCUS_CONTROLLER_H_ |
#include "base/memory/scoped_ptr.h" |
+#include "base/observer_list.h" |
#include "components/mus/ws/server_window_drawn_tracker_observer.h" |
namespace mus { |
namespace ws { |
-class FocusControllerDelegate; |
+class FocusControllerObserver; |
class ServerWindow; |
class ServerWindowDrawnTracker; |
-// Tracks a focused window. Focus is moved to another window when the drawn |
-// state of the focused window changes and the delegate is notified. |
+// Describes the source of the change. |
+enum class FocusControllerChangeSource { |
+ EXPLICIT, |
+ DRAWN_STATE_CHANGED, |
+}; |
+ |
+// Tracks the focused window. Focus is moved to another window when the drawn |
+// state of the focused window changes. |
class FocusController : public ServerWindowDrawnTrackerObserver { |
public: |
- explicit FocusController(FocusControllerDelegate* delegate); |
+ FocusController(); |
~FocusController() override; |
// Sets the focused window. Does nothing if |window| is currently focused. |
@@ -31,26 +38,24 @@ class FocusController : public ServerWindowDrawnTrackerObserver { |
// Moves activation to the next activatable window. |
void CycleActivationForward(); |
- private: |
- // Describes the source of the change. |
- enum ChangeSource { |
- CHANGE_SOURCE_EXPLICIT, |
- CHANGE_SOURCE_DRAWN_STATE_CHANGED, |
- }; |
+ void AddObserver(FocusControllerObserver* observer); |
+ void RemoveObserver(FocusControllerObserver* observer); |
+ private: |
// Returns whether |window| can be focused or activated. |
bool CanBeFocused(ServerWindow* window) const; |
bool CanBeActivated(ServerWindow* window) const; |
// Implementation of SetFocusedWindow(). |
- void SetFocusedWindowImpl(ServerWindow* window, ChangeSource change_source); |
+ void SetFocusedWindowImpl(FocusControllerChangeSource change_source, |
+ ServerWindow* window); |
// ServerWindowDrawnTrackerObserver: |
void OnDrawnStateChanged(ServerWindow* ancestor, |
ServerWindow* window, |
bool is_drawn) override; |
- FocusControllerDelegate* delegate_; |
+ base::ObserverList<FocusControllerObserver> observers_; |
scoped_ptr<ServerWindowDrawnTracker> drawn_tracker_; |
DISALLOW_COPY_AND_ASSIGN(FocusController); |