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

Unified Diff: athena/input/input_manager_impl.cc

Issue 305873002: InputManager/AcceleratorManager for athena (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix auto repeat test Created 6 years, 6 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
Index: athena/input/input_manager_impl.cc
diff --git a/athena/input/input_manager_impl.cc b/athena/input/input_manager_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2b7bcc6703613f88d22dbcf626f8829000078111
--- /dev/null
+++ b/athena/input/input_manager_impl.cc
@@ -0,0 +1,121 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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/accelerator_manager_impl.h"
+#include "base/logging.h"
+#include "ui/aura/client/event_client.h"
+#include "ui/aura/env.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* GetToplevelEventTarget() OVERRIDE { return this; }
sadrul 2014/06/05 19:24:32 Let's call this something else to disambiguate fro
oshima 2014/06/05 20:36:40 Changed to TopmostEventTarget().
+ virtual AcceleratorManager* GetAcceleratorManager() OVERRIDE {
+ return accelerator_manager_.get();
+ }
+
+ // Overridden from aura::client::EventClient:
+ virtual bool CanProcessEventsWithinSubtree(
+ const aura::Window* window) const OVERRIDE {
+ return true;
+ }
+
+ // ui::EventTarget:
+ virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
+ virtual 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);
+};
+
+InputManagerImpl::InputManagerImpl()
+ : accelerator_manager_(new AcceleratorManagerImpl) {
+ DCHECK(!instance);
+ instance = this;
+}
+
+InputManagerImpl::~InputManagerImpl() {
+ DCHECK_EQ(instance, this);
+ Shutdown();
+ instance = NULL;
+}
+
+void InputManagerImpl::Init() {
+ accelerator_manager_->Init();
+}
+
+void InputManagerImpl::Shutdown() {
+ accelerator_manager_.reset();
+}
+
+void InputManagerImpl::OnRootWindowCreated(aura::Window* root_window) {
+ aura::client::SetEventClient(root_window, this);
+ accelerator_manager_->OnRootWindowCreated(root_window);
+}
+
+bool InputManagerImpl::CanAcceptEvent(const ui::Event& event) {
+ return true;
+}
+
+ui::EventTarget* InputManagerImpl::GetParentTarget() {
+ return aura::Env::GetInstance();
+}
+
+scoped_ptr<ui::EventTargetIterator> InputManagerImpl::GetChildIterator() const {
+ return scoped_ptr<ui::EventTargetIterator>();
+}
+
+ui::EventTargeter* InputManagerImpl::GetEventTargeter() {
+ NOTREACHED();
+ return NULL;
+}
+
+void InputManagerImpl::OnEvent(ui::Event* event) {
+}
+
+} // namespace
+
+// static
+InputManager* InputManager::Create() {
+ (new InputManagerImpl)->Init();
+ DCHECK(instance);
+ return instance;
+}
+
+// static
+InputManager* InputManager::Get() {
+ DCHECK(instance);
+ return instance;
+}
+
+// static
+void InputManager::Shutdown() {
+ DCHECK(instance);
+ delete instance;
+ DCHECK(!instance);
+}
+
+} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698