Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2476)

Unified Diff: athena/input/input_manager_impl.cc

Issue 654343002: Intorduce PowerButtonObserver API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative fix Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/input/input_manager_impl.h ('k') | athena/input/input_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/input/input_manager_impl.cc
diff --git a/athena/input/input_manager_impl.cc b/athena/input/input_manager_impl.cc
index 1594b43b16e8d5bf9bd8582a6a990e25ec9bc0e9..0815a7a7cdd4229d157d189bdeb2cf06cd6dfed4 100644
--- a/athena/input/input_manager_impl.cc
+++ b/athena/input/input_manager_impl.cc
@@ -2,60 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "athena/input/public/input_manager.h"
+#include "athena/input/input_manager_impl.h"
-#include "athena/input/accelerator_manager_impl.h"
+#include "athena/input/power_button_controller.h"
#include "base/logging.h"
-#include "ui/aura/client/event_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
-#include "ui/events/event_target.h"
namespace athena {
namespace {
InputManager* instance = NULL;
-class InputManagerImpl : public InputManager,
- public ui::EventTarget,
- public aura::client::EventClient {
- public:
- InputManagerImpl();
- virtual ~InputManagerImpl();
-
- void Init();
- void Shutdown();
-
- private:
- // InputManager:
- virtual void OnRootWindowCreated(aura::Window* root_window) override;
- virtual ui::EventTarget* GetTopmostEventTarget() override { return this; }
- virtual AcceleratorManager* GetAcceleratorManager() override {
- return accelerator_manager_.get();
- }
-
- // Overridden from aura::client::EventClient:
- virtual bool CanProcessEventsWithinSubtree(
- const aura::Window* window) const override {
- return window && !window->ignore_events();
- }
- virtual ui::EventTarget* GetToplevelEventTarget() override { return this; }
-
- // ui::EventTarget:
- virtual bool CanAcceptEvent(const ui::Event& event) override;
- virtual ui::EventTarget* GetParentTarget() override;
- virtual scoped_ptr<ui::EventTargetIterator> GetChildIterator() const override;
- virtual ui::EventTargeter* GetEventTargeter() override;
- virtual void OnEvent(ui::Event* event) override;
-
- scoped_ptr<AcceleratorManagerImpl> accelerator_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(InputManagerImpl);
-};
+} // namespace
InputManagerImpl::InputManagerImpl()
: accelerator_manager_(
- AcceleratorManagerImpl::CreateGlobalAcceleratorManager()) {
+ AcceleratorManagerImpl::CreateGlobalAcceleratorManager()),
+ power_button_controller_(new PowerButtonController) {
DCHECK(!instance);
instance = this;
}
@@ -68,6 +32,7 @@ InputManagerImpl::~InputManagerImpl() {
void InputManagerImpl::Init() {
accelerator_manager_->Init();
+ power_button_controller_->InstallAccelerators();
}
void InputManagerImpl::Shutdown() {
@@ -79,6 +44,31 @@ void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
accelerator_manager_->OnRootWindowCreated(root_window);
}
+ui::EventTarget* InputManagerImpl::GetTopmostEventTarget() {
+ return this;
+}
+
+AcceleratorManager* InputManagerImpl::GetAcceleratorManager() {
+ return accelerator_manager_.get();
+}
+
+void InputManagerImpl::AddPowerButtonObserver(PowerButtonObserver* observer) {
+ power_button_controller_->AddPowerButtonObserver(observer);
+}
+void InputManagerImpl::RemovePowerButtonObserver(
+ PowerButtonObserver* observer) {
+ power_button_controller_->RemovePowerButtonObserver(observer);
+}
+
+bool InputManagerImpl::CanProcessEventsWithinSubtree(
+ const aura::Window* window) const {
+ return window && !window->ignore_events();
+}
+
+ui::EventTarget* InputManagerImpl::GetToplevelEventTarget() {
+ return this;
+}
+
bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
return true;
}
@@ -99,7 +89,9 @@ ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
void InputManagerImpl::OnEvent(ui::Event* event) {
}
-} // namespace
+int InputManagerImpl::SetPowerButtonTimeoutMsForTest(int timeout) {
+ return power_button_controller_->SetPowerButtonTimeoutMsForTest(timeout);
+}
// static
InputManager* InputManager::Create() {
« no previous file with comments | « athena/input/input_manager_impl.h ('k') | athena/input/input_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698