Index: chromecast/graphics/cast_focus_client_aura.h |
diff --git a/chromecast/graphics/cast_focus_client_aura.h b/chromecast/graphics/cast_focus_client_aura.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..92a7f7aa789775730e2e5af7cb8d3b635b4da370 |
--- /dev/null |
+++ b/chromecast/graphics/cast_focus_client_aura.h |
@@ -0,0 +1,65 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROMECAST_GRAPHICS_CAST_FOCUS_CLIENT_AURA_H_ |
+#define CHROMECAST_GRAPHICS_CAST_FOCUS_CLIENT_AURA_H_ |
+ |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/observer_list.h" |
+#include "ui/aura/client/focus_change_observer.h" |
+#include "ui/aura/client/focus_client.h" |
+#include "ui/aura/window_observer.h" |
+ |
+namespace aura { |
+class Window; |
+} |
+ |
+namespace chromecast { |
+ |
+class CastFocusClientAura : public aura::WindowObserver, |
+ public aura::client::FocusClient { |
+ public: |
+ CastFocusClientAura(); |
+ ~CastFocusClientAura() override; |
+ |
+ void reset(); |
halliwell
2017/01/24 00:54:46
naming nit: Reset
And is it intended as a public A
Joshua LeVasseur
2017/01/24 03:39:50
Fixed, and switched to private.
|
+ |
+ // aura::client::FocusClient implementation: |
+ void AddObserver(aura::client::FocusChangeObserver* observer) override; |
+ void RemoveObserver(aura::client::FocusChangeObserver* observer) override; |
+ void FocusWindow(aura::Window* window) override; |
+ void ResetFocusWithinActiveWindow(aura::Window* window) override; |
+ aura::Window* GetFocusedWindow() override; |
+ |
+ private: |
+ // aura::WindowObserver implementation: |
+ void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
+ void OnWindowDestroying(aura::Window* window) override; |
+ void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; |
+ |
+ // Change the focused window and notify focus observers. |
+ void UpdateWindowFocus(); |
+ // Get the window that should be focused. |
+ aura::Window* GetWindowToFocus(); |
+ // Get the top-most window in a window's hierarchy. |
+ aura::Window* GetTopLevelWindow(aura::Window* window); |
+ |
+ base::ObserverList<aura::client::FocusChangeObserver> focus_observers_; |
+ |
+ // Track the currently focused window, which isn't necessarily a top-level |
+ // window. |
+ aura::Window* focused_window_; |
+ // Track the windows that we've focused in the past, so that we can restore |
+ // focus to them. We assume that this is a small list so that we can perform |
+ // linear ops on it. |
+ std::vector<aura::Window*> focusable_windows_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CastFocusClientAura); |
+}; |
+ |
+} // namespace chromecast |
+ |
+#endif // CHROMECAST_GRAPHICS_CAST_FOCUS_CLIENT_AURA_H_ |