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" |
| 11 #include "grit/component_strings.h" | 11 #include "grit/component_strings.h" |
| 12 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 12 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 13 #include "third_party/WebKit/public/web/WebFormControlElement.h" | |
| 14 #include "third_party/WebKit/public/web/WebFormElement.h" | |
| 13 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 14 | 16 |
| 15 using blink::WebAutofillClient; | 17 using blink::WebAutofillClient; |
| 16 | 18 |
| 17 namespace autofill { | 19 namespace autofill { |
| 18 | 20 |
| 19 AutofillExternalDelegate::AutofillExternalDelegate( | 21 AutofillExternalDelegate::AutofillExternalDelegate( |
| 20 AutofillManager* autofill_manager, | 22 AutofillManager* autofill_manager, |
| 21 AutofillDriver* autofill_driver) | 23 AutofillDriver* autofill_driver) |
| 22 : autofill_manager_(autofill_manager), | 24 : autofill_manager_(autofill_manager), |
| 23 autofill_driver_(autofill_driver), | 25 autofill_driver_(autofill_driver), |
| 24 password_autofill_manager_(autofill_driver), | 26 password_autofill_manager_(autofill_driver), |
| 25 autofill_query_id_(0), | 27 autofill_query_id_(0), |
| 26 display_warning_if_disabled_(false), | 28 display_warning_if_disabled_(false), |
| 27 has_autofill_suggestion_(false), | 29 has_autofill_suggestion_(false), |
| 28 has_shown_autofill_popup_for_current_edit_(false), | 30 has_shown_autofill_popup_for_current_edit_(false), |
| 29 weak_ptr_factory_(this) { | 31 weak_ptr_factory_(this) { |
| 30 DCHECK(autofill_manager); | 32 DCHECK(autofill_manager); |
| 31 } | 33 } |
| 32 | 34 |
| 33 AutofillExternalDelegate::~AutofillExternalDelegate() {} | 35 AutofillExternalDelegate::~AutofillExternalDelegate() {} |
| 34 | 36 |
| 35 void AutofillExternalDelegate::OnQuery(int query_id, | 37 void AutofillExternalDelegate::OnQuery(int query_id, |
| 36 const FormData& form, | 38 const FormData& form, |
| 37 const FormFieldData& field, | 39 const FormFieldData& field, |
| 40 const blink::WebFormElement& element, | |
| 38 const gfx::RectF& element_bounds, | 41 const gfx::RectF& element_bounds, |
| 39 bool display_warning_if_disabled) { | 42 bool display_warning_if_disabled) { |
| 40 autofill_query_form_ = form; | 43 autofill_query_form_ = form; |
| 41 autofill_query_field_ = field; | 44 autofill_query_field_ = field; |
| 45 web_form_element_ = element; | |
| 42 display_warning_if_disabled_ = display_warning_if_disabled; | 46 display_warning_if_disabled_ = display_warning_if_disabled; |
| 43 autofill_query_id_ = query_id; | 47 autofill_query_id_ = query_id; |
| 44 element_bounds_ = element_bounds; | 48 element_bounds_ = element_bounds; |
| 45 } | 49 } |
| 46 | 50 |
| 47 void AutofillExternalDelegate::OnSuggestionsReturned( | 51 void AutofillExternalDelegate::OnSuggestionsReturned( |
| 48 int query_id, | 52 int query_id, |
| 49 const std::vector<base::string16>& autofill_values, | 53 const std::vector<base::string16>& autofill_values, |
| 50 const std::vector<base::string16>& autofill_labels, | 54 const std::vector<base::string16>& autofill_labels, |
| 51 const std::vector<base::string16>& autofill_icons, | 55 const std::vector<base::string16>& autofill_icons, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 if (autofill_query_field_.is_focusable) { | 108 if (autofill_query_field_.is_focusable) { |
| 105 autofill_manager_->delegate()->ShowAutofillPopup( | 109 autofill_manager_->delegate()->ShowAutofillPopup( |
| 106 element_bounds_, | 110 element_bounds_, |
| 107 autofill_query_field_.text_direction, | 111 autofill_query_field_.text_direction, |
| 108 values, | 112 values, |
| 109 labels, | 113 labels, |
| 110 icons, | 114 icons, |
| 111 ids, | 115 ids, |
| 112 GetWeakPtr()); | 116 GetWeakPtr()); |
| 113 } | 117 } |
| 114 } | 118 }OnShowPasswordSuggestions |
|
vabr (Chromium)
2014/01/10 18:40:00
This looks misplaced. Please delete "OnShowPasswor
| |
| 115 | 119 |
| 116 void AutofillExternalDelegate::OnShowPasswordSuggestions( | 120 void AutofillExternalDelegate::OnShowPasswordSuggestions( |
| 117 const std::vector<base::string16>& suggestions, | 121 const std::vector<base::string16>& suggestions, |
| 118 const std::vector<base::string16>& realms, | 122 const std::vector<base::string16>& realms, |
| 119 const FormFieldData& field, | 123 const FormFieldData& field, |
| 124 const blink::WebFormElement& element, | |
| 120 const gfx::RectF& element_bounds) { | 125 const gfx::RectF& element_bounds) { |
| 121 autofill_query_field_ = field; | 126 autofill_query_field_ = field; |
| 127 web_form_element_ = element; | |
| 122 element_bounds_ = element_bounds; | 128 element_bounds_ = element_bounds; |
| 123 | 129 |
| 124 if (suggestions.empty()) { | 130 if (suggestions.empty()) { |
| 125 autofill_manager_->delegate()->HideAutofillPopup(); | 131 autofill_manager_->delegate()->HideAutofillPopup(); |
| 126 return; | 132 return; |
| 127 } | 133 } |
| 128 | 134 |
| 129 std::vector<base::string16> empty(suggestions.size()); | 135 std::vector<base::string16> empty(suggestions.size()); |
| 130 std::vector<int> password_ids(suggestions.size(), | 136 std::vector<int> password_ids(suggestions.size(), |
| 131 WebAutofillClient::MenuItemIDPasswordEntry); | 137 WebAutofillClient::MenuItemIDPasswordEntry); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 FillAutofillFormData(identifier, false); | 199 FillAutofillFormData(identifier, false); |
| 194 } | 200 } |
| 195 | 201 |
| 196 autofill_manager_->delegate()->HideAutofillPopup(); | 202 autofill_manager_->delegate()->HideAutofillPopup(); |
| 197 } | 203 } |
| 198 | 204 |
| 199 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, | 205 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, |
| 200 int identifier) { | 206 int identifier) { |
| 201 if (identifier > 0) { | 207 if (identifier > 0) { |
| 202 autofill_manager_->RemoveAutofillProfileOrCreditCard(identifier); | 208 autofill_manager_->RemoveAutofillProfileOrCreditCard(identifier); |
| 209 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry) { | |
| 210 bool success = password_autofill_manager_.RemovePasswordSuggestion( | |
| 211 autofill_query_field_, | |
| 212 web_form_element_); | |
| 213 DCHECK(success); | |
| 203 } else { | 214 } else { |
| 204 autofill_manager_->RemoveAutocompleteEntry(autofill_query_field_.name, | 215 autofill_manager_->RemoveAutocompleteEntry(autofill_query_field_.name, |
| 205 value); | 216 value); |
| 206 } | 217 } |
| 207 } | 218 } |
| 208 | 219 |
| 209 void AutofillExternalDelegate::DidEndTextFieldEditing() { | 220 void AutofillExternalDelegate::DidEndTextFieldEditing() { |
| 210 autofill_manager_->delegate()->HideAutofillPopup(); | 221 autofill_manager_->delegate()->HideAutofillPopup(); |
| 211 | 222 |
| 212 has_shown_autofill_popup_for_current_edit_ = false; | 223 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. | 360 // Set the values that all datalist elements share. |
| 350 autofill_icons->insert(autofill_icons->begin(), | 361 autofill_icons->insert(autofill_icons->begin(), |
| 351 data_list_values_.size(), | 362 data_list_values_.size(), |
| 352 base::string16()); | 363 base::string16()); |
| 353 autofill_unique_ids->insert(autofill_unique_ids->begin(), | 364 autofill_unique_ids->insert(autofill_unique_ids->begin(), |
| 354 data_list_values_.size(), | 365 data_list_values_.size(), |
| 355 WebAutofillClient::MenuItemIDDataListEntry); | 366 WebAutofillClient::MenuItemIDDataListEntry); |
| 356 } | 367 } |
| 357 | 368 |
| 358 } // namespace autofill | 369 } // namespace autofill |
| OLD | NEW |