| 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_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 "dbus/message.h" | 9 #include "dbus/message.h" |
| 10 #include "chromeos/dbus/ibus/ibus_text.h" | 10 #include "chromeos/dbus/ibus/ibus_text.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 << "The attachment field is array of dictionary entry."; | 71 << "The attachment field is array of dictionary entry."; |
| 72 return false; | 72 return false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 std::string key; | 75 std::string key; |
| 76 if (!dictionary_reader.PopString(&key)) { | 76 if (!dictionary_reader.PopString(&key)) { |
| 77 LOG(ERROR) << "Invalid attachement structure: " | 77 LOG(ERROR) << "Invalid attachement structure: " |
| 78 << "The 1st dictionary entry should be string."; | 78 << "The 1st dictionary entry should be string."; |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 if (key != "mozc.candidates") | 81 if (key != "show_window_at_composition") |
| 82 continue; | 82 continue; |
| 83 | 83 |
| 84 dbus::MessageReader variant_reader(NULL); | 84 dbus::MessageReader variant_reader(NULL); |
| 85 if (!dictionary_reader.PopVariant(&variant_reader)) { | 85 if (!dictionary_reader.PopVariant(&variant_reader)) { |
| 86 LOG(ERROR) << "Invalid attachment structure: " | 86 LOG(ERROR) << "Invalid attachment structure: " |
| 87 << "The 2nd dictionary entry shuold be variant."; | 87 << "The 2nd dictionary entry shuold be variant."; |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 dbus::MessageReader sub_variant_reader(NULL); | 91 dbus::MessageReader sub_variant_reader(NULL); |
| 92 if (!variant_reader.PopVariant(&sub_variant_reader)) { | 92 if (!variant_reader.PopVariant(&sub_variant_reader)) { |
| 93 LOG(ERROR) << "Invalid attachment structure: " | 93 LOG(ERROR) << "Invalid attachment structure: " |
| 94 << "The 2nd variant entry should contain variant."; | 94 << "The 2nd variant entry should contain variant."; |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 | 97 |
| 98 uint8* bytes = NULL; | 98 bool show_window_at_composition = false; |
| 99 size_t length = 0; | 99 if (!sub_variant_reader.PopBool(&show_window_at_composition)) |
| 100 if (!sub_variant_reader.PopArrayOfBytes(&bytes, &length)) { | 100 continue; // Ignores other field. |
| 101 LOG(ERROR) << "Invalid mozc.candidates structure: " | |
| 102 << "The mozc.candidates contains array of bytes."; | |
| 103 return false; | |
| 104 } | |
| 105 | 101 |
| 106 table->set_serialized_mozc_candidates_data( | 102 table->set_show_window_at_composition(show_window_at_composition); |
| 107 std::string(reinterpret_cast<char*>(bytes), length)); | |
| 108 } | 103 } |
| 109 | 104 |
| 110 uint32 page_size = 0; | 105 uint32 page_size = 0; |
| 111 if (!ibus_object_reader.PopUint32(&page_size)) { | 106 if (!ibus_object_reader.PopUint32(&page_size)) { |
| 112 LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: " | 107 LOG(ERROR) << "Invalid variant structure[IBusLookupTable]: " |
| 113 << "1st argument should be uint32."; | 108 << "1st argument should be uint32."; |
| 114 return false; | 109 return false; |
| 115 } | 110 } |
| 116 table->set_page_size(page_size); | 111 table->set_page_size(page_size); |
| 117 | 112 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 cursor_position_(0), | 201 cursor_position_(0), |
| 207 is_cursor_visible_(true), | 202 is_cursor_visible_(true), |
| 208 orientation_(IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL) { | 203 orientation_(IBUS_LOOKUP_TABLE_ORIENTATION_HORIZONTAL) { |
| 209 } | 204 } |
| 210 | 205 |
| 211 IBusLookupTable::~IBusLookupTable() { | 206 IBusLookupTable::~IBusLookupTable() { |
| 212 } | 207 } |
| 213 | 208 |
| 214 } // namespace ibus | 209 } // namespace ibus |
| 215 } // namespace chromeos | 210 } // namespace chromeos |
| OLD | NEW |