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

Side by Side Diff: components/autofill/core/browser/ui/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, 9 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/ui/autofill/autofill_dialog_common.h" 5 #include "components/autofill/core/browser/ui/autofill_dialog_common.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/browser_process.h"
9 #include "components/autofill/core/browser/autofill_country.h" 8 #include "components/autofill/core/browser/autofill_country.h"
10 #include "components/autofill/core/browser/autofill_field.h" 9 #include "components/autofill/core/browser/autofill_field.h"
11 #include "components/autofill/core/browser/autofill_type.h" 10 #include "components/autofill/core/browser/autofill_type.h"
12 11
13 namespace autofill { 12 namespace autofill {
14 namespace common { 13 namespace common {
15 14
16 bool ServerTypeEncompassesFieldType(ServerFieldType type, 15 bool ServerTypeEncompassesFieldType(ServerFieldType type,
17 const AutofillType& field_type) { 16 const AutofillType& field_type) {
18 // If any credit card expiration info is asked for, show both month and year 17 // If any credit card expiration info is asked for, show both month and year
(...skipping 11 matching lines...) Expand all
30 if (server_type == CREDIT_CARD_TYPE) 29 if (server_type == CREDIT_CARD_TYPE)
31 return type == CREDIT_CARD_NUMBER; 30 return type == CREDIT_CARD_NUMBER;
32 31
33 // Check the groups to distinguish billing types from shipping ones. 32 // Check the groups to distinguish billing types from shipping ones.
34 AutofillType autofill_type = AutofillType(type); 33 AutofillType autofill_type = AutofillType(type);
35 if (autofill_type.group() != field_type.group()) 34 if (autofill_type.group() != field_type.group())
36 return false; 35 return false;
37 36
38 // The page may ask for individual address lines; this roughly matches the 37 // The page may ask for individual address lines; this roughly matches the
39 // street address blob. 38 // street address blob.
40 if (server_type == ADDRESS_HOME_LINE1 || 39 if (server_type == ADDRESS_HOME_LINE1 || server_type == ADDRESS_HOME_LINE2 ||
41 server_type == ADDRESS_HOME_LINE2 || 40 server_type == ADDRESS_HOME_LINE3) {
42 server_type == ADDRESS_HOME_LINE3) {
43 return autofill_type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS; 41 return autofill_type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS;
44 } 42 }
45 43
46 // First, middle and last name are parsed from full name. 44 // First, middle and last name are parsed from full name.
47 if (field_type.group() == NAME || field_type.group() == NAME_BILLING) 45 if (field_type.group() == NAME || field_type.group() == NAME_BILLING)
48 return autofill_type.GetStorableType() == NAME_FULL; 46 return autofill_type.GetStorableType() == NAME_FULL;
49 47
50 return autofill_type.GetStorableType() == server_type; 48 return autofill_type.GetStorableType() == server_type;
51 } 49 }
52 50
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs) { 118 std::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs) {
121 std::vector<ServerFieldType> types; 119 std::vector<ServerFieldType> types;
122 for (size_t i = 0; i < inputs.size(); ++i) { 120 for (size_t i = 0; i < inputs.size(); ++i) {
123 types.push_back(inputs[i].type); 121 types.push_back(inputs[i].type);
124 } 122 }
125 return types; 123 return types;
126 } 124 }
127 125
128 } // namespace common 126 } // namespace common
129 } // namespace autofill 127 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698