| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 46 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| 47 #include "content/public/browser/browser_context.h" | 47 #include "content/public/browser/browser_context.h" |
| 48 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
| 51 #include "content/public/browser/render_view_host.h" | 51 #include "content/public/browser/render_view_host.h" |
| 52 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
| 53 #include "content/public/common/form_data.h" |
| 54 #include "content/public/common/form_data_predictions.h" |
| 55 #include "content/public/common/form_field.h" |
| 56 #include "content/public/common/password_form_fill_data.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 content::BrowserThread; | 65 using content::BrowserThread; |
| 66 using content::FormData; |
| 67 using content::FormDataPredictions; |
| 68 using content::FormField; |
| 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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 } | 708 } |
| 709 | 709 |
| 710 void AutofillManager::OnHideAutofillPopup() { | 710 void AutofillManager::OnHideAutofillPopup() { |
| 711 if (external_delegate_) | 711 if (external_delegate_) |
| 712 external_delegate_->HideAutofillPopup(); | 712 external_delegate_->HideAutofillPopup(); |
| 713 } | 713 } |
| 714 | 714 |
| 715 void AutofillManager::OnShowPasswordGenerationPopup( | 715 void AutofillManager::OnShowPasswordGenerationPopup( |
| 716 const gfx::Rect& bounds, | 716 const gfx::Rect& bounds, |
| 717 int max_length, | 717 int max_length, |
| 718 const webkit::forms::PasswordForm& form) { | 718 const content::PasswordForm& form) { |
| 719 password_generator_.reset(new autofill::PasswordGenerator(max_length)); | 719 password_generator_.reset(new autofill::PasswordGenerator(max_length)); |
| 720 manager_delegate_->ShowPasswordGenerationBubble( | 720 manager_delegate_->ShowPasswordGenerationBubble( |
| 721 bounds, form, password_generator_.get()); | 721 bounds, form, password_generator_.get()); |
| 722 } | 722 } |
| 723 | 723 |
| 724 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { | 724 void AutofillManager::RemoveAutofillProfileOrCreditCard(int unique_id) { |
| 725 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); | 725 const std::vector<AutofillProfile*>& profiles = personal_data_->profiles(); |
| 726 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); | 726 const std::vector<CreditCard*>& credit_cards = personal_data_->credit_cards(); |
| 727 const AutofillProfile* profile = NULL; | 727 const AutofillProfile* profile = NULL; |
| 728 const CreditCard* credit_card = NULL; | 728 const CreditCard* credit_card = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 739 if (variant != 0) | 739 if (variant != 0) |
| 740 return; | 740 return; |
| 741 | 741 |
| 742 if (profile) | 742 if (profile) |
| 743 personal_data_->RemoveProfile(profile->guid()); | 743 personal_data_->RemoveProfile(profile->guid()); |
| 744 else | 744 else |
| 745 personal_data_->RemoveCreditCard(credit_card->guid()); | 745 personal_data_->RemoveCreditCard(credit_card->guid()); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void AutofillManager::OnAddPasswordFormMapping( | 748 void AutofillManager::OnAddPasswordFormMapping( |
| 749 const webkit::forms::FormField& form, | 749 const content::FormField& form, |
| 750 const webkit::forms::PasswordFormFillData& fill_data) { | 750 const content::PasswordFormFillData& fill_data) { |
| 751 if (external_delegate_) | 751 if (external_delegate_) |
| 752 external_delegate_->AddPasswordFormMapping(form, fill_data); | 752 external_delegate_->AddPasswordFormMapping(form, fill_data); |
| 753 } | 753 } |
| 754 | 754 |
| 755 void AutofillManager::OnShowPasswordSuggestions( | 755 void AutofillManager::OnShowPasswordSuggestions( |
| 756 const webkit::forms::FormField& field, | 756 const content::FormField& field, |
| 757 const gfx::Rect& bounds, | 757 const gfx::Rect& bounds, |
| 758 const std::vector<string16>& suggestions) { | 758 const std::vector<string16>& suggestions) { |
| 759 if (external_delegate_) | 759 if (external_delegate_) |
| 760 external_delegate_->OnShowPasswordSuggestions(suggestions, field, bounds); | 760 external_delegate_->OnShowPasswordSuggestions(suggestions, field, bounds); |
| 761 } | 761 } |
| 762 | 762 |
| 763 void AutofillManager::OnSetDataList(const std::vector<string16>& values, | 763 void AutofillManager::OnSetDataList(const std::vector<string16>& values, |
| 764 const std::vector<string16>& labels, | 764 const std::vector<string16>& labels, |
| 765 const std::vector<string16>& icons, | 765 const std::vector<string16>& icons, |
| 766 const std::vector<int>& unique_ids) { | 766 const std::vector<int>& unique_ids) { |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1388 *profile_guid = IDToGUID(profile_id); | 1388 *profile_guid = IDToGUID(profile_id); |
| 1389 } | 1389 } |
| 1390 | 1390 |
| 1391 void AutofillManager::UpdateInitialInteractionTimestamp( | 1391 void AutofillManager::UpdateInitialInteractionTimestamp( |
| 1392 const TimeTicks& interaction_timestamp) { | 1392 const TimeTicks& interaction_timestamp) { |
| 1393 if (initial_interaction_timestamp_.is_null() || | 1393 if (initial_interaction_timestamp_.is_null() || |
| 1394 interaction_timestamp < initial_interaction_timestamp_) { | 1394 interaction_timestamp < initial_interaction_timestamp_) { |
| 1395 initial_interaction_timestamp_ = interaction_timestamp; | 1395 initial_interaction_timestamp_ = interaction_timestamp; |
| 1396 } | 1396 } |
| 1397 } | 1397 } |
| OLD | NEW |