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 if (delegate_
&& delegate_
->IsCancelingKeyEvent(event
))
29 // Pass key events only when they are sent to a child of the delegate's
31 aura::Window
* target
= static_cast<aura::Window
*>(event
->target());
32 if (!delegate_
|| !delegate_
->GetWindow() ||
33 !delegate_
->GetWindow()->Contains(target
))
34 event
->StopPropagation();
37 void OverlayEventFilter::OnLoginStateChanged(
38 user::LoginStatus status
) {
42 void OverlayEventFilter::OnAppTerminating() {
46 void OverlayEventFilter::OnLockStateChanged(bool locked
) {
50 void OverlayEventFilter::Activate(Delegate
* delegate
) {
56 void OverlayEventFilter::Deactivate(Delegate
* delegate
) {
57 if (delegate_
== delegate
)
61 void OverlayEventFilter::Cancel() {
68 bool OverlayEventFilter::IsActive() {
69 return delegate_
!= nullptr;