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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), | 265 AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), |
266 net::FormatUrlWithOffsets(info.url(), languages_, format_types, | 266 net::FormatUrlWithOffsets(info.url(), languages_, format_types, |
267 net::UnescapeRule::SPACES, NULL, NULL, &offsets)); | 267 net::UnescapeRule::SPACES, NULL, NULL, &offsets)); |
268 history::TermMatches new_matches = | 268 history::TermMatches new_matches = |
269 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); | 269 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); |
270 match.contents = net::FormatUrl(info.url(), languages_, format_types, | 270 match.contents = net::FormatUrl(info.url(), languages_, format_types, |
271 net::UnescapeRule::SPACES, NULL, NULL, NULL); | 271 net::UnescapeRule::SPACES, NULL, NULL, NULL); |
272 match.contents_class = | 272 match.contents_class = |
273 SpansFromTermMatch(new_matches, match.contents.length(), true); | 273 SpansFromTermMatch(new_matches, match.contents.length(), true); |
274 | 274 |
275 if (!history_match.can_inline) { | 275 if (history_match.can_inline) { |
276 match.inline_autocomplete_offset = string16::npos; | |
277 } else { | |
278 DCHECK(!new_matches.empty()); | 276 DCHECK(!new_matches.empty()); |
279 match.inline_autocomplete_offset = new_matches[0].offset + | 277 size_t inline_autocomplete_offset = new_matches[0].offset + |
280 new_matches[0].length; | 278 new_matches[0].length; |
281 // The following will happen if the user has typed an URL with a scheme | 279 // |inline_autocomplete_offset| may be beyond the end of the |
282 // and the last character typed is a slash because that slash is removed | 280 // |fill_into_edit| if the user has typed an URL with a scheme and the |
283 // by the FormatURLWithOffsets call above. | 281 // last character typed is a slash. That slash is removed by the |
284 if (match.inline_autocomplete_offset > match.fill_into_edit.length()) | 282 // FormatURLWithOffsets call above. |
285 match.inline_autocomplete_offset = match.fill_into_edit.length(); | 283 if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
| 284 match.inline_autocompletion = |
| 285 match.fill_into_edit.substr(inline_autocomplete_offset); |
| 286 } |
286 } | 287 } |
287 | 288 |
288 // Format the description autocomplete presentation. | 289 // Format the description autocomplete presentation. |
289 match.description = info.title(); | 290 match.description = info.title(); |
290 match.description_class = SpansFromTermMatch( | 291 match.description_class = SpansFromTermMatch( |
291 history_match.title_matches, match.description.length(), false); | 292 history_match.title_matches, match.description.length(), false); |
292 | 293 |
293 match.RecordAdditionalInfo("typed count", info.typed_count()); | 294 match.RecordAdditionalInfo("typed count", info.typed_count()); |
294 match.RecordAdditionalInfo("visit count", info.visit_count()); | 295 match.RecordAdditionalInfo("visit count", info.visit_count()); |
295 match.RecordAdditionalInfo("last visit", info.last_visit()); | 296 match.RecordAdditionalInfo("last visit", info.last_visit()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 do { | 334 do { |
334 offset += matches[i].length; | 335 offset += matches[i].length; |
335 ++i; | 336 ++i; |
336 } while ((i < match_count) && (offset == matches[i].offset)); | 337 } while ((i < match_count) && (offset == matches[i].offset)); |
337 if (offset < text_length) | 338 if (offset < text_length) |
338 spans.push_back(ACMatchClassification(offset, url_style)); | 339 spans.push_back(ACMatchClassification(offset, url_style)); |
339 } | 340 } |
340 | 341 |
341 return spans; | 342 return spans; |
342 } | 343 } |
OLD | NEW |