| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // work if the delegate has a pointer to the AutofillManager, but | 233 // work if the delegate has a pointer to the AutofillManager, but |
| 234 // future directions may not need such a pointer. | 234 // future directions may not need such a pointer. |
| 235 external_delegate_ = delegate; | 235 external_delegate_ = delegate; |
| 236 autocomplete_history_manager_->SetExternalDelegate(delegate); | 236 autocomplete_history_manager_->SetExternalDelegate(delegate); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void AutofillManager::ShowAutofillSettings() { | 239 void AutofillManager::ShowAutofillSettings() { |
| 240 manager_delegate_->ShowAutofillSettings(); | 240 manager_delegate_->ShowAutofillSettings(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 #if defined(OS_MACOSX) |
| 244 bool AutofillManager::ShouldShowAccessAddressBookSuggestion( |
| 245 const FormData& form, |
| 246 const FormFieldData& field) { |
| 247 if (!personal_data_) |
| 248 return false; |
| 249 FormStructure* form_structure = NULL; |
| 250 AutofillField* autofill_field = NULL; |
| 251 if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field)) |
| 252 return false; |
| 253 |
| 254 return personal_data_->ShouldShowAccessAddressBookSuggestion( |
| 255 autofill_field->Type()); |
| 256 } |
| 257 |
| 258 bool AutofillManager::AccessAddressBook() { |
| 259 if (!personal_data_) |
| 260 return false; |
| 261 return personal_data_->AccessAddressBook(); |
| 262 } |
| 263 #endif // defined(OS_MACOSX) |
| 264 |
| 243 bool AutofillManager::OnFormSubmitted(const FormData& form, | 265 bool AutofillManager::OnFormSubmitted(const FormData& form, |
| 244 const TimeTicks& timestamp) { | 266 const TimeTicks& timestamp) { |
| 245 if (!IsValidFormData(form)) | 267 if (!IsValidFormData(form)) |
| 246 return false; | 268 return false; |
| 247 | 269 |
| 248 // Let Autocomplete know as well. | 270 // Let Autocomplete know as well. |
| 249 autocomplete_history_manager_->OnFormSubmitted(form); | 271 autocomplete_history_manager_->OnFormSubmitted(form); |
| 250 | 272 |
| 251 // Grab a copy of the form data. | 273 // Grab a copy of the form data. |
| 252 scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); | 274 scoped_ptr<FormStructure> submitted_form(new FormStructure(form)); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); | 607 metric_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); |
| 586 if (!user_did_autofill_) { | 608 if (!user_did_autofill_) { |
| 587 user_did_autofill_ = true; | 609 user_did_autofill_ = true; |
| 588 metric_logger_->LogUserHappinessMetric( | 610 metric_logger_->LogUserHappinessMetric( |
| 589 AutofillMetrics::USER_DID_AUTOFILL_ONCE); | 611 AutofillMetrics::USER_DID_AUTOFILL_ONCE); |
| 590 } | 612 } |
| 591 | 613 |
| 592 UpdateInitialInteractionTimestamp(timestamp); | 614 UpdateInitialInteractionTimestamp(timestamp); |
| 593 } | 615 } |
| 594 | 616 |
| 617 void AutofillManager::OnPingAck() { |
| 618 external_delegate_->OnPingAck(); |
| 619 } |
| 620 |
| 595 void AutofillManager::DidShowSuggestions(bool is_new_popup) { | 621 void AutofillManager::DidShowSuggestions(bool is_new_popup) { |
| 596 if (test_delegate_) | 622 if (test_delegate_) |
| 597 test_delegate_->DidShowSuggestions(); | 623 test_delegate_->DidShowSuggestions(); |
| 598 | 624 |
| 599 if (is_new_popup) { | 625 if (is_new_popup) { |
| 600 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN); | 626 metric_logger_->LogUserHappinessMetric(AutofillMetrics::SUGGESTIONS_SHOWN); |
| 601 | 627 |
| 602 if (!did_show_suggestions_) { | 628 if (!did_show_suggestions_) { |
| 603 did_show_suggestions_ = true; | 629 did_show_suggestions_ = true; |
| 604 metric_logger_->LogUserHappinessMetric( | 630 metric_logger_->LogUserHappinessMetric( |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 return false; | 1164 return false; |
| 1139 | 1165 |
| 1140 // Disregard forms that we wouldn't ever autofill in the first place. | 1166 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1141 if (!form.ShouldBeParsed(true)) | 1167 if (!form.ShouldBeParsed(true)) |
| 1142 return false; | 1168 return false; |
| 1143 | 1169 |
| 1144 return true; | 1170 return true; |
| 1145 } | 1171 } |
| 1146 | 1172 |
| 1147 } // namespace autofill | 1173 } // namespace autofill |
| OLD | NEW |