OLD | NEW |
(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 |
| 14 namespace i18n { |
| 15 namespace addressinput { |
| 16 class PreloadSupplier; |
| 17 struct AddressData; |
| 18 } |
| 19 } |
| 20 |
| 21 namespace autofill { |
| 22 |
| 23 // Suggests address completions for a partially entered address from the user. |
| 24 class InputSuggester { |
| 25 public: |
| 26 // Does not take ownership of |supplier|, which should not be NULL. |
| 27 explicit InputSuggester(::i18n::addressinput::PreloadSupplier* supplier); |
| 28 ~InputSuggester(); |
| 29 |
| 30 // Fills in |suggestions| for the partially typed in |user_input|, assuming |
| 31 // the user is typing in the |focused_field|. If the number of |suggestions| |
| 32 // is over the |suggestion_limit|, then returns no |suggestions| at all. |
| 33 // |
| 34 // Sample user input: |
| 35 // country code = "CN" |
| 36 // dependent locality = "Zongyang" |
| 37 // focused field = DEPENDENT_LOCALITY |
| 38 // suggestions limit = 10 |
| 39 // Suggestion: |
| 40 // [{dependent_locality: "Zongyang Xian", |
| 41 // locality: "Anqing Shi", |
| 42 // administrative_area: "Anhui Sheng"}] |
| 43 // |
| 44 // Builds the index for generating suggestions lazily. |
| 45 // |
| 46 // The |suggestions| parameter should not be NULL. The |focused_field| |
| 47 // parameter should be either POSTAL_CODE or between ADMIN_AREA and |
| 48 // DEPENDENT_LOCALITY inclusively. |
| 49 void GetSuggestions( |
| 50 const ::i18n::addressinput::AddressData& user_input, |
| 51 ::i18n::addressinput::AddressField focused_field, |
| 52 size_t suggestion_limit, |
| 53 std::vector< ::i18n::addressinput::AddressData>* suggestions); |
| 54 |
| 55 private: |
| 56 class TrieCollection; |
| 57 |
| 58 // A collection of tries for generating suggestions. |
| 59 scoped_ptr<TrieCollection> trie_collection_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(InputSuggester); |
| 62 }; |
| 63 |
| 64 } // namespace autofill |
| 65 |
| 66 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_ |
OLD | NEW |