OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/autofill/autofill_scanner.h" | 5 #include "chrome/browser/autofill/autofill_scanner.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/autofill/autofill_field.h" | 8 #include "chrome/browser/autofill/autofill_field.h" |
9 #include "unicode/regex.h" | |
10 | 9 |
11 AutofillScanner::AutofillScanner( | 10 AutofillScanner::AutofillScanner( |
12 const std::vector<const AutofillField*>& fields) | 11 const std::vector<const AutofillField*>& fields) |
13 : cursor_(fields.begin()), | 12 : cursor_(fields.begin()), |
14 end_(fields.end()) { | 13 end_(fields.end()) { |
15 } | 14 } |
16 | 15 |
17 AutofillScanner::~AutofillScanner() { | 16 AutofillScanner::~AutofillScanner() { |
18 } | 17 } |
19 | 18 |
(...skipping 17 matching lines...) Expand all Loading... |
37 | 36 |
38 void AutofillScanner::Rewind() { | 37 void AutofillScanner::Rewind() { |
39 DCHECK(!saved_cursors_.empty()); | 38 DCHECK(!saved_cursors_.empty()); |
40 cursor_ = saved_cursors_.back(); | 39 cursor_ = saved_cursors_.back(); |
41 saved_cursors_.pop_back(); | 40 saved_cursors_.pop_back(); |
42 } | 41 } |
43 | 42 |
44 void AutofillScanner::SaveCursor() { | 43 void AutofillScanner::SaveCursor() { |
45 saved_cursors_.push_back(cursor_); | 44 saved_cursors_.push_back(cursor_); |
46 } | 45 } |
47 | |
48 namespace autofill { | |
49 | |
50 bool MatchString(const string16& input, const string16& pattern) { | |
51 UErrorCode status = U_ZERO_ERROR; | |
52 icu::UnicodeString icu_pattern(pattern.data(), pattern.length()); | |
53 icu::UnicodeString icu_input(input.data(), input.length()); | |
54 icu::RegexMatcher matcher(icu_pattern, icu_input, | |
55 UREGEX_CASE_INSENSITIVE, status); | |
56 DCHECK(U_SUCCESS(status)); | |
57 | |
58 UBool match = matcher.find(0, status); | |
59 DCHECK(U_SUCCESS(status)); | |
60 return !!match; | |
61 } | |
62 | |
63 } // namespace autofill | |
64 | |
OLD | NEW |