Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Unified Diff: components/mus/ws/focus_controller.h

Issue 1465143004: Converts focusmanager from delegate to observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/ws/connection_manager.h ('k') | components/mus/ws/focus_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « components/mus/ws/connection_manager.h ('k') | components/mus/ws/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698