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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/corewm/activation_change_shim.cc
===================================================================
--- ui/views/corewm/activation_change_shim.cc (revision 0)
+++ ui/views/corewm/activation_change_shim.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 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.
+
+#include "ui/views/corewm/activation_change_shim.h"
+
+#include "base/command_line.h"
+#include "ui/aura/window.h"
+#include "ui/base/events/event_target.h"
+#include "ui/views/corewm/corewm_switches.h"
+#include "ui/views/corewm/focus_change_event.h"
+
+namespace views {
+namespace corewm {
+namespace {
+bool UseFocusController() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseFocusController);
+}
+}
+
+ActivationChangeShim::ActivationChangeShim(ui::EventTarget* target)
+ : target_(target) {
+ if (UseFocusController() && target_)
+ target_->AddPreTargetHandler(this);
+}
+
+ActivationChangeShim::~ActivationChangeShim() {
+ if (UseFocusController() && target_)
+ target_->RemovePreTargetHandler(this);
+}
+
+void ActivationChangeShim::OnWindowActivated(aura::Window* active,
+ aura::Window* old_active) {
+}
+
+ui::EventResult ActivationChangeShim::OnEvent(ui::Event* event) {
+ if (event->type() == FocusChangeEvent::activation_changed_event_type()) {
+ DCHECK(UseFocusController());
+ FocusChangeEvent* fce = static_cast<FocusChangeEvent*>(event);
+ OnWindowActivated(static_cast<aura::Window*>(event->target()),
+ static_cast<aura::Window*>(fce->last_focus()));
+ }
+ return EventHandler::OnEvent(event);
+}
+
+} // namespace corewm
+} // namespace views
« 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