OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef ATHENA_INPUT_INPUT_MANAGER_IMPL_H_ |
| 6 #define ATHENA_INPUT_INPUT_MANAGER_IMPL_H_ |
| 7 |
| 8 #include "athena/input/public/input_manager.h" |
| 9 |
| 10 #include "athena/athena_export.h" |
| 11 #include "athena/input/accelerator_manager_impl.h" |
| 12 #include "base/observer_list.h" |
| 13 #include "base/timer/timer.h" |
| 14 #include "chromeos/dbus/power_manager_client.h" |
| 15 #include "ui/aura/client/event_client.h" |
| 16 #include "ui/events/event_target.h" |
| 17 |
| 18 namespace athena { |
| 19 namespace test { |
| 20 class ScopedPowerButtonTimeoutShortener; |
| 21 } |
| 22 |
| 23 class ATHENA_EXPORT InputManagerImpl |
| 24 : public InputManager, |
| 25 public ui::EventTarget, |
| 26 public aura::client::EventClient, |
| 27 public chromeos::PowerManagerClient::Observer, |
| 28 public AcceleratorHandler { |
| 29 public: |
| 30 InputManagerImpl(); |
| 31 virtual ~InputManagerImpl(); |
| 32 |
| 33 void Init(); |
| 34 void Shutdown(); |
| 35 |
| 36 private: |
| 37 friend class test::ScopedPowerButtonTimeoutShortener; |
| 38 |
| 39 // InputManager: |
| 40 virtual void OnRootWindowCreated(aura::Window* root_window) override; |
| 41 virtual ui::EventTarget* GetTopmostEventTarget() override; |
| 42 virtual AcceleratorManager* GetAcceleratorManager() override; |
| 43 virtual void AddPowerButtonObserver(PowerButtonObserver* observer) override; |
| 44 virtual void RemovePowerButtonObserver( |
| 45 PowerButtonObserver* observer) override; |
| 46 |
| 47 // Overridden from aura::client::EventClient: |
| 48 virtual bool CanProcessEventsWithinSubtree( |
| 49 const aura::Window* window) const override; |
| 50 virtual ui::EventTarget* GetToplevelEventTarget() override; |
| 51 |
| 52 // ui::EventTarget: |
| 53 virtual bool CanAcceptEvent(const ui::Event& event) override; |
| 54 virtual ui::EventTarget* GetParentTarget() override; |
| 55 virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override; |
| 56 virtual ui::EventTargeter* GetEventTargeter() override; |
| 57 virtual void OnEvent(ui::Event* event) override; |
| 58 |
| 59 // chromeos::PowerManagerClient::Observer: |
| 60 virtual void BrightnessChanged(int level, bool user_initiated) override; |
| 61 virtual void PowerButtonEventReceived( |
| 62 bool down, |
| 63 const base::TimeTicks& timestamp) override; |
| 64 |
| 65 // AcceleratorHandler: |
| 66 virtual bool IsCommandEnabled(int command_id) const override; |
| 67 virtual bool OnAcceleratorFired(int command_id, |
| 68 const ui::Accelerator& accelerator) override; |
| 69 |
| 70 // A timer callabck to notify the long press event. |
| 71 void NotifyLongPress(); |
| 72 |
| 73 void InstallAccelerators(); |
| 74 |
| 75 int SetPowerButtonTimeoutMsForTest(int timeout); |
| 76 |
| 77 scoped_ptr<AcceleratorManagerImpl> accelerator_manager_; |
| 78 |
| 79 int power_button_timeout_ms_; |
| 80 ObserverList<PowerButtonObserver> power_button_observers_; |
| 81 // The last time at which the screen brightness was 0%. |
| 82 base::TimeTicks zero_brightness_end_time_; |
| 83 bool brightness_is_zero_; |
| 84 base::OneShotTimer<InputManagerImpl> timer_; |
| 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(InputManagerImpl); |
| 87 }; |
| 88 |
| 89 } // namespace athena |
| 90 |
| 91 #endif // ATHENA_INPUT_INPUT_MANAGER_IMPL_H_ |
OLD | NEW |