CreateSessionAndGenerateRequest() to use enum for |init_data_type|
[chromium-blink-merge.git] / ui / base / ime / chromeos / ime_bridge.cc
blobb0b4e3e4a884e79669379573270120195d676970
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 ~IMEBridgeImpl() override {}
27 // IMEBridge override.
28 IMEInputContextHandlerInterface* GetInputContextHandler() const override {
29 return input_context_handler_;
32 // IMEBridge override.
33 void SetInputContextHandler(
34 IMEInputContextHandlerInterface* handler) override {
35 input_context_handler_ = handler;
38 // IMEBridge override.
39 void SetCurrentEngineHandler(IMEEngineHandlerInterface* handler) override {
40 engine_handler_ = handler;
43 // IMEBridge override.
44 IMEEngineHandlerInterface* GetCurrentEngineHandler() const override {
45 return engine_handler_;
48 // IMEBridge override.
49 IMECandidateWindowHandlerInterface* GetCandidateWindowHandler()
50 const override {
51 return candidate_window_handler_;
54 // IMEBridge override.
55 void SetCandidateWindowHandler(
56 IMECandidateWindowHandlerInterface* handler) override {
57 candidate_window_handler_ = handler;
60 // IMEBridge override.
61 void SetCurrentTextInputType(ui::TextInputType input_type) override {
62 current_text_input_ = input_type;
65 // IMEBridge override.
66 ui::TextInputType GetCurrentTextInputType() const override {
67 return current_text_input_;
70 private:
71 IMEInputContextHandlerInterface* input_context_handler_;
72 IMEEngineHandlerInterface* engine_handler_;
73 IMECandidateWindowHandlerInterface* candidate_window_handler_;
74 ui::TextInputType current_text_input_;
76 DISALLOW_COPY_AND_ASSIGN(IMEBridgeImpl);
79 ///////////////////////////////////////////////////////////////////////////////
80 // IMEBridge
81 IMEBridge::IMEBridge() {
84 IMEBridge::~IMEBridge() {
87 // static.
88 void IMEBridge::Initialize() {
89 if (!g_ime_bridge)
90 g_ime_bridge = new IMEBridgeImpl();
93 // static.
94 void IMEBridge::Shutdown() {
95 delete g_ime_bridge;
96 g_ime_bridge = NULL;
99 // static.
100 IMEBridge* IMEBridge::Get() {
101 return g_ime_bridge;
104 } // namespace chromeos