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" |
21 #include "chrome/browser/autocomplete/history_url_provider.h" | 22 #include "chrome/browser/autocomplete/history_url_provider.h" |
22 #include "chrome/browser/autocomplete/in_memory_url_index.h" | 23 #include "chrome/browser/autocomplete/in_memory_url_index.h" |
23 #include "chrome/browser/autocomplete/in_memory_url_index_types.h" | 24 #include "chrome/browser/autocomplete/in_memory_url_index_types.h" |
24 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 25 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
25 #include "chrome/browser/history/history_service_factory.h" | 26 #include "chrome/browser/history/history_service_factory.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 28 #include "chrome/browser/search_engines/template_url_service_factory.h" |
28 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/crash_keys.h" |
29 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
31 #include "components/bookmarks/browser/bookmark_model.h" | 33 #include "components/bookmarks/browser/bookmark_model.h" |
32 #include "components/history/core/browser/history_database.h" | 34 #include "components/history/core/browser/history_database.h" |
33 #include "components/history/core/browser/history_service.h" | 35 #include "components/history/core/browser/history_service.h" |
34 #include "components/metrics/proto/omnibox_input_type.pb.h" | 36 #include "components/metrics/proto/omnibox_input_type.pb.h" |
35 #include "components/omnibox/autocomplete_match_type.h" | 37 #include "components/omnibox/autocomplete_match_type.h" |
36 #include "components/omnibox/autocomplete_result.h" | 38 #include "components/omnibox/autocomplete_result.h" |
37 #include "components/omnibox/omnibox_field_trial.h" | 39 #include "components/omnibox/omnibox_field_trial.h" |
38 #include "components/search_engines/template_url.h" | 40 #include "components/search_engines/template_url.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, | 253 info.url(), languages_, format_types, net::UnescapeRule::SPACES, NULL, |
252 NULL, &adjustments); | 254 NULL, &adjustments); |
253 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); | 255 base::OffsetAdjuster::AdjustOffsets(adjustments, &offsets); |
254 TermMatches new_matches = | 256 TermMatches new_matches = |
255 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); | 257 ReplaceOffsetsInTermMatches(history_match.url_matches, offsets); |
256 match.contents_class = | 258 match.contents_class = |
257 SpansFromTermMatch(new_matches, match.contents.length(), true); | 259 SpansFromTermMatch(new_matches, match.contents.length(), true); |
258 | 260 |
259 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. | 261 // Set |inline_autocompletion| and |allowed_to_be_default_match| if possible. |
260 if (history_match.can_inline) { | 262 if (history_match.can_inline) { |
261 DCHECK(!new_matches.empty()); | 263 base::debug::ScopedCrashKey crash_info( |
| 264 crash_keys::kBug464926CrashKey, |
| 265 info.url().spec().substr(0, 30) + " " + |
| 266 base::UTF16ToUTF8(autocomplete_input_.text()).substr(0, 20) + " " + |
| 267 base::SizeTToString(history_match.url_matches.size()) + " " + |
| 268 base::SizeTToString(offsets.size()));; |
| 269 CHECK(!new_matches.empty()); |
262 size_t inline_autocomplete_offset = new_matches[0].offset + | 270 size_t inline_autocomplete_offset = new_matches[0].offset + |
263 new_matches[0].length; | 271 new_matches[0].length; |
264 // |inline_autocomplete_offset| may be beyond the end of the | 272 // |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 | 273 // |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 | 274 // last character typed is a slash. That slash is removed by the |
267 // FormatURLWithOffsets call above. | 275 // FormatURLWithOffsets call above. |
268 if (inline_autocomplete_offset < match.fill_into_edit.length()) { | 276 if (inline_autocomplete_offset < match.fill_into_edit.length()) { |
269 match.inline_autocompletion = | 277 match.inline_autocompletion = |
270 match.fill_into_edit.substr(inline_autocomplete_offset); | 278 match.fill_into_edit.substr(inline_autocomplete_offset); |
271 } | 279 } |
272 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || | 280 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || |
273 !PreventInlineAutocomplete(autocomplete_input_); | 281 !PreventInlineAutocomplete(autocomplete_input_); |
274 } | 282 } |
275 match.EnsureUWYTIsAllowedToBeDefault( | 283 match.EnsureUWYTIsAllowedToBeDefault( |
276 autocomplete_input_.canonicalized_url(), | 284 autocomplete_input_.canonicalized_url(), |
277 TemplateURLServiceFactory::GetForProfile(profile_)); | 285 TemplateURLServiceFactory::GetForProfile(profile_)); |
278 | 286 |
279 // Format the description autocomplete presentation. | 287 // Format the description autocomplete presentation. |
280 match.description = info.title(); | 288 match.description = info.title(); |
281 match.description_class = SpansFromTermMatch( | 289 match.description_class = SpansFromTermMatch( |
282 history_match.title_matches, match.description.length(), false); | 290 history_match.title_matches, match.description.length(), false); |
283 | 291 |
284 match.RecordAdditionalInfo("typed count", info.typed_count()); | 292 match.RecordAdditionalInfo("typed count", info.typed_count()); |
285 match.RecordAdditionalInfo("visit count", info.visit_count()); | 293 match.RecordAdditionalInfo("visit count", info.visit_count()); |
286 match.RecordAdditionalInfo("last visit", info.last_visit()); | 294 match.RecordAdditionalInfo("last visit", info.last_visit()); |
287 | 295 |
288 return match; | 296 return match; |
289 } | 297 } |
OLD | NEW |