Roll src/third_party/WebKit 6b63e20:35e1984 (svn 201060:201061)
[chromium-blink-merge.git] / components / view_manager / focus_controller.h
blob74599c53165d5ed866190cdefe48260ce9e72a90
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VIEW_MANAGER_FOCUS_CONTROLLER_H_
6 #define COMPONENTS_VIEW_MANAGER_FOCUS_CONTROLLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/view_manager/server_view_drawn_tracker_observer.h"
11 namespace view_manager {
13 class FocusControllerDelegate;
14 class ServerView;
15 class ServerViewDrawnTracker;
17 // Tracks a focused view. Focus is moved to another view when the drawn state
18 // of the focused view changes and the delegate is notified.
19 class FocusController : public ServerViewDrawnTrackerObserver {
20 public:
21 explicit FocusController(FocusControllerDelegate* delegate);
22 ~FocusController() override;
24 // Sets the focused view. Does nothing if |view| is currently focused. This
25 // does not notify the delegate.
26 void SetFocusedView(ServerView* view);
27 ServerView* GetFocusedView();
29 private:
30 // Describes the source of the change.
31 enum ChangeSource {
32 CHANGE_SOURCE_EXPLICIT,
33 CHANGE_SOURCE_DRAWN_STATE_CHANGED,
36 // Implementation of SetFocusedView().
37 void SetFocusedViewImpl(ServerView* view, ChangeSource change_source);
39 // ServerViewDrawnTrackerObserver:
40 void OnDrawnStateChanged(ServerView* ancestor,
41 ServerView* view,
42 bool is_drawn) override;
44 FocusControllerDelegate* delegate_;
45 scoped_ptr<ServerViewDrawnTracker> drawn_tracker_;
47 DISALLOW_COPY_AND_ASSIGN(FocusController);
50 } // namespace view_manager
52 #endif // COMPONENTS_VIEW_MANAGER_FOCUS_CONTROLLER_H_