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 "ash/wm/partial_screenshot_view.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura/window_delegate.h"
10 #include "ui/events/event.h"
11 #include "ui/views/widget/widget.h"
15 OverlayEventFilter::OverlayEventFilter()
19 OverlayEventFilter::~OverlayEventFilter() {
23 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent
* event
) {
27 // Do not consume a translated key event which is generated by an IME (e.g.,
28 // ui::VKEY_PROCESSKEY) since the key event is generated in response to a key
29 // press or release before showing the ovelay. This is important not to
30 // confuse key event handling JavaScript code in a page.
31 if (event
->IsTranslated())
34 if (delegate_
&& delegate_
->IsCancelingKeyEvent(event
))
37 // Pass key events only when they are sent to a child of the delegate's
39 aura::Window
* target
= static_cast<aura::Window
*>(event
->target());
40 if (!delegate_
|| !delegate_
->GetWindow() ||
41 !delegate_
->GetWindow()->Contains(target
))
42 event
->StopPropagation();
45 void OverlayEventFilter::OnLoginStateChanged(
46 user::LoginStatus status
) {
50 void OverlayEventFilter::OnAppTerminating() {
54 void OverlayEventFilter::OnLockStateChanged(bool locked
) {
58 void OverlayEventFilter::Activate(Delegate
* delegate
) {
64 void OverlayEventFilter::Deactivate(Delegate
* delegate
) {
65 if (delegate_
== delegate
)
69 void OverlayEventFilter::Cancel() {
74 bool OverlayEventFilter::IsActive() {
75 return delegate_
!= NULL
;