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

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

Issue 242613006: [Autofill] Enable Autofill for dynamically created forms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 driver_->GetBlockingPool()->PostTaskAndReply( 296 driver_->GetBlockingPool()->PostTaskAndReply(
297 FROM_HERE, 297 FROM_HERE,
298 base::Bind(&DeterminePossibleFieldTypesForUpload, 298 base::Bind(&DeterminePossibleFieldTypesForUpload,
299 copied_profiles, 299 copied_profiles,
300 copied_credit_cards, 300 copied_credit_cards,
301 app_locale_, 301 app_locale_,
302 raw_submitted_form), 302 raw_submitted_form),
303 base::Bind(&AutofillManager::UploadFormDataAsyncCallback, 303 base::Bind(&AutofillManager::UploadFormDataAsyncCallback,
304 weak_ptr_factory_.GetWeakPtr(), 304 weak_ptr_factory_.GetWeakPtr(),
305 base::Owned(submitted_form.release()), 305 base::Owned(submitted_form.release()),
306 forms_loaded_timestamp_, 306 forms_loaded_timestamps_[form],
307 initial_interaction_timestamp_, 307 initial_interaction_timestamp_,
308 timestamp)); 308 timestamp));
309 } 309 }
310 310
311 return true; 311 return true;
312 } 312 }
313 313
314 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms, 314 void AutofillManager::OnFormsSeen(const std::vector<FormData>& forms,
315 const TimeTicks& timestamp, 315 const TimeTicks& timestamp) {
316 autofill::FormsSeenState state) {
317 if (!IsValidFormDataVector(forms)) 316 if (!IsValidFormDataVector(forms))
318 return; 317 return;
319 318
320 bool is_post_document_load = state == autofill::DYNAMIC_FORMS_SEEN;
321 // If new forms were added dynamically, treat as a new page.
322 if (is_post_document_load)
323 Reset();
324
325 if (!driver_->RendererIsAvailable()) 319 if (!driver_->RendererIsAvailable())
326 return; 320 return;
327 321
328 bool enabled = IsAutofillEnabled(); 322 bool enabled = IsAutofillEnabled();
329 if (!has_logged_autofill_enabled_) { 323 if (!has_logged_autofill_enabled_) {
330 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled); 324 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled);
331 has_logged_autofill_enabled_ = true; 325 has_logged_autofill_enabled_ = true;
332 } 326 }
333 327
334 if (!enabled) 328 if (!enabled)
335 return; 329 return;
336 330
337 forms_loaded_timestamp_ = timestamp; 331 for (size_t i = 0; i < forms.size(); ++i)
332 forms_loaded_timestamps_[forms[i]] = timestamp;
Ilya Sherman 2014/04/25 00:43:02 nit: I'd prefer that you add curly braces around t
Garrett Casto 2014/04/29 22:57:43 Done.
338 ParseForms(forms); 333 ParseForms(forms);
339 } 334 }
340 335
341 void AutofillManager::OnTextFieldDidChange(const FormData& form, 336 void AutofillManager::OnTextFieldDidChange(const FormData& form,
342 const FormFieldData& field, 337 const FormFieldData& field,
343 const TimeTicks& timestamp) { 338 const TimeTicks& timestamp) {
344 if (!IsValidFormData(form) || !IsValidFormFieldData(field)) 339 if (!IsValidFormData(form) || !IsValidFormFieldData(field))
345 return; 340 return;
346 341
347 FormStructure* form_structure = NULL; 342 FormStructure* form_structure = NULL;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 } 811 }
817 812
818 void AutofillManager::Reset() { 813 void AutofillManager::Reset() {
819 form_structures_.clear(); 814 form_structures_.clear();
820 has_logged_autofill_enabled_ = false; 815 has_logged_autofill_enabled_ = false;
821 has_logged_address_suggestions_count_ = false; 816 has_logged_address_suggestions_count_ = false;
822 did_show_suggestions_ = false; 817 did_show_suggestions_ = false;
823 user_did_type_ = false; 818 user_did_type_ = false;
824 user_did_autofill_ = false; 819 user_did_autofill_ = false;
825 user_did_edit_autofilled_field_ = false; 820 user_did_edit_autofilled_field_ = false;
826 forms_loaded_timestamp_ = TimeTicks(); 821 forms_loaded_timestamps_.clear();
827 initial_interaction_timestamp_ = TimeTicks(); 822 initial_interaction_timestamp_ = TimeTicks();
828 external_delegate_->Reset(); 823 external_delegate_->Reset();
829 } 824 }
830 825
831 AutofillManager::AutofillManager(AutofillDriver* driver, 826 AutofillManager::AutofillManager(AutofillDriver* driver,
832 autofill::AutofillManagerDelegate* delegate, 827 autofill::AutofillManagerDelegate* delegate,
833 PersonalDataManager* personal_data) 828 PersonalDataManager* personal_data)
834 : driver_(driver), 829 : driver_(driver),
835 manager_delegate_(delegate), 830 manager_delegate_(delegate),
836 app_locale_("en-US"), 831 app_locale_("en-US"),
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 return false; 1162 return false;
1168 1163
1169 // Disregard forms that we wouldn't ever autofill in the first place. 1164 // Disregard forms that we wouldn't ever autofill in the first place.
1170 if (!form.ShouldBeParsed(true)) 1165 if (!form.ShouldBeParsed(true))
1171 return false; 1166 return false;
1172 1167
1173 return true; 1168 return true;
1174 } 1169 }
1175 1170
1176 } // namespace autofill 1171 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/common/form_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698