Commit 0e925379 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[AF] Makes autofill_agent accept FormDataPredictions instead of FormStructure

This CL changes the autofill_agent in iOS so that it expects a vector of

This makes it easier to fiddle the displayed type prediction (e.g., from
overal to server) and makes the interface more similar to that of Desktop.

autofill: :FormDataPredictions instead of a vector FormStructure pointers.
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I79d45ae585d98621b03d2753829405ee47bae8d3
Reviewed-on: https://chromium-review.googlesource.com/953206Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541798}
parent 07845935
......@@ -9,13 +9,13 @@
#include "base/memory/weak_ptr.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/common/form_data_predictions.h"
#import "components/autofill/ios/browser/form_suggestion_provider.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h"
namespace autofill {
class AutofillPopupDelegate;
struct FormData;
class FormStructure;
}
class PrefService;
......@@ -53,7 +53,7 @@ class WebState;
// Renders the field type predictions specified in |forms|. This method is a
// no-op if the relevant experiment is not enabled.
- (void)renderAutofillTypePredictions:
(const std::vector<autofill::FormStructure*>&)forms;
(const std::vector<autofill::FormDataPredictions>&)forms;
@end
......
......@@ -925,24 +925,21 @@ void GetFormAndField(autofill::FormData* form,
}
- (void)renderAutofillTypePredictions:
(const std::vector<autofill::FormStructure*>&)structure {
(const std::vector<autofill::FormDataPredictions>&)forms {
if (!base::FeatureList::IsEnabled(
autofill::features::kAutofillShowTypePredictions)) {
return;
}
base::DictionaryValue predictionData;
for (autofill::FormStructure* form : structure) {
for (const auto& form : forms) {
auto formJSONData = std::make_unique<base::DictionaryValue>();
autofill::FormData formData = form->ToFormData();
for (const auto& field : *form) {
autofill::AutofillType type(field->Type());
if (type.IsUnknown())
continue;
formJSONData->SetKey(base::UTF16ToUTF8(field->name),
base::Value(type.ToString()));
DCHECK(form.fields.size() == form.data.fields.size());
for (size_t i = 0; i < form.fields.size(); i++) {
formJSONData->SetKey(base::UTF16ToUTF8(form.data.fields[i].name),
base::Value(form.fields[i].overall_type));
}
predictionData.SetWithoutPathExpansion(base::UTF16ToUTF8(formData.name),
predictionData.SetWithoutPathExpansion(base::UTF16ToUTF8(form.data.name),
std::move(formJSONData));
}
std::string dataString;
......
......@@ -5,6 +5,7 @@
#include "components/autofill/ios/browser/autofill_driver_ios.h"
#include "base/memory/ptr_util.h"
#include "components/autofill/core/browser/form_structure.h"
#include "components/autofill/ios/browser/autofill_driver_ios_bridge.h"
#include "ios/web/public/browser_state.h"
#import "ios/web/public/origin_util.h"
......@@ -76,7 +77,8 @@ void AutofillDriverIOS::PropagateAutofillPredictions(
void AutofillDriverIOS::SendAutofillTypePredictionsToRenderer(
const std::vector<FormStructure*>& forms) {
[bridge_ sendAutofillTypePredictionsToRenderer:forms];
[bridge_ sendAutofillTypePredictionsToRenderer:
FormStructure::GetFieldTypePredictions(forms)];
}
void AutofillDriverIOS::RendererShouldAcceptDataListSuggestion(
......
......@@ -9,9 +9,10 @@
#include <vector>
#include "components/autofill/core/common/form_data_predictions.h"
namespace autofill {
struct FormData;
class FormStructure;
}
// Interface used to pipe form data from AutofillDriverIOS to the embedder.
......@@ -21,7 +22,7 @@ class FormStructure;
result:(const autofill::FormData&)result;
- (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms;
(const std::vector<autofill::FormDataPredictions>&)forms;
@end
......
......@@ -7,13 +7,11 @@
#import <UIKit/UIKit.h>
#include <vector>
#include "components/autofill/core/common/form_data_predictions.h"
@class AutofillAgent;
@protocol FormSuggestionProvider;
namespace autofill {
class FormStructure;
}
namespace ios {
class ChromeBrowserState;
}
......@@ -61,7 +59,7 @@ passwordGenerationManager:
// Sends the field type predictions specified in |forms| to the renderer. This
// method is a no-op if the appropriate experiment is not set.
- (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms;
(const std::vector<autofill::FormDataPredictions>&)forms;
// Sets a weak reference to the view controller used to present UI.
- (void)setBaseViewController:(UIViewController*)baseViewController;
......
......@@ -179,7 +179,7 @@ showAutofillPopup:(const std::vector<autofill::Suggestion>&)popup_suggestions
}
- (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms {
(const std::vector<autofill::FormDataPredictions>&)forms {
[_autofillAgent renderAutofillTypePredictions:forms];
}
......
......@@ -260,7 +260,7 @@
}
- (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms {
(const std::vector<autofill::FormDataPredictions>&)forms {
// Not supported.
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment