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 @@ ...@@ -9,13 +9,13 @@
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "components/autofill/core/browser/autofill_metrics.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 "components/autofill/ios/browser/form_suggestion_provider.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h" #import "ios/web/public/web_state/web_state_observer_bridge.h"
namespace autofill { namespace autofill {
class AutofillPopupDelegate; class AutofillPopupDelegate;
struct FormData; struct FormData;
class FormStructure;
} }
class PrefService; class PrefService;
...@@ -53,7 +53,7 @@ class WebState; ...@@ -53,7 +53,7 @@ class WebState;
// Renders the field type predictions specified in |forms|. This method is a // Renders the field type predictions specified in |forms|. This method is a
// no-op if the relevant experiment is not enabled. // no-op if the relevant experiment is not enabled.
- (void)renderAutofillTypePredictions: - (void)renderAutofillTypePredictions:
(const std::vector<autofill::FormStructure*>&)forms; (const std::vector<autofill::FormDataPredictions>&)forms;
@end @end
......
...@@ -925,24 +925,21 @@ void GetFormAndField(autofill::FormData* form, ...@@ -925,24 +925,21 @@ void GetFormAndField(autofill::FormData* form,
} }
- (void)renderAutofillTypePredictions: - (void)renderAutofillTypePredictions:
(const std::vector<autofill::FormStructure*>&)structure { (const std::vector<autofill::FormDataPredictions>&)forms {
if (!base::FeatureList::IsEnabled( if (!base::FeatureList::IsEnabled(
autofill::features::kAutofillShowTypePredictions)) { autofill::features::kAutofillShowTypePredictions)) {
return; return;
} }
base::DictionaryValue predictionData; base::DictionaryValue predictionData;
for (autofill::FormStructure* form : structure) { for (const auto& form : forms) {
auto formJSONData = std::make_unique<base::DictionaryValue>(); auto formJSONData = std::make_unique<base::DictionaryValue>();
autofill::FormData formData = form->ToFormData(); DCHECK(form.fields.size() == form.data.fields.size());
for (const auto& field : *form) { for (size_t i = 0; i < form.fields.size(); i++) {
autofill::AutofillType type(field->Type()); formJSONData->SetKey(base::UTF16ToUTF8(form.data.fields[i].name),
if (type.IsUnknown()) base::Value(form.fields[i].overall_type));
continue;
formJSONData->SetKey(base::UTF16ToUTF8(field->name),
base::Value(type.ToString()));
} }
predictionData.SetWithoutPathExpansion(base::UTF16ToUTF8(formData.name), predictionData.SetWithoutPathExpansion(base::UTF16ToUTF8(form.data.name),
std::move(formJSONData)); std::move(formJSONData));
} }
std::string dataString; std::string dataString;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/autofill/ios/browser/autofill_driver_ios.h" #include "components/autofill/ios/browser/autofill_driver_ios.h"
#include "base/memory/ptr_util.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 "components/autofill/ios/browser/autofill_driver_ios_bridge.h"
#include "ios/web/public/browser_state.h" #include "ios/web/public/browser_state.h"
#import "ios/web/public/origin_util.h" #import "ios/web/public/origin_util.h"
...@@ -76,7 +77,8 @@ void AutofillDriverIOS::PropagateAutofillPredictions( ...@@ -76,7 +77,8 @@ void AutofillDriverIOS::PropagateAutofillPredictions(
void AutofillDriverIOS::SendAutofillTypePredictionsToRenderer( void AutofillDriverIOS::SendAutofillTypePredictionsToRenderer(
const std::vector<FormStructure*>& forms) { const std::vector<FormStructure*>& forms) {
[bridge_ sendAutofillTypePredictionsToRenderer:forms]; [bridge_ sendAutofillTypePredictionsToRenderer:
FormStructure::GetFieldTypePredictions(forms)];
} }
void AutofillDriverIOS::RendererShouldAcceptDataListSuggestion( void AutofillDriverIOS::RendererShouldAcceptDataListSuggestion(
......
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
#include <vector> #include <vector>
#include "components/autofill/core/common/form_data_predictions.h"
namespace autofill { namespace autofill {
struct FormData; struct FormData;
class FormStructure;
} }
// Interface used to pipe form data from AutofillDriverIOS to the embedder. // Interface used to pipe form data from AutofillDriverIOS to the embedder.
...@@ -21,7 +22,7 @@ class FormStructure; ...@@ -21,7 +22,7 @@ class FormStructure;
result:(const autofill::FormData&)result; result:(const autofill::FormData&)result;
- (void)sendAutofillTypePredictionsToRenderer: - (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms; (const std::vector<autofill::FormDataPredictions>&)forms;
@end @end
......
...@@ -7,13 +7,11 @@ ...@@ -7,13 +7,11 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#include <vector> #include <vector>
#include "components/autofill/core/common/form_data_predictions.h"
@class AutofillAgent; @class AutofillAgent;
@protocol FormSuggestionProvider; @protocol FormSuggestionProvider;
namespace autofill {
class FormStructure;
}
namespace ios { namespace ios {
class ChromeBrowserState; class ChromeBrowserState;
} }
...@@ -61,7 +59,7 @@ passwordGenerationManager: ...@@ -61,7 +59,7 @@ passwordGenerationManager:
// Sends the field type predictions specified in |forms| to the renderer. This // Sends the field type predictions specified in |forms| to the renderer. This
// method is a no-op if the appropriate experiment is not set. // method is a no-op if the appropriate experiment is not set.
- (void)sendAutofillTypePredictionsToRenderer: - (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. // Sets a weak reference to the view controller used to present UI.
- (void)setBaseViewController:(UIViewController*)baseViewController; - (void)setBaseViewController:(UIViewController*)baseViewController;
......
...@@ -179,7 +179,7 @@ showAutofillPopup:(const std::vector<autofill::Suggestion>&)popup_suggestions ...@@ -179,7 +179,7 @@ showAutofillPopup:(const std::vector<autofill::Suggestion>&)popup_suggestions
} }
- (void)sendAutofillTypePredictionsToRenderer: - (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms { (const std::vector<autofill::FormDataPredictions>&)forms {
[_autofillAgent renderAutofillTypePredictions:forms]; [_autofillAgent renderAutofillTypePredictions:forms];
} }
......
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
} }
- (void)sendAutofillTypePredictionsToRenderer: - (void)sendAutofillTypePredictionsToRenderer:
(const std::vector<autofill::FormStructure*>&)forms { (const std::vector<autofill::FormDataPredictions>&)forms {
// Not supported. // 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