Index: components/autofill/content/renderer/autofill_agent.cc |
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc |
index 31068330ae94793b6238892e9bc27b57bc7ca8d7..1f80d2ef6fcfa8fceb0c553484d147dbb365e2d6 100644 |
--- a/components/autofill/content/renderer/autofill_agent.cc |
+++ b/components/autofill/content/renderer/autofill_agent.cc |
@@ -19,6 +19,7 @@ |
#include "components/autofill/core/common/autofill_constants.h" |
#include "components/autofill/core/common/autofill_data_validation.h" |
#include "components/autofill/core/common/autofill_switches.h" |
+#include "components/autofill/core/common/autofill_util.h" |
#include "components/autofill/core/common/form_data.h" |
#include "components/autofill/core/common/form_data_predictions.h" |
#include "components/autofill/core/common/form_field_data.h" |
@@ -723,8 +724,16 @@ void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
was_query_node_autofilled_ = element_.isAutofilled(); |
node->setSuggestedValue(value.substr(0, node->maxLength())); |
node->setAutofilled(true); |
- node->setSelectionRange(node->value().length(), |
- node->suggestedValue().length()); |
+ |
+ if (IsFeatureSubstringMatchEnabled()) { |
+ size_t start = autofill::GetTextSelectionStart(value, node->value()); |
+ if (start != base::string16::npos) { |
Evan Stade
2015/04/27 19:25:21
no curlies
Pritam Nikam
2015/04/28 14:45:55
Done.
|
+ node->setSelectionRange(start, node->suggestedValue().length()); |
+ } |
+ } else { |
+ node->setSelectionRange(node->value().length(), |
+ node->suggestedValue().length()); |
+ } |
} |
void AutofillAgent::ProcessForms() { |