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 // TODO(nona): Remvoe IBusUiController | |
5 | |
6 #include "chrome/browser/chromeos/input_method/ibus_ui_controller.h" | |
7 | |
8 #include <sstream> | |
9 | |
10 #include "ash/shell.h" | |
11 #include "base/logging.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/string_util.h" | |
14 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | |
15 #include "chrome/browser/chromeos/input_method/input_method_descriptor.h" | |
16 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | |
17 #include "chrome/browser/chromeos/input_method/input_method_util.h" | |
18 #include "chromeos/dbus/dbus_thread_manager.h" | |
19 #include "chromeos/dbus/ibus/ibus_lookup_table.h" | |
20 #include "ui/aura/client/aura_constants.h" | |
21 #include "ui/aura/root_window.h" | |
22 #include "ui/base/ime/input_method_ibus.h" | |
23 | |
24 namespace chromeos { | |
25 namespace input_method { | |
26 namespace { | |
27 | |
28 // Returns pointer of IBusPanelService. This function returns NULL if it is not | |
29 // ready. | |
30 ibus::IBusPanelService* GetIBusPanelService() { | |
31 return DBusThreadManager::Get()->GetIBusPanelService(); | |
32 } | |
33 | |
34 } // namespace | |
35 | |
36 // The real implementation of the IBusUiController. | |
37 IBusUiController::IBusUiController() { | |
38 } | |
39 | |
40 IBusUiController::~IBusUiController() { | |
41 } | |
42 | |
43 void IBusUiController::NotifyCandidateClicked(int index, int button, | |
44 int flags) { | |
45 ibus::IBusPanelService* service = GetIBusPanelService(); | |
46 if (service) { | |
47 service->CandidateClicked( | |
48 index, | |
49 static_cast<ibus::IBusMouseButton>(button), | |
50 flags); | |
51 } | |
52 } | |
53 | |
54 void IBusUiController::NotifyCursorUp() { | |
55 ibus::IBusPanelService* service = GetIBusPanelService(); | |
56 if (service) | |
57 service->CursorUp(); | |
58 } | |
59 | |
60 void IBusUiController::NotifyCursorDown() { | |
61 ibus::IBusPanelService* service = GetIBusPanelService(); | |
62 if (service) | |
63 service->CursorDown(); | |
64 } | |
65 | |
66 void IBusUiController::NotifyPageUp() { | |
67 ibus::IBusPanelService* service = GetIBusPanelService(); | |
68 if (service) | |
69 service->PageUp(); | |
70 } | |
71 | |
72 void IBusUiController::NotifyPageDown() { | |
73 ibus::IBusPanelService* service = GetIBusPanelService(); | |
74 if (service) | |
75 service->PageDown(); | |
76 } | |
77 | |
78 void IBusUiController::AddObserver(Observer* observer) { | |
79 observers_.AddObserver(observer); | |
80 } | |
81 | |
82 void IBusUiController::RemoveObserver(Observer* observer) { | |
83 observers_.RemoveObserver(observer); | |
84 } | |
85 | |
86 void IBusUiController::HideAuxiliaryText() { | |
87 FOR_EACH_OBSERVER(Observer, observers_, OnHideAuxiliaryText()); | |
88 } | |
89 | |
90 void IBusUiController::HideLookupTable() { | |
91 FOR_EACH_OBSERVER(Observer, observers_, OnHideLookupTable()); | |
92 } | |
93 | |
94 void IBusUiController::UpdateAuxiliaryText(const std::string& text, | |
95 bool visible) { | |
96 FOR_EACH_OBSERVER(Observer, observers_, | |
97 OnUpdateAuxiliaryText(text, visible)); | |
98 } | |
99 | |
100 void IBusUiController::UpdatePreeditText(const std::string& text, | |
101 uint32 cursor_pos, | |
102 bool visible) { | |
103 FOR_EACH_OBSERVER(Observer, observers_, | |
104 OnUpdatePreeditText(text, cursor_pos, visible)); | |
105 } | |
106 | |
107 void IBusUiController::HidePreeditText() { | |
108 FOR_EACH_OBSERVER(Observer, observers_, OnHidePreeditText()); | |
109 } | |
110 | |
111 void IBusUiController::UpdateLookupTable(const ibus::IBusLookupTable& table, | |
112 bool visible) { | |
113 FOR_EACH_OBSERVER(Observer, observers_, OnUpdateLookupTable(table, visible)); | |
114 } | |
115 | |
116 void IBusUiController::SetCursorLocation(const ibus::Rect& cursor_location, | |
117 const ibus::Rect& composition_head) { | |
118 FOR_EACH_OBSERVER(Observer, | |
119 observers_, | |
120 OnSetCursorLocation(cursor_location, composition_head)); | |
121 } | |
122 | |
123 } // namespace input_method | |
124 } // namespace chromeos | |
OLD | NEW |