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"
8 #include "base/logging.h"
9 #include "base/memory/singleton.h"
13 static IMEBridge
* g_ime_bridge
= NULL
;
15 // An implementation of IMEBridge.
16 class IMEBridgeImpl
: public IMEBridge
{
19 : input_context_handler_(NULL
),
20 engine_handler_(NULL
),
21 candidate_window_handler_(NULL
),
22 current_input_context_(ui::TEXT_INPUT_TYPE_NONE
,
23 ui::TEXT_INPUT_MODE_DEFAULT
,
26 ~IMEBridgeImpl() override
{}
28 // IMEBridge override.
29 IMEInputContextHandlerInterface
* GetInputContextHandler() const override
{
30 return input_context_handler_
;
33 // IMEBridge override.
34 void SetInputContextHandler(
35 IMEInputContextHandlerInterface
* handler
) override
{
36 input_context_handler_
= handler
;
39 // IMEBridge override.
40 void SetCurrentEngineHandler(IMEEngineHandlerInterface
* handler
) override
{
41 engine_handler_
= handler
;
44 // IMEBridge override.
45 IMEEngineHandlerInterface
* GetCurrentEngineHandler() const override
{
46 return engine_handler_
;
49 // IMEBridge override.
50 IMECandidateWindowHandlerInterface
* GetCandidateWindowHandler()
52 return candidate_window_handler_
;
55 // IMEBridge override.
56 void SetCandidateWindowHandler(
57 IMECandidateWindowHandlerInterface
* handler
) override
{
58 candidate_window_handler_
= handler
;
61 // IMEBridge override.
62 void SetCurrentInputContext(
63 const IMEEngineHandlerInterface::InputContext
& input_context
) override
{
64 current_input_context_
= input_context
;
67 // IMEBridge override.
68 const IMEEngineHandlerInterface::InputContext
& GetCurrentInputContext()
70 return current_input_context_
;
74 IMEInputContextHandlerInterface
* input_context_handler_
;
75 IMEEngineHandlerInterface
* engine_handler_
;
76 IMECandidateWindowHandlerInterface
* candidate_window_handler_
;
77 IMEEngineHandlerInterface::InputContext current_input_context_
;
79 DISALLOW_COPY_AND_ASSIGN(IMEBridgeImpl
);
82 ///////////////////////////////////////////////////////////////////////////////
84 IMEBridge::IMEBridge() {
87 IMEBridge::~IMEBridge() {
91 void IMEBridge::Initialize() {
93 g_ime_bridge
= new IMEBridgeImpl();
97 void IMEBridge::Shutdown() {
103 IMEBridge
* IMEBridge::Get() {
107 } // namespace chromeos