1// Copyright (c) 2012 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 UI_WM_CORE_INPUT_METHOD_EVENT_FILTER_H_
6#define UI_WM_CORE_INPUT_METHOD_EVENT_FILTER_H_
7
8#include "base/compiler_specific.h"
9#include "base/macros.h"
10#include "base/memory/scoped_ptr.h"
11#include "ui/base/ime/input_method_delegate.h"
12#include "ui/events/event_handler.h"
13#include "ui/gfx/native_widget_types.h"
14#include "ui/wm/wm_export.h"
15
16namespace ui {
17class EventProcessor;
18class InputMethod;
19}
20
21namespace wm {
22
23// An event filter that forwards a KeyEvent to a system IME, and dispatches a
24// TranslatedKeyEvent to the root window as needed.
25class WM_EXPORT InputMethodEventFilter
26    : public ui::EventHandler,
27      public ui::internal::InputMethodDelegate {
28 public:
29  explicit InputMethodEventFilter(gfx::AcceleratedWidget widget);
30  virtual ~InputMethodEventFilter();
31
32  void SetInputMethodPropertyInRootWindow(aura::Window* root_window);
33
34  ui::InputMethod* input_method() const { return input_method_.get(); }
35
36 private:
37  // Overridden from ui::EventHandler:
38  virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
39
40  // Overridden from ui::internal::InputMethodDelegate:
41  virtual bool DispatchKeyEventPostIME(const ui::KeyEvent& event) OVERRIDE;
42
43  scoped_ptr<ui::InputMethod> input_method_;
44
45  DISALLOW_COPY_AND_ASSIGN(InputMethodEventFilter);
46};
47
48}  // namespace wm
49
50#endif  // UI_WM_CORE_INPUT_METHOD_EVENT_FILTER_H_
51