summaryrefslogtreecommitdiffstats
path: root/ui/base/ime/ime_bridge.h
blob: 5db8bbaa19f56141ab3c853445270e3f3bdf8bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// 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.

#ifndef UI_BASE_IME_IME_BRIDGE_H_
#define UI_BASE_IME_IME_BRIDGE_H_

#include "base/macros.h"
#include "build/build_config.h"
#include "ui/base/ime/ime_engine_handler_interface.h"
#include "ui/base/ime/ime_input_context_handler_interface.h"
#include "ui/base/ime/ui_base_ime_export.h"

#if defined(OS_CHROMEOS)
#include "ui/base/ime/chromeos/ime_candidate_window_handler_interface.h"

namespace chromeos {
class IMECandidateWindowHandlerInterface;
}
#endif

namespace ui {

// IMEBridge provides access of each IME related handler. This class
// is used for IME implementation.
class UI_BASE_IME_EXPORT IMEBridge {
 public:
  virtual ~IMEBridge();

  // Allocates the global instance. Must be called before any calls to Get().
  static void Initialize();

  // Releases the global instance.
  static void Shutdown();

  // Returns IMEBridge global instance. Initialize() must be called first.
  static IMEBridge* Get();

  // Returns current InputContextHandler. This function returns NULL if input
  // context is not ready to use.
  virtual IMEInputContextHandlerInterface* GetInputContextHandler() const = 0;

  // Updates current InputContextHandler. If there is no active input context,
  // pass NULL for |handler|. Caller must release |handler|.
  virtual void SetInputContextHandler(
      IMEInputContextHandlerInterface* handler) = 0;

  // Updates current EngineHandler. If there is no active engine service, pass
  // NULL for |handler|. Caller must release |handler|.
  virtual void SetCurrentEngineHandler(IMEEngineHandlerInterface* handler) = 0;

  // Returns current EngineHandler. This function returns NULL if current engine
  // is not ready to use.
  virtual IMEEngineHandlerInterface* GetCurrentEngineHandler() const = 0;

  // Updates the current input context.
  // This is called from InputMethodChromeOS.
  virtual void SetCurrentInputContext(
      const IMEEngineHandlerInterface::InputContext& input_context) = 0;

  // Returns the current input context.
  // This is called from InputMethodEngine.
  virtual const IMEEngineHandlerInterface::InputContext&
  GetCurrentInputContext() const = 0;

#if defined(OS_CHROMEOS)
  // Returns current CandidateWindowHandler. This function returns NULL if
  // current candidate window is not ready to use.
  virtual chromeos::IMECandidateWindowHandlerInterface*
  GetCandidateWindowHandler() const = 0;

  // Updates current CandidatWindowHandler. If there is no active candidate
  // window service, pass NULL for |handler|. Caller must release |handler|.
  virtual void SetCandidateWindowHandler(
      chromeos::IMECandidateWindowHandlerInterface* handler) = 0;
#endif

 protected:
  IMEBridge();

 private:
  DISALLOW_COPY_AND_ASSIGN(IMEBridge);
};

}  // namespace ui

#endif  // UI_BASE_IME_IME_BRIDGE_H_