Add owners for offlinepages
[chromium-blink-merge.git] / ash / wm / overlay_event_filter.cc
bloba728b9e1ac1fa3cf33507f77ec564a90454fcc97
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"
12 namespace ash {
14 OverlayEventFilter::OverlayEventFilter()
15 : delegate_(NULL) {
18 OverlayEventFilter::~OverlayEventFilter() {
19 delegate_ = NULL;
22 void OverlayEventFilter::OnKeyEvent(ui::KeyEvent* event) {
23 if (!delegate_)
24 return;
26 if (delegate_ && delegate_->IsCancelingKeyEvent(event))
27 Cancel();
29 // Pass key events only when they are sent to a child of the delegate's
30 // window.
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) {
39 Cancel();
42 void OverlayEventFilter::OnAppTerminating() {
43 Cancel();
46 void OverlayEventFilter::OnLockStateChanged(bool locked) {
47 Cancel();
50 void OverlayEventFilter::Activate(Delegate* delegate) {
51 if (delegate_)
52 delegate_->Cancel();
53 delegate_ = delegate;
56 void OverlayEventFilter::Deactivate(Delegate* delegate) {
57 if (delegate_ == delegate)
58 delegate_ = nullptr;
61 void OverlayEventFilter::Cancel() {
62 if (delegate_) {
63 delegate_->Cancel();
64 delegate_ = nullptr;
68 bool OverlayEventFilter::IsActive() {
69 return delegate_ != nullptr;
72 } // namespace ash