| Index: chrome/common/extensions/api/input_ime/input_components_handler.cc
|
| diff --git a/chrome/common/extensions/api/input_ime/input_components_handler.cc b/chrome/common/extensions/api/input_ime/input_components_handler.cc
|
| index ce48bef2206b56dd0bc84160df2e5ea51f355e63..216ab0780f90f71ef892b0515a8286e53cece227 100644
|
| --- a/chrome/common/extensions/api/input_ime/input_components_handler.cc
|
| +++ b/chrome/common/extensions/api/input_ime/input_components_handler.cc
|
| @@ -11,8 +11,12 @@
|
| #include "base/values.h"
|
| #include "chrome/common/extensions/extension.h"
|
| #include "chrome/common/extensions/extension_manifest_constants.h"
|
| +#include "chrome/common/extensions/manifest.h"
|
| #include "extensions/common/error_utils.h"
|
|
|
| +namespace keys = extension_manifest_keys;
|
| +namespace errors = extension_manifest_errors;
|
| +
|
| namespace extensions {
|
|
|
| InputComponentInfo::InputComponentInfo()
|
| @@ -31,7 +35,7 @@ InputComponents::~InputComponents() {}
|
| const std::vector<InputComponentInfo>* InputComponents::GetInputComponents(
|
| const Extension* extension) {
|
| InputComponents* info = static_cast<InputComponents*>(
|
| - extension->GetManifestData(extension_manifest_keys::kInputComponents));
|
| + extension->GetManifestData(keys::kInputComponents));
|
| return info ? &info->input_components : NULL;
|
| }
|
|
|
| @@ -41,13 +45,12 @@ InputComponentsHandler::InputComponentsHandler() {
|
| InputComponentsHandler::~InputComponentsHandler() {
|
| }
|
|
|
| -bool InputComponentsHandler::Parse(const base::Value* value,
|
| - Extension* extension,
|
| +bool InputComponentsHandler::Parse(Extension* extension,
|
| string16* error) {
|
| scoped_ptr<InputComponents> info(new InputComponents);
|
| const ListValue* list_value = NULL;
|
| - if (!value->GetAsList(&list_value)) {
|
| - *error = ASCIIToUTF16(extension_manifest_errors::kInvalidInputComponents);
|
| + if (!extension->manifest()->GetList(keys::kInputComponents, &list_value)) {
|
| + *error = ASCIIToUTF16(errors::kInvalidInputComponents);
|
| return false;
|
| }
|
| for (size_t i = 0; i < list_value->GetSize(); ++i) {
|
| @@ -64,61 +67,59 @@ bool InputComponentsHandler::Parse(const base::Value* value,
|
| bool shortcut_shift = false;
|
|
|
| if (!list_value->GetDictionary(i, &module_value)) {
|
| - *error = ASCIIToUTF16(extension_manifest_errors::kInvalidInputComponents);
|
| + *error = ASCIIToUTF16(errors::kInvalidInputComponents);
|
| return false;
|
| }
|
|
|
| // Get input_components[i].name.
|
| - if (!module_value->GetString(extension_manifest_keys::kName, &name_str)) {
|
| + if (!module_value->GetString(keys::kName, &name_str)) {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentName,
|
| + errors::kInvalidInputComponentName,
|
| base::IntToString(i));
|
| return false;
|
| }
|
|
|
| // Get input_components[i].type.
|
| std::string type_str;
|
| - if (module_value->GetString(extension_manifest_keys::kType, &type_str)) {
|
| + if (module_value->GetString(keys::kType, &type_str)) {
|
| if (type_str == "ime") {
|
| type = INPUT_COMPONENT_TYPE_IME;
|
| } else {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentType,
|
| + errors::kInvalidInputComponentType,
|
| base::IntToString(i));
|
| return false;
|
| }
|
| } else {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentType,
|
| + errors::kInvalidInputComponentType,
|
| base::IntToString(i));
|
| return false;
|
| }
|
|
|
| // Get input_components[i].id.
|
| - if (!module_value->GetString(extension_manifest_keys::kId, &id_str)) {
|
| + if (!module_value->GetString(keys::kId, &id_str)) {
|
| id_str = "";
|
| }
|
|
|
| // Get input_components[i].description.
|
| - if (!module_value->GetString(extension_manifest_keys::kDescription,
|
| - &description_str)) {
|
| + if (!module_value->GetString(keys::kDescription, &description_str)) {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentDescription,
|
| + errors::kInvalidInputComponentDescription,
|
| base::IntToString(i));
|
| return false;
|
| }
|
| +
|
| // Get input_components[i].language.
|
| - if (!module_value->GetString(extension_manifest_keys::kLanguage,
|
| - &language_str)) {
|
| + if (!module_value->GetString(keys::kLanguage, &language_str)) {
|
| language_str = "";
|
| }
|
|
|
| // Get input_components[i].layouts.
|
| const ListValue* layouts_value = NULL;
|
| - if (!module_value->GetList(extension_manifest_keys::kLayouts,
|
| - &layouts_value)) {
|
| + if (!module_value->GetList(keys::kLayouts, &layouts_value)) {
|
| *error = ASCIIToUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentLayouts);
|
| + errors::kInvalidInputComponentLayouts);
|
| return false;
|
| }
|
|
|
| @@ -126,47 +127,43 @@ bool InputComponentsHandler::Parse(const base::Value* value,
|
| std::string layout_name_str;
|
| if (!layouts_value->GetString(j, &layout_name_str)) {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentLayoutName,
|
| + errors::kInvalidInputComponentLayoutName,
|
| base::IntToString(i), base::IntToString(j));
|
| return false;
|
| }
|
| layouts.insert(layout_name_str);
|
| }
|
|
|
| - if (module_value->HasKey(extension_manifest_keys::kShortcutKey)) {
|
| + if (module_value->HasKey(keys::kShortcutKey)) {
|
| const DictionaryValue* shortcut_value = NULL;
|
| - if (!module_value->GetDictionary(extension_manifest_keys::kShortcutKey,
|
| + if (!module_value->GetDictionary(keys::kShortcutKey,
|
| &shortcut_value)) {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentShortcutKey,
|
| + errors::kInvalidInputComponentShortcutKey,
|
| base::IntToString(i));
|
| return false;
|
| }
|
|
|
| // Get input_components[i].shortcut_keycode.
|
| - if (!shortcut_value->GetString(extension_manifest_keys::kKeycode,
|
| - &shortcut_keycode_str)) {
|
| + if (!shortcut_value->GetString(keys::kKeycode, &shortcut_keycode_str)) {
|
| *error = ErrorUtils::FormatErrorMessageUTF16(
|
| - extension_manifest_errors::kInvalidInputComponentShortcutKeycode,
|
| + errors::kInvalidInputComponentShortcutKeycode,
|
| base::IntToString(i));
|
| return false;
|
| }
|
|
|
| // Get input_components[i].shortcut_alt.
|
| - if (!shortcut_value->GetBoolean(extension_manifest_keys::kAltKey,
|
| - &shortcut_alt)) {
|
| + if (!shortcut_value->GetBoolean(keys::kAltKey, &shortcut_alt)) {
|
| shortcut_alt = false;
|
| }
|
|
|
| // Get input_components[i].shortcut_ctrl.
|
| - if (!shortcut_value->GetBoolean(extension_manifest_keys::kCtrlKey,
|
| - &shortcut_ctrl)) {
|
| + if (!shortcut_value->GetBoolean(keys::kCtrlKey, &shortcut_ctrl)) {
|
| shortcut_ctrl = false;
|
| }
|
|
|
| // Get input_components[i].shortcut_shift.
|
| - if (!shortcut_value->GetBoolean(extension_manifest_keys::kShiftKey,
|
| - &shortcut_shift)) {
|
| + if (!shortcut_value->GetBoolean(keys::kShiftKey, &shortcut_shift)) {
|
| shortcut_shift = false;
|
| }
|
| }
|
| @@ -184,8 +181,7 @@ bool InputComponentsHandler::Parse(const base::Value* value,
|
| info->input_components.back().shortcut_ctrl = shortcut_ctrl;
|
| info->input_components.back().shortcut_shift = shortcut_shift;
|
| }
|
| - extension->SetManifestData(extension_manifest_keys::kInputComponents,
|
| - info.release());
|
| + extension->SetManifestData(keys::kInputComponents, info.release());
|
| return true;
|
| }
|
|
|
|
|