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

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

Issue 11783053: Clean Up: Remove ibus namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 | Annotate | Revision Log
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_lookup_table.h" 5 #include "chromeos/dbus/ibus/ibus_lookup_table.h"
6 6
7 #include <string> 7 #include <string>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chromeos/dbus/ibus/ibus_object.h" 10 #include "chromeos/dbus/ibus/ibus_object.h"
11 #include "chromeos/dbus/ibus/ibus_text.h" 11 #include "chromeos/dbus/ibus/ibus_text.h"
12 #include "dbus/message.h" 12 #include "dbus/message.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 // TODO(nona): Remove ibus namespace after complete libibus removal.
16 namespace ibus {
17 15
18 namespace { 16 namespace {
19 // The default entry number of a page in IBusLookupTable. 17 // The default entry number of a page in IBusLookupTable.
20 const int kDefaultPageSize = 9; 18 const int kDefaultPageSize = 9;
21 const char kShowWindowAtCompositionKey[] = "show_window_at_composition"; 19 const char kShowWindowAtCompositionKey[] = "show_window_at_composition";
22 } // namespace 20 } // namespace
23 21
24 void AppendIBusLookupTable(const IBusLookupTable& table, 22 void AppendIBusLookupTable(const IBusLookupTable& table,
25 dbus::MessageWriter* writer) { 23 dbus::MessageWriter* writer) {
26 IBusObjectWriter ibus_lookup_table_writer("IBusLookupTable", 24 IBusObjectWriter ibus_lookup_table_writer("IBusLookupTable",
27 "uubbiavav", 25 "uubbiavav",
28 writer); 26 writer);
29 scoped_ptr<base::Value> show_position( 27 scoped_ptr<base::Value> show_position(
30 base::Value::CreateBooleanValue(table.show_window_at_composition())); 28 base::Value::CreateBooleanValue(table.show_window_at_composition()));
31 ibus_lookup_table_writer.AddAttachment(kShowWindowAtCompositionKey, 29 ibus_lookup_table_writer.AddAttachment(kShowWindowAtCompositionKey,
32 *show_position.get()); 30 *show_position.get());
33 ibus_lookup_table_writer.CloseHeader(); 31 ibus_lookup_table_writer.CloseHeader();
34 ibus_lookup_table_writer.AppendUint32(table.page_size()); 32 ibus_lookup_table_writer.AppendUint32(table.page_size());
35 ibus_lookup_table_writer.AppendUint32(table.cursor_position()); 33 ibus_lookup_table_writer.AppendUint32(table.cursor_position());
36 ibus_lookup_table_writer.AppendBool(table.is_cursor_visible()); 34 ibus_lookup_table_writer.AppendBool(table.is_cursor_visible());
37 ibus_lookup_table_writer.AppendBool(false); // Not used in Chrome. 35 ibus_lookup_table_writer.AppendBool(false); // Not used in Chrome.
38 ibus_lookup_table_writer.AppendInt32(static_cast<int32>(table.orientation())); 36 ibus_lookup_table_writer.AppendInt32(static_cast<int32>(table.orientation()));
39 37
40 const std::vector<IBusLookupTable::Entry>& candidates = table.candidates(); 38 const std::vector<IBusLookupTable::Entry>& candidates = table.candidates();
41 dbus::MessageWriter text_writer(NULL); 39 dbus::MessageWriter text_writer(NULL);
42 ibus_lookup_table_writer.OpenArray("v", &text_writer); 40 ibus_lookup_table_writer.OpenArray("v", &text_writer);
43 bool have_labels = false; 41 bool have_labels = false;
44 for (size_t i = 0; i < candidates.size(); ++i) { 42 for (size_t i = 0; i < candidates.size(); ++i) {
45 // Write candidate string as IBusText. 43 // Write candidate string as IBusText.
46 ibus::IBusText text; 44 IBusText text;
47 text.set_text(candidates[i].value); 45 text.set_text(candidates[i].value);
48 text.set_annotation(candidates[i].annotation); 46 text.set_annotation(candidates[i].annotation);
49 text.set_description_title(candidates[i].description_title); 47 text.set_description_title(candidates[i].description_title);
50 text.set_description_body(candidates[i].description_body); 48 text.set_description_body(candidates[i].description_body);
51 AppendIBusText(text, &text_writer); 49 AppendIBusText(text, &text_writer);
52 if (!candidates[i].label.empty()) 50 if (!candidates[i].label.empty())
53 have_labels = true; 51 have_labels = true;
54 } 52 }
55 ibus_lookup_table_writer.CloseContainer(&text_writer); 53 ibus_lookup_table_writer.CloseContainer(&text_writer);
56 54
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 123
126 dbus::MessageReader text_array_reader(NULL); 124 dbus::MessageReader text_array_reader(NULL);
127 if (!ibus_object_reader.PopArray(&text_array_reader)) { 125 if (!ibus_object_reader.PopArray(&text_array_reader)) {
128 LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: " 126 LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
129 << "6th argument should be array."; 127 << "6th argument should be array.";
130 return false; 128 return false;
131 } 129 }
132 130
133 std::vector<IBusLookupTable::Entry>* candidates = table->mutable_candidates(); 131 std::vector<IBusLookupTable::Entry>* candidates = table->mutable_candidates();
134 while (text_array_reader.HasMoreData()) { 132 while (text_array_reader.HasMoreData()) {
135 ibus::IBusText candidate_text; 133 IBusText candidate_text;
136 // The attributes in IBusText are not used in Chrome. 134 // The attributes in IBusText are not used in Chrome.
137 if (!PopIBusText(&text_array_reader, &candidate_text)) { 135 if (!PopIBusText(&text_array_reader, &candidate_text)) {
138 LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: " 136 LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: "
139 << "6th argument should be array of IBusText."; 137 << "6th argument should be array of IBusText.";
140 return false; 138 return false;
141 } 139 }
142 IBusLookupTable::Entry entry; 140 IBusLookupTable::Entry entry;
143 entry.value = candidate_text.text(); 141 entry.value = candidate_text.text();
144 entry.annotation = candidate_text.annotation(); 142 entry.annotation = candidate_text.annotation();
145 entry.description_title = candidate_text.description_title(); 143 entry.description_title = candidate_text.description_title();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 candidates_.clear(); 220 candidates_.clear();
223 candidates_ = table.candidates_; 221 candidates_ = table.candidates_;
224 } 222 }
225 223
226 IBusLookupTable::Entry::Entry() { 224 IBusLookupTable::Entry::Entry() {
227 } 225 }
228 226
229 IBusLookupTable::Entry::~Entry() { 227 IBusLookupTable::Entry::~Entry() {
230 } 228 }
231 229
232 } // namespace ibus
233 } // namespace chromeos 230 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/ibus/ibus_lookup_table.h ('k') | chromeos/dbus/ibus/ibus_lookup_table_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698