Chromium Code Reviews| 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> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/guid.h" | 16 #include "base/guid.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram.h" | |
|
Ilya Sherman
2015/05/15 21:14:58
nit: Please include histogram_macros.h instead.
erikchen
2015/05/15 21:37:23
Done.
| |
| 20 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 21 #include "base/strings/string16.h" | 22 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/threading/sequenced_worker_pool.h" | 25 #include "base/threading/sequenced_worker_pool.h" |
| 25 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 26 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 26 #include "components/autofill/core/browser/autofill_client.h" | 27 #include "components/autofill/core/browser/autofill_client.h" |
| 27 #include "components/autofill/core/browser/autofill_data_model.h" | 28 #include "components/autofill/core/browser/autofill_data_model.h" |
| 28 #include "components/autofill/core/browser/autofill_experiments.h" | 29 #include "components/autofill/core/browser/autofill_experiments.h" |
| 29 #include "components/autofill/core/browser/autofill_external_delegate.h" | 30 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 } | 694 } |
| 694 | 695 |
| 695 void AutofillManager::OnHidePopup() { | 696 void AutofillManager::OnHidePopup() { |
| 696 if (!IsAutofillEnabled()) | 697 if (!IsAutofillEnabled()) |
| 697 return; | 698 return; |
| 698 | 699 |
| 699 autocomplete_history_manager_->CancelPendingQuery(); | 700 autocomplete_history_manager_->CancelPendingQuery(); |
| 700 client_->HideAutofillPopup(); | 701 client_->HideAutofillPopup(); |
| 701 } | 702 } |
| 702 | 703 |
| 704 void AutofillManager::OnUserDidAcceptAutofillSuggestion(int unique_id) { | |
| 705 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 706 size_t variant = 0; | |
| 707 const AutofillProfile* profile = nullptr; | |
| 708 bool result = GetProfile(unique_id, &profile, &variant); | |
| 709 if (!result) | |
| 710 return; | |
| 711 | |
| 712 bool is_from_address_book = | |
| 713 profile->record_type() == AutofillProfile::AUXILIARY_PROFILE; | |
| 714 UMA_HISTOGRAM_BOOLEAN("Autofill.MacAddressBook.AcceptedResultFromAddressBook", | |
|
Ilya Sherman
2015/05/15 21:14:58
nit: I'd name this "AcceptedResultIsFromAddressBoo
erikchen
2015/05/15 21:37:23
Done.
| |
| 715 is_from_address_book); | |
| 716 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
| 717 } | |
| 718 | |
| 703 bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { | 719 bool AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { |
| 704 std::string guid; | 720 std::string guid; |
| 705 size_t variant = 0; | 721 size_t variant = 0; |
| 706 const CreditCard* credit_card = nullptr; | 722 const CreditCard* credit_card = nullptr; |
| 707 const AutofillProfile* profile = nullptr; | 723 const AutofillProfile* profile = nullptr; |
| 708 if (GetCreditCard(unique_id, &credit_card)) { | 724 if (GetCreditCard(unique_id, &credit_card)) { |
| 709 if (credit_card->record_type() != CreditCard::LOCAL_CARD) | 725 if (credit_card->record_type() != CreditCard::LOCAL_CARD) |
| 710 return false; | 726 return false; |
| 711 | 727 |
| 712 guid = credit_card->guid(); | 728 guid = credit_card->guid(); |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1511 return false; | 1527 return false; |
| 1512 | 1528 |
| 1513 // Disregard forms that we wouldn't ever autofill in the first place. | 1529 // Disregard forms that we wouldn't ever autofill in the first place. |
| 1514 if (!form.ShouldBeParsed()) | 1530 if (!form.ShouldBeParsed()) |
| 1515 return false; | 1531 return false; |
| 1516 | 1532 |
| 1517 return true; | 1533 return true; |
| 1518 } | 1534 } |
| 1519 | 1535 |
| 1520 } // namespace autofill | 1536 } // namespace autofill |
| OLD | NEW |