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

Side by Side Diff: third_party/libaddressinput/chromium/input_suggester.h

Issue 298863012: Use upstream libaddressinput in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Specify the string size in canonicalizer. Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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 THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fi eld.h"
13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_in put_helper.h"
14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_va lidator.h"
15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/region_dat a_builder.h"
16
17 namespace i18n {
18 namespace addressinput {
19 class PreloadSupplier;
20 class RegionData;
21 struct AddressData;
22 }
23 }
24
25 namespace autofill {
26
27 class StringCanonicalizer;
28
29 // Suggests address completions for a partially entered address from the user.
30 class InputSuggester {
31 public:
32 // Does not take ownership of |supplier|, which should not be NULL.
33 explicit InputSuggester(::i18n::addressinput::PreloadSupplier* supplier);
34 ~InputSuggester();
35
36 // Fills in |suggestions| for the partially typed in |user_input|, assuming
37 // the user is typing in the |focused_field|. If the number of |suggestions|
38 // is over the |suggestion_limit|, then returns no |suggestions| at all.
39 //
40 // Sample user input 1:
41 // country code = "US"
42 // postal code = "90066"
43 // focused field = POSTAL_CODE
44 // suggestions limit = 1
45 // Suggestion:
46 // [{administrative_area: "CA"}]
47 //
48 // Sample user input 2:
49 // country code = "CN"
50 // dependent locality = "Zongyang"
51 // focused field = DEPENDENT_LOCALITY
52 // suggestions limit = 10
53 // Suggestion:
54 // [{dependent_locality: "Zongyang Xian",
55 // locality: "Anqing Shi",
56 // administrative_area: "Anhui Sheng"}]
57 //
58 // Builds the index for generating suggestions lazily.
59 //
60 // The |suggestions| parameter should not be NULL. The |focused_field|
61 // parameter should be either POSTAL_CODE or between ADMIN_AREA and
62 // DEPENDENT_LOCALITY inclusively.
63 void GetSuggestions(
64 const ::i18n::addressinput::AddressData& user_input,
65 ::i18n::addressinput::AddressField focused_field,
66 size_t suggestion_limit,
67 std::vector< ::i18n::addressinput::AddressData>* suggestions);
68
69 private:
70 class SubRegionData;
71
72 // The method to be invoked by |validated_| callback.
73 void Validated(bool success,
74 const ::i18n::addressinput::AddressData&,
75 const ::i18n::addressinput::FieldProblemMap&);
76
77 // Data source for region data.
78 ::i18n::addressinput::RegionDataBuilder region_data_builder_;
79
80 // Suggests sub-regions based on postal code.
81 const ::i18n::addressinput::AddressInputHelper input_helper_;
82
83 // Verifies that suggested sub-regions match the postal code.
84 ::i18n::addressinput::AddressValidator validator_;
85
86 // The callback for |validator_| to invoke when validation finishes.
87 const scoped_ptr<const ::i18n::addressinput::AddressValidator::Callback>
88 validated_;
89
90 // A mapping from a COUNTRY level region to a collection of all of its
91 // sub-regions along with metadata used to construct suggestions.
92 std::map<const ::i18n::addressinput::RegionData*, const SubRegionData*>
93 sub_regions_;
94
95 // Canonicalizes strings for case and diacritic insensitive search of
96 // sub-region names.
97 scoped_ptr<StringCanonicalizer> canonicalizer_;
Evan Stade 2014/06/27 01:26:58 why is this a scoped_ptr
please use gerrit instead 2014/06/27 08:43:38 Changed to not be a scoped_ptr.
98
99 DISALLOW_COPY_AND_ASSIGN(InputSuggester);
100 };
101
102 } // namespace autofill
103
104 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698