OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), | 270 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), |
271 net::FormatUrlWithOffsets(info.url(), languages_, format_types, | 271 net::FormatUrlWithOffsets(info.url(), languages_, format_types, |
272 net::UnescapeRule::SPACES, NULL, NULL, &offsets)); | 272 net::UnescapeRule::SPACES, NULL, NULL, &offsets)); |
273 history::TermMatches new_matches = | 273 history::TermMatches new_matches = |
274 ReplaceOffsetsInTermMatches(history_match.url_matches(), offsets); | 274 ReplaceOffsetsInTermMatches(history_match.url_matches(), offsets); |
275 match.contents = net::FormatUrl(info.url(), languages_, format_types, | 275 match.contents = net::FormatUrl(info.url(), languages_, format_types, |
276 net::UnescapeRule::SPACES, NULL, NULL, NULL); | 276 net::UnescapeRule::SPACES, NULL, NULL, NULL); |
277 match.contents_class = | 277 match.contents_class = |
278 SpansFromTermMatch(new_matches, match.contents.length(), true); | 278 SpansFromTermMatch(new_matches, match.contents.length(), true); |
279 | 279 |
280 match.allowed_to_be_default_match = history_match.can_inline() && | 280 if (history_match.can_inline()) { |
281 !PreventInlineAutocomplete(autocomplete_input_); | |
282 if (match.allowed_to_be_default_match) { | |
283 DCHECK(!new_matches.empty()); | 281 DCHECK(!new_matches.empty()); |
284 size_t inline_autocomplete_offset = new_matches[0].offset + | 282 size_t inline_autocomplete_offset = new_matches[0].offset + |
285 new_matches[0].length; | 283 new_matches[0].length; |
286 // |inline_autocomplete_offset| may be beyond the end of the | 284 // |inline_autocomplete_offset| may be beyond the end of the |
287 // |fill_into_edit| if the user has typed an URL with a scheme and the | 285 // |fill_into_edit| if the user has typed an URL with a scheme and the |
288 // last character typed is a slash. That slash is removed by the | 286 // last character typed is a slash. That slash is removed by the |
289 // FormatURLWithOffsets call above. | 287 // FormatURLWithOffsets call above. |
290 if (inline_autocomplete_offset < match.fill_into_edit.length()) { | 288 if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
291 match.inline_autocompletion = | 289 match.inline_autocompletion = |
292 match.fill_into_edit.substr(inline_autocomplete_offset); | 290 match.fill_into_edit.substr(inline_autocomplete_offset); |
293 } | 291 } |
| 292 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
| 293 !PreventInlineAutocomplete(autocomplete_input_); |
294 } | 294 } |
295 | 295 |
296 // Format the description autocomplete presentation. | 296 // Format the description autocomplete presentation. |
297 match.description = info.title(); | 297 match.description = info.title(); |
298 match.description_class = SpansFromTermMatch( | 298 match.description_class = SpansFromTermMatch( |
299 history_match.title_matches(), match.description.length(), false); | 299 history_match.title_matches(), match.description.length(), false); |
300 | 300 |
301 match.RecordAdditionalInfo("typed count", info.typed_count()); | 301 match.RecordAdditionalInfo("typed count", info.typed_count()); |
302 match.RecordAdditionalInfo("visit count", info.visit_count()); | 302 match.RecordAdditionalInfo("visit count", info.visit_count()); |
303 match.RecordAdditionalInfo("last visit", info.last_visit()); | 303 match.RecordAdditionalInfo("last visit", info.last_visit()); |
304 | 304 |
305 return match; | 305 return match; |
306 } | 306 } |
307 | 307 |
308 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { | 308 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { |
309 if (index_for_testing_.get()) | 309 if (index_for_testing_.get()) |
310 return index_for_testing_.get(); | 310 return index_for_testing_.get(); |
311 | 311 |
312 HistoryService* const history_service = | 312 HistoryService* const history_service = |
313 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 313 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
314 if (!history_service) | 314 if (!history_service) |
315 return NULL; | 315 return NULL; |
316 | 316 |
317 return history_service->InMemoryIndex(); | 317 return history_service->InMemoryIndex(); |
318 } | 318 } |
OLD | NEW |