This source file includes following definitions.
- Parse
- Keys
#include "chrome/common/extensions/api/spellcheck/spellcheck_handler.h"
#include "base/strings/utf_string_conversions.h"
#include "extensions/common/manifest_constants.h"
namespace extensions {
namespace keys = manifest_keys;
namespace errors = manifest_errors;
SpellcheckDictionaryInfo::SpellcheckDictionaryInfo() {
}
SpellcheckDictionaryInfo::~SpellcheckDictionaryInfo() {
}
SpellcheckHandler::SpellcheckHandler() {
}
SpellcheckHandler::~SpellcheckHandler() {
}
bool SpellcheckHandler::Parse(Extension* extension, base::string16* error) {
const base::DictionaryValue* spellcheck_value = NULL;
if (!extension->manifest()->GetDictionary(keys::kSpellcheck,
&spellcheck_value)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheck);
return false;
}
scoped_ptr<SpellcheckDictionaryInfo> spellcheck_info(
new SpellcheckDictionaryInfo);
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLanguage) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryLanguage,
&spellcheck_info->language)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryLanguage);
return false;
}
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryLocale) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryLocale,
&spellcheck_info->locale)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryLocale);
return false;
}
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryFormat) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryFormat,
&spellcheck_info->format)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryFormat);
return false;
}
if (!spellcheck_value->HasKey(keys::kSpellcheckDictionaryPath) ||
!spellcheck_value->GetString(keys::kSpellcheckDictionaryPath,
&spellcheck_info->path)) {
*error = base::ASCIIToUTF16(errors::kInvalidSpellcheckDictionaryPath);
return false;
}
extension->SetManifestData(keys::kSpellcheck, spellcheck_info.release());
return true;
}
const std::vector<std::string> SpellcheckHandler::Keys() const {
return SingleKey(keys::kSpellcheck);
}
}