Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/ibus/ibus_text.h" | 5 #include "chromeos/dbus/ibus/ibus_text.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chromeos/dbus/ibus/ibus_object.h" | 8 #include "chromeos/dbus/ibus/ibus_object.h" |
| 9 #include "dbus/message.h" | 9 #include "dbus/message.h" |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 attribute.end_index = selection_attributes[i].end_index; | 86 attribute.end_index = selection_attributes[i].end_index; |
| 87 AppendIBusAttribute(&attribute_array_writer, attribute); | 87 AppendIBusAttribute(&attribute_array_writer, attribute); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Close all writers. | 90 // Close all writers. |
| 91 ibus_attr_list_writer.CloseContainer(&attribute_array_writer); | 91 ibus_attr_list_writer.CloseContainer(&attribute_array_writer); |
| 92 ibus_attr_list_writer.CloseAll(); | 92 ibus_attr_list_writer.CloseAll(); |
| 93 ibus_text_writer.CloseAll(); | 93 ibus_text_writer.CloseAll(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void CHROMEOS_EXPORT AppendStringAsIBusText(const std::string& text, | |
| 97 dbus::MessageWriter* writer) { | |
| 98 IBusText ibus_text; | |
| 99 ibus_text.set_text(text); | |
| 100 AppendIBusText(ibus_text, writer); | |
| 101 } | |
| 102 | |
| 96 bool PopIBusText(dbus::MessageReader* reader, IBusText* ibus_text) { | 103 bool PopIBusText(dbus::MessageReader* reader, IBusText* ibus_text) { |
| 97 IBusObjectReader ibus_text_reader("IBusText", reader); | 104 IBusObjectReader ibus_text_reader("IBusText", reader); |
| 98 if (!ibus_text_reader.Init()) | 105 if (!ibus_text_reader.Init()) |
| 99 return false; | 106 return false; |
| 100 | 107 |
| 101 std::string text; | 108 std::string text; |
| 102 if (!ibus_text_reader.PopString(&text)) { | 109 if (!ibus_text_reader.PopString(&text)) { |
| 103 LOG(ERROR) << "Invalid variant structure[IBusText]: " | 110 LOG(ERROR) << "Invalid variant structure[IBusText]: " |
| 104 << "1st argument should be string."; | 111 << "1st argument should be string."; |
| 105 return false; | 112 return false; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 selection_attribute.end_index = attribute.end_index; | 153 selection_attribute.end_index = attribute.end_index; |
| 147 selection_attributes->push_back(selection_attribute); | 154 selection_attributes->push_back(selection_attribute); |
| 148 } else { | 155 } else { |
| 149 DVLOG(1) << "Chrome does not support background attribute."; | 156 DVLOG(1) << "Chrome does not support background attribute."; |
| 150 } | 157 } |
| 151 } | 158 } |
| 152 | 159 |
| 153 return true; | 160 return true; |
| 154 } | 161 } |
| 155 | 162 |
| 163 bool CHROMEOS_EXPORT PopStringFromIBusText(dbus::MessageReader* reader, | |
| 164 std::string* text) { | |
| 165 IBusText ibus_text; | |
| 166 bool result = PopIBusText(reader, &ibus_text); | |
| 167 text->assign(ibus_text.text()); | |
|
satorux1
2012/05/18 01:11:06
Should we do this when |result| is false?
Maybe:
Seigo Nonaka
2012/05/18 01:18:43
Done
On 2012/05/18 01:11:06, satorux1 wrote:
| |
| 168 return result; | |
| 169 } | |
| 170 | |
| 156 /////////////////////////////////////////////////////////////////////////////// | 171 /////////////////////////////////////////////////////////////////////////////// |
| 157 // IBusText | 172 // IBusText |
| 158 IBusText::IBusText() | 173 IBusText::IBusText() |
| 159 : text_("") { | 174 : text_("") { |
| 160 } | 175 } |
| 161 | 176 |
| 162 IBusText::~IBusText() { | 177 IBusText::~IBusText() { |
| 163 } | 178 } |
| 164 | 179 |
| 165 std::string IBusText::text() const { | 180 std::string IBusText::text() const { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 185 return &selection_attributes_; | 200 return &selection_attributes_; |
| 186 } | 201 } |
| 187 | 202 |
| 188 const std::vector<IBusText::SelectionAttribute>& | 203 const std::vector<IBusText::SelectionAttribute>& |
| 189 IBusText::selection_attributes() const { | 204 IBusText::selection_attributes() const { |
| 190 return selection_attributes_; | 205 return selection_attributes_; |
| 191 } | 206 } |
| 192 | 207 |
| 193 } // namespace ibus | 208 } // namespace ibus |
| 194 } // namespace chromeos | 209 } // namespace chromeos |
| OLD | NEW |