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

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

Issue 1059393002: Remove --respect-autocomplete-off-autofill flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix last 3 tests Created 5 years, 8 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); 451 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE);
452 } 452 }
453 } 453 }
454 454
455 UpdateInitialInteractionTimestamp(timestamp); 455 UpdateInitialInteractionTimestamp(timestamp);
456 } 456 }
457 457
458 void AutofillManager::OnQueryFormFieldAutofill(int query_id, 458 void AutofillManager::OnQueryFormFieldAutofill(int query_id,
459 const FormData& form, 459 const FormData& form,
460 const FormFieldData& field, 460 const FormFieldData& field,
461 const gfx::RectF& bounding_box, 461 const gfx::RectF& bounding_box) {
462 bool display_warning) {
463 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) 462 if (!IsValidFormData(form) || !IsValidFormFieldData(field))
464 return; 463 return;
465 464
466 std::vector<Suggestion> suggestions; 465 std::vector<Suggestion> suggestions;
467 466
468 external_delegate_->OnQuery(query_id, 467 external_delegate_->OnQuery(query_id, form, field, bounding_box);
469 form,
470 field,
471 bounding_box,
472 display_warning);
473 468
474 // Need to refresh models before using the form_event_loggers. 469 // Need to refresh models before using the form_event_loggers.
475 bool is_autofill_possible = RefreshDataModels(); 470 bool is_autofill_possible = RefreshDataModels();
476 471
477 FormStructure* form_structure = NULL; 472 FormStructure* form_structure = NULL;
478 AutofillField* autofill_field = NULL; 473 AutofillField* autofill_field = NULL;
479 bool got_autofillable_form = 474 bool got_autofillable_form =
480 GetCachedFormAndField(form, field, &form_structure, &autofill_field) && 475 GetCachedFormAndField(form, field, &form_structure, &autofill_field) &&
481 // Don't send suggestions or track forms that aren't auto-fillable. 476 // Don't send suggestions or track forms that aren't auto-fillable.
482 form_structure->IsAutofillable(); 477 form_structure->IsAutofillable();
(...skipping 11 matching lines...) Expand all
494 got_autofillable_form) { 489 got_autofillable_form) {
495 AutofillType type = autofill_field->Type(); 490 AutofillType type = autofill_field->Type();
496 bool is_filling_credit_card = (type.group() == CREDIT_CARD); 491 bool is_filling_credit_card = (type.group() == CREDIT_CARD);
497 if (is_filling_credit_card) { 492 if (is_filling_credit_card) {
498 suggestions = GetCreditCardSuggestions(field, type); 493 suggestions = GetCreditCardSuggestions(field, type);
499 } else { 494 } else {
500 suggestions = 495 suggestions =
501 GetProfileSuggestions(*form_structure, field, *autofill_field); 496 GetProfileSuggestions(*form_structure, field, *autofill_field);
502 } 497 }
503 if (!suggestions.empty()) { 498 if (!suggestions.empty()) {
504 // Don't provide Autofill suggestions when Autofill is disabled, and don't 499 // Don't provide credit card suggestions for non-HTTPS pages. However,
505 // provide credit card suggestions for non-HTTPS pages. However, provide a 500 // do provide a warning to the user.
506 // warning to the user in these cases.
507 int warning = 0;
508 if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) { 501 if (is_filling_credit_card && !FormIsHTTPS(*form_structure)) {
509 warning = IDS_AUTOFILL_WARNING_INSECURE_CONNECTION; 502 Suggestion warning_suggestion(l10n_util::GetStringUTF16(
510 } 503 IDS_AUTOFILL_WARNING_INSECURE_CONNECTION));
511 if (warning) {
512 Suggestion warning_suggestion(l10n_util::GetStringUTF16(warning));
513 warning_suggestion.frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE; 504 warning_suggestion.frontend_id = POPUP_ITEM_ID_WARNING_MESSAGE;
514 suggestions.assign(1, warning_suggestion); 505 suggestions.assign(1, warning_suggestion);
515 } else { 506 } else {
516 bool section_is_autofilled = 507 bool section_is_autofilled =
517 SectionIsAutofilled(*form_structure, form, 508 SectionIsAutofilled(*form_structure, form,
518 autofill_field->section()); 509 autofill_field->section());
519 if (section_is_autofilled) { 510 if (section_is_autofilled) {
520 // If the relevant section is auto-filled and the renderer is querying 511 // If the relevant section is auto-filled and the renderer is querying
521 // for suggestions, then the user is editing the value of a field. 512 // for suggestions, then the user is editing the value of a field.
522 // In this case, mimic autocomplete: don't display labels or icons, 513 // In this case, mimic autocomplete: don't display labels or icons,
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 return false; 1497 return false;
1507 1498
1508 // Disregard forms that we wouldn't ever autofill in the first place. 1499 // Disregard forms that we wouldn't ever autofill in the first place.
1509 if (!form.ShouldBeParsed()) 1500 if (!form.ShouldBeParsed())
1510 return false; 1501 return false;
1511 1502
1512 return true; 1503 return true;
1513 } 1504 }
1514 1505
1515 } // namespace autofill 1506 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698