| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" | 5 #include "chrome/browser/chromeos/login/ui/input_events_blocker.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 | 10 |
| 11 namespace chromeos { | 11 namespace chromeos { |
| 12 | 12 |
| 13 InputEventsBlocker::InputEventsBlocker() { | 13 InputEventsBlocker::InputEventsBlocker() { |
| 14 ash::Shell::GetInstance()->PrependPreTargetHandler(this); | 14 if (ash::Shell::HasInstance()) |
| 15 ash::Shell::GetInstance()->PrependPreTargetHandler(this); |
| 15 VLOG(1) << "InputEventsBlocker " << this << " created."; | 16 VLOG(1) << "InputEventsBlocker " << this << " created."; |
| 16 } | 17 } |
| 17 | 18 |
| 18 InputEventsBlocker::~InputEventsBlocker() { | 19 InputEventsBlocker::~InputEventsBlocker() { |
| 19 ash::Shell::GetInstance()->RemovePreTargetHandler(this); | 20 if (ash::Shell::HasInstance()) |
| 21 ash::Shell::GetInstance()->RemovePreTargetHandler(this); |
| 20 VLOG(1) << "InputEventsBlocker " << this << " destroyed."; | 22 VLOG(1) << "InputEventsBlocker " << this << " destroyed."; |
| 21 } | 23 } |
| 22 | 24 |
| 23 void InputEventsBlocker::OnKeyEvent(ui::KeyEvent* event) { | 25 void InputEventsBlocker::OnKeyEvent(ui::KeyEvent* event) { |
| 24 event->StopPropagation(); | 26 event->StopPropagation(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void InputEventsBlocker::OnMouseEvent(ui::MouseEvent* event) { | 29 void InputEventsBlocker::OnMouseEvent(ui::MouseEvent* event) { |
| 28 event->StopPropagation(); | 30 event->StopPropagation(); |
| 29 } | 31 } |
| 30 | 32 |
| 31 void InputEventsBlocker::OnTouchEvent(ui::TouchEvent* event) { | 33 void InputEventsBlocker::OnTouchEvent(ui::TouchEvent* event) { |
| 32 event->StopPropagation(); | 34 event->StopPropagation(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 void InputEventsBlocker::OnGestureEvent(ui::GestureEvent* event) { | 37 void InputEventsBlocker::OnGestureEvent(ui::GestureEvent* event) { |
| 36 event->StopPropagation(); | 38 event->StopPropagation(); |
| 37 } | 39 } |
| 38 | 40 |
| 39 } // namespace chromeos | 41 } // namespace chromeos |
| OLD | NEW |