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_external_delegate.h" | 5 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 8 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 9 #include "components/autofill/core/browser/autofill_driver.h" | 9 #include "components/autofill/core/browser/autofill_driver.h" |
| 10 #include "components/autofill/core/browser/autofill_manager.h" | 10 #include "components/autofill/core/browser/autofill_manager.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 has_shown_autofill_popup_for_current_edit_(false), | 28 has_shown_autofill_popup_for_current_edit_(false), |
| 29 weak_ptr_factory_(this) { | 29 weak_ptr_factory_(this) { |
| 30 DCHECK(autofill_manager); | 30 DCHECK(autofill_manager); |
| 31 } | 31 } |
| 32 | 32 |
| 33 AutofillExternalDelegate::~AutofillExternalDelegate() {} | 33 AutofillExternalDelegate::~AutofillExternalDelegate() {} |
| 34 | 34 |
| 35 void AutofillExternalDelegate::OnQuery(int query_id, | 35 void AutofillExternalDelegate::OnQuery(int query_id, |
| 36 const FormData& form, | 36 const FormData& form, |
| 37 const FormFieldData& field, | 37 const FormFieldData& field, |
| 38 const PasswordForm& passwordform, | |
|
vabr (Chromium)
2014/01/13 14:46:29
Why do you actually need the PasswordForm in OnQue
riadh.chtara
2014/01/13 20:56:08
I m not really but this the logic I followed:
When
vabr (Chromium)
2014/01/14 14:11:02
We should not just blindly copy the lifetime of an
| |
| 38 const gfx::RectF& element_bounds, | 39 const gfx::RectF& element_bounds, |
| 39 bool display_warning_if_disabled) { | 40 bool display_warning_if_disabled) { |
| 40 autofill_query_form_ = form; | 41 autofill_query_form_ = form; |
| 41 autofill_query_field_ = field; | 42 autofill_query_field_ = field; |
| 43 autofill_query_password_form_ = passwordform; | |
| 42 display_warning_if_disabled_ = display_warning_if_disabled; | 44 display_warning_if_disabled_ = display_warning_if_disabled; |
| 43 autofill_query_id_ = query_id; | 45 autofill_query_id_ = query_id; |
| 44 element_bounds_ = element_bounds; | 46 element_bounds_ = element_bounds; |
| 45 } | 47 } |
| 46 | 48 |
| 47 void AutofillExternalDelegate::OnSuggestionsReturned( | 49 void AutofillExternalDelegate::OnSuggestionsReturned( |
| 48 int query_id, | 50 int query_id, |
| 49 const std::vector<base::string16>& autofill_values, | 51 const std::vector<base::string16>& autofill_values, |
| 50 const std::vector<base::string16>& autofill_labels, | 52 const std::vector<base::string16>& autofill_labels, |
| 51 const std::vector<base::string16>& autofill_icons, | 53 const std::vector<base::string16>& autofill_icons, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 icons, | 112 icons, |
| 111 ids, | 113 ids, |
| 112 GetWeakPtr()); | 114 GetWeakPtr()); |
| 113 } | 115 } |
| 114 } | 116 } |
| 115 | 117 |
| 116 void AutofillExternalDelegate::OnShowPasswordSuggestions( | 118 void AutofillExternalDelegate::OnShowPasswordSuggestions( |
| 117 const std::vector<base::string16>& suggestions, | 119 const std::vector<base::string16>& suggestions, |
| 118 const std::vector<base::string16>& realms, | 120 const std::vector<base::string16>& realms, |
| 119 const FormFieldData& field, | 121 const FormFieldData& field, |
| 122 const PasswordForm& passwordform, | |
| 120 const gfx::RectF& element_bounds) { | 123 const gfx::RectF& element_bounds) { |
| 121 autofill_query_field_ = field; | 124 autofill_query_field_ = field; |
| 125 autofill_query_password_form_ = passwordform; | |
| 122 element_bounds_ = element_bounds; | 126 element_bounds_ = element_bounds; |
| 123 | 127 |
| 124 if (suggestions.empty()) { | 128 if (suggestions.empty()) { |
| 125 autofill_manager_->delegate()->HideAutofillPopup(); | 129 autofill_manager_->delegate()->HideAutofillPopup(); |
| 126 return; | 130 return; |
| 127 } | 131 } |
| 128 | 132 |
| 129 std::vector<base::string16> empty(suggestions.size()); | 133 std::vector<base::string16> empty(suggestions.size()); |
| 130 std::vector<int> password_ids(suggestions.size(), | 134 std::vector<int> password_ids(suggestions.size(), |
| 131 WebAutofillClient::MenuItemIDPasswordEntry); | 135 WebAutofillClient::MenuItemIDPasswordEntry); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 FillAutofillFormData(identifier, false); | 197 FillAutofillFormData(identifier, false); |
| 194 } | 198 } |
| 195 | 199 |
| 196 autofill_manager_->delegate()->HideAutofillPopup(); | 200 autofill_manager_->delegate()->HideAutofillPopup(); |
| 197 } | 201 } |
| 198 | 202 |
| 199 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, | 203 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, |
| 200 int identifier) { | 204 int identifier) { |
| 201 if (identifier > 0) { | 205 if (identifier > 0) { |
| 202 autofill_manager_->RemoveAutofillProfileOrCreditCard(identifier); | 206 autofill_manager_->RemoveAutofillProfileOrCreditCard(identifier); |
| 207 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry) { | |
| 208 bool success = password_autofill_manager_.RemovePasswordSuggestion( | |
| 209 autofill_query_field_, | |
| 210 autofill_query_password_form_); | |
| 211 DCHECK(success); | |
| 203 } else { | 212 } else { |
| 204 autofill_manager_->RemoveAutocompleteEntry(autofill_query_field_.name, | 213 autofill_manager_->RemoveAutocompleteEntry(autofill_query_field_.name, |
| 205 value); | 214 value); |
| 206 } | 215 } |
| 207 } | 216 } |
| 208 | 217 |
| 209 void AutofillExternalDelegate::DidEndTextFieldEditing() { | 218 void AutofillExternalDelegate::DidEndTextFieldEditing() { |
| 210 autofill_manager_->delegate()->HideAutofillPopup(); | 219 autofill_manager_->delegate()->HideAutofillPopup(); |
| 211 | 220 |
| 212 has_shown_autofill_popup_for_current_edit_ = false; | 221 has_shown_autofill_popup_for_current_edit_ = false; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 // Set the values that all datalist elements share. | 358 // Set the values that all datalist elements share. |
| 350 autofill_icons->insert(autofill_icons->begin(), | 359 autofill_icons->insert(autofill_icons->begin(), |
| 351 data_list_values_.size(), | 360 data_list_values_.size(), |
| 352 base::string16()); | 361 base::string16()); |
| 353 autofill_unique_ids->insert(autofill_unique_ids->begin(), | 362 autofill_unique_ids->insert(autofill_unique_ids->begin(), |
| 354 data_list_values_.size(), | 363 data_list_values_.size(), |
| 355 WebAutofillClient::MenuItemIDDataListEntry); | 364 WebAutofillClient::MenuItemIDDataListEntry); |
| 356 } | 365 } |
| 357 | 366 |
| 358 } // namespace autofill | 367 } // namespace autofill |
| OLD | NEW |