OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/chromeos/input_method/component_extension_ime_manager_i
mpl.h" | 5 #include "chrome/browser/chromeos/input_method/component_extension_ime_manager_i
mpl.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/extensions/component_loader.h" | 9 #include "chrome/browser/extensions/component_loader.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 callback)); | 122 callback)); |
123 } | 123 } |
124 | 124 |
125 bool ComponentExtensionIMEManagerImpl::IsInitialized() { | 125 bool ComponentExtensionIMEManagerImpl::IsInitialized() { |
126 return is_initialized_; | 126 return is_initialized_; |
127 } | 127 } |
128 | 128 |
129 // static | 129 // static |
130 bool ComponentExtensionIMEManagerImpl::ReadEngineComponent( | 130 bool ComponentExtensionIMEManagerImpl::ReadEngineComponent( |
131 const DictionaryValue& dict, | 131 const DictionaryValue& dict, |
132 IBusComponent::EngineDescription* out) { | 132 ComponentExtensionEngine* out) { |
133 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 133 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
134 DCHECK(out); | 134 DCHECK(out); |
135 std::string type; | 135 std::string type; |
136 if (!dict.GetString(extension_manifest_keys::kType, &type)) | 136 if (!dict.GetString(extension_manifest_keys::kType, &type)) |
137 return false; | 137 return false; |
138 if (type != "ime") | 138 if (type != "ime") |
139 return false; | 139 return false; |
140 if (!dict.GetString(extension_manifest_keys::kId, &out->engine_id)) | 140 if (!dict.GetString(extension_manifest_keys::kId, &out->engine_id)) |
141 return false; | 141 return false; |
142 if (!dict.GetString(extension_manifest_keys::kName, &out->display_name)) | 142 if (!dict.GetString(extension_manifest_keys::kName, &out->display_name)) |
143 return false; | 143 return false; |
144 if (!dict.GetString(extension_manifest_keys::kLanguage, &out->language_code)) | 144 if (!dict.GetString(extension_manifest_keys::kLanguage, &out->language_code)) |
145 return false; | 145 return false; |
146 | 146 |
147 const ListValue* layouts = NULL; | 147 const ListValue* layouts = NULL; |
148 if (!dict.GetList(extension_manifest_keys::kLayouts, &layouts)) | 148 if (!dict.GetList(extension_manifest_keys::kLayouts, &layouts)) |
149 return false; | 149 return false; |
150 | 150 |
151 if (layouts->GetSize() > 0) { | 151 for (size_t i = 0; i < layouts->GetSize(); ++i) { |
152 if (!layouts->GetString(0, &out->layout)) | 152 std::string buffer; |
153 return false; | 153 if (layouts->GetString(i, &buffer)) |
| 154 out->layouts.push_back(buffer); |
154 } | 155 } |
155 return true; | 156 return true; |
156 } | 157 } |
157 | 158 |
158 // static | 159 // static |
159 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo( | 160 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo( |
160 const DictionaryValue& manifest, | 161 const DictionaryValue& manifest, |
161 const std::string& extension_id, | 162 const std::string& extension_id, |
162 ComponentExtensionIME* out) { | 163 ComponentExtensionIME* out) { |
163 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 164 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 const ListValue* component_list; | 211 const ListValue* component_list; |
211 if (!manifest->GetList(extension_manifest_keys::kInputComponents, | 212 if (!manifest->GetList(extension_manifest_keys::kInputComponents, |
212 &component_list)) | 213 &component_list)) |
213 continue; | 214 continue; |
214 | 215 |
215 for (size_t i = 0; i < component_list->GetSize(); ++i) { | 216 for (size_t i = 0; i < component_list->GetSize(); ++i) { |
216 const DictionaryValue* dictionary; | 217 const DictionaryValue* dictionary; |
217 if (!component_list->GetDictionary(i, &dictionary)) | 218 if (!component_list->GetDictionary(i, &dictionary)) |
218 continue; | 219 continue; |
219 | 220 |
220 IBusComponent::EngineDescription engine; | 221 ComponentExtensionEngine engine; |
221 ReadEngineComponent(*dictionary, &engine); | 222 ReadEngineComponent(*dictionary, &engine); |
222 component_ime.engines.push_back(engine); | 223 component_ime.engines.push_back(engine); |
223 } | 224 } |
224 out_imes->push_back(component_ime); | 225 out_imes->push_back(component_ime); |
225 } | 226 } |
226 } | 227 } |
227 | 228 |
228 void ComponentExtensionIMEManagerImpl::OnReadComponentExtensionsInfo( | 229 void ComponentExtensionIMEManagerImpl::OnReadComponentExtensionsInfo( |
229 std::vector<ComponentExtensionIME>* result, | 230 std::vector<ComponentExtensionIME>* result, |
230 const base::Closure& callback) { | 231 const base::Closure& callback) { |
231 DCHECK(thread_checker_.CalledOnValidThread()); | 232 DCHECK(thread_checker_.CalledOnValidThread()); |
232 DCHECK(result); | 233 DCHECK(result); |
233 component_extension_list_ = *result; | 234 component_extension_list_ = *result; |
234 is_initialized_ = true; | 235 is_initialized_ = true; |
235 callback.Run(); | 236 callback.Run(); |
236 } | 237 } |
237 | 238 |
238 } // namespace chromeos | 239 } // namespace chromeos |
OLD | NEW |