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

Unified 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: Validate required fields without rules. 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 side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/input_suggester.h
diff --git a/third_party/libaddressinput/chromium/input_suggester.h b/third_party/libaddressinput/chromium/input_suggester.h
new file mode 100644
index 0000000000000000000000000000000000000000..c1a8031b3e78c4d4be9751822f6eed11733a0a1a
--- /dev/null
+++ b/third_party/libaddressinput/chromium/input_suggester.h
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_
+#define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_field.h"
+
+namespace i18n {
+namespace addressinput {
+class PreloadSupplier;
+struct AddressData;
+}
+}
+
+namespace autofill {
+
+// Suggests address completions for a partially entered address from the user.
+class InputSuggester {
+ public:
+ // Does not take ownership of |supplier|, which should not be NULL.
+ explicit InputSuggester(::i18n::addressinput::PreloadSupplier* supplier);
+ ~InputSuggester();
+
+ // Fills in |suggestions| for the partially typed in |user_input|, assuming
+ // the user is typing in the |focused_field|. If the number of |suggestions|
+ // is over the |suggestion_limit|, then returns no |suggestions| at all.
+ //
+ // Sample user input:
+ // country code = "CN"
+ // dependent locality = "Zongyang"
+ // focused field = DEPENDENT_LOCALITY
+ // suggestions limit = 10
+ // Suggestion:
+ // [{dependent_locality: "Zongyang Xian",
+ // locality: "Anqing Shi",
+ // administrative_area: "Anhui Sheng"}]
+ //
+ // Builds the index for generating suggestions lazily.
+ //
+ // The |suggestions| parameter should not be NULL. The |focused_field|
+ // parameter should be either POSTAL_CODE or between ADMIN_AREA and
+ // DEPENDENT_LOCALITY inclusively.
+ void GetSuggestions(
+ const ::i18n::addressinput::AddressData& user_input,
+ ::i18n::addressinput::AddressField focused_field,
+ size_t suggestion_limit,
+ std::vector< ::i18n::addressinput::AddressData>* suggestions);
+
+ private:
+ class TrieCollection;
+
+ // A collection of tries for generating suggestions.
+ scoped_ptr<TrieCollection> trie_collection_;
+
+ DISALLOW_COPY_AND_ASSIGN(InputSuggester);
+};
+
+} // namespace autofill
+
+#endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_INPUT_SUGGESTER_H_

Powered by Google App Engine
This is Rietveld 408576698