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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // |fill_into_edit| if the user has typed an URL with a scheme and the | 268 // |fill_into_edit| if the user has typed an URL with a scheme and the |
269 // last character typed is a slash. That slash is removed by the | 269 // last character typed is a slash. That slash is removed by the |
270 // FormatURLWithOffsets call above. | 270 // FormatURLWithOffsets call above. |
271 if (inline_autocomplete_offset < match.fill_into_edit.length()) { | 271 if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
272 match.inline_autocompletion = | 272 match.inline_autocompletion = |
273 match.fill_into_edit.substr(inline_autocomplete_offset); | 273 match.fill_into_edit.substr(inline_autocomplete_offset); |
274 } | 274 } |
275 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || | 275 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
276 !PreventInlineAutocomplete(autocomplete_input_); | 276 !PreventInlineAutocomplete(autocomplete_input_); |
277 } | 277 } |
| 278 // Also allow a user's input to be marked as default if it would be fixed |
| 279 // up to something equivalent to the URL-what-you-typed match. This handles |
| 280 // cases like the cursor being into the middle of input, making |
| 281 // ScoredHistoryMatch think the input is two terms and thus be unable to |
| 282 // decide if it's inlineable. |
| 283 match.ComputeStrippedDestinationURL(profile_); |
| 284 if (AutocompleteMatch::GURLToStrippedGURL( |
| 285 autocomplete_input_.canonicalized_url(), profile_, |
| 286 base::string16()) == match.stripped_destination_url) |
| 287 match.allowed_to_be_default_match = true; |
278 | 288 |
279 // Format the description autocomplete presentation. | 289 // Format the description autocomplete presentation. |
280 match.description = info.title(); | 290 match.description = info.title(); |
281 match.description_class = SpansFromTermMatch( | 291 match.description_class = SpansFromTermMatch( |
282 history_match.title_matches(), match.description.length(), false); | 292 history_match.title_matches(), match.description.length(), false); |
283 | 293 |
284 match.RecordAdditionalInfo("typed count", info.typed_count()); | 294 match.RecordAdditionalInfo("typed count", info.typed_count()); |
285 match.RecordAdditionalInfo("visit count", info.visit_count()); | 295 match.RecordAdditionalInfo("visit count", info.visit_count()); |
286 match.RecordAdditionalInfo("last visit", info.last_visit()); | 296 match.RecordAdditionalInfo("last visit", info.last_visit()); |
287 | 297 |
288 return match; | 298 return match; |
289 } | 299 } |
290 | 300 |
291 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { | 301 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { |
292 if (index_for_testing_.get()) | 302 if (index_for_testing_.get()) |
293 return index_for_testing_.get(); | 303 return index_for_testing_.get(); |
294 | 304 |
295 HistoryService* const history_service = | 305 HistoryService* const history_service = |
296 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 306 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
297 if (!history_service) | 307 if (!history_service) |
298 return NULL; | 308 return NULL; |
299 | 309 |
300 return history_service->InMemoryIndex(); | 310 return history_service->InMemoryIndex(); |
301 } | 311 } |
OLD | NEW |