Disable some more flaky AppWindowInterceptAllKeysTest.* on Windows
[chromium-blink-merge.git] / athena / input / input_manager_impl.cc
blobbd901b86641e546390a720f090ebafb32f07e86e
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
3 // found in the LICENSE file.
5 #include "athena/input/input_manager_impl.h"
7 #include "athena/input/power_button_controller.h"
8 #include "base/logging.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/window.h"
12 namespace athena {
13 namespace {
15 InputManager* instance = nullptr;
17 } // namespace
19 InputManagerImpl::InputManagerImpl()
20 : accelerator_manager_(
21 AcceleratorManagerImpl::CreateGlobalAcceleratorManager()),
22 power_button_controller_(new PowerButtonController) {
23 DCHECK(!instance);
24 instance = this;
27 InputManagerImpl::~InputManagerImpl() {
28 DCHECK_EQ(instance, this);
29 Shutdown();
30 instance = nullptr;
33 void InputManagerImpl::Init() {
34 accelerator_manager_->Init();
35 power_button_controller_->InstallAccelerators();
38 void InputManagerImpl::Shutdown() {
39 accelerator_manager_.reset();
42 void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
43 aura::client::SetEventClient(root_window, this);
44 accelerator_manager_->OnRootWindowCreated(root_window);
47 ui::EventTarget* InputManagerImpl::GetTopmostEventTarget() {
48 return this;
51 AcceleratorManager* InputManagerImpl::GetAcceleratorManager() {
52 return accelerator_manager_.get();
55 void InputManagerImpl::AddPowerButtonObserver(PowerButtonObserver* observer) {
56 power_button_controller_->AddPowerButtonObserver(observer);
58 void InputManagerImpl::RemovePowerButtonObserver(
59 PowerButtonObserver* observer) {
60 power_button_controller_->RemovePowerButtonObserver(observer);
63 bool InputManagerImpl::CanProcessEventsWithinSubtree(
64 const aura::Window* window) const {
65 return window && !window->ignore_events();
68 ui::EventTarget* InputManagerImpl::GetToplevelEventTarget() {
69 return this;
72 bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
73 return true;
76 ui::EventTarget* InputManagerImpl::GetParentTarget() {
77 return aura::Env::GetInstance();
80 scoped_ptr<ui::EventTargetIterator> InputManagerImpl::GetChildIterator() const {
81 return scoped_ptr<ui::EventTargetIterator>();
84 ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
85 NOTREACHED();
86 return nullptr;
89 void InputManagerImpl::OnEvent(ui::Event* event) {
92 int InputManagerImpl::SetPowerButtonTimeoutMsForTest(int timeout) {
93 return power_button_controller_->SetPowerButtonTimeoutMsForTest(timeout);
96 // static
97 InputManager* InputManager::Create() {
98 (new InputManagerImpl)->Init();
99 DCHECK(instance);
100 return instance;
103 // static
104 InputManager* InputManager::Get() {
105 DCHECK(instance);
106 return instance;
109 // static
110 void InputManager::Shutdown() {
111 DCHECK(instance);
112 delete instance;
113 DCHECK(!instance);
116 } // namespace athena