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/browser/extensions/api/input_ime/input_ime_api.h" | 5 #include "chrome/browser/extensions/api/input_ime/input_ime_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 ListValue* candidates, | 654 ListValue* candidates, |
655 std::vector<chromeos::InputMethodEngine::Candidate>* output) { | 655 std::vector<chromeos::InputMethodEngine::Candidate>* output) { |
656 for (size_t i = 0; i < candidates->GetSize(); ++i) { | 656 for (size_t i = 0; i < candidates->GetSize(); ++i) { |
657 DictionaryValue* candidate_dict; | 657 DictionaryValue* candidate_dict; |
658 EXTENSION_FUNCTION_VALIDATE(candidates->GetDictionary(i, &candidate_dict)); | 658 EXTENSION_FUNCTION_VALIDATE(candidates->GetDictionary(i, &candidate_dict)); |
659 | 659 |
660 std::string candidate; | 660 std::string candidate; |
661 int id; | 661 int id; |
662 std::string label; | 662 std::string label; |
663 std::string annotation; | 663 std::string annotation; |
664 chromeos::InputMethodEngine::UsageEntry usage_entry; | |
664 | 665 |
665 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetString(keys::kCandidateKey, | 666 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetString(keys::kCandidateKey, |
666 &candidate)); | 667 &candidate)); |
667 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetInteger(keys::kIdKey, &id)); | 668 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetInteger(keys::kIdKey, &id)); |
668 | 669 |
669 if (candidate_dict->HasKey(keys::kLabelKey)) { | 670 if (candidate_dict->HasKey(keys::kLabelKey)) { |
670 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetString(keys::kLabelKey, | 671 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetString(keys::kLabelKey, |
671 &label)); | 672 &label)); |
672 } | 673 } |
673 if (candidate_dict->HasKey(keys::kAnnotationKey)) { | 674 if (candidate_dict->HasKey(keys::kAnnotationKey)) { |
674 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetString( | 675 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetString( |
675 keys::kAnnotationKey, | 676 keys::kAnnotationKey, |
676 &annotation)); | 677 &annotation)); |
677 } | 678 } |
678 | 679 |
680 if (candidate_dict->HasKey(keys::kUsageKey)) { | |
681 DictionaryValue* usage_dict; | |
682 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetDictionary(keys::kUsageKey, | |
683 &usage_dict)); | |
684 if (usage_dict->HasKey(keys::kUsageTitleKey) && | |
685 usage_dict->HasKey(keys::kUsageBodyKey)) { | |
Matt Perry
2012/11/30 20:38:08
Looking at the json, "title" and "body" are not op
Seigo Nonaka
2012/12/01 15:31:18
Done.
| |
686 EXTENSION_FUNCTION_VALIDATE(usage_dict->GetString(keys::kUsageTitleKey, | |
687 &usage_entry.title)); | |
688 EXTENSION_FUNCTION_VALIDATE(usage_dict->GetString(keys::kUsageBodyKey, | |
689 &usage_entry.body)); | |
690 } | |
691 } | |
692 | |
679 output->push_back(chromeos::InputMethodEngine::Candidate()); | 693 output->push_back(chromeos::InputMethodEngine::Candidate()); |
680 output->back().value = candidate; | 694 output->back().value = candidate; |
681 output->back().id = id; | 695 output->back().id = id; |
682 output->back().label = label; | 696 output->back().label = label; |
683 output->back().annotation = annotation; | 697 output->back().annotation = annotation; |
698 output->back().usage = usage_entry; | |
684 | 699 |
685 if (candidate_dict->HasKey(keys::kCandidatesKey)) { | 700 if (candidate_dict->HasKey(keys::kCandidatesKey)) { |
686 ListValue* sub_list; | 701 ListValue* sub_list; |
687 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetList(keys::kCandidatesKey, | 702 EXTENSION_FUNCTION_VALIDATE(candidate_dict->GetList(keys::kCandidatesKey, |
688 &sub_list)); | 703 &sub_list)); |
689 if (!ReadCandidates(sub_list, &(output->back().candidates))) { | 704 if (!ReadCandidates(sub_list, &(output->back().candidates))) { |
690 error_ = kErrorBadCandidateList; | 705 error_ = kErrorBadCandidateList; |
691 return false; | 706 return false; |
692 } | 707 } |
693 } | 708 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); | 831 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(1, &handled)); |
817 | 832 |
818 InputImeEventRouter::GetInstance()->OnEventHandled( | 833 InputImeEventRouter::GetInstance()->OnEventHandled( |
819 extension_id(), request_id_str, handled); | 834 extension_id(), request_id_str, handled); |
820 | 835 |
821 return true; | 836 return true; |
822 } | 837 } |
823 #endif | 838 #endif |
824 | 839 |
825 } // namespace extensions | 840 } // namespace extensions |
OLD | NEW |