| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/browser/autofill/password_generator.h" | 35 #include "chrome/browser/autofill/password_generator.h" |
| 36 #include "chrome/browser/autofill/personal_data_manager.h" | 36 #include "chrome/browser/autofill/personal_data_manager.h" |
| 37 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 37 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 38 #include "chrome/browser/autofill/phone_number.h" | 38 #include "chrome/browser/autofill/phone_number.h" |
| 39 #include "chrome/browser/autofill/phone_number_i18n.h" | 39 #include "chrome/browser/autofill/phone_number_i18n.h" |
| 40 #include "chrome/browser/autofill/select_control_handler.h" | 40 #include "chrome/browser/autofill/select_control_handler.h" |
| 41 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 41 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 42 #include "chrome/common/autofill_messages.h" | 42 #include "chrome/common/autofill_messages.h" |
| 43 #include "chrome/common/chrome_notification_types.h" | 43 #include "chrome/common/chrome_notification_types.h" |
| 44 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/form_data.h" |
| 46 #include "chrome/common/form_data_predictions.h" |
| 47 #include "chrome/common/form_field.h" |
| 48 #include "chrome/common/password_form_fill_data.h" |
| 45 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/url_constants.h" | 50 #include "chrome/common/url_constants.h" |
| 47 #include "content/public/browser/browser_context.h" | 51 #include "content/public/browser/browser_context.h" |
| 48 #include "content/public/browser/browser_thread.h" | 52 #include "content/public/browser/browser_thread.h" |
| 49 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/notification_source.h" | 54 #include "content/public/browser/notification_source.h" |
| 51 #include "content/public/browser/render_view_host.h" | 55 #include "content/public/browser/render_view_host.h" |
| 52 #include "content/public/browser/web_contents.h" | 56 #include "content/public/browser/web_contents.h" |
| 53 #include "googleurl/src/gurl.h" | 57 #include "googleurl/src/gurl.h" |
| 54 #include "grit/generated_resources.h" | 58 #include "grit/generated_resources.h" |
| 55 #include "ipc/ipc_message_macros.h" | 59 #include "ipc/ipc_message_macros.h" |
| 56 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" | 60 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" |
| 57 #include "ui/base/l10n/l10n_util.h" | 61 #include "ui/base/l10n/l10n_util.h" |
| 58 #include "ui/gfx/rect.h" | 62 #include "ui/gfx/rect.h" |
| 59 #include "webkit/forms/form_data.h" | |
| 60 #include "webkit/forms/form_data_predictions.h" | |
| 61 #include "webkit/forms/form_field.h" | |
| 62 #include "webkit/forms/password_form_dom_manager.h" | |
| 63 | 63 |
| 64 using base::TimeTicks; | 64 using base::TimeTicks; |
| 65 using chrome::FormData; |
| 66 using chrome::FormDataPredictions; |
| 67 using chrome::FormField; |
| 65 using content::BrowserThread; | 68 using content::BrowserThread; |
| 66 using content::RenderViewHost; | 69 using content::RenderViewHost; |
| 67 using switches::kEnableAutofillFeedback; | 70 using switches::kEnableAutofillFeedback; |
| 68 using webkit::forms::FormData; | |
| 69 using webkit::forms::FormDataPredictions; | |
| 70 using webkit::forms::FormField; | |
| 71 | 71 |
| 72 namespace { | 72 namespace { |
| 73 | 73 |
| 74 // We only send a fraction of the forms to upload server. | 74 // We only send a fraction of the forms to upload server. |
| 75 // The rate for positive/negative matches potentially could be different. | 75 // The rate for positive/negative matches potentially could be different. |
| 76 const double kAutofillPositiveUploadRateDefaultValue = 0.20; | 76 const double kAutofillPositiveUploadRateDefaultValue = 0.20; |
| 77 const double kAutofillNegativeUploadRateDefaultValue = 0.20; | 77 const double kAutofillNegativeUploadRateDefaultValue = 0.20; |
| 78 | 78 |
| 79 const size_t kMaxRecentFormSignaturesToRemember = 3; | 79 const size_t kMaxRecentFormSignaturesToRemember = 3; |
| 80 | 80 |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 709 } |
| 710 | 710 |
| 711 void AutofillManager::OnHideAutofillPopup() { | 711 void AutofillManager::OnHideAutofillPopup() { |
| 712 if (external_delegate_) | 712 if (external_delegate_) |
| 713 external_delegate_->HideAutofillPopup(); | 713 external_delegate_->HideAutofillPopup(); |
| 714 } | 714 } |
| 715 | 715 |
| 716 void AutofillManager::OnShowPasswordGenerationPopup( | 716 void AutofillManager::OnShowPasswordGenerationPopup( |
| 717 const gfx::Rect& bounds, | 717 const gfx::Rect& bounds, |
| 718 int max_length, | 718 int max_length, |
| 719 const webkit::forms::PasswordForm& form) { | 719 const content::PasswordForm& form) { |
| 720 password_generator_.reset(new autofill::PasswordGenerator(max_length)); | 720 password_generator_.reset(new autofill::PasswordGenerator(max_length)); |
| 721 manager_delegate_->ShowPasswordGenerationBubble( | 721 manager_delegate_->ShowPasswordGenerationBubble( |
| 722 bounds, form, password_generator_.get()); | 722 bounds, form, password_generator_.get()); |
| 723 } | 723 } |
| 724 | 724 |
| 725 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { | 725 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { |
| 726 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); | 726 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); |
| 727 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); | 727 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); |
| 728 const AutofillProfile* profile = NULL; | 728 const AutofillProfile* profile = NULL; |
| 729 const CreditCard* credit_card = NULL; | 729 const CreditCard* credit_card = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 740 if (variant != 0) | 740 if (variant != 0) |
| 741 return; | 741 return; |
| 742 | 742 |
| 743 if (profile) | 743 if (profile) |
| 744 personal_data_->RemoveProfile(profile->guid()); | 744 personal_data_->RemoveProfile(profile->guid()); |
| 745 else | 745 else |
| 746 personal_data_->RemoveCreditCard(credit_card->guid()); | 746 personal_data_->RemoveCreditCard(credit_card->guid()); |
| 747 } | 747 } |
| 748 | 748 |
| 749 void AutofillManager::OnAddPasswordFormMapping( | 749 void AutofillManager::OnAddPasswordFormMapping( |
| 750 const webkit::forms::FormField& form, | 750 const chrome::FormField& form, |
| 751 const webkit::forms::PasswordFormFillData& fill_data) { | 751 const chrome::PasswordFormFillData& fill_data) { |
| 752 if (external_delegate_) | 752 if (external_delegate_) |
| 753 external_delegate_->AddPasswordFormMapping(form, fill_data); | 753 external_delegate_->AddPasswordFormMapping(form, fill_data); |
| 754 } | 754 } |
| 755 | 755 |
| 756 void AutofillManager::OnShowPasswordSuggestions( | 756 void AutofillManager::OnShowPasswordSuggestions( |
| 757 const webkit::forms::FormField& field, | 757 const chrome::FormField& field, |
| 758 const gfx::Rect& bounds, | 758 const gfx::Rect& bounds, |
| 759 const std::vector<string16>& suggestions) { | 759 const std::vector<string16>& suggestions) { |
| 760 if (external_delegate_) | 760 if (external_delegate_) |
| 761 external_delegate_->OnShowPasswordSuggestions(suggestions, field, bounds); | 761 external_delegate_->OnShowPasswordSuggestions(suggestions, field, bounds); |
| 762 } | 762 } |
| 763 | 763 |
| 764 void AutofillManager::OnSetDataList(const std::vector<string16>& values, | 764 void AutofillManager::OnSetDataList(const std::vector<string16>& values, |
| 765 const std::vector<string16>& labels, | 765 const std::vector<string16>& labels, |
| 766 const std::vector<string16>& icons, | 766 const std::vector<string16>& icons, |
| 767 const std::vector<int>& unique_ids) { | 767 const std::vector<int>& unique_ids) { |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 *profile_guid = IDToGUID(profile_id); | 1389 *profile_guid = IDToGUID(profile_id); |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 void AutofillManager::UpdateInitialInteractionTimestamp( | 1392 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1393 const TimeTicks& interaction_timestamp) { | 1393 const TimeTicks& interaction_timestamp) { |
| 1394 if (initial_interaction_timestamp_.is_null() || | 1394 if (initial_interaction_timestamp_.is_null() || |
| 1395 interaction_timestamp < initial_interaction_timestamp_) { | 1395 interaction_timestamp < initial_interaction_timestamp_) { |
| 1396 initial_interaction_timestamp_ = interaction_timestamp; | 1396 initial_interaction_timestamp_ = interaction_timestamp; |
| 1397 } | 1397 } |
| 1398 } | 1398 } |
| OLD | NEW |