| OLD | NEW |
| 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 if ((*iter) == field) { | 527 if ((*iter) == field) { |
| 528 data_model->FillFormField( | 528 data_model->FillFormField( |
| 529 *autofill_field, variant, app_locale_, &(*iter)); | 529 *autofill_field, variant, app_locale_, &(*iter)); |
| 530 // Mark the cached field as autofilled, so that we can detect when a | 530 // Mark the cached field as autofilled, so that we can detect when a |
| 531 // user edits an autofilled field (for metrics). | 531 // user edits an autofilled field (for metrics). |
| 532 autofill_field->is_autofilled = true; | 532 autofill_field->is_autofilled = true; |
| 533 break; | 533 break; |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 | 536 |
| 537 host->Send(new AutofillMsg_FormDataFilled(host->GetRoutingID(), query_id, | 537 driver_->SendFormDataToRenderer(query_id, result); |
| 538 result)); | |
| 539 return; | 538 return; |
| 540 } | 539 } |
| 541 | 540 |
| 542 // Cache the field type for the field from which the user initiated autofill. | 541 // Cache the field type for the field from which the user initiated autofill. |
| 543 FieldTypeGroup initiating_group_type = | 542 FieldTypeGroup initiating_group_type = |
| 544 AutofillType(autofill_field->type()).group(); | 543 AutofillType(autofill_field->type()).group(); |
| 545 DCHECK_EQ(form_structure->field_count(), form.fields.size()); | 544 DCHECK_EQ(form_structure->field_count(), form.fields.size()); |
| 546 for (size_t i = 0; i < form_structure->field_count(); ++i) { | 545 for (size_t i = 0; i < form_structure->field_count(); ++i) { |
| 547 if (form_structure->field(i)->section() != autofill_field->section()) | 546 if (form_structure->field(i)->section() != autofill_field->section()) |
| 548 continue; | 547 continue; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 572 form_structure->field(i)->is_autofilled = true; | 571 form_structure->field(i)->is_autofilled = true; |
| 573 } | 572 } |
| 574 } | 573 } |
| 575 | 574 |
| 576 autofilled_form_signatures_.push_front(form_structure->FormSignature()); | 575 autofilled_form_signatures_.push_front(form_structure->FormSignature()); |
| 577 // Only remember the last few forms that we've seen, both to avoid false | 576 // Only remember the last few forms that we've seen, both to avoid false |
| 578 // positives and to avoid wasting memory. | 577 // positives and to avoid wasting memory. |
| 579 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) | 578 if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember) |
| 580 autofilled_form_signatures_.pop_back(); | 579 autofilled_form_signatures_.pop_back(); |
| 581 | 580 |
| 582 host->Send(new AutofillMsg_FormDataFilled( | 581 driver_->SendFormDataToRenderer(query_id, result); |
| 583 host->GetRoutingID(), query_id, result)); | |
| 584 } | 582 } |
| 585 | 583 |
| 586 void AutofillManager::OnShowAutofillDialog() { | 584 void AutofillManager::OnShowAutofillDialog() { |
| 587 manager_delegate_->ShowAutofillSettings(); | 585 manager_delegate_->ShowAutofillSettings(); |
| 588 } | 586 } |
| 589 | 587 |
| 590 void AutofillManager::OnDidPreviewAutofillFormData() { | 588 void AutofillManager::OnDidPreviewAutofillFormData() { |
| 591 if (test_delegate_) | 589 if (test_delegate_) |
| 592 test_delegate_->DidPreviewFormData(); | 590 test_delegate_->DidPreviewFormData(); |
| 593 } | 591 } |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 bool AutofillManager::GetHost(RenderViewHost** host) const { | 946 bool AutofillManager::GetHost(RenderViewHost** host) const { |
| 949 if (!IsAutofillEnabled()) | 947 if (!IsAutofillEnabled()) |
| 950 return false; | 948 return false; |
| 951 | 949 |
| 952 // No autofill data to return if the profiles are empty. | 950 // No autofill data to return if the profiles are empty. |
| 953 if (personal_data_->GetProfiles().empty() && | 951 if (personal_data_->GetProfiles().empty() && |
| 954 personal_data_->GetCreditCards().empty()) { | 952 personal_data_->GetCreditCards().empty()) { |
| 955 return false; | 953 return false; |
| 956 } | 954 } |
| 957 | 955 |
| 958 *host = driver_->GetWebContents()->GetRenderViewHost(); | 956 if (!driver_->RendererIsAvailable()) |
| 959 if (!*host) | |
| 960 return false; | 957 return false; |
| 961 | 958 |
| 959 *host = driver_->GetWebContents()->GetRenderViewHost(); |
| 962 return true; | 960 return true; |
| 963 } | 961 } |
| 964 | 962 |
| 965 bool AutofillManager::GetProfileOrCreditCard( | 963 bool AutofillManager::GetProfileOrCreditCard( |
| 966 int unique_id, | 964 int unique_id, |
| 967 const AutofillDataModel** data_model, | 965 const AutofillDataModel** data_model, |
| 968 size_t* variant) const { | 966 size_t* variant) const { |
| 969 // Unpack the |unique_id| into component parts. | 967 // Unpack the |unique_id| into component parts. |
| 970 GUIDPair credit_card_guid; | 968 GUIDPair credit_card_guid; |
| 971 GUIDPair profile_guid; | 969 GUIDPair profile_guid; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 | 1250 |
| 1253 void AutofillManager::UpdateInitialInteractionTimestamp( | 1251 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1254 const TimeTicks& interaction_timestamp) { | 1252 const TimeTicks& interaction_timestamp) { |
| 1255 if (initial_interaction_timestamp_.is_null() || | 1253 if (initial_interaction_timestamp_.is_null() || |
| 1256 interaction_timestamp < initial_interaction_timestamp_) { | 1254 interaction_timestamp < initial_interaction_timestamp_) { |
| 1257 initial_interaction_timestamp_ = interaction_timestamp; | 1255 initial_interaction_timestamp_ = interaction_timestamp; |
| 1258 } | 1256 } |
| 1259 } | 1257 } |
| 1260 | 1258 |
| 1261 } // namespace autofill | 1259 } // namespace autofill |
| OLD | NEW |