Chromium Code Reviews| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 GURL options_page_url; | |
| 67 bool shortcut_alt = false; | 68 bool shortcut_alt = false; |
| 68 bool shortcut_ctrl = false; | 69 bool shortcut_ctrl = false; |
| 69 bool shortcut_shift = false; | 70 bool shortcut_shift = false; |
| 70 | 71 |
| 71 if (!list_value->GetDictionary(i, &module_value)) { | 72 if (!list_value->GetDictionary(i, &module_value)) { |
| 72 *error = base::ASCIIToUTF16(errors::kInvalidInputComponents); | 73 *error = base::ASCIIToUTF16(errors::kInvalidInputComponents); |
| 73 return false; | 74 return false; |
| 74 } | 75 } |
| 75 | 76 |
| 76 // Get input_components[i].name. | 77 // Get input_components[i].name. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 if (module_value->GetString(keys::kInputView, &input_view_str)) { | 188 if (module_value->GetString(keys::kInputView, &input_view_str)) { |
| 188 input_view_url = extension->GetResourceURL(input_view_str); | 189 input_view_url = extension->GetResourceURL(input_view_str); |
| 189 if (!input_view_url.is_valid()) { | 190 if (!input_view_url.is_valid()) { |
| 190 *error = ErrorUtils::FormatErrorMessageUTF16( | 191 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 191 errors::kInvalidInputView, | 192 errors::kInvalidInputView, |
| 192 base::IntToString(i)); | 193 base::IntToString(i)); |
| 193 return false; | 194 return false; |
| 194 } | 195 } |
| 195 } | 196 } |
| 196 | 197 |
| 198 // Get input_components[i].options_page_url. | |
| 199 // Note: 'options_page_url' is optional in manifest. | |
|
not at google - send to devlin
2014/01/14 17:28:06
it's just "options_page"?
Shu Chen
2014/01/15 05:24:54
Done.
| |
| 200 std::string options_page_str; | |
| 201 if (module_value->GetString(keys::kImeOptionsPage, &options_page_str)) { | |
| 202 options_page_url = extension->GetResourceURL(options_page_str); | |
| 203 if (!options_page_url.is_valid()) { | |
| 204 // Fall back to extension's options page. | |
| 205 // This is for backward compatibility. | |
| 206 options_page_url = extensions::ManifestURL::GetOptionsPage(extension); | |
| 207 } | |
| 208 } | |
|
kevers
2014/01/14 19:33:08
Missing else block? options_page_url does not app
Shu Chen
2014/01/15 05:24:54
Done.
| |
| 209 | |
| 197 info->input_components.push_back(InputComponentInfo()); | 210 info->input_components.push_back(InputComponentInfo()); |
| 198 info->input_components.back().name = name_str; | 211 info->input_components.back().name = name_str; |
| 199 info->input_components.back().type = type; | 212 info->input_components.back().type = type; |
| 200 info->input_components.back().id = id_str; | 213 info->input_components.back().id = id_str; |
| 201 info->input_components.back().description = description_str; | 214 info->input_components.back().description = description_str; |
| 202 info->input_components.back().languages = languages; | 215 info->input_components.back().languages = languages; |
| 203 info->input_components.back().layouts.insert(layouts.begin(), | 216 info->input_components.back().layouts.insert(layouts.begin(), |
| 204 layouts.end()); | 217 layouts.end()); |
| 205 info->input_components.back().shortcut_keycode = shortcut_keycode_str; | 218 info->input_components.back().shortcut_keycode = shortcut_keycode_str; |
| 206 info->input_components.back().shortcut_alt = shortcut_alt; | 219 info->input_components.back().shortcut_alt = shortcut_alt; |
| 207 info->input_components.back().shortcut_ctrl = shortcut_ctrl; | 220 info->input_components.back().shortcut_ctrl = shortcut_ctrl; |
| 208 info->input_components.back().shortcut_shift = shortcut_shift; | 221 info->input_components.back().shortcut_shift = shortcut_shift; |
| 209 info->input_components.back().options_page_url = | 222 info->input_components.back().options_page_url = options_page_url; |
| 210 extensions::ManifestURL::GetOptionsPage(extension); | |
| 211 info->input_components.back().input_view_url = input_view_url; | 223 info->input_components.back().input_view_url = input_view_url; |
| 212 } | 224 } |
| 213 extension->SetManifestData(keys::kInputComponents, info.release()); | 225 extension->SetManifestData(keys::kInputComponents, info.release()); |
| 214 return true; | 226 return true; |
| 215 } | 227 } |
| 216 | 228 |
| 217 const std::vector<std::string> | 229 const std::vector<std::string> |
| 218 InputComponentsHandler::PrerequisiteKeys() const { | 230 InputComponentsHandler::PrerequisiteKeys() const { |
| 219 return SingleKey(keys::kOptionsPage); | 231 return SingleKey(keys::kOptionsPage); |
| 220 } | 232 } |
| 221 | 233 |
| 222 const std::vector<std::string> InputComponentsHandler::Keys() const { | 234 const std::vector<std::string> InputComponentsHandler::Keys() const { |
| 223 return SingleKey(keys::kInputComponents); | 235 return SingleKey(keys::kInputComponents); |
| 224 } | 236 } |
| 225 | 237 |
| 226 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |