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

Side by Side Diff: chrome/browser/autofill/autofill_manager.cc

Issue 11415221: Add support for autofilling radio buttons and checkboxes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix the nit. Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autofill/autofill_manager.h" 5 #include "chrome/browser/autofill/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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 if (result.fields[i] == field || 647 if (result.fields[i] == field ||
648 field_group_type == initiating_group_type) { 648 field_group_type == initiating_group_type) {
649 use_variant = variant; 649 use_variant = variant;
650 } 650 }
651 form_group->FillFormField(*cached_field, 651 form_group->FillFormField(*cached_field,
652 use_variant, 652 use_variant,
653 &result.fields[i]); 653 &result.fields[i]);
654 // Mark the cached field as autofilled, so that we can detect when a user 654 // Mark the cached field as autofilled, so that we can detect when a user
655 // edits an autofilled field (for metrics). 655 // edits an autofilled field (for metrics).
656 form_structure->field(i)->is_autofilled = true; 656 form_structure->field(i)->is_autofilled = true;
657 } else if (cached_field->type() == FIELD_WITH_DEFAULT_VALUE &&
658 cached_field->is_checkable) {
659 // For a form with radio buttons, like:
660 // <form>
661 // <input type="radio" name="sex" value="male">Male<br>
662 // <input type="radio" name="sex" value="female">Female
663 // </form>
664 // If the default value specified at the server is "female", then
665 // Autofill server responds back with following field mappings
666 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female")
667 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female")
668 // Note that, the field mapping is repeated twice to respond to both the
669 // input elements with the same name/signature in the form.
670 string16 default_value = UTF8ToUTF16(cached_field->default_value());
671 // Mark the field checked if server says the default value of the field
672 // to be this field's value.
673 result.fields[i].is_checked = (default_value == result.fields[i].value);
674 // Mark the cached field as autofilled, so that we can detect when a user
675 // edits an autofilled field (for metrics).
676 form_structure->field(i)->is_autofilled = true;
657 } 677 }
658 } 678 }
659 679
660 autofilled_form_signatures_.push_front(form_structure->FormSignature()); 680 autofilled_form_signatures_.push_front(form_structure->FormSignature());
661 // Only remember the last few forms that we've seen, both to avoid false 681 // Only remember the last few forms that we've seen, both to avoid false
662 // positives and to avoid wasting memory. 682 // positives and to avoid wasting memory.
663 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) 683 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember)
664 autofilled_form_signatures_.pop_back(); 684 autofilled_form_signatures_.pop_back();
665 685
666 host->Send(new AutofillMsg_FormDataFilled( 686 host->Send(new AutofillMsg_FormDataFilled(
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 *profile_guid = IDToGUID(profile_id); 1358 *profile_guid = IDToGUID(profile_id);
1339 } 1359 }
1340 1360
1341 void AutofillManager::UpdateInitialInteractionTimestamp( 1361 void AutofillManager::UpdateInitialInteractionTimestamp(
1342 const TimeTicks& interaction_timestamp) { 1362 const TimeTicks& interaction_timestamp) {
1343 if (initial_interaction_timestamp_.is_null() || 1363 if (initial_interaction_timestamp_.is_null() ||
1344 interaction_timestamp < initial_interaction_timestamp_) { 1364 interaction_timestamp < initial_interaction_timestamp_) {
1345 initial_interaction_timestamp_ = interaction_timestamp; 1365 initial_interaction_timestamp_ = interaction_timestamp;
1346 } 1366 }
1347 } 1367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698