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 "chrome/common/extensions/api/input_ime/input_components_handler.h" | 5 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 // Get input_components[i].language. | 113 // Get input_components[i].language. |
114 if (!module_value->GetString(keys::kLanguage, &language_str)) { | 114 if (!module_value->GetString(keys::kLanguage, &language_str)) { |
115 language_str = ""; | 115 language_str = ""; |
116 } | 116 } |
117 | 117 |
118 // Get input_components[i].layouts. | 118 // Get input_components[i].layouts. |
119 const ListValue* layouts_value = NULL; | 119 const ListValue* layouts_value = NULL; |
120 if (!module_value->GetList(keys::kLayouts, &layouts_value)) { | 120 if (module_value->GetList(keys::kLayouts, &layouts_value)) { |
121 *error = ASCIIToUTF16( | 121 for (size_t j = 0; j < layouts_value->GetSize(); ++j) { |
122 errors::kInvalidInputComponentLayouts); | 122 std::string layout_name_str; |
123 return false; | 123 if (!layouts_value->GetString(j, &layout_name_str)) { |
124 } | 124 *error = ErrorUtils::FormatErrorMessageUTF16( |
125 | 125 errors::kInvalidInputComponentLayoutName, |
126 for (size_t j = 0; j < layouts_value->GetSize(); ++j) { | 126 base::IntToString(i), base::IntToString(j)); |
127 std::string layout_name_str; | 127 return false; |
128 if (!layouts_value->GetString(j, &layout_name_str)) { | 128 } |
129 *error = ErrorUtils::FormatErrorMessageUTF16( | 129 layouts.insert(layout_name_str); |
130 errors::kInvalidInputComponentLayoutName, | |
131 base::IntToString(i), base::IntToString(j)); | |
132 return false; | |
133 } | 130 } |
134 layouts.insert(layout_name_str); | |
135 } | 131 } |
136 | 132 |
137 if (module_value->HasKey(keys::kShortcutKey)) { | 133 if (module_value->HasKey(keys::kShortcutKey)) { |
138 const DictionaryValue* shortcut_value = NULL; | 134 const DictionaryValue* shortcut_value = NULL; |
139 if (!module_value->GetDictionary(keys::kShortcutKey, | 135 if (!module_value->GetDictionary(keys::kShortcutKey, |
140 &shortcut_value)) { | 136 &shortcut_value)) { |
141 *error = ErrorUtils::FormatErrorMessageUTF16( | 137 *error = ErrorUtils::FormatErrorMessageUTF16( |
142 errors::kInvalidInputComponentShortcutKey, | 138 errors::kInvalidInputComponentShortcutKey, |
143 base::IntToString(i)); | 139 base::IntToString(i)); |
144 return false; | 140 return false; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 } | 179 } |
184 extension->SetManifestData(keys::kInputComponents, info.release()); | 180 extension->SetManifestData(keys::kInputComponents, info.release()); |
185 return true; | 181 return true; |
186 } | 182 } |
187 | 183 |
188 const std::vector<std::string> InputComponentsHandler::Keys() const { | 184 const std::vector<std::string> InputComponentsHandler::Keys() const { |
189 return SingleKey(keys::kInputComponents); | 185 return SingleKey(keys::kInputComponents); |
190 } | 186 } |
191 | 187 |
192 } // namespace extensions | 188 } // namespace extensions |
OLD | NEW |