blob: 630cf376bbb53e6466eec26f707ae37e255ac560 (
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
// Copyright (c) 2012 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.
#include "chromeos/ime/ibus_bridge.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
namespace chromeos {
static IBusBridge* g_ibus_bridge = NULL;
// An implementation of IBusBridge.
class IBusBridgeImpl : public IBusBridge {
public:
IBusBridgeImpl()
: input_context_handler_(NULL),
engine_handler_(NULL),
candidate_window_handler_(NULL),
panel_handler_(NULL) {
}
virtual ~IBusBridgeImpl() {
}
// IBusBridge override.
virtual IBusInputContextHandlerInterface*
GetInputContextHandler() const OVERRIDE {
return input_context_handler_;
}
// IBusBridge override.
virtual void SetInputContextHandler(
IBusInputContextHandlerInterface* handler) OVERRIDE {
input_context_handler_ = handler;
}
// IBusBridge override.
virtual IBusEngineHandlerInterface* GetEngineHandler() const OVERRIDE {
return engine_handler_;
}
// IBusBridge override.
virtual void SetEngineHandler(IBusEngineHandlerInterface* handler) OVERRIDE {
engine_handler_ = handler;
}
// IBusBridge override.
virtual IBusPanelCandidateWindowHandlerInterface*
GetCandidateWindowHandler() const OVERRIDE {
return candidate_window_handler_;
}
// IBusBridge override.
virtual void SetCandidateWindowHandler(
IBusPanelCandidateWindowHandlerInterface* handler) OVERRIDE {
candidate_window_handler_ = handler;
}
// IBusBridge override.
virtual IBusPanelPropertyHandlerInterface* GetPanelHandler() const OVERRIDE {
return panel_handler_;
}
// IBusBridge override.
virtual void SetPanelHandler(
IBusPanelPropertyHandlerInterface* handler) OVERRIDE {
panel_handler_ = handler;
}
private:
IBusInputContextHandlerInterface* input_context_handler_;
IBusEngineHandlerInterface* engine_handler_;
IBusPanelCandidateWindowHandlerInterface* candidate_window_handler_;
IBusPanelPropertyHandlerInterface* panel_handler_;
DISALLOW_COPY_AND_ASSIGN(IBusBridgeImpl);
};
///////////////////////////////////////////////////////////////////////////////
// IBusBridge
IBusBridge::IBusBridge() {
}
IBusBridge::~IBusBridge() {
}
// static.
void IBusBridge::Initialize() {
CHECK(!g_ibus_bridge) << "Already initialized.";
g_ibus_bridge = new IBusBridgeImpl();
}
// static.
void IBusBridge::Shutdown() {
CHECK(g_ibus_bridge) << "Shutdown called before Initialize().";
delete g_ibus_bridge;
g_ibus_bridge = NULL;
}
// static.
IBusBridge* IBusBridge::Get() {
return g_ibus_bridge;
}
} // namespace chromeos
|