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.
5 #include "ash/wm/overlay_event_filter.h"
7 #include "ui/aura/window.h"
8 #include "ui/aura/window_delegate.h"
9 #include "ui/events/event.h"
10 #include "ui/views/widget/widget.h"
14 OverlayEventFilter::OverlayEventFilter()
18 OverlayEventFilter::~OverlayEventFilter() {
22 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent
* event
) {
26 // Do not consume a translated key event which is generated by an IME (e.g.,
27 // ui::VKEY_PROCESSKEY) since the key event is generated in response to a key
28 // press or release before showing the ovelay. This is important not to
29 // confuse key event handling JavaScript code in a page.
30 if (event
->IsTranslated())
33 if (delegate_
&& delegate_
->IsCancelingKeyEvent(event
))
36 // Pass key events only when they are sent to a child of the delegate's
38 aura::Window
* target
= static_cast<aura::Window
*>(event
->target());
39 if (!delegate_
|| !delegate_
->GetWindow() ||
40 !delegate_
->GetWindow()->Contains(target
))
41 event
->StopPropagation();
44 void OverlayEventFilter::OnLoginStateChanged(
45 user::LoginStatus status
) {
49 void OverlayEventFilter::OnAppTerminating() {
53 void OverlayEventFilter::OnLockStateChanged(bool locked
) {
57 void OverlayEventFilter::Activate(Delegate
* delegate
) {
63 void OverlayEventFilter::Deactivate(Delegate
* delegate
) {
64 if (delegate_
== delegate
)
68 void OverlayEventFilter::Cancel() {
75 bool OverlayEventFilter::IsActive() {
76 return delegate_
!= nullptr;