| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/common/extensions/api/input_ime/input_components_handler.h" | 5 #include "chrome/common/extensions/api/input_ime/input_components_handler.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 | 45 |
| 46 InputComponentsHandler::~InputComponentsHandler() { | 46 InputComponentsHandler::~InputComponentsHandler() { |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool InputComponentsHandler::Parse(Extension* extension, | 49 bool InputComponentsHandler::Parse(Extension* extension, |
| 50 base::string16* error) { | 50 base::string16* error) { |
| 51 scoped_ptr<InputComponents> info(new InputComponents); | 51 scoped_ptr<InputComponents> info(new InputComponents); |
| 52 const base::ListValue* list_value = NULL; | 52 const base::ListValue* list_value = NULL; |
| 53 if (!extension->manifest()->GetList(keys::kInputComponents, &list_value)) { | 53 if (!extension->manifest()->GetList(keys::kInputComponents, &list_value)) { |
| 54 *error = ASCIIToUTF16(errors::kInvalidInputComponents); | 54 *error = base::ASCIIToUTF16(errors::kInvalidInputComponents); |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 for (size_t i = 0; i < list_value->GetSize(); ++i) { | 57 for (size_t i = 0; i < list_value->GetSize(); ++i) { |
| 58 const base::DictionaryValue* module_value = NULL; | 58 const base::DictionaryValue* module_value = NULL; |
| 59 std::string name_str; | 59 std::string name_str; |
| 60 InputComponentType type; | 60 InputComponentType type; |
| 61 std::string id_str; | 61 std::string id_str; |
| 62 std::string description_str; | 62 std::string description_str; |
| 63 std::set<std::string> languages; | 63 std::set<std::string> languages; |
| 64 std::set<std::string> layouts; | 64 std::set<std::string> layouts; |
| 65 std::string shortcut_keycode_str; | 65 std::string shortcut_keycode_str; |
| 66 GURL input_view_url; | 66 GURL input_view_url; |
| 67 bool shortcut_alt = false; | 67 bool shortcut_alt = false; |
| 68 bool shortcut_ctrl = false; | 68 bool shortcut_ctrl = false; |
| 69 bool shortcut_shift = false; | 69 bool shortcut_shift = false; |
| 70 | 70 |
| 71 if (!list_value->GetDictionary(i, &module_value)) { | 71 if (!list_value->GetDictionary(i, &module_value)) { |
| 72 *error = ASCIIToUTF16(errors::kInvalidInputComponents); | 72 *error = base::ASCIIToUTF16(errors::kInvalidInputComponents); |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Get input_components[i].name. | 76 // Get input_components[i].name. |
| 77 if (!module_value->GetString(keys::kName, &name_str)) { | 77 if (!module_value->GetString(keys::kName, &name_str)) { |
| 78 *error = ErrorUtils::FormatErrorMessageUTF16( | 78 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 79 errors::kInvalidInputComponentName, | 79 errors::kInvalidInputComponentName, |
| 80 base::IntToString(i)); | 80 base::IntToString(i)); |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 const std::vector<std::string> | 217 const std::vector<std::string> |
| 218 InputComponentsHandler::PrerequisiteKeys() const { | 218 InputComponentsHandler::PrerequisiteKeys() const { |
| 219 return SingleKey(keys::kOptionsPage); | 219 return SingleKey(keys::kOptionsPage); |
| 220 } | 220 } |
| 221 | 221 |
| 222 const std::vector<std::string> InputComponentsHandler::Keys() const { | 222 const std::vector<std::string> InputComponentsHandler::Keys() const { |
| 223 return SingleKey(keys::kInputComponents); | 223 return SingleKey(keys::kInputComponents); |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace extensions | 226 } // namespace extensions |
| OLD | NEW |