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

Side by Side Diff: components/view_manager/focus_controller.cc

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 months 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 unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "components/view_manager/focus_controller.h"
6
7 #include "components/view_manager/focus_controller_delegate.h"
8 #include "components/view_manager/server_view.h"
9 #include "components/view_manager/server_view_drawn_tracker.h"
10
11 namespace view_manager {
12
13 FocusController::FocusController(FocusControllerDelegate* delegate)
14 : delegate_(delegate) {
15 }
16
17 FocusController::~FocusController() {
18 }
19
20 void FocusController::SetFocusedView(ServerView* view) {
21 if (GetFocusedView() == view)
22 return;
23
24 SetFocusedViewImpl(view, CHANGE_SOURCE_EXPLICIT);
25 }
26
27 ServerView* FocusController::GetFocusedView() {
28 return drawn_tracker_ ? drawn_tracker_->view() : nullptr;
29 }
30
31 void FocusController::SetFocusedViewImpl(ServerView* view,
32 ChangeSource change_source) {
33 ServerView* old = GetFocusedView();
34
35 DCHECK(!view || view->IsDrawn());
36
37 if (view)
38 drawn_tracker_.reset(new ServerViewDrawnTracker(view, this));
39 else
40 drawn_tracker_.reset();
41
42 if (change_source == CHANGE_SOURCE_DRAWN_STATE_CHANGED)
43 delegate_->OnFocusChanged(old, view);
44 }
45
46 void FocusController::OnDrawnStateChanged(ServerView* ancestor,
47 ServerView* view,
48 bool is_drawn) {
49 DCHECK(!is_drawn); // We only observe when drawn.
50 SetFocusedViewImpl(ancestor, CHANGE_SOURCE_DRAWN_STATE_CHANGED);
51 }
52
53 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/view_manager/focus_controller.h ('k') | components/view_manager/focus_controller_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698