Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / autofill / autofill_dialog_i18n_input.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_I18N_INPUT_H_
6 #define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_I18N_INPUT_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_common.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
14 #include "components/autofill/core/browser/autofill_type.h"
15 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_field.h"
16
17 namespace i18n {
18 namespace addressinput {
19 struct AddressData;
20 }
21 }
22
23 namespace autofill {
24
25 class AutofillProfile;
26 class CreditCard;
27
28 namespace i18ninput {
29
30 // Builds internationalized address input fields for |address_type| (e.g.
31 // billing or shipping) in |country_code| (e.g. "US" or "CH").
32 //
33 // The |inputs| and |language_code| are output-only parameters.
34 //
35 // The function adds the fields (at most 13) to |inputs|. This parameter should
36 // not be NULL.
37 //
38 // The function sets the |language_code| to be used for address formatting. This
39 // parameter can be NULL.
40 void BuildAddressInputs(common::AddressType address_type,
41                         const std::string& country_code,
42                         DetailInputs* inputs,
43                         std::string* language_code);
44
45 // Returns whether the given card is complete and verified (i.e. was reviewed
46 // by the user and not just automatically aggregated).
47 bool CardHasCompleteAndVerifiedData(const CreditCard& card);
48
49 // As above, but for the address in |profile|. Region-aware, meaning that the
50 // exact set of required fields depends on the region.
51 bool AddressHasCompleteAndVerifiedData(const AutofillProfile& profile);
52
53 // Returns the corresponding Autofill server type for |field|.
54 ServerFieldType TypeForField(::i18n::addressinput::AddressField field,
55                              common::AddressType address_type);
56
57 // Sets |field| to the corresponding address field for the Autofill
58 // |server_type|. Returns |true| if |server_type| can be represented as an
59 // address field. The |field| parameter can be NULL.
60 bool FieldForType(ServerFieldType server_type,
61                   ::i18n::addressinput::AddressField* field);
62
63 // Creates an AddressData object for internationalized address display or
64 // validation using |get_info| for field values.
65 void CreateAddressData(
66     const base::Callback<base::string16(const AutofillType&)>& get_info,
67     ::i18n::addressinput::AddressData* address_data);
68
69 // Whether or not |country_code| has a fully supported address format.
70 // TODO(dbeam): remove this when filling dependent locality is supported.
71 // http://crbug.com/340929
72 bool CountryIsFullySupported(const std::string& country_code);
73
74 }  // namespace i18ninput
75 }  // namespace autofill
76
77 #endif  // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_DIALOG_I18N_INPUT_H_