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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 // Only preview the data if it is a profile. | 170 // Only preview the data if it is a profile. |
171 if (identifier > 0) | 171 if (identifier > 0) |
172 FillAutofillFormData(identifier, true); | 172 FillAutofillFormData(identifier, true); |
173 } | 173 } |
174 | 174 |
175 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, | 175 void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, |
176 int identifier) { | 176 int identifier) { |
177 if (identifier == WebAutofillClient::MenuItemIDAutofillOptions) { | 177 if (identifier == WebAutofillClient::MenuItemIDAutofillOptions) { |
178 // User selected 'Autofill Options'. | 178 // User selected 'Autofill Options'. |
179 autofill_manager_->OnShowAutofillDialog(); | 179 autofill_manager_->ShowAutofillSettings(); |
180 } else if (identifier == WebAutofillClient::MenuItemIDClearForm) { | 180 } else if (identifier == WebAutofillClient::MenuItemIDClearForm) { |
181 // User selected 'Clear form'. | 181 // User selected 'Clear form'. |
182 autofill_driver_->RendererShouldClearFilledForm(); | 182 autofill_driver_->RendererShouldClearFilledForm(); |
183 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry) { | 183 } else if (identifier == WebAutofillClient::MenuItemIDPasswordEntry) { |
184 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion( | 184 bool success = password_autofill_manager_.DidAcceptAutofillSuggestion( |
185 autofill_query_field_, value); | 185 autofill_query_field_, value); |
186 DCHECK(success); | 186 DCHECK(success); |
187 } else if (identifier == WebAutofillClient::MenuItemIDDataListEntry) { | 187 } else if (identifier == WebAutofillClient::MenuItemIDDataListEntry) { |
188 autofill_driver_->RendererShouldAcceptDataListSuggestion(value); | 188 autofill_driver_->RendererShouldAcceptDataListSuggestion(value); |
189 } else if (identifier == WebAutofillClient::MenuItemIDAutocompleteEntry) { | 189 } else if (identifier == WebAutofillClient::MenuItemIDAutocompleteEntry) { |
(...skipping 26 matching lines...) Expand all Loading... |
216 autofill_driver_->RendererShouldClearPreviewedForm(); | 216 autofill_driver_->RendererShouldClearPreviewedForm(); |
217 } | 217 } |
218 | 218 |
219 void AutofillExternalDelegate::Reset() { | 219 void AutofillExternalDelegate::Reset() { |
220 autofill_manager_->delegate()->HideAutofillPopup(); | 220 autofill_manager_->delegate()->HideAutofillPopup(); |
221 | 221 |
222 password_autofill_manager_.Reset(); | 222 password_autofill_manager_.Reset(); |
223 } | 223 } |
224 | 224 |
225 void AutofillExternalDelegate::AddPasswordFormMapping( | 225 void AutofillExternalDelegate::AddPasswordFormMapping( |
226 const FormFieldData& form, | 226 const FormFieldData& username_field, |
227 const PasswordFormFillData& fill_data) { | 227 const PasswordFormFillData& fill_data) { |
228 password_autofill_manager_.AddPasswordFormMapping(form, fill_data); | 228 password_autofill_manager_.AddPasswordFormMapping(username_field, fill_data); |
229 } | 229 } |
230 | 230 |
231 base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { | 231 base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() { |
232 return weak_ptr_factory_.GetWeakPtr(); | 232 return weak_ptr_factory_.GetWeakPtr(); |
233 } | 233 } |
234 | 234 |
235 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, | 235 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, |
236 bool is_preview) { | 236 bool is_preview) { |
237 // If the selected element is a warning we don't want to do anything. | 237 // If the selected element is a warning we don't want to do anything. |
238 if (unique_id == WebAutofillClient::MenuItemIDWarningMessage) | 238 if (unique_id == WebAutofillClient::MenuItemIDWarningMessage) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 // Set the values that all datalist elements share. | 349 // Set the values that all datalist elements share. |
350 autofill_icons->insert(autofill_icons->begin(), | 350 autofill_icons->insert(autofill_icons->begin(), |
351 data_list_values_.size(), | 351 data_list_values_.size(), |
352 base::string16()); | 352 base::string16()); |
353 autofill_unique_ids->insert(autofill_unique_ids->begin(), | 353 autofill_unique_ids->insert(autofill_unique_ids->begin(), |
354 data_list_values_.size(), | 354 data_list_values_.size(), |
355 WebAutofillClient::MenuItemIDDataListEntry); | 355 WebAutofillClient::MenuItemIDDataListEntry); |
356 } | 356 } |
357 | 357 |
358 } // namespace autofill | 358 } // namespace autofill |
OLD | NEW |