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

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: Work in progress. Created 6 years, 6 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/region_dat a_builder.h"
14
15 namespace i18n {
16 namespace addressinput {
17 class PreloadSupplier;
18 class RegionData;
19 struct AddressData;
20 }
21 }
22
23 namespace autofill {
24
25 class StringCanonicalizer;
26 class SubRegionData;
27
28 // Suggests address completions for a partially entered address from the user.
29 class InputSuggester {
30 public:
31 // Does not take ownership of |supplier|, which should not be NULL.
32 explicit InputSuggester(::i18n::addressinput::PreloadSupplier* supplier);
33 ~InputSuggester();
34
35 // Fills in |suggestions| for the partially typed in |user_input|, assuming
36 // the user is typing in the |focused_field|. If the number of |suggestions|
37 // is over the |suggestion_limit|, then returns no |suggestions| at all.
38 //
39 // Sample user input:
40 // country code = "CN"
41 // dependent locality = "Zongyang"
42 // focused field = DEPENDENT_LOCALITY
43 // suggestions limit = 10
44 // Suggestion:
45 // [{dependent_locality: "Zongyang Xian",
46 // locality: "Anqing Shi",
47 // administrative_area: "Anhui Sheng"}]
48 //
49 // Builds the index for generating suggestions lazily.
50 //
51 // The |suggestions| parameter should not be NULL. The |focused_field|
52 // parameter should be either POSTAL_CODE or between ADMIN_AREA and
53 // DEPENDENT_LOCALITY inclusively.
54 void GetSuggestions(
55 const ::i18n::addressinput::AddressData& user_input,
56 ::i18n::addressinput::AddressField focused_field,
57 size_t suggestion_limit,
58 std::vector< ::i18n::addressinput::AddressData>* suggestions);
59
60 private:
61 // Data source for region data.
62 ::i18n::addressinput::RegionDataBuilder region_data_builder_;
63
64 // A mapping from a COUNTRY level region to a collection of all of its
65 // sub-regions along with metadata used to construct suggestions.
66 std::map<const ::i18n::addressinput::RegionData*, const SubRegionData*>
67 sub_regions_;
68
69 // Canonicalizes strings for case and diacritic insensitive search.
70 scoped_ptr<StringCanonicalizer> canonicalizer_;
71
72 DISALLOW_COPY_AND_ASSIGN(InputSuggester);
73 };
74
75 } // namespace autofill
76
77 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698