Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 667043002: Add a flag to ignore autocomplete="off" for Autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: fix preview on fields with no autocomplete="off" / add a flag to disable https:// requirements for … Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "components/autofill/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 DCHECK_EQ(values.size(), labels.size()); 487 DCHECK_EQ(values.size(), labels.size());
488 DCHECK_EQ(values.size(), icons.size()); 488 DCHECK_EQ(values.size(), icons.size());
489 DCHECK_EQ(values.size(), unique_ids.size()); 489 DCHECK_EQ(values.size(), unique_ids.size());
490 490
491 if (!values.empty()) { 491 if (!values.empty()) {
492 // Don't provide Autofill suggestions when Autofill is disabled, and don't 492 // Don't provide Autofill suggestions when Autofill is disabled, and don't
493 // provide credit card suggestions for non-HTTPS pages. However, provide a 493 // provide credit card suggestions for non-HTTPS pages. However, provide a
494 // warning to the user in these cases. 494 // warning to the user in these cases.
495 int warning = 0; 495 int warning = 0;
496 if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) 496 if (is_filling_credit_card && !FormIsHTTPS(*form_structure) &&
497 !CommandLine::ForCurrentProcess()->HasSwitch(
498 "reduce-security-for-testing")) {
Evan Stade 2014/10/22 21:52:33 this is a string literal because the flag is defin
Ilya Sherman 2014/10/23 00:35:27 This seems unrelated to this CL. I'd honestly pre
Evan Stade 2014/10/23 02:02:20 split this into a separate CL.
497 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; 499 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION;
500 }
498 if (warning) { 501 if (warning) {
499 values.assign(1, l10n_util::GetStringUTF16(warning)); 502 values.assign(1, l10n_util::GetStringUTF16(warning));
500 labels.assign(1, base::string16()); 503 labels.assign(1, base::string16());
501 icons.assign(1, base::string16()); 504 icons.assign(1, base::string16());
502 unique_ids.assign(1, POPUP_ITEM_ID_WARNING_MESSAGE); 505 unique_ids.assign(1, POPUP_ITEM_ID_WARNING_MESSAGE);
503 } else { 506 } else {
504 bool section_is_autofilled = 507 bool section_is_autofilled =
505 SectionIsAutofilled(*form_structure, form, 508 SectionIsAutofilled(*form_structure, form,
506 autofill_field->section()); 509 autofill_field->section());
507 if (section_is_autofilled) { 510 if (section_is_autofilled) {
(...skipping 15 matching lines...) Expand all
523 // The first time we show suggestions on this page, log the number of 526 // The first time we show suggestions on this page, log the number of
524 // suggestions shown. 527 // suggestions shown.
525 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) { 528 if (!has_logged_address_suggestions_count_ && !section_is_autofilled) {
526 metric_logger_->LogAddressSuggestionsCount(values.size()); 529 metric_logger_->LogAddressSuggestionsCount(values.size());
527 has_logged_address_suggestions_count_ = true; 530 has_logged_address_suggestions_count_ = true;
528 } 531 }
529 } 532 }
530 } 533 }
531 } 534 }
532 535
533 // Add the results from AutoComplete. They come back asynchronously, so we 536 if (field.should_autocomplete) {
534 // hand off what we generated and they will send the results back to the 537 // Add the results from AutoComplete. They come back asynchronously, so we
535 // renderer. 538 // hand off what we generated and they will send the results back to the
536 autocomplete_history_manager_->OnGetAutocompleteSuggestions( 539 // renderer.
537 query_id, field.name, field.value, field.form_control_type, values, 540 autocomplete_history_manager_->OnGetAutocompleteSuggestions(
538 labels, icons, unique_ids); 541 query_id, field.name, field.value, field.form_control_type, values,
542 labels, icons, unique_ids);
543 } else {
544 // Autocomplete is disabled for this field; only pass back Autofill
545 // suggestions.
546 autocomplete_history_manager_->CancelPendingQuery();
547 external_delegate_->OnSuggestionsReturned(
548 query_id, values, labels, icons, unique_ids);
549 }
539 } 550 }
540 551
541 void AutofillManager::FillOrPreviewForm( 552 void AutofillManager::FillOrPreviewForm(
542 AutofillDriver::RendererFormDataAction action, 553 AutofillDriver::RendererFormDataAction action,
543 int query_id, 554 int query_id,
544 const FormData& form, 555 const FormData& form,
545 const FormFieldData& field, 556 const FormFieldData& field,
546 int unique_id) { 557 int unique_id) {
547 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) 558 if (!IsValidFormData(form) || !IsValidFormFieldData(field))
548 return; 559 return;
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 return false; 1253 return false;
1243 1254
1244 // Disregard forms that we wouldn't ever autofill in the first place. 1255 // Disregard forms that we wouldn't ever autofill in the first place.
1245 if (!form.ShouldBeParsed()) 1256 if (!form.ShouldBeParsed())
1246 return false; 1257 return false;
1247 1258
1248 return true; 1259 return true;
1249 } 1260 }
1250 1261
1251 } // namespace autofill 1262 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698