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/autocomplete/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 // HistoryQuickProvider matches are currently not deletable. | 92 // HistoryQuickProvider matches are currently not deletable. |
93 // TODO(mrossetti): Determine when a match should be deletable. | 93 // TODO(mrossetti): Determine when a match should be deletable. |
94 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} | 94 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} |
95 | 95 |
96 void HistoryQuickProvider::DoAutocomplete() { | 96 void HistoryQuickProvider::DoAutocomplete() { |
97 // Get the matching URLs from the DB. | 97 // Get the matching URLs from the DB. |
98 string16 term_string = autocomplete_input_.text(); | 98 string16 term_string = autocomplete_input_.text(); |
| 99 // TODO(mrossetti): Temporary workaround for http://crbug.com/88498. |
| 100 // Just give up after 50 characters. |
| 101 if (term_string.size() > 50) |
| 102 return; |
99 term_string = UnescapeURLComponent(term_string, | 103 term_string = UnescapeURLComponent(term_string, |
100 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); | 104 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS); |
101 history::InMemoryURLIndex::String16Vector terms( | 105 history::InMemoryURLIndex::String16Vector terms( |
102 InMemoryURLIndex::WordVectorFromString16(term_string, false)); | 106 InMemoryURLIndex::WordVectorFromString16(term_string, false)); |
103 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(terms); | 107 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(terms); |
104 if (matches.empty()) | 108 if (matches.empty()) |
105 return; | 109 return; |
106 | 110 |
107 // Artificially reduce the score of high-scoring matches which should not be | 111 // Artificially reduce the score of high-scoring matches which should not be |
108 // inline autocompletd. Each such result gets the next available | 112 // inline autocompletd. Each such result gets the next available |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 do { | 227 do { |
224 offset += matches[i].length; | 228 offset += matches[i].length; |
225 ++i; | 229 ++i; |
226 } while ((i < match_count) && (offset == matches[i].offset)); | 230 } while ((i < match_count) && (offset == matches[i].offset)); |
227 if (offset < text_length) | 231 if (offset < text_length) |
228 spans.push_back(ACMatchClassification(offset, url_style)); | 232 spans.push_back(ACMatchClassification(offset, url_style)); |
229 } | 233 } |
230 | 234 |
231 return spans; | 235 return spans; |
232 } | 236 } |
OLD | NEW |