Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / base / ime / chromeos / ime_bridge.cc
blob49d0f73df3c4f01655b25db8a707a2aaa76cd964
1 // Copyright 2014 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.
5 #include "ui/base/ime/chromeos/ime_bridge.h"
7 #include <map>
8 #include "base/logging.h"
9 #include "base/memory/singleton.h"
11 namespace chromeos {
13 static IMEBridge* g_ime_bridge = NULL;
15 // An implementation of IMEBridge.
16 class IMEBridgeImpl : public IMEBridge {
17 public:
18 IMEBridgeImpl()
19 : input_context_handler_(NULL),
20 engine_handler_(NULL),
21 candidate_window_handler_(NULL),
22 current_text_input_(ui::TEXT_INPUT_TYPE_NONE) {
25 virtual ~IMEBridgeImpl() {
28 // IMEBridge override.
29 virtual IMEInputContextHandlerInterface*
30 GetInputContextHandler() const OVERRIDE {
31 return input_context_handler_;
34 // IMEBridge override.
35 virtual void SetInputContextHandler(
36 IMEInputContextHandlerInterface* handler) OVERRIDE {
37 input_context_handler_ = handler;
40 // IMEBridge override.
41 virtual void SetCurrentEngineHandler(
42 IMEEngineHandlerInterface* handler) OVERRIDE {
43 engine_handler_ = handler;
46 // IMEBridge override.
47 virtual IMEEngineHandlerInterface* GetCurrentEngineHandler() const OVERRIDE {
48 return engine_handler_;
51 // IMEBridge override.
52 virtual IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() const
53 OVERRIDE {
54 return candidate_window_handler_;
57 // IMEBridge override.
58 virtual void SetCandidateWindowHandler(
59 IMECandidateWindowHandlerInterface* handler) OVERRIDE {
60 candidate_window_handler_ = handler;
63 // IMEBridge override.
64 virtual void SetCurrentTextInputType(ui::TextInputType input_type) OVERRIDE {
65 current_text_input_ = input_type;
68 // IMEBridge override.
69 virtual ui::TextInputType GetCurrentTextInputType() const OVERRIDE {
70 return current_text_input_;
73 private:
74 IMEInputContextHandlerInterface* input_context_handler_;
75 IMEEngineHandlerInterface* engine_handler_;
76 IMECandidateWindowHandlerInterface* candidate_window_handler_;
77 ui::TextInputType current_text_input_;
79 DISALLOW_COPY_AND_ASSIGN(IMEBridgeImpl);
82 ///////////////////////////////////////////////////////////////////////////////
83 // IMEBridge
84 IMEBridge::IMEBridge() {
87 IMEBridge::~IMEBridge() {
90 // static.
91 void IMEBridge::Initialize() {
92 if (!g_ime_bridge)
93 g_ime_bridge = new IMEBridgeImpl();
96 // static.
97 void IMEBridge::Shutdown() {
98 delete g_ime_bridge;
99 g_ime_bridge = NULL;
102 // static.
103 IMEBridge* IMEBridge::Get() {
104 return g_ime_bridge;
107 } // namespace chromeos