OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/history/query_parser.h" | 5 #include "chrome/browser/history/query_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/break_iterator.h" | 9 #include "base/i18n/break_iterator.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 } | 238 } |
239 } | 239 } |
240 return false; | 240 return false; |
241 } | 241 } |
242 | 242 |
243 QueryParser::QueryParser() { | 243 QueryParser::QueryParser() { |
244 } | 244 } |
245 | 245 |
246 // static | 246 // static |
247 bool QueryParser::IsWordLongEnoughForPrefixSearch(const string16& word) { | 247 bool QueryParser::IsWordLongEnoughForPrefixSearch(const string16& word) { |
248 DCHECK(word.size() > 0); | 248 DCHECK(!word.empty()); |
249 size_t minimum_length = 3; | 249 size_t minimum_length = 3; |
250 // We intentionally exclude Hangul Jamos (both Conjoining and compatibility) | 250 // We intentionally exclude Hangul Jamos (both Conjoining and compatibility) |
251 // because they 'behave like' Latin letters. Moreover, we should | 251 // because they 'behave like' Latin letters. Moreover, we should |
252 // normalize the former before reaching here. | 252 // normalize the former before reaching here. |
253 if (0xAC00 <= word[0] && word[0] <= 0xD7A3) | 253 if (0xAC00 <= word[0] && word[0] <= 0xD7A3) |
254 minimum_length = 2; | 254 minimum_length = 2; |
255 return word.size() >= minimum_length; | 255 return word.size() >= minimum_length; |
256 } | 256 } |
257 | 257 |
258 // Returns true if the character is considered a quote. | 258 // Returns true if the character is considered a quote. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (iter.IsWord()) { | 377 if (iter.IsWord()) { |
378 string16 word = iter.GetString(); | 378 string16 word = iter.GetString(); |
379 if (!word.empty()) { | 379 if (!word.empty()) { |
380 words->push_back(QueryWord()); | 380 words->push_back(QueryWord()); |
381 words->back().word = word; | 381 words->back().word = word; |
382 words->back().position = iter.prev(); | 382 words->back().position = iter.prev(); |
383 } | 383 } |
384 } | 384 } |
385 } | 385 } |
386 } | 386 } |
OLD | NEW |