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

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

Issue 22794012: Rename extension_manifest_keys namespace to extensions::manifest_keys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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"
11 #include "chrome/browser/extensions/extension_system.h" 11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/extension_file_util.h" 15 #include "chrome/common/extensions/extension_file_util.h"
16 #include "chrome/common/extensions/extension_l10n_util.h" 16 #include "chrome/common/extensions/extension_l10n_util.h"
17 #include "chrome/common/extensions/extension_manifest_constants.h"
18 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "extensions/common/manifest_constants.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 20
21 namespace chromeos { 21 namespace chromeos {
22 22
23 namespace { 23 namespace {
24 24
25 struct WhitelistedComponentExtensionIME { 25 struct WhitelistedComponentExtensionIME {
26 const char* id; 26 const char* id;
27 const char* path; 27 const char* path;
28 } whitelisted_component_extension[] = { 28 } whitelisted_component_extension[] = {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return is_initialized_; 170 return is_initialized_;
171 } 171 }
172 172
173 // static 173 // static
174 bool ComponentExtensionIMEManagerImpl::ReadEngineComponent( 174 bool ComponentExtensionIMEManagerImpl::ReadEngineComponent(
175 const DictionaryValue& dict, 175 const DictionaryValue& dict,
176 ComponentExtensionEngine* out) { 176 ComponentExtensionEngine* out) {
177 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 177 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
178 DCHECK(out); 178 DCHECK(out);
179 std::string type; 179 std::string type;
180 if (!dict.GetString(extension_manifest_keys::kType, &type)) 180 if (!dict.GetString(extensions::manifest_keys::kType, &type))
181 return false; 181 return false;
182 if (type != "ime") 182 if (type != "ime")
183 return false; 183 return false;
184 if (!dict.GetString(extension_manifest_keys::kId, &out->engine_id)) 184 if (!dict.GetString(extensions::manifest_keys::kId, &out->engine_id))
185 return false; 185 return false;
186 if (!dict.GetString(extension_manifest_keys::kName, &out->display_name)) 186 if (!dict.GetString(extensions::manifest_keys::kName, &out->display_name))
187 return false; 187 return false;
188 188
189 std::set<std::string> languages; 189 std::set<std::string> languages;
190 const base::Value* language_value = NULL; 190 const base::Value* language_value = NULL;
191 if (dict.Get(extension_manifest_keys::kLanguage, &language_value)) { 191 if (dict.Get(extensions::manifest_keys::kLanguage, &language_value)) {
192 if (language_value->GetType() == base::Value::TYPE_STRING) { 192 if (language_value->GetType() == base::Value::TYPE_STRING) {
193 std::string language_str; 193 std::string language_str;
194 language_value->GetAsString(&language_str); 194 language_value->GetAsString(&language_str);
195 languages.insert(language_str); 195 languages.insert(language_str);
196 } else if (language_value->GetType() == base::Value::TYPE_LIST) { 196 } else if (language_value->GetType() == base::Value::TYPE_LIST) {
197 const base::ListValue* language_list = NULL; 197 const base::ListValue* language_list = NULL;
198 language_value->GetAsList(&language_list); 198 language_value->GetAsList(&language_list);
199 for (size_t j = 0; j < language_list->GetSize(); ++j) { 199 for (size_t j = 0; j < language_list->GetSize(); ++j) {
200 std::string language_str; 200 std::string language_str;
201 if (language_list->GetString(j, &language_str)) 201 if (language_list->GetString(j, &language_str))
202 languages.insert(language_str); 202 languages.insert(language_str);
203 } 203 }
204 } 204 }
205 } 205 }
206 DCHECK(!languages.empty()); 206 DCHECK(!languages.empty());
207 out->language_codes.assign(languages.begin(), languages.end()); 207 out->language_codes.assign(languages.begin(), languages.end());
208 208
209 const ListValue* layouts = NULL; 209 const ListValue* layouts = NULL;
210 if (!dict.GetList(extension_manifest_keys::kLayouts, &layouts)) 210 if (!dict.GetList(extensions::manifest_keys::kLayouts, &layouts))
211 return false; 211 return false;
212 212
213 for (size_t i = 0; i < layouts->GetSize(); ++i) { 213 for (size_t i = 0; i < layouts->GetSize(); ++i) {
214 std::string buffer; 214 std::string buffer;
215 if (layouts->GetString(i, &buffer)) 215 if (layouts->GetString(i, &buffer))
216 out->layouts.push_back(buffer); 216 out->layouts.push_back(buffer);
217 } 217 }
218 return true; 218 return true;
219 } 219 }
220 220
221 // static 221 // static
222 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo( 222 bool ComponentExtensionIMEManagerImpl::ReadExtensionInfo(
223 const DictionaryValue& manifest, 223 const DictionaryValue& manifest,
224 const std::string& extension_id, 224 const std::string& extension_id,
225 ComponentExtensionIME* out) { 225 ComponentExtensionIME* out) {
226 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 226 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
227 if (!manifest.GetString(extension_manifest_keys::kDescription, 227 if (!manifest.GetString(extensions::manifest_keys::kDescription,
228 &out->description)) 228 &out->description))
229 return false; 229 return false;
230 std::string url_string; 230 std::string url_string;
231 if (!manifest.GetString(extension_manifest_keys::kOptionsPage, &url_string)) 231 if (!manifest.GetString(extensions::manifest_keys::kOptionsPage, &url_string))
232 return true; // It's okay to return true on no option page case. 232 return true; // It's okay to return true on no option page case.
233 233
234 GURL url = extensions::Extension::GetResourceURL( 234 GURL url = extensions::Extension::GetResourceURL(
235 extensions::Extension::GetBaseURLFromExtensionId(extension_id), 235 extensions::Extension::GetBaseURLFromExtensionId(extension_id),
236 url_string); 236 url_string);
237 if (!url.is_valid()) 237 if (!url.is_valid())
238 return false; 238 return false;
239 out->options_page_url = url; 239 out->options_page_url = url;
240 return true; 240 return true;
241 } 241 }
(...skipping 22 matching lines...) Expand all
264 if (!manifest.get()) 264 if (!manifest.get())
265 continue; 265 continue;
266 266
267 if (!ReadExtensionInfo(*manifest.get(), 267 if (!ReadExtensionInfo(*manifest.get(),
268 whitelisted_component_extension[i].id, 268 whitelisted_component_extension[i].id,
269 &component_ime)) 269 &component_ime))
270 continue; 270 continue;
271 component_ime.id = whitelisted_component_extension[i].id; 271 component_ime.id = whitelisted_component_extension[i].id;
272 272
273 const ListValue* component_list; 273 const ListValue* component_list;
274 if (!manifest->GetList(extension_manifest_keys::kInputComponents, 274 if (!manifest->GetList(extensions::manifest_keys::kInputComponents,
275 &component_list)) 275 &component_list))
276 continue; 276 continue;
277 277
278 for (size_t i = 0; i < component_list->GetSize(); ++i) { 278 for (size_t i = 0; i < component_list->GetSize(); ++i) {
279 const DictionaryValue* dictionary; 279 const DictionaryValue* dictionary;
280 if (!component_list->GetDictionary(i, &dictionary)) 280 if (!component_list->GetDictionary(i, &dictionary))
281 continue; 281 continue;
282 282
283 ComponentExtensionEngine engine; 283 ComponentExtensionEngine engine;
284 ReadEngineComponent(*dictionary, &engine); 284 ReadEngineComponent(*dictionary, &engine);
285 component_ime.engines.push_back(engine); 285 component_ime.engines.push_back(engine);
286 } 286 }
287 out_imes->push_back(component_ime); 287 out_imes->push_back(component_ime);
288 } 288 }
289 } 289 }
290 290
291 void ComponentExtensionIMEManagerImpl::OnReadComponentExtensionsInfo( 291 void ComponentExtensionIMEManagerImpl::OnReadComponentExtensionsInfo(
292 std::vector<ComponentExtensionIME>* result, 292 std::vector<ComponentExtensionIME>* result,
293 const base::Closure& callback) { 293 const base::Closure& callback) {
294 DCHECK(thread_checker_.CalledOnValidThread()); 294 DCHECK(thread_checker_.CalledOnValidThread());
295 DCHECK(result); 295 DCHECK(result);
296 component_extension_list_ = *result; 296 component_extension_list_ = *result;
297 is_initialized_ = true; 297 is_initialized_ = true;
298 callback.Run(); 298 callback.Run();
299 } 299 }
300 300
301 } // namespace chromeos 301 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/kiosk_app_data.cc ('k') | chrome/browser/extensions/admin_policy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698