OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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. | |
4 | |
5 #ifndef CHROMEOS_IME_IBUS_BRIDGE_H_ | |
6 #define CHROMEOS_IME_IBUS_BRIDGE_H_ | |
7 | |
8 #include <string> | |
9 #include "base/basictypes.h" | |
10 #include "base/memory/singleton.h" | |
11 | |
12 namespace chromeos { | |
13 class IBusInputContextHandlerInterface; | |
14 class IBusEngineHandlerInterface; | |
15 | |
16 namespace ibus { | |
17 class IBusPanelCandidateWindowHandlerInterface; | |
18 class IBusPanelPropertyHandlerInterface; | |
19 } // namespace ibus | |
20 | |
21 // IBusBridge provides access of each IME related handler. This class is used | |
22 // for IME implementation without ibus-daemon. The legacy ibus IME communicates | |
23 // their engine with dbus protocol, but new implementation doesn't. Instead of | |
24 // dbus communcation, new implementation calls target service(e.g. PanelService | |
25 // or EngineService) directly by using this class. IBusBridge is managed as | |
26 // singleton object. | |
27 class IBusBridge { | |
28 public: | |
29 // Returns IBusBridge instance. | |
30 static IBusBridge* GetInstance(); | |
31 | |
32 // Returns current InputContextHandler. This function returns NULL if input | |
33 // context is not ready to use. | |
34 IBusInputContextHandlerInterface* input_context_handler() const { | |
35 return input_context_handler_; | |
36 } | |
37 | |
38 // Updates current InputContextHandler. If there is no active input context, | |
39 // pass NULL for |handler|. Caller must release |handler|. | |
40 void set_input_context_handler(IBusInputContextHandlerInterface* handler) { | |
41 input_context_handler_ = handler; | |
42 } | |
43 | |
44 // Returns current EngineHandler. This function returns NULL if current engine | |
45 // is not ready to use. | |
46 IBusEngineHandlerInterface* engine_handler() const { | |
47 return engine_handler_; | |
48 } | |
49 | |
50 // Updates current EngineHandler. If there is no active engine service, pass | |
51 // NULL for |handler|. Caller must release |handler|. | |
52 void set_engine_handler(IBusEngineHandlerInterface* handler) { | |
53 engine_handler_ = handler; | |
54 } | |
55 | |
56 // Returns current CandidateWindowHandler. This function returns NULL if | |
57 // current candidate window is not ready to use. | |
58 ibus::IBusPanelCandidateWindowHandlerInterface* | |
59 candidate_window_handler() const { | |
60 return candidate_window_handler_; | |
61 } | |
62 | |
63 // Updates current CandidatWindowHandler. If there is no active candidate | |
64 // window service, pass NULL for |handler|. Caller must release |handler|. | |
65 void set_candidate_window_handler( | |
66 ibus::IBusPanelCandidateWindowHandlerInterface* handler) { | |
67 candidate_window_handler_ = handler; | |
68 } | |
69 | |
70 // Returns current PropertyHandler. This function returns NULL if panel window | |
71 // is not ready to use. | |
72 ibus::IBusPanelPropertyHandlerInterface* panel_handler() const { | |
73 return panel_handler_; | |
74 } | |
75 | |
76 // Updates current PropertyHandler. If there is no active property service, | |
77 // pass NULL for |handler|. Caller must release |handler|. | |
78 void set_panel_handler(ibus::IBusPanelPropertyHandlerInterface* handler) { | |
79 panel_handler_ = handler; | |
80 } | |
81 | |
82 private: | |
83 // Singleton implementation. Use GetInstance for getting instance. | |
84 IBusBridge(); | |
85 friend struct DefaultSingletonTraits<IBusBridge>; | |
86 | |
87 IBusInputContextHandlerInterface* input_context_handler_; | |
88 IBusEngineHandlerInterface* engine_handler_; | |
89 ibus::IBusPanelCandidateWindowHandlerInterface* candidate_window_handler_; | |
90 ibus::IBusPanelPropertyHandlerInterface* panel_handler_; | |
91 | |
92 DISALLOW_COPY_AND_ASSIGN(IBusBridge); | |
93 }; | |
94 | |
95 } // namespace chromeos | |
96 | |
97 #endif // CHROMEOS_IME_IBUS_BRIDGE_H_ | |
OLD | NEW |