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

Side by Side Diff: chrome/browser/chromeos/input_method/component_extension_ime_manager_impl.cc

Issue 13949015: Supporting multiple keyboard layouts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comment Created 7 years, 8 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 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 callback)); 133 callback));
134 } 134 }
135 135
136 bool ComponentExtensionIMEManagerImpl::IsInitialized() { 136 bool ComponentExtensionIMEManagerImpl::IsInitialized() {
137 return is_initialized_; 137 return is_initialized_;
138 } 138 }
139 139
140 // static 140 // static
141 bool ComponentExtensionIMEManagerImpl::ReadEngineComponent( 141 bool ComponentExtensionIMEManagerImpl::ReadEngineComponent(
142 const DictionaryValue& dict, 142 const DictionaryValue& dict,
143 IBusComponent::EngineDescription* out) { 143 ComponentExtensionEngine* out) {
144 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 144 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
145 DCHECK(out); 145 DCHECK(out);
146 std::string type; 146 std::string type;
147 if (!dict.GetString(extension_manifest_keys::kType, &type)) 147 if (!dict.GetString(extension_manifest_keys::kType, &type))
148 return false; 148 return false;
149 if (type != "ime") 149 if (type != "ime")
150 return false; 150 return false;
151 if (!dict.GetString(extension_manifest_keys::kId, &out->engine_id)) 151 if (!dict.GetString(extension_manifest_keys::kId, &out->engine_id))
152 return false; 152 return false;
153 if (!dict.GetString(extension_manifest_keys::kName, &out->display_name)) 153 if (!dict.GetString(extension_manifest_keys::kName, &out->display_name))
154 return false; 154 return false;
155 if (!dict.GetString(extension_manifest_keys::kLanguage, &out->language_code)) 155 if (!dict.GetString(extension_manifest_keys::kLanguage, &out->language_code))
156 return false; 156 return false;
157 157
158 const ListValue* layouts = NULL; 158 const ListValue* layouts = NULL;
159 if (!dict.GetList(extension_manifest_keys::kLayouts, &layouts)) 159 if (!dict.GetList(extension_manifest_keys::kLayouts, &layouts))
160 return false; 160 return false;
161 161
162 if (layouts->GetSize() > 0) { 162 for (size_t i = 0; i < layouts->GetSize(); ++i) {
163 if (!layouts->GetString(0, &out->layout)) 163 std::string buffer;
164 return false; 164 if (layouts->GetString(i, &buffer))
165 out->layouts.push_back(buffer);
165 } 166 }
166 return true; 167 return true;
167 } 168 }
168 169
169 // static 170 // static
170 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo( 171 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo(
171 const DictionaryValue& manifest, 172 const DictionaryValue& manifest,
172 const std::string& extension_id, 173 const std::string& extension_id,
173 ComponentExtensionIME* out) { 174 ComponentExtensionIME* out) {
174 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 175 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 const ListValue* component_list; 222 const ListValue* component_list;
222 if (!manifest->GetList(extension_manifest_keys::kInputComponents, 223 if (!manifest->GetList(extension_manifest_keys::kInputComponents,
223 &component_list)) 224 &component_list))
224 continue; 225 continue;
225 226
226 for (size_t i = 0; i < component_list->GetSize(); ++i) { 227 for (size_t i = 0; i < component_list->GetSize(); ++i) {
227 const DictionaryValue* dictionary; 228 const DictionaryValue* dictionary;
228 if (!component_list->GetDictionary(i, &dictionary)) 229 if (!component_list->GetDictionary(i, &dictionary))
229 continue; 230 continue;
230 231
231 IBusComponent::EngineDescription engine; 232 ComponentExtensionEngine engine;
232 ReadEngineComponent(*dictionary, &engine); 233 ReadEngineComponent(*dictionary, &engine);
233 component_ime.engines.push_back(engine); 234 component_ime.engines.push_back(engine);
234 } 235 }
235 out_imes->push_back(component_ime); 236 out_imes->push_back(component_ime);
236 } 237 }
237 } 238 }
238 239
239 void ComponentExtensionIMEManagerImpl::OnReadComponentExtensionsInfo( 240 void ComponentExtensionIMEManagerImpl::OnReadComponentExtensionsInfo(
240 std::vector<ComponentExtensionIME>* result, 241 std::vector<ComponentExtensionIME>* result,
241 const base::Closure& callback) { 242 const base::Closure& callback) {
242 DCHECK(thread_checker_.CalledOnValidThread()); 243 DCHECK(thread_checker_.CalledOnValidThread());
243 DCHECK(result); 244 DCHECK(result);
244 component_extension_list_ = *result; 245 component_extension_list_ = *result;
245 is_initialized_ = true; 246 is_initialized_ = true;
246 callback.Run(); 247 callback.Run();
247 } 248 }
248 249
249 } // namespace chromeos 250 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698