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

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

Issue 353223002: Omnibox: Fix URL-What-You-Typed Allowed-To-Be-Default-Match Issues (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove some test cases; add dcheck Created 6 years, 5 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 | Annotate | Revision Log
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"
11 #include "base/i18n/break_iterator.h" 11 #include "base/i18n/break_iterator.h"
12 #include "base/i18n/case_conversion.h"
Peter Kasting 2014/07/09 22:36:00 Nit: Is this needed?
Mark P 2014/07/09 23:12:23 Not anymore. Removed.
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/autocomplete_result.h" 21 #include "chrome/browser/autocomplete/autocomplete_result.h"
21 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 22 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // |fill_into_edit| if the user has typed an URL with a scheme and the 269 // |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 270 // last character typed is a slash. That slash is removed by the
270 // FormatURLWithOffsets call above. 271 // FormatURLWithOffsets call above.
271 if (inline_autocomplete_offset < match.fill_into_edit.length()) { 272 if (inline_autocomplete_offset < match.fill_into_edit.length()) {
272 match.inline_autocompletion = 273 match.inline_autocompletion =
273 match.fill_into_edit.substr(inline_autocomplete_offset); 274 match.fill_into_edit.substr(inline_autocomplete_offset);
274 } 275 }
275 match.allowed_to_be_default_match = match.inline_autocompletion.empty() || 276 match.allowed_to_be_default_match = match.inline_autocompletion.empty() ||
276 !PreventInlineAutocomplete(autocomplete_input_); 277 !PreventInlineAutocomplete(autocomplete_input_);
277 } 278 }
279 match.EnsureUWYTIsAllowedToBeDefault(
280 autocomplete_input_.canonicalized_url(),
281 TemplateURLServiceFactory::GetForProfile(profile_));
278 282
279 // Format the description autocomplete presentation. 283 // Format the description autocomplete presentation.
280 match.description = info.title(); 284 match.description = info.title();
281 match.description_class = SpansFromTermMatch( 285 match.description_class = SpansFromTermMatch(
282 history_match.title_matches(), match.description.length(), false); 286 history_match.title_matches(), match.description.length(), false);
283 287
284 match.RecordAdditionalInfo("typed count", info.typed_count()); 288 match.RecordAdditionalInfo("typed count", info.typed_count());
285 match.RecordAdditionalInfo("visit count", info.visit_count()); 289 match.RecordAdditionalInfo("visit count", info.visit_count());
286 match.RecordAdditionalInfo("last visit", info.last_visit()); 290 match.RecordAdditionalInfo("last visit", info.last_visit());
287 291
288 return match; 292 return match;
289 } 293 }
290 294
291 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { 295 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() {
292 if (index_for_testing_.get()) 296 if (index_for_testing_.get())
293 return index_for_testing_.get(); 297 return index_for_testing_.get();
294 298
295 HistoryService* const history_service = 299 HistoryService* const history_service =
296 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 300 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
297 if (!history_service) 301 if (!history_service)
298 return NULL; 302 return NULL;
299 303
300 return history_service->InMemoryIndex(); 304 return history_service->InMemoryIndex();
301 } 305 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698