Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chromeos/dbus/ibus/ibus_text.cc

Issue 10332228: Extends IBusText I/O function. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Apply comments. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/ibus/ibus_text.h ('k') | chromeos/dbus/ibus/ibus_text_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 if(!PopIBusText(reader, &ibus_text))
167 return false;
168 *text = ibus_text.text();
169 return true;
170 }
171
156 /////////////////////////////////////////////////////////////////////////////// 172 ///////////////////////////////////////////////////////////////////////////////
157 // IBusText 173 // IBusText
158 IBusText::IBusText() 174 IBusText::IBusText()
159 : text_("") { 175 : text_("") {
160 } 176 }
161 177
162 IBusText::~IBusText() { 178 IBusText::~IBusText() {
163 } 179 }
164 180
165 std::string IBusText::text() const { 181 std::string IBusText::text() const {
(...skipping 19 matching lines...) Expand all
185 return &selection_attributes_; 201 return &selection_attributes_;
186 } 202 }
187 203
188 const std::vector<IBusText::SelectionAttribute>& 204 const std::vector<IBusText::SelectionAttribute>&
189 IBusText::selection_attributes() const { 205 IBusText::selection_attributes() const {
190 return selection_attributes_; 206 return selection_attributes_;
191 } 207 }
192 208
193 } // namespace ibus 209 } // namespace ibus
194 } // namespace chromeos 210 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/ibus/ibus_text.h ('k') | chromeos/dbus/ibus/ibus_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698