OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } // namespace | 220 } // namespace |
221 | 221 |
222 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) | 222 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents) |
223 : TabContentsObserver(tab_contents->tab_contents()), | 223 : TabContentsObserver(tab_contents->tab_contents()), |
224 tab_contents_wrapper_(tab_contents), | 224 tab_contents_wrapper_(tab_contents), |
225 personal_data_(NULL), | 225 personal_data_(NULL), |
226 download_manager_(tab_contents->profile()), | 226 download_manager_(tab_contents->profile()), |
227 disable_download_manager_requests_(false), | 227 disable_download_manager_requests_(false), |
228 metric_logger_(new AutofillMetrics), | 228 metric_logger_(new AutofillMetrics), |
229 has_logged_autofill_enabled_(false), | 229 has_logged_autofill_enabled_(false), |
230 has_logged_address_suggestions_count_(false) { | 230 has_logged_address_suggestions_count_(false), |
| 231 did_show_suggestions_(false), |
| 232 user_did_type_(false), |
| 233 user_did_autofill_(false), |
| 234 user_did_edit_autofilled_field_(false) { |
231 DCHECK(tab_contents); | 235 DCHECK(tab_contents); |
232 | 236 |
233 // |personal_data_| is NULL when using TestTabContents. | 237 // |personal_data_| is NULL when using TestTabContents. |
234 personal_data_ = | 238 personal_data_ = |
235 tab_contents->profile()->GetOriginalProfile()->GetPersonalDataManager(); | 239 tab_contents->profile()->GetOriginalProfile()->GetPersonalDataManager(); |
236 download_manager_.SetObserver(this); | 240 download_manager_.SetObserver(this); |
237 } | 241 } |
238 | 242 |
239 AutofillManager::~AutofillManager() { | 243 AutofillManager::~AutofillManager() { |
240 download_manager_.SetObserver(NULL); | 244 download_manager_.SetObserver(NULL); |
(...skipping 30 matching lines...) Expand all Loading... |
271 const content::LoadCommittedDetails& details, | 275 const content::LoadCommittedDetails& details, |
272 const ViewHostMsg_FrameNavigate_Params& params) { | 276 const ViewHostMsg_FrameNavigate_Params& params) { |
273 Reset(); | 277 Reset(); |
274 } | 278 } |
275 | 279 |
276 bool AutofillManager::OnMessageReceived(const IPC::Message& message) { | 280 bool AutofillManager::OnMessageReceived(const IPC::Message& message) { |
277 bool handled = true; | 281 bool handled = true; |
278 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message) | 282 IPC_BEGIN_MESSAGE_MAP(AutofillManager, message) |
279 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen) | 283 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormsSeen, OnFormsSeen) |
280 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormSubmitted, OnFormSubmitted) | 284 IPC_MESSAGE_HANDLER(AutofillHostMsg_FormSubmitted, OnFormSubmitted) |
| 285 IPC_MESSAGE_HANDLER(AutofillHostMsg_TextFieldDidChange, |
| 286 OnTextFieldDidChange) |
281 IPC_MESSAGE_HANDLER(AutofillHostMsg_QueryFormFieldAutofill, | 287 IPC_MESSAGE_HANDLER(AutofillHostMsg_QueryFormFieldAutofill, |
282 OnQueryFormFieldAutofill) | 288 OnQueryFormFieldAutofill) |
283 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, | 289 IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowAutofillDialog, |
284 OnShowAutofillDialog) | 290 OnShowAutofillDialog) |
285 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, | 291 IPC_MESSAGE_HANDLER(AutofillHostMsg_FillAutofillFormData, |
286 OnFillAutofillFormData) | 292 OnFillAutofillFormData) |
| 293 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidPreviewAutofillFormData, |
| 294 OnDidPreviewAutofillFormData) |
287 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, | 295 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidFillAutofillFormData, |
288 OnDidFillAutofillFormData) | 296 OnDidFillAutofillFormData) |
289 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, | 297 IPC_MESSAGE_HANDLER(AutofillHostMsg_DidShowAutofillSuggestions, |
290 OnDidShowAutofillSuggestions) | 298 OnDidShowAutofillSuggestions) |
291 IPC_MESSAGE_UNHANDLED(handled = false) | 299 IPC_MESSAGE_UNHANDLED(handled = false) |
292 IPC_END_MESSAGE_MAP() | 300 IPC_END_MESSAGE_MAP() |
293 | 301 |
294 return handled; | 302 return handled; |
295 } | 303 } |
296 | 304 |
297 void AutofillManager::OnFormSubmitted(const FormData& form) { | 305 void AutofillManager::OnFormSubmitted(const FormData& form) { |
298 // Let AutoComplete know as well. | 306 // Let AutoComplete know as well. |
299 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); | 307 tab_contents_wrapper_->autocomplete_history_manager()->OnFormSubmitted(form); |
300 | 308 |
301 if (!IsAutofillEnabled()) | |
302 return; | |
303 | |
304 if (tab_contents()->browser_context()->IsOffTheRecord()) | 309 if (tab_contents()->browser_context()->IsOffTheRecord()) |
305 return; | 310 return; |
306 | 311 |
307 // Don't save data that was submitted through JavaScript. | 312 // Don't save data that was submitted through JavaScript. |
308 if (!form.user_submitted) | 313 if (!form.user_submitted) |
309 return; | 314 return; |
310 | 315 |
311 // Grab a copy of the form data. | 316 // Grab a copy of the form data. |
312 FormStructure submitted_form(form); | 317 FormStructure submitted_form(form); |
313 | 318 |
314 // Disregard forms that we wouldn't ever autofill in the first place. | 319 // Disregard forms that we wouldn't ever autofill in the first place. |
315 if (!submitted_form.ShouldBeParsed(true)) | 320 if (!submitted_form.ShouldBeParsed(true)) |
316 return; | 321 return; |
317 | 322 |
| 323 if (user_did_autofill_) { |
| 324 metric_logger_->LogUserHappinessMetric( |
| 325 AutofillMetrics::FORM_SUBMITTED_AFTER_AUTOFILL); |
| 326 } else { |
| 327 metric_logger_->LogUserHappinessMetric( |
| 328 AutofillMetrics::FORM_SUBMITTED_WITHOUT_AUTOFILL); |
| 329 } |
| 330 |
318 // Ignore forms not present in our cache. These are typically forms with | 331 // Ignore forms not present in our cache. These are typically forms with |
319 // wonky JavaScript that also makes them not auto-fillable. | 332 // wonky JavaScript that also makes them not auto-fillable. |
320 FormStructure* cached_submitted_form; | 333 FormStructure* cached_submitted_form; |
321 if (!FindCachedForm(form, &cached_submitted_form)) | 334 if (!FindCachedForm(form, &cached_submitted_form)) |
322 return; | 335 return; |
323 submitted_form.UpdateFromCache(*cached_submitted_form); | 336 submitted_form.UpdateFromCache(*cached_submitted_form); |
324 | 337 |
| 338 // We delay this check until now for the sake of metrics. |
| 339 if (!IsAutofillEnabled()) |
| 340 return; |
| 341 |
325 // Only upload server statistics and UMA metrics if at least some local data | 342 // Only upload server statistics and UMA metrics if at least some local data |
326 // is available to use as a baseline. | 343 // is available to use as a baseline. |
327 if (!personal_data_->profiles().empty() || | 344 if (!personal_data_->profiles().empty() || |
328 !personal_data_->credit_cards().empty()) { | 345 !personal_data_->credit_cards().empty()) { |
329 DeterminePossibleFieldTypesForUpload(&submitted_form); | 346 DeterminePossibleFieldTypesForUpload(&submitted_form); |
330 submitted_form.LogQualityMetrics(*metric_logger_); | 347 submitted_form.LogQualityMetrics(*metric_logger_); |
331 | 348 |
332 if (submitted_form.ShouldBeCrowdsourced()) | 349 if (submitted_form.ShouldBeCrowdsourced()) |
333 UploadFormData(submitted_form); | 350 UploadFormData(submitted_form); |
334 } | 351 } |
(...skipping 10 matching lines...) Expand all Loading... |
345 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled); | 362 metric_logger_->LogIsAutofillEnabledAtPageLoad(enabled); |
346 has_logged_autofill_enabled_ = true; | 363 has_logged_autofill_enabled_ = true; |
347 } | 364 } |
348 | 365 |
349 if (!enabled) | 366 if (!enabled) |
350 return; | 367 return; |
351 | 368 |
352 ParseForms(forms); | 369 ParseForms(forms); |
353 } | 370 } |
354 | 371 |
| 372 void AutofillManager::OnTextFieldDidChange(const FormData& form, |
| 373 const FormField& field) { |
| 374 if (user_did_type_ && user_did_edit_autofilled_field_) |
| 375 return; |
| 376 |
| 377 FormStructure* form_structure = NULL; |
| 378 AutofillField* autofill_field = NULL; |
| 379 if (!FindCachedFormAndField(form, field, &form_structure, &autofill_field)) |
| 380 return; |
| 381 |
| 382 if (!user_did_type_) { |
| 383 user_did_type_ = true; |
| 384 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE); |
| 385 } |
| 386 |
| 387 if (!user_did_edit_autofilled_field_ && autofill_field->is_autofilled) { |
| 388 user_did_edit_autofilled_field_ = true; |
| 389 metric_logger_->LogUserHappinessMetric( |
| 390 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD); |
| 391 } |
| 392 } |
| 393 |
355 void AutofillManager::OnQueryFormFieldAutofill( | 394 void AutofillManager::OnQueryFormFieldAutofill( |
356 int query_id, | 395 int query_id, |
357 const webkit_glue::FormData& form, | 396 const webkit_glue::FormData& form, |
358 const webkit_glue::FormField& field) { | 397 const webkit_glue::FormField& field) { |
359 std::vector<string16> values; | 398 std::vector<string16> values; |
360 std::vector<string16> labels; | 399 std::vector<string16> labels; |
361 std::vector<string16> icons; | 400 std::vector<string16> icons; |
362 std::vector<int> unique_ids; | 401 std::vector<int> unique_ids; |
363 | 402 |
364 RenderViewHost* host = NULL; | 403 RenderViewHost* host = NULL; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 AutofillFieldType field_type = autofill_field->type(); | 539 AutofillFieldType field_type = autofill_field->type(); |
501 if (profile) { | 540 if (profile) { |
502 DCHECK_NE(AutofillType::CREDIT_CARD, | 541 DCHECK_NE(AutofillType::CREDIT_CARD, |
503 AutofillType(field_type).group()); | 542 AutofillType(field_type).group()); |
504 FillFormField(profile, field_type, profile_guid.second, &(*iter)); | 543 FillFormField(profile, field_type, profile_guid.second, &(*iter)); |
505 } else { | 544 } else { |
506 DCHECK_EQ(AutofillType::CREDIT_CARD, | 545 DCHECK_EQ(AutofillType::CREDIT_CARD, |
507 AutofillType(field_type).group()); | 546 AutofillType(field_type).group()); |
508 FillCreditCardFormField(credit_card, field_type, &(*iter)); | 547 FillCreditCardFormField(credit_card, field_type, &(*iter)); |
509 } | 548 } |
| 549 |
| 550 // Mark the cached field as autofilled, so that we can detect when a |
| 551 // user edits an autofilled field (for metrics). |
| 552 autofill_field->is_autofilled = true; |
510 break; | 553 break; |
511 } | 554 } |
512 } | 555 } |
513 | 556 |
514 host->Send(new AutofillMsg_FormDataFilled(host->routing_id(), query_id, | 557 host->Send(new AutofillMsg_FormDataFilled(host->routing_id(), query_id, |
515 result)); | 558 result)); |
516 return; | 559 return; |
517 } | 560 } |
518 | 561 |
519 // The list of fields in |form_structure| and |result.fields| often match | 562 // The list of fields in |form_structure| and |result.fields| often match |
(...skipping 30 matching lines...) Expand all Loading... |
550 if (result.fields[j] == field) { | 593 if (result.fields[j] == field) { |
551 FillFormField(profile, field_type, profile_guid.second, | 594 FillFormField(profile, field_type, profile_guid.second, |
552 &result.fields[j]); | 595 &result.fields[j]); |
553 } else { | 596 } else { |
554 FillFormField(profile, field_type, 0, &result.fields[j]); | 597 FillFormField(profile, field_type, 0, &result.fields[j]); |
555 } | 598 } |
556 } else { | 599 } else { |
557 DCHECK_EQ(AutofillType::CREDIT_CARD, field_group_type); | 600 DCHECK_EQ(AutofillType::CREDIT_CARD, field_group_type); |
558 FillCreditCardFormField(credit_card, field_type, &result.fields[j]); | 601 FillCreditCardFormField(credit_card, field_type, &result.fields[j]); |
559 } | 602 } |
| 603 |
| 604 // Mark the cached field as autofilled, so that we can detect when a user |
| 605 // edits an autofilled field (for metrics). |
| 606 form_structure->field(k)->is_autofilled = true; |
560 } | 607 } |
561 | 608 |
562 // We found a matching field in the |form_structure|, so on the next | 609 // We found a matching field in the |form_structure|, so on the next |
563 // iteration we should proceed to the next |form_structure| field. | 610 // iteration we should proceed to the next |form_structure| field. |
564 ++i; | 611 ++i; |
565 } | 612 } |
566 | 613 |
567 autofilled_form_signatures_.push_front(form_structure->FormSignature()); | 614 autofilled_form_signatures_.push_front(form_structure->FormSignature()); |
568 // Only remember the last few forms that we've seen, both to avoid false | 615 // Only remember the last few forms that we've seen, both to avoid false |
569 // positives and to avoid wasting memory. | 616 // positives and to avoid wasting memory. |
570 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) | 617 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) |
571 autofilled_form_signatures_.pop_back(); | 618 autofilled_form_signatures_.pop_back(); |
572 | 619 |
573 host->Send(new AutofillMsg_FormDataFilled( | 620 host->Send(new AutofillMsg_FormDataFilled( |
574 host->routing_id(), query_id, result)); | 621 host->routing_id(), query_id, result)); |
575 } | 622 } |
576 | 623 |
577 void AutofillManager::OnShowAutofillDialog() { | 624 void AutofillManager::OnShowAutofillDialog() { |
578 Browser* browser = BrowserList::GetLastActiveWithProfile( | 625 Browser* browser = BrowserList::GetLastActiveWithProfile( |
579 Profile::FromBrowserContext(tab_contents()->browser_context())); | 626 Profile::FromBrowserContext(tab_contents()->browser_context())); |
580 if (browser) | 627 if (browser) |
581 browser->ShowOptionsTab(chrome::kAutofillSubPage); | 628 browser->ShowOptionsTab(chrome::kAutofillSubPage); |
582 } | 629 } |
583 | 630 |
| 631 void AutofillManager::OnDidPreviewAutofillFormData() { |
| 632 NotificationService::current()->Notify( |
| 633 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, |
| 634 Source<RenderViewHost>(tab_contents()->render_view_host()), |
| 635 NotificationService::NoDetails()); |
| 636 } |
| 637 |
| 638 |
584 void AutofillManager::OnDidFillAutofillFormData() { | 639 void AutofillManager::OnDidFillAutofillFormData() { |
585 NotificationService::current()->Notify( | 640 NotificationService::current()->Notify( |
586 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, | 641 chrome::NOTIFICATION_AUTOFILL_DID_FILL_FORM_DATA, |
587 Source<RenderViewHost>(tab_contents()->render_view_host()), | 642 Source<RenderViewHost>(tab_contents()->render_view_host()), |
588 NotificationService::NoDetails()); | 643 NotificationService::NoDetails()); |
| 644 |
| 645 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); |
| 646 if (!user_did_autofill_) { |
| 647 user_did_autofill_ = true; |
| 648 metric_logger_->LogUserHappinessMetric( |
| 649 AutofillMetrics::USER_DID_AUTOFILL_FIRST_TIME); |
| 650 } |
589 } | 651 } |
590 | 652 |
591 void AutofillManager::OnDidShowAutofillSuggestions() { | 653 void AutofillManager::OnDidShowAutofillSuggestions(bool is_new_popup) { |
592 NotificationService::current()->Notify( | 654 NotificationService::current()->Notify( |
593 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS, | 655 chrome::NOTIFICATION_AUTOFILL_DID_SHOW_SUGGESTIONS, |
594 Source<RenderViewHost>(tab_contents()->render_view_host()), | 656 Source<RenderViewHost>(tab_contents()->render_view_host()), |
595 NotificationService::NoDetails()); | 657 NotificationService::NoDetails()); |
| 658 |
| 659 if (is_new_popup) { |
| 660 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN); |
| 661 |
| 662 if (!did_show_suggestions_) { |
| 663 did_show_suggestions_ = true; |
| 664 metric_logger_->LogUserHappinessMetric( |
| 665 AutofillMetrics::SUGGESTIONS_SHOWN_FIRST_TIME); |
| 666 } |
| 667 } |
596 } | 668 } |
597 | 669 |
598 void AutofillManager::OnLoadedServerPredictions( | 670 void AutofillManager::OnLoadedServerPredictions( |
599 const std::string& response_xml) { | 671 const std::string& response_xml) { |
600 // Parse and store the server predictions. | 672 // Parse and store the server predictions. |
601 FormStructure::ParseQueryResponse(response_xml, | 673 FormStructure::ParseQueryResponse(response_xml, |
602 form_structures_.get(), | 674 form_structures_.get(), |
603 *metric_logger_); | 675 *metric_logger_); |
604 | 676 |
605 // If the corresponding flag is set, annotate forms with the predicted types. | 677 // If the corresponding flag is set, annotate forms with the predicted types. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); | 709 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); |
638 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); | 710 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); |
639 std::vector<FormGroup*> stored_data; | 711 std::vector<FormGroup*> stored_data; |
640 stored_data.insert(stored_data.end(), profiles.begin(), profiles.end()); | 712 stored_data.insert(stored_data.end(), profiles.begin(), profiles.end()); |
641 stored_data.insert(stored_data.end(), credit_cards.begin(), | 713 stored_data.insert(stored_data.end(), credit_cards.begin(), |
642 credit_cards.end()); | 714 credit_cards.end()); |
643 | 715 |
644 // For each field in the |submitted_form|, extract the value. Then for each | 716 // For each field in the |submitted_form|, extract the value. Then for each |
645 // profile or credit card, identify any stored types that match the value. | 717 // profile or credit card, identify any stored types that match the value. |
646 for (size_t i = 0; i < submitted_form->field_count(); i++) { | 718 for (size_t i = 0; i < submitted_form->field_count(); i++) { |
647 const AutofillField* field = submitted_form->field(i); | 719 AutofillField* field = submitted_form->field(i); |
648 string16 value = CollapseWhitespace(field->value, false); | 720 string16 value = CollapseWhitespace(field->value, false); |
649 FieldTypeSet matching_types; | 721 FieldTypeSet matching_types; |
650 for (std::vector<FormGroup*>::const_iterator it = stored_data.begin(); | 722 for (std::vector<FormGroup*>::const_iterator it = stored_data.begin(); |
651 it != stored_data.end(); ++it) { | 723 it != stored_data.end(); ++it) { |
652 (*it)->GetMatchingTypes(value, &matching_types); | 724 (*it)->GetMatchingTypes(value, &matching_types); |
653 } | 725 } |
654 | 726 |
655 if (matching_types.empty()) | 727 if (matching_types.empty()) |
656 matching_types.insert(UNKNOWN_TYPE); | 728 matching_types.insert(UNKNOWN_TYPE); |
657 | 729 |
658 submitted_form->set_possible_types(i, matching_types); | 730 field->set_possible_types(matching_types); |
659 } | 731 } |
660 } | 732 } |
661 | 733 |
662 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { | 734 void AutofillManager::ImportFormData(const FormStructure& submitted_form) { |
663 const CreditCard* imported_credit_card; | 735 const CreditCard* imported_credit_card; |
664 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) | 736 if (!personal_data_->ImportFormData(submitted_form, &imported_credit_card)) |
665 return; | 737 return; |
666 | 738 |
667 // If credit card information was submitted, show an infobar to offer to save | 739 // If credit card information was submitted, show an infobar to offer to save |
668 // it. | 740 // it. |
(...skipping 26 matching lines...) Expand all Loading... |
695 personal_data_->GetNonEmptyTypes(&non_empty_types); | 767 personal_data_->GetNonEmptyTypes(&non_empty_types); |
696 | 768 |
697 download_manager_.StartUploadRequest(submitted_form, was_autofilled, | 769 download_manager_.StartUploadRequest(submitted_form, was_autofilled, |
698 non_empty_types); | 770 non_empty_types); |
699 } | 771 } |
700 | 772 |
701 void AutofillManager::Reset() { | 773 void AutofillManager::Reset() { |
702 form_structures_.reset(); | 774 form_structures_.reset(); |
703 has_logged_autofill_enabled_ = false; | 775 has_logged_autofill_enabled_ = false; |
704 has_logged_address_suggestions_count_ = false; | 776 has_logged_address_suggestions_count_ = false; |
| 777 did_show_suggestions_ = false; |
| 778 user_did_type_ = false; |
| 779 user_did_autofill_ = false; |
| 780 user_did_edit_autofilled_field_ = false; |
705 } | 781 } |
706 | 782 |
707 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, | 783 AutofillManager::AutofillManager(TabContentsWrapper* tab_contents, |
708 PersonalDataManager* personal_data) | 784 PersonalDataManager* personal_data) |
709 : TabContentsObserver(tab_contents->tab_contents()), | 785 : TabContentsObserver(tab_contents->tab_contents()), |
710 tab_contents_wrapper_(tab_contents), | 786 tab_contents_wrapper_(tab_contents), |
711 personal_data_(personal_data), | 787 personal_data_(personal_data), |
712 download_manager_(NULL), | 788 download_manager_(NULL), |
713 disable_download_manager_requests_(true), | 789 disable_download_manager_requests_(true), |
714 metric_logger_(new AutofillMetrics), | 790 metric_logger_(new AutofillMetrics), |
715 has_logged_autofill_enabled_(false), | 791 has_logged_autofill_enabled_(false), |
716 has_logged_address_suggestions_count_(false) { | 792 has_logged_address_suggestions_count_(false), |
| 793 did_show_suggestions_(false), |
| 794 user_did_type_(false), |
| 795 user_did_autofill_(false), |
| 796 user_did_edit_autofilled_field_(false) { |
717 DCHECK(tab_contents); | 797 DCHECK(tab_contents); |
718 } | 798 } |
719 | 799 |
720 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { | 800 void AutofillManager::set_metric_logger(const AutofillMetrics* metric_logger) { |
721 metric_logger_.reset(metric_logger); | 801 metric_logger_.reset(metric_logger); |
722 } | 802 } |
723 | 803 |
724 bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles, | 804 bool AutofillManager::GetHost(const std::vector<AutofillProfile*>& profiles, |
725 const std::vector<CreditCard*>& credit_cards, | 805 const std::vector<CreditCard*>& credit_cards, |
726 RenderViewHost** host) const { | 806 RenderViewHost** host) const { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 // If none of the forms were parsed, no use querying the server. | 1086 // If none of the forms were parsed, no use querying the server. |
1007 if (!form_structures_.empty() && !disable_download_manager_requests_) | 1087 if (!form_structures_.empty() && !disable_download_manager_requests_) |
1008 download_manager_.StartQueryRequest(form_structures_, *metric_logger_); | 1088 download_manager_.StartQueryRequest(form_structures_, *metric_logger_); |
1009 | 1089 |
1010 for (std::vector<FormStructure*>::const_iterator iter = | 1090 for (std::vector<FormStructure*>::const_iterator iter = |
1011 non_queryable_forms.begin(); | 1091 non_queryable_forms.begin(); |
1012 iter != non_queryable_forms.end(); ++iter) { | 1092 iter != non_queryable_forms.end(); ++iter) { |
1013 form_structures_.push_back(*iter); | 1093 form_structures_.push_back(*iter); |
1014 } | 1094 } |
1015 | 1095 |
| 1096 if (!form_structures_.empty()) |
| 1097 metric_logger_->LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); |
| 1098 |
1016 CheckForPopularForms(form_structures_.get(), tab_contents_wrapper_, | 1099 CheckForPopularForms(form_structures_.get(), tab_contents_wrapper_, |
1017 tab_contents()); | 1100 tab_contents()); |
1018 } | 1101 } |
1019 | 1102 |
1020 int AutofillManager::GUIDToID(const GUIDPair& guid) { | 1103 int AutofillManager::GUIDToID(const GUIDPair& guid) { |
1021 static int last_id = 1; | 1104 static int last_id = 1; |
1022 | 1105 |
1023 if (!guid::IsValidGUID(guid.first)) | 1106 if (!guid::IsValidGUID(guid.first)) |
1024 return 0; | 1107 return 0; |
1025 | 1108 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 void AutofillManager::UnpackGUIDs(int id, | 1149 void AutofillManager::UnpackGUIDs(int id, |
1067 GUIDPair* cc_guid, | 1150 GUIDPair* cc_guid, |
1068 GUIDPair* profile_guid) { | 1151 GUIDPair* profile_guid) { |
1069 int cc_id = id >> std::numeric_limits<unsigned short>::digits & | 1152 int cc_id = id >> std::numeric_limits<unsigned short>::digits & |
1070 std::numeric_limits<unsigned short>::max(); | 1153 std::numeric_limits<unsigned short>::max(); |
1071 int profile_id = id & std::numeric_limits<unsigned short>::max(); | 1154 int profile_id = id & std::numeric_limits<unsigned short>::max(); |
1072 | 1155 |
1073 *cc_guid = IDToGUID(cc_id); | 1156 *cc_guid = IDToGUID(cc_id); |
1074 *profile_guid = IDToGUID(profile_id); | 1157 *profile_guid = IDToGUID(profile_id); |
1075 } | 1158 } |
OLD | NEW |