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 #include "chromeos/dbus/ibus/ibus_engine_service.h" | |
6 | |
7 #include <string> | |
8 #include "base/bind.h" | |
9 #include "base/callback.h" | |
10 #include "chromeos/dbus/ibus/ibus_constants.h" | |
11 #include "chromeos/dbus/ibus/ibus_text.h" | |
12 #include "chromeos/ime/ibus_bridge.h" | |
13 | |
14 namespace chromeos { | |
15 // An implementation of IBusEngineService without ibus-daemon interaction. | |
16 // Currently this class is used only on linux desktop. | |
17 // TODO(nona): Use this on ChromeOS device once crbug.com/171351 is fixed. | |
18 class IBusEngineServiceDaemonlessImpl : public IBusEngineService { | |
19 public: | |
20 IBusEngineServiceDaemonlessImpl() {} | |
21 virtual ~IBusEngineServiceDaemonlessImpl() {} | |
22 | |
23 // IBusEngineService override. | |
24 virtual void SetEngine(IBusEngineHandlerInterface* handler) OVERRIDE { | |
25 IBusBridge::Get()->SetEngineHandler(handler); | |
26 } | |
27 | |
28 // IBusEngineService override. | |
29 virtual void UnsetEngine(IBusEngineHandlerInterface* handler) OVERRIDE { | |
30 if (IBusBridge::Get()->GetEngineHandler() == handler) | |
31 IBusBridge::Get()->SetEngineHandler(NULL); | |
32 } | |
33 | |
34 // IBusEngineService override. | |
35 virtual void UpdatePreedit(const IBusText& ibus_text, | |
36 uint32 cursor_pos, | |
37 bool is_visible, | |
38 IBusEnginePreeditFocusOutMode mode) OVERRIDE { | |
39 IBusInputContextHandlerInterface* input_context = | |
40 IBusBridge::Get()->GetInputContextHandler(); | |
41 if (input_context) | |
42 input_context->UpdatePreeditText(ibus_text, cursor_pos, is_visible); | |
43 } | |
44 | |
45 // IBusEngineService override. | |
46 virtual void UpdateAuxiliaryText(const IBusText& ibus_text, | |
47 bool is_visible) OVERRIDE { | |
48 IBusPanelCandidateWindowHandlerInterface* candidate_window = | |
49 IBusBridge::Get()->GetCandidateWindowHandler(); | |
50 if (candidate_window) | |
51 candidate_window->UpdateAuxiliaryText(ibus_text.text(), is_visible); | |
52 } | |
53 | |
54 // IBusEngineService override. | |
55 virtual void ForwardKeyEvent(uint32 keyval, uint32 keycode, | |
56 uint32 state) OVERRIDE { | |
57 IBusInputContextHandlerInterface* input_context = | |
58 IBusBridge::Get()->GetInputContextHandler(); | |
59 if (input_context) | |
60 input_context->ForwardKeyEvent(keyval, keycode, state); | |
61 } | |
62 | |
63 // IBusEngineService override. | |
64 virtual void RequireSurroundingText() OVERRIDE { | |
65 // Do nothing. | |
66 } | |
67 | |
68 // IBusEngineService override. | |
69 virtual void DeleteSurroundingText(int32 offset, uint32 length) OVERRIDE { | |
70 IBusInputContextHandlerInterface* input_context = | |
71 IBusBridge::Get()->GetInputContextHandler(); | |
72 if (input_context) | |
73 input_context->DeleteSurroundingText(offset, length); | |
74 } | |
75 private: | |
76 DISALLOW_COPY_AND_ASSIGN(IBusEngineServiceDaemonlessImpl); | |
77 }; | |
78 | |
79 IBusEngineService::IBusEngineService() { | |
80 } | |
81 | |
82 IBusEngineService::~IBusEngineService() { | |
83 } | |
84 | |
85 // static | |
86 IBusEngineService* IBusEngineService::Create() { | |
87 return new IBusEngineServiceDaemonlessImpl(); | |
88 } | |
89 | |
90 } // namespace chromeos | |
OLD | NEW |