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

Side by Side Diff: ui/views/corewm/activation_change_shim.cc

Issue 11421194: Hook up the FocusController behind a flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/corewm/activation_change_shim.h ('k') | ui/views/corewm/corewm_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 "ui/views/corewm/activation_change_shim.h"
6
7 #include "base/command_line.h"
8 #include "ui/aura/window.h"
9 #include "ui/base/events/event_target.h"
10 #include "ui/views/corewm/corewm_switches.h"
11 #include "ui/views/corewm/focus_change_event.h"
12
13 namespace views {
14 namespace corewm {
15 namespace {
16 bool UseFocusController() {
17 return CommandLine::ForCurrentProcess()->HasSwitch(
18 switches::kUseFocusController);
19 }
20 }
21
22 ActivationChangeShim::ActivationChangeShim(ui::EventTarget* target)
23 : target_(target) {
24 if (UseFocusController() && target_)
25 target_->AddPreTargetHandler(this);
26 }
27
28 ActivationChangeShim::~ActivationChangeShim() {
29 if (UseFocusController() && target_)
30 target_->RemovePreTargetHandler(this);
31 }
32
33 void ActivationChangeShim::OnWindowActivated(aura::Window* active,
34 aura::Window* old_active) {
35 }
36
37 ui::EventResult ActivationChangeShim::OnEvent(ui::Event* event) {
38 if (event->type() == FocusChangeEvent::activation_changed_event_type()) {
39 DCHECK(UseFocusController());
40 FocusChangeEvent* fce = static_cast<FocusChangeEvent*>(event);
41 OnWindowActivated(static_cast<aura::Window*>(event->target()),
42 static_cast<aura::Window*>(fce->last_focus()));
43 }
44 return EventHandler::OnEvent(event);
45 }
46
47 } // namespace corewm
48 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/activation_change_shim.h ('k') | ui/views/corewm/corewm_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698