1// Copyright (c) 2013 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_BASE_IME_INPUT_METHOD_TSF_H_
6#define UI_BASE_IME_INPUT_METHOD_TSF_H_
7
8#include <windows.h>
9
10#include <string>
11
12#include "base/memory/scoped_ptr.h"
13#include "ui/base/ime/input_method_win.h"
14
15namespace ui {
16
17class TSFEventRouter;
18
19// An InputMethod implementation based on Windows TSF API.
20class UI_EXPORT InputMethodTSF : public InputMethodWin {
21 public:
22  InputMethodTSF(internal::InputMethodDelegate* delegate,
23                 HWND toplevel_window_handle);
24  virtual ~InputMethodTSF();
25
26  // Overridden from InputMethod:
27  virtual void OnFocus() OVERRIDE;
28  virtual void OnBlur() OVERRIDE;
29  virtual bool OnUntranslatedIMEMessage(const base::NativeEvent& event,
30                                        NativeEventResult* result) OVERRIDE;
31  virtual void OnTextInputTypeChanged(const TextInputClient* client) OVERRIDE;
32  virtual void OnCaretBoundsChanged(const TextInputClient* client) OVERRIDE;
33  virtual void CancelComposition(const TextInputClient* client) OVERRIDE;
34  virtual void DetachTextInputClient(TextInputClient* client) OVERRIDE;
35  virtual bool IsCandidatePopupOpen() const OVERRIDE;
36
37  // Overridden from InputMethodBase:
38  virtual void OnWillChangeFocusedClient(TextInputClient* focused_before,
39                                         TextInputClient* focused) OVERRIDE;
40  virtual void OnDidChangeFocusedClient(TextInputClient* focused_before,
41                                        TextInputClient* focused) OVERRIDE;
42
43 private:
44  class TSFEventObserver;
45
46  // Asks the client to confirm current composition text.
47  void ConfirmCompositionText();
48
49  // TSF event router and observer.
50  scoped_ptr<TSFEventObserver> tsf_event_observer_;
51  scoped_ptr<TSFEventRouter> tsf_event_router_;
52
53  DISALLOW_COPY_AND_ASSIGN(InputMethodTSF);
54};
55
56}  // namespace ui
57
58#endif  // UI_BASE_IME_INPUT_METHOD_TSF_H_
59