OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "ios/chrome/browser/autofill/autofill_agent.h" | 5 #import "ios/chrome/browser/autofill/autofill_agent.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 [jsAutofillManager_ fillActiveFormField:base::SysUTF8ToNSString(dataString) | 803 [jsAutofillManager_ fillActiveFormField:base::SysUTF8ToNSString(dataString) |
804 completionHandler:suggestionHandledCompletion_]; | 804 completionHandler:suggestionHandledCompletion_]; |
805 suggestionHandledCompletion_ = nil; | 805 suggestionHandledCompletion_ = nil; |
806 } | 806 } |
807 | 807 |
808 - (void)onFormDataFilled:(const autofill::FormData&)form { | 808 - (void)onFormDataFilled:(const autofill::FormData&)form { |
809 std::unique_ptr<base::DictionaryValue> formData(new base::DictionaryValue); | 809 std::unique_ptr<base::DictionaryValue> formData(new base::DictionaryValue); |
810 formData->SetString("formName", base::UTF16ToUTF8(form.name)); | 810 formData->SetString("formName", base::UTF16ToUTF8(form.name)); |
811 // Note: Destruction of all child base::Value types is handled by the root | 811 // Note: Destruction of all child base::Value types is handled by the root |
812 // formData object on its own destruction. | 812 // formData object on its own destruction. |
813 base::DictionaryValue* fieldsData = new base::DictionaryValue; | 813 auto fieldsData = base::MakeUnique<base::DictionaryValue>(); |
814 | 814 |
815 const std::vector<autofill::FormFieldData>& fields = form.fields; | 815 const std::vector<autofill::FormFieldData>& fields = form.fields; |
816 for (const auto& fieldData : fields) { | 816 for (const auto& fieldData : fields) { |
817 fieldsData->SetStringWithoutPathExpansion(base::UTF16ToUTF8(fieldData.name), | 817 fieldsData->SetStringWithoutPathExpansion(base::UTF16ToUTF8(fieldData.name), |
818 fieldData.value); | 818 fieldData.value); |
819 } | 819 } |
820 formData->Set("fields", fieldsData); | 820 formData->Set("fields", std::move(fieldsData)); |
821 | 821 |
822 // Stringify the JSON data and send it to the UIWebView-side fillForm method. | 822 // Stringify the JSON data and send it to the UIWebView-side fillForm method. |
823 std::string dataString; | 823 std::string dataString; |
824 base::JSONWriter::Write(*formData.get(), &dataString); | 824 base::JSONWriter::Write(*formData.get(), &dataString); |
825 | 825 |
826 // It is possible that the fill was not initiated by selecting a suggestion. | 826 // It is possible that the fill was not initiated by selecting a suggestion. |
827 // In this case we provide an empty callback. | 827 // In this case we provide an empty callback. |
828 if (!suggestionHandledCompletion_) | 828 if (!suggestionHandledCompletion_) |
829 suggestionHandledCompletion_ = [^{ | 829 suggestionHandledCompletion_ = [^{ |
830 } copy]; | 830 } copy]; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 } | 873 } |
874 predictionData.SetWithoutPathExpansion(base::UTF16ToUTF8(formData.name), | 874 predictionData.SetWithoutPathExpansion(base::UTF16ToUTF8(formData.name), |
875 std::move(formJSONData)); | 875 std::move(formJSONData)); |
876 } | 876 } |
877 std::string dataString; | 877 std::string dataString; |
878 base::JSONWriter::Write(predictionData, &dataString); | 878 base::JSONWriter::Write(predictionData, &dataString); |
879 [jsAutofillManager_ fillPredictionData:base::SysUTF8ToNSString(dataString)]; | 879 [jsAutofillManager_ fillPredictionData:base::SysUTF8ToNSString(dataString)]; |
880 } | 880 } |
881 | 881 |
882 @end | 882 @end |
OLD | NEW |