Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3735)

Unified Diff: chrome/browser/ui/autofill/autofill_dialog_common.cc

Issue 974323002: Componentize autofill dialog common code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_dialog_common.cc
diff --git a/chrome/browser/ui/autofill/autofill_dialog_common.cc b/chrome/browser/ui/autofill/autofill_dialog_common.cc
deleted file mode 100644
index fd2cadce4333e02f406500bec99a1db0662909b2..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/autofill/autofill_dialog_common.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/autofill/autofill_dialog_common.h"
-
-#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/browser_process.h"
-#include "components/autofill/core/browser/autofill_country.h"
-#include "components/autofill/core/browser/autofill_field.h"
-#include "components/autofill/core/browser/autofill_type.h"
-
-namespace autofill {
-namespace common {
-
-bool ServerTypeEncompassesFieldType(ServerFieldType type,
- const AutofillType& field_type) {
- // If any credit card expiration info is asked for, show both month and year
- // inputs.
- ServerFieldType server_type = field_type.GetStorableType();
- if (server_type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
- server_type == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
- server_type == CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR ||
- server_type == CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR ||
- server_type == CREDIT_CARD_EXP_MONTH) {
- return type == CREDIT_CARD_EXP_4_DIGIT_YEAR ||
- type == CREDIT_CARD_EXP_MONTH;
- }
-
- if (server_type == CREDIT_CARD_TYPE)
- return type == CREDIT_CARD_NUMBER;
-
- // Check the groups to distinguish billing types from shipping ones.
- AutofillType autofill_type = AutofillType(type);
- if (autofill_type.group() != field_type.group())
- return false;
-
- // The page may ask for individual address lines; this roughly matches the
- // street address blob.
- if (server_type == ADDRESS_HOME_LINE1 ||
- server_type == ADDRESS_HOME_LINE2 ||
- server_type == ADDRESS_HOME_LINE3) {
- return autofill_type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS;
- }
-
- // First, middle and last name are parsed from full name.
- if (field_type.group() == NAME || field_type.group() == NAME_BILLING)
- return autofill_type.GetStorableType() == NAME_FULL;
-
- return autofill_type.GetStorableType() == server_type;
-}
-
-bool ServerTypeMatchesField(DialogSection section,
- ServerFieldType type,
- const AutofillField& field) {
- AutofillType field_type = field.Type();
-
- // The credit card name is filled from the billing section's data.
- if (field_type.GetStorableType() == CREDIT_CARD_NAME &&
- (section == SECTION_BILLING || section == SECTION_CC_BILLING)) {
- return type == NAME_BILLING_FULL;
- }
-
- return ServerTypeEncompassesFieldType(type, field_type);
-}
-
-bool IsCreditCardType(ServerFieldType type) {
- return AutofillType(type).group() == CREDIT_CARD;
-}
-
-void BuildInputs(const DetailInput* input_template,
- size_t template_size,
- DetailInputs* inputs) {
- for (size_t i = 0; i < template_size; ++i) {
- const DetailInput* input = &input_template[i];
- inputs->push_back(*input);
- }
-}
-
-AutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent(
- DialogSection section) {
- switch (section) {
- case SECTION_BILLING:
- return AutofillMetrics::DIALOG_UI_BILLING_ITEM_ADDED;
-
- case SECTION_CC_BILLING:
- return AutofillMetrics::DIALOG_UI_CC_BILLING_ITEM_ADDED;
-
- case SECTION_SHIPPING:
- return AutofillMetrics::DIALOG_UI_SHIPPING_ITEM_ADDED;
-
- case SECTION_CC:
- return AutofillMetrics::DIALOG_UI_CC_ITEM_ADDED;
- }
-
- NOTREACHED();
- return AutofillMetrics::NUM_DIALOG_UI_EVENTS;
-}
-
-AutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent(
- DialogSection section) {
- switch (section) {
- case SECTION_BILLING:
- return AutofillMetrics::DIALOG_UI_BILLING_SELECTED_SUGGESTION_CHANGED;
-
- case SECTION_CC_BILLING:
- return AutofillMetrics::DIALOG_UI_CC_BILLING_SELECTED_SUGGESTION_CHANGED;
-
- case SECTION_SHIPPING:
- return AutofillMetrics::DIALOG_UI_SHIPPING_SELECTED_SUGGESTION_CHANGED;
-
- case SECTION_CC:
- return AutofillMetrics::DIALOG_UI_CC_SELECTED_SUGGESTION_CHANGED;
- }
-
- NOTREACHED();
- return AutofillMetrics::NUM_DIALOG_UI_EVENTS;
-}
-
-std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs) {
- std::vector<ServerFieldType> types;
- for (size_t i = 0; i < inputs.size(); ++i) {
- types.push_back(inputs[i].type);
- }
- return types;
-}
-
-} // namespace common
-} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698