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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "components/autofill/core/browser/popup_item_ids.h" | 24 #include "components/autofill/core/browser/popup_item_ids.h" |
25 #include "components/autofill/core/common/autofill_util.h" | 25 #include "components/autofill/core/common/autofill_util.h" |
26 #include "grit/components_strings.h" | 26 #include "grit/components_strings.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 | 28 |
29 namespace autofill { | 29 namespace autofill { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 // Returns true if the suggestion entry is an Autofill warning message. | 33 // Returns true if the suggestion entry is an Autofill warning message. |
34 // Warning message should display on top of suggestion list. | 34 // Warning messages should display on top of suggestion list. |
35 bool IsAutofillWarningEntry(int frontend_id) { | 35 bool IsAutofillWarningEntry(int frontend_id) { |
36 return frontend_id == POPUP_ITEM_ID_WARNING_MESSAGE; | 36 return frontend_id == |
| 37 POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE || |
| 38 frontend_id == POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE; |
37 } | 39 } |
38 | 40 |
39 } // anonymous namespace | 41 } // anonymous namespace |
40 | 42 |
41 AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, | 43 AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, |
42 AutofillDriver* driver) | 44 AutofillDriver* driver) |
43 : manager_(manager), | 45 : manager_(manager), |
44 driver_(driver), | 46 driver_(driver), |
45 query_id_(0), | 47 query_id_(0), |
46 has_autofill_suggestions_(false), | 48 has_autofill_suggestions_(false), |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 } | 288 } |
287 | 289 |
288 void AutofillExternalDelegate::OnCreditCardScanned(const CreditCard& card) { | 290 void AutofillExternalDelegate::OnCreditCardScanned(const CreditCard& card) { |
289 manager_->FillCreditCardForm(query_id_, query_form_, query_field_, card, | 291 manager_->FillCreditCardForm(query_id_, query_form_, query_field_, card, |
290 base::string16()); | 292 base::string16()); |
291 } | 293 } |
292 | 294 |
293 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, | 295 void AutofillExternalDelegate::FillAutofillFormData(int unique_id, |
294 bool is_preview) { | 296 bool is_preview) { |
295 // If the selected element is a warning we don't want to do anything. | 297 // If the selected element is a warning we don't want to do anything. |
296 if (unique_id == POPUP_ITEM_ID_WARNING_MESSAGE) | 298 if (IsAutofillWarningEntry(unique_id)) |
297 return; | 299 return; |
298 | 300 |
299 AutofillDriver::RendererFormDataAction renderer_action = is_preview ? | 301 AutofillDriver::RendererFormDataAction renderer_action = is_preview ? |
300 AutofillDriver::FORM_DATA_ACTION_PREVIEW : | 302 AutofillDriver::FORM_DATA_ACTION_PREVIEW : |
301 AutofillDriver::FORM_DATA_ACTION_FILL; | 303 AutofillDriver::FORM_DATA_ACTION_FILL; |
302 | 304 |
303 DCHECK(driver_->RendererIsAvailable()); | 305 DCHECK(driver_->RendererIsAvailable()); |
304 // Fill the values for the whole form. | 306 // Fill the values for the whole form. |
305 manager_->FillOrPreviewForm(renderer_action, | 307 manager_->FillOrPreviewForm(renderer_action, |
306 query_id_, | 308 query_id_, |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 suggestions->insert(suggestions->begin(), data_list_values_.size(), | 380 suggestions->insert(suggestions->begin(), data_list_values_.size(), |
379 Suggestion()); | 381 Suggestion()); |
380 for (size_t i = 0; i < data_list_values_.size(); i++) { | 382 for (size_t i = 0; i < data_list_values_.size(); i++) { |
381 (*suggestions)[i].value = data_list_values_[i]; | 383 (*suggestions)[i].value = data_list_values_[i]; |
382 (*suggestions)[i].label = data_list_labels_[i]; | 384 (*suggestions)[i].label = data_list_labels_[i]; |
383 (*suggestions)[i].frontend_id = POPUP_ITEM_ID_DATALIST_ENTRY; | 385 (*suggestions)[i].frontend_id = POPUP_ITEM_ID_DATALIST_ENTRY; |
384 } | 386 } |
385 } | 387 } |
386 | 388 |
387 } // namespace autofill | 389 } // namespace autofill |
OLD | NEW |