Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / ui / focus_ring_controller.h
blob200e95f402fb045dbd38dd253d561ae68ac422fd
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chromeos/ui/focus_ring_layer.h"
11 #include "ui/views/focus/focus_manager.h"
12 #include "ui/views/focus/widget_focus_manager.h"
13 #include "ui/views/widget/widget_observer.h"
15 namespace views {
16 class View;
17 class Widget;
20 namespace chromeos {
22 // FocusRingController manages the focus ring around the focused view. It
23 // follows widget focus change and update the focus ring layer when the focused
24 // view of the widget changes.
25 class FocusRingController : public FocusRingLayerDelegate,
26 public views::WidgetObserver,
27 public views::WidgetFocusChangeListener,
28 public views::FocusChangeListener {
29 public:
30 FocusRingController();
31 ~FocusRingController() override;
33 // Turns on/off the focus ring.
34 void SetVisible(bool visible);
36 private:
37 // FocusRingLayerDelegate.
38 void OnDeviceScaleFactorChanged() override;
40 // Sets the focused |widget|.
41 void SetWidget(views::Widget* widget);
43 // Updates the focus ring to the focused view of |widget_|. If |widget_| is
44 // NULL or has no focused view, removes the focus ring. Otherwise, draws it.
45 void UpdateFocusRing();
47 // views::WidgetObserver overrides:
48 void OnWidgetDestroying(views::Widget* widget) override;
49 void OnWidgetBoundsChanged(views::Widget* widget,
50 const gfx::Rect& new_bounds) override;
52 // views::WidgetFocusChangeListener overrides:
53 void OnNativeFocusChanged(gfx::NativeView focused_now) override;
55 // views::FocusChangeListener overrides:
56 void OnWillChangeFocus(views::View* focused_before,
57 views::View* focused_now) override;
58 void OnDidChangeFocus(views::View* focused_before,
59 views::View* focused_now) override;
61 bool visible_;
63 views::Widget* widget_;
64 scoped_ptr<FocusRingLayer> focus_ring_layer_;
66 DISALLOW_COPY_AND_ASSIGN(FocusRingController);
69 } // namespace chromeos
71 #endif // CHROME_BROWSER_CHROMEOS_UI_FOCUS_RING_CONTROLLER_H_