Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: chrome/browser/autocomplete/history_quick_provider.cc

Issue 1124033003: Omnibox - Fix Rare HQP Crash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 match.contents = net::FormatUrlWithAdjustments( 250 match.contents = net::FormatUrlWithAdjustments(
251 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, 251 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL,
252 NULL, &adjustments); 252 NULL, &adjustments);
253 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); 253 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets);
254 TermMatches new_matches = 254 TermMatches new_matches =
255 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); 255 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets);
256 match.contents_class = 256 match.contents_class =
257 SpansFromTermMatch(new_matches, match.contents.length(), true); 257 SpansFromTermMatch(new_matches, match.contents.length(), true);
258 258
259 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. 259 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible.
260 // The second part of this test can happen if the only match(es) of the user's
261 // term occur in places FormatUrl() decides to omit in the formatted url.
262 // In these cases, it's impossible to set |inline_autocompletion| correctly
263 // and hence the match cannot be the default match. I (mpearson@) do not
264 // know under what circumstances this can occur.
265 // See crbug.com/464926.
260 if (history_match.can_inline) { 266 if (history_match.can_inline) {
261 DCHECK(!new_matches.empty()); 267 DCHECK(!new_matches.empty()) << "url=" << info.url().spec() << " input="
262 size_t inline_autocomplete_offset = new_matches[0].offset + 268 << autocomplete_input_.text() << " history_match.url_matches.size="
263 new_matches[0].length; 269 << history_match.url_matches.size() << " offsets.size="
264 // |inline_autocomplete_offset| may be beyond the end of the 270 << offsets.size();
265 // |fill_into_edit| if the user has typed an URL with a scheme and the 271 if (!new_matches.empty()) {
266 // last character typed is a slash. That slash is removed by the 272 size_t inline_autocomplete_offset = new_matches[0].offset +
267 // FormatURLWithOffsets call above. 273 new_matches[0].length;
268 if (inline_autocomplete_offset < match.fill_into_edit.length()) { 274 // |inline_autocomplete_offset| may be beyond the end of the
269 match.inline_autocompletion = 275 // |fill_into_edit| if the user has typed an URL with a scheme and the
270 match.fill_into_edit.substr(inline_autocomplete_offset); 276 // last character typed is a slash. That slash is removed by the
277 // FormatURLWithOffsets call above.
278 if (inline_autocomplete_offset < match.fill_into_edit.length()) {
279 match.inline_autocompletion =
280 match.fill_into_edit.substr(inline_autocomplete_offset);
281 }
282 match.allowed_to_be_default_match = match.inline_autocompletion.empty() ||
283 !PreventInlineAutocomplete(autocomplete_input_);
271 } 284 }
272 match.allowed_to_be_default_match = match.inline_autocompletion.empty() ||
273 !PreventInlineAutocomplete(autocomplete_input_);
274 } 285 }
275 match.EnsureUWYTIsAllowedToBeDefault( 286 match.EnsureUWYTIsAllowedToBeDefault(
276 autocomplete_input_.canonicalized_url(), 287 autocomplete_input_.canonicalized_url(),
277 TemplateURLServiceFactory::GetForProfile(profile_)); 288 TemplateURLServiceFactory::GetForProfile(profile_));
278 289
279 // Format the description autocomplete presentation. 290 // Format the description autocomplete presentation.
280 match.description = info.title(); 291 match.description = info.title();
281 match.description_class = SpansFromTermMatch( 292 match.description_class = SpansFromTermMatch(
282 history_match.title_matches, match.description.length(), false); 293 history_match.title_matches, match.description.length(), false);
283 294
284 match.RecordAdditionalInfo("typed count", info.typed_count()); 295 match.RecordAdditionalInfo("typed count", info.typed_count());
285 match.RecordAdditionalInfo("visit count", info.visit_count()); 296 match.RecordAdditionalInfo("visit count", info.visit_count());
286 match.RecordAdditionalInfo("last visit", info.last_visit()); 297 match.RecordAdditionalInfo("last visit", info.last_visit());
287 298
288 return match; 299 return match;
289 } 300 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698