Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / autofill / core / common / autofill_util.h
blob81c306222cdb2dc3cd5fa8ba00f48de1b95e115e
1 // Copyright 2015 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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_UTIL_H_
6 #define COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_UTIL_H_
8 #include "base/strings/string16.h"
10 namespace autofill {
12 // Returns true when command line switch |kEnableSuggestionsWithSubstringMatch|
13 // is on.
14 bool IsFeatureSubstringMatchEnabled();
16 // Returns true when keyboard accessory is enabled.
17 bool IsKeyboardAccessoryEnabled();
19 // A token is a sequences of contiguous characters separated by any of the
20 // characters that are part of delimiter set {' ', '.', ',', '-', '_', '@'}.
22 // Returns true if the |field_contents| is a substring of the |suggestion|
23 // starting at token boundaries. |field_contents| can span multiple |suggestion|
24 // tokens.
25 bool FieldIsSuggestionSubstringStartingOnTokenBoundary(
26 const base::string16& suggestion,
27 const base::string16& field_contents,
28 bool case_sensitive);
30 // Finds the first occurrence of a searched substring |field_contents| within
31 // the string |suggestion| starting at token boundaries and returns the index to
32 // the end of the located substring, or base::string16::npos if the substring is
33 // not found. "preview-on-hover" feature is one such use case where the
34 // substring |field_contents| may not be found within the string |suggestion|.
35 size_t GetTextSelectionStart(const base::string16& suggestion,
36 const base::string16& field_contents,
37 bool case_sensitive);
39 } // namespace autofill
41 #endif // COMPONENTS_AUTOFILL_CORE_COMMON_AUTOFILL_UTIL_H_