autofill_dialog_common.h revision 010d83a9304c5a91596085d917d248abff47903a
1032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// Copyright 2013 The Chromium Authors. All rights reserved. 2032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// Use of this source code is governed by a BSD-style license that can be 3032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// found in the LICENSE file. 4032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 521c62da287237d39d0d95004881ea4baae3be6daChris Lattner#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ 621c62da287237d39d0d95004881ea4baae3be6daChris Lattner#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ 7032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 8032091d7f62774443c282915964189ea3d8930dePatrick Jenkins#include "chrome/browser/ui/autofill/autofill_dialog_types.h" 9032091d7f62774443c282915964189ea3d8930dePatrick Jenkins#include "components/autofill/core/browser/autofill_type.h" 10032091d7f62774443c282915964189ea3d8930dePatrick Jenkins#include "components/autofill/core/browser/field_types.h" 11032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 12032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsnamespace autofill { 13032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsclass AutofillProfile; 14032091d7f62774443c282915964189ea3d8930dePatrick Jenkins} 15032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 167f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattnernamespace wallet { 17032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsclass Address; 18032091d7f62774443c282915964189ea3d8930dePatrick Jenkins} 197f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner 20032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsnamespace autofill { 21032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsnamespace common { 22032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 23032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// The types of addresses this class supports building. 24032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsenum AddressType { 25032091d7f62774443c282915964189ea3d8930dePatrick Jenkins ADDRESS_TYPE_BILLING, 26032091d7f62774443c282915964189ea3d8930dePatrick Jenkins ADDRESS_TYPE_SHIPPING, 27032091d7f62774443c282915964189ea3d8930dePatrick Jenkins}; 28032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 29032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// Returns true if |type| should be shown when |field_type| has been requested. 30032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// This filters the types that we fill into the page to match the ones the 317f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner// dialog actually cares about, preventing rAc from giving away data that an 321d1ef14248a24cb7239e0bc9298d84004a8044e6Nick Lewycky// AutofillProfile or other data source might know about the user which isn't 33ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman// represented in the dialog. 34032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsbool ServerTypeEncompassesFieldType(ServerFieldType type, 35032091d7f62774443c282915964189ea3d8930dePatrick Jenkins const AutofillType& field_type); 36032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 377f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner// Returns true if |type| in the given |section| should be used for a 38ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman// site-requested |field|. 39032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsbool ServerTypeMatchesField(DialogSection section, 40ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman ServerFieldType type, 417f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner const AutofillField& field); 427f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner 43032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// Returns true if the |type| belongs to the CREDIT_CARD field type group. 44032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsbool IsCreditCardType(ServerFieldType type); 45032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 461d1ef14248a24cb7239e0bc9298d84004a8044e6Nick Lewycky// Constructs |inputs| from the array of inputs in |input_template|. 477f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattnervoid BuildInputs(const DetailInput input_template[], 487f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner size_t template_size, 49032091d7f62774443c282915964189ea3d8930dePatrick Jenkins DetailInputs* inputs); 50032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 51032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding 521d1ef14248a24cb7239e0bc9298d84004a8044e6Nick Lewycky// to the |section|. 53032091d7f62774443c282915964189ea3d8930dePatrick JenkinsAutofillMetrics::DialogUiEvent DialogSectionToUiItemAddedEvent( 54032091d7f62774443c282915964189ea3d8930dePatrick Jenkins DialogSection section); 55032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 56032091d7f62774443c282915964189ea3d8930dePatrick Jenkins// Returns the AutofillMetrics::DIALOG_UI_*_ITEM_ADDED metric corresponding 57ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman// to the |section|. 581d1ef14248a24cb7239e0bc9298d84004a8044e6Nick LewyckyAutofillMetrics::DialogUiEvent DialogSectionToUiSelectionChangedEvent( 59ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman DialogSection section); 60032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 617f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner// Gets just the |type| attributes from each DetailInput. 62032091d7f62774443c282915964189ea3d8930dePatrick Jenkinsstd::vector<ServerFieldType> TypesFromInputs(const DetailInputs& inputs); 631d1ef14248a24cb7239e0bc9298d84004a8044e6Nick Lewycky 64ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman} // namespace common 65ac95cc79ac0b899d566cc29c0f646f39c2fa35c0Dan Gohman} // namespace autofill 66032091d7f62774443c282915964189ea3d8930dePatrick Jenkins 67032091d7f62774443c282915964189ea3d8930dePatrick Jenkins#endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_COMMON_H_ 687f27570ae0cb716927f946f4e73a55f60d99b3e2Chris Lattner