Chromium Code Reviews| 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" |
| 11 #include "base/debug/crash_logging.h" | |
| 11 #include "base/i18n/break_iterator.h" | 12 #include "base/i18n/break_iterator.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 21 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, | 252 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, |
| 252 NULL, &adjustments); | 253 NULL, &adjustments); |
| 253 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); | 254 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); |
| 254 TermMatches new_matches = | 255 TermMatches new_matches = |
| 255 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); | 256 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); |
| 256 match.contents_class = | 257 match.contents_class = |
| 257 SpansFromTermMatch(new_matches, match.contents.length(), true); | 258 SpansFromTermMatch(new_matches, match.contents.length(), true); |
| 258 | 259 |
| 259 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. | 260 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. |
| 260 if (history_match.can_inline) { | 261 if (history_match.can_inline) { |
| 262 base::debug::ScopedCrashKey crash_info( | |
| 263 "bug_464926_info", | |
| 264 info.url().spec() + " " + | |
| 265 base::UTF16ToUTF8(autocomplete_input_.text()) + " " + | |
| 266 base::SizeTToString(history_match.url_matches.size()) + " " + | |
| 267 base::SizeTToString(offsets.size()));; | |
| 261 DCHECK(!new_matches.empty()); | 268 DCHECK(!new_matches.empty()); |
|
Peter Kasting
2015/05/11 23:34:42
Can you upgrade this DCHECK to CHECK to find insta
Mark P
2015/05/11 23:45:15
There is no need; it'll crash anyway on the line b
Peter Kasting
2015/05/11 23:47:13
I'm mostly worried about it not crashing until sli
Mark P
2015/05/11 23:49:59
Done.
| |
| 262 size_t inline_autocomplete_offset = new_matches[0].offset + | 269 size_t inline_autocomplete_offset = new_matches[0].offset + |
| 263 new_matches[0].length; | 270 new_matches[0].length; |
| 264 // |inline_autocomplete_offset| may be beyond the end of the | 271 // |inline_autocomplete_offset| may be beyond the end of the |
| 265 // |fill_into_edit| if the user has typed an URL with a scheme and the | 272 // |fill_into_edit| if the user has typed an URL with a scheme and the |
| 266 // last character typed is a slash. That slash is removed by the | 273 // last character typed is a slash. That slash is removed by the |
| 267 // FormatURLWithOffsets call above. | 274 // FormatURLWithOffsets call above. |
| 268 if (inline_autocomplete_offset < match.fill_into_edit.length()) { | 275 if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
| 269 match.inline_autocompletion = | 276 match.inline_autocompletion = |
| 270 match.fill_into_edit.substr(inline_autocomplete_offset); | 277 match.fill_into_edit.substr(inline_autocomplete_offset); |
| 271 } | 278 } |
| 272 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || | 279 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
| 273 !PreventInlineAutocomplete(autocomplete_input_); | 280 !PreventInlineAutocomplete(autocomplete_input_); |
| 274 } | 281 } |
| 275 match.EnsureUWYTIsAllowedToBeDefault( | 282 match.EnsureUWYTIsAllowedToBeDefault( |
| 276 autocomplete_input_.canonicalized_url(), | 283 autocomplete_input_.canonicalized_url(), |
| 277 TemplateURLServiceFactory::GetForProfile(profile_)); | 284 TemplateURLServiceFactory::GetForProfile(profile_)); |
| 278 | 285 |
| 279 // Format the description autocomplete presentation. | 286 // Format the description autocomplete presentation. |
| 280 match.description = info.title(); | 287 match.description = info.title(); |
| 281 match.description_class = SpansFromTermMatch( | 288 match.description_class = SpansFromTermMatch( |
| 282 history_match.title_matches, match.description.length(), false); | 289 history_match.title_matches, match.description.length(), false); |
| 283 | 290 |
| 284 match.RecordAdditionalInfo("typed count", info.typed_count()); | 291 match.RecordAdditionalInfo("typed count", info.typed_count()); |
| 285 match.RecordAdditionalInfo("visit count", info.visit_count()); | 292 match.RecordAdditionalInfo("visit count", info.visit_count()); |
| 286 match.RecordAdditionalInfo("last visit", info.last_visit()); | 293 match.RecordAdditionalInfo("last visit", info.last_visit()); |
| 287 | 294 |
| 288 return match; | 295 return match; |
| 289 } | 296 } |
| OLD | NEW |