| 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 "components/autofill/core/browser/popup_item_ids.h" | 11 #include "components/autofill/core/browser/popup_item_ids.h" |
| 12 #include "grit/component_strings.h" | 12 #include "grit/component_strings.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 | 14 |
| 15 namespace autofill { | 15 namespace autofill { |
| 16 | 16 |
| 17 AutofillExternalDelegate::AutofillExternalDelegate( | 17 AutofillExternalDelegate::AutofillExternalDelegate( |
| 18 AutofillManager* autofill_manager, | 18 AutofillManager* autofill_manager, |
| 19 AutofillDriver* autofill_driver) | 19 AutofillDriver* autofill_driver, |
| 20 PasswordAutofillManager* password_autofill_manager) |
| 20 : autofill_manager_(autofill_manager), | 21 : autofill_manager_(autofill_manager), |
| 21 autofill_driver_(autofill_driver), | 22 autofill_driver_(autofill_driver), |
| 22 password_autofill_manager_(autofill_driver), | 23 password_autofill_manager_(password_autofill_manager), |
| 23 autofill_query_id_(0), | 24 autofill_query_id_(0), |
| 24 display_warning_if_disabled_(false), | 25 display_warning_if_disabled_(false), |
| 25 has_autofill_suggestion_(false), | 26 has_autofill_suggestion_(false), |
| 26 has_shown_autofill_popup_for_current_edit_(false), | 27 has_shown_autofill_popup_for_current_edit_(false), |
| 27 weak_ptr_factory_(this) { | 28 weak_ptr_factory_(this) { |
| 28 DCHECK(autofill_manager); | 29 DCHECK(autofill_manager); |
| 29 } | 30 } |
| 30 | 31 |
| 31 AutofillExternalDelegate::~AutofillExternalDelegate() {} | 32 AutofillExternalDelegate::~AutofillExternalDelegate() {} |
| 32 | 33 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 173 |
| 173 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, | 174 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, |
| 174 int identifier) { | 175 int identifier) { |
| 175 if (identifier == POPUP_ITEM_ID_AUTOFILL_OPTIONS) { | 176 if (identifier == POPUP_ITEM_ID_AUTOFILL_OPTIONS) { |
| 176 // User selected 'Autofill Options'. | 177 // User selected 'Autofill Options'. |
| 177 autofill_manager_->ShowAutofillSettings(); | 178 autofill_manager_->ShowAutofillSettings(); |
| 178 } else if (identifier == POPUP_ITEM_ID_CLEAR_FORM) { | 179 } else if (identifier == POPUP_ITEM_ID_CLEAR_FORM) { |
| 179 // User selected 'Clear form'. | 180 // User selected 'Clear form'. |
| 180 autofill_driver_->RendererShouldClearFilledForm(); | 181 autofill_driver_->RendererShouldClearFilledForm(); |
| 181 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { | 182 } else if (identifier == POPUP_ITEM_ID_PASSWORD_ENTRY) { |
| 182 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion( | 183 password_autofill_manager_->DidAcceptAutofillSuggestion( |
| 183 autofill_query_field_, value); | 184 autofill_query_field_, value); |
| 184 DCHECK(success); | |
| 185 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { | 185 } else if (identifier == POPUP_ITEM_ID_DATALIST_ENTRY) { |
| 186 autofill_driver_->RendererShouldAcceptDataListSuggestion(value); | 186 autofill_driver_->RendererShouldAcceptDataListSuggestion(value); |
| 187 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { | 187 } else if (identifier == POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY) { |
| 188 // User selected an Autocomplete, so we fill directly. | 188 // User selected an Autocomplete, so we fill directly. |
| 189 autofill_driver_->RendererShouldSetNodeText(value); | 189 autofill_driver_->RendererShouldSetNodeText(value); |
| 190 } else { | 190 } else { |
| 191 FillAutofillFormData(identifier, false); | 191 FillAutofillFormData(identifier, false); |
| 192 } | 192 } |
| 193 | 193 |
| 194 autofill_manager_->delegate()->HideAutofillPopup(); | 194 autofill_manager_->delegate()->HideAutofillPopup(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 209 | 209 |
| 210 has_shown_autofill_popup_for_current_edit_ = false; | 210 has_shown_autofill_popup_for_current_edit_ = false; |
| 211 } | 211 } |
| 212 | 212 |
| 213 void AutofillExternalDelegate::ClearPreviewedForm() { | 213 void AutofillExternalDelegate::ClearPreviewedForm() { |
| 214 autofill_driver_->RendererShouldClearPreviewedForm(); | 214 autofill_driver_->RendererShouldClearPreviewedForm(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void AutofillExternalDelegate::Reset() { | 217 void AutofillExternalDelegate::Reset() { |
| 218 autofill_manager_->delegate()->HideAutofillPopup(); | 218 autofill_manager_->delegate()->HideAutofillPopup(); |
| 219 | 219 password_autofill_manager_->Reset(); |
| 220 password_autofill_manager_.Reset(); | |
| 221 } | 220 } |
| 222 | 221 |
| 223 void AutofillExternalDelegate::AddPasswordFormMapping( | 222 void AutofillExternalDelegate::AddPasswordFormMapping( |
| 224 const FormFieldData& username_field, | 223 const FormFieldData& username_field, |
| 225 const PasswordFormFillData& fill_data) { | 224 const PasswordFormFillData& fill_data) { |
| 226 password_autofill_manager_.AddPasswordFormMapping(username_field, fill_data); | 225 password_autofill_manager_->AddPasswordFormMapping(username_field, fill_data); |
| 227 } | 226 } |
| 228 | 227 |
| 229 base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { | 228 base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { |
| 230 return weak_ptr_factory_.GetWeakPtr(); | 229 return weak_ptr_factory_.GetWeakPtr(); |
| 231 } | 230 } |
| 232 | 231 |
| 233 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, | 232 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, |
| 234 bool is_preview) { | 233 bool is_preview) { |
| 235 // If the selected element is a warning we don't want to do anything. | 234 // If the selected element is a warning we don't want to do anything. |
| 236 if (unique_id == POPUP_ITEM_ID_WARNING_MESSAGE) | 235 if (unique_id == POPUP_ITEM_ID_WARNING_MESSAGE) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Set the values that all datalist elements share. | 343 // Set the values that all datalist elements share. |
| 345 autofill_icons->insert(autofill_icons->begin(), | 344 autofill_icons->insert(autofill_icons->begin(), |
| 346 data_list_values_.size(), | 345 data_list_values_.size(), |
| 347 base::string16()); | 346 base::string16()); |
| 348 autofill_unique_ids->insert(autofill_unique_ids->begin(), | 347 autofill_unique_ids->insert(autofill_unique_ids->begin(), |
| 349 data_list_values_.size(), | 348 data_list_values_.size(), |
| 350 POPUP_ITEM_ID_DATALIST_ENTRY); | 349 POPUP_ITEM_ID_DATALIST_ENTRY); |
| 351 } | 350 } |
| 352 | 351 |
| 353 } // namespace autofill | 352 } // namespace autofill |
| OLD | NEW |