Mac VideoCapture: return empty GetModel() for non-USB non-built-in cameras.
[chromium-blink-merge.git] / athena / input / input_manager_impl.cc
blobb0b11a9e39ed4f4d196a745fca4519a563cc64bd
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/public/input_manager.h"
7 #include "athena/input/accelerator_manager_impl.h"
8 #include "base/logging.h"
9 #include "ui/aura/client/event_client.h"
10 #include "ui/aura/env.h"
11 #include "ui/aura/window.h"
12 #include "ui/events/event_target.h"
14 namespace athena {
15 namespace {
17 InputManager* instance = NULL;
19 class InputManagerImpl : public InputManager,
20 public ui::EventTarget,
21 public aura::client::EventClient {
22 public:
23 InputManagerImpl();
24 virtual ~InputManagerImpl();
26 void Init();
27 void Shutdown();
29 private:
30 // InputManager:
31 virtual void OnRootWindowCreated(aura::Window* root_window) OVERRIDE;
32 virtual ui::EventTarget* GetTopmostEventTarget() OVERRIDE { return this; }
33 virtual AcceleratorManager* GetAcceleratorManager() OVERRIDE {
34 return accelerator_manager_.get();
37 // Overridden from aura::client::EventClient:
38 virtual bool CanProcessEventsWithinSubtree(
39 const aura::Window* window) const OVERRIDE {
40 return window && !window->ignore_events();
42 virtual ui::EventTarget* GetToplevelEventTarget() OVERRIDE { return this; }
44 // ui::EventTarget:
45 virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
46 virtual ui::EventTarget* GetParentTarget() OVERRIDE;
47 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const OVERRIDE;
48 virtual ui::EventTargeter* GetEventTargeter() OVERRIDE;
49 virtual void OnEvent(ui::Event* event) OVERRIDE;
51 scoped_ptr<AcceleratorManagerImpl> accelerator_manager_;
53 DISALLOW_COPY_AND_ASSIGN(InputManagerImpl);
56 InputManagerImpl::InputManagerImpl()
57 : accelerator_manager_(
58 AcceleratorManagerImpl::CreateGlobalAcceleratorManager()) {
59 DCHECK(!instance);
60 instance = this;
63 InputManagerImpl::~InputManagerImpl() {
64 DCHECK_EQ(instance, this);
65 Shutdown();
66 instance = NULL;
69 void InputManagerImpl::Init() {
70 accelerator_manager_->Init();
73 void InputManagerImpl::Shutdown() {
74 accelerator_manager_.reset();
77 void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
78 aura::client::SetEventClient(root_window, this);
79 accelerator_manager_->OnRootWindowCreated(root_window);
82 bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
83 return true;
86 ui::EventTarget* InputManagerImpl::GetParentTarget() {
87 return aura::Env::GetInstance();
90 scoped_ptr<ui::EventTargetIterator> InputManagerImpl::GetChildIterator() const {
91 return scoped_ptr<ui::EventTargetIterator>();
94 ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
95 NOTREACHED();
96 return NULL;
99 void InputManagerImpl::OnEvent(ui::Event* event) {
102 } // namespace
104 // static
105 InputManager* InputManager::Create() {
106 (new InputManagerImpl)->Init();
107 DCHECK(instance);
108 return instance;
111 // static
112 InputManager* InputManager::Get() {
113 DCHECK(instance);
114 return instance;
117 // static
118 void InputManager::Shutdown() {
119 DCHECK(instance);
120 delete instance;
121 DCHECK(!instance);
124 } // namespace athena