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

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

Issue 672773003: Include a URL what-you-typed option when the default search provider is not available and the input… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix style nits, convert virtual to override in unit test Created 6 years, 1 month 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 | « AUTHORS ('k') | chrome/browser/autocomplete/history_url_provider_unittest.cc » ('j') | 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_url_provider.h" 5 #include "chrome/browser/autocomplete/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 *j, i->prefix.length(), !i->num_components, 749 *j, i->prefix.length(), !i->num_components,
750 i->num_components >= best_prefix->num_components)); 750 i->num_components >= best_prefix->num_components));
751 } 751 }
752 } 752 }
753 753
754 // Create sorted list of suggestions. 754 // Create sorted list of suggestions.
755 CullPoorMatches(params); 755 CullPoorMatches(params);
756 SortAndDedupMatches(&params->matches); 756 SortAndDedupMatches(&params->matches);
757 757
758 // Try to create a shorter suggestion from the best match. 758 // Try to create a shorter suggestion from the best match.
759 // We consider the what you typed match eligible for display when there's a 759 // We consider the what you typed match eligible for display when it's
760 // reasonable chance the user actually cares: 760 // navigable and there's a reasonable chance the user intended to do
761 // * Their input can be opened as a URL, and 761 // something other than search. We use a variety of heuristics to determine
762 // * We parsed the input as a URL, or it starts with an explicit "http:" or 762 // this, e.g. whether the user explicitly typed a scheme, or if omnibox
763 // "https:". 763 // searching has been disabled by policy. In the cases where we've parsed as
764 // Otherwise, this is just low-quality noise. In the cases where we've parsed 764 // UNKNOWN, we'll still show an accidental search infobar if need be.
765 // as UNKNOWN, we'll still show an accidental search infobar if need be.
766 VisitClassifier classifier(this, params->input, db); 765 VisitClassifier classifier(this, params->input, db);
767 params->have_what_you_typed_match = 766 params->have_what_you_typed_match =
768 (params->input.type() != metrics::OmniboxInputType::QUERY) && 767 (params->input.type() != metrics::OmniboxInputType::QUERY) &&
769 ((params->input.type() != metrics::OmniboxInputType::UNKNOWN) || 768 ((params->input.type() != metrics::OmniboxInputType::UNKNOWN) ||
770 (classifier.type() == VisitClassifier::UNVISITED_INTRANET) || 769 (classifier.type() == VisitClassifier::UNVISITED_INTRANET) ||
771 !params->trim_http || 770 !params->trim_http ||
772 (AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0)); 771 (AutocompleteInput::NumNonHostComponents(params->input.parts()) > 0) ||
772 !params->default_search_provider);
773 const bool have_shorter_suggestion_suitable_for_inline_autocomplete = 773 const bool have_shorter_suggestion_suitable_for_inline_autocomplete =
774 PromoteOrCreateShorterSuggestion( 774 PromoteOrCreateShorterSuggestion(
775 db, params->have_what_you_typed_match, params); 775 db, params->have_what_you_typed_match, params);
776 776
777 // Check whether what the user typed appears in history. 777 // Check whether what the user typed appears in history.
778 const bool can_check_history_for_exact_match = 778 const bool can_check_history_for_exact_match =
779 // Checking what_you_typed_match.is_history_what_you_typed_match tells us 779 // Checking what_you_typed_match.is_history_what_you_typed_match tells us
780 // whether SuggestExactInput() succeeded in constructing a valid match. 780 // whether SuggestExactInput() succeeded in constructing a valid match.
781 params->what_you_typed_match.is_history_what_you_typed_match && 781 params->what_you_typed_match.is_history_what_you_typed_match &&
782 // Additionally, in the case where the user has typed "foo.com" and 782 // Additionally, in the case where the user has typed "foo.com" and
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, 1155 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
1156 match.contents.length(), ACMatchClassification::URL, 1156 match.contents.length(), ACMatchClassification::URL,
1157 &match.contents_class); 1157 &match.contents_class);
1158 } 1158 }
1159 match.description = info.title(); 1159 match.description = info.title();
1160 match.description_class = 1160 match.description_class =
1161 ClassifyDescription(params.input.text(), match.description); 1161 ClassifyDescription(params.input.text(), match.description);
1162 RecordAdditionalInfoFromUrlRow(info, &match); 1162 RecordAdditionalInfoFromUrlRow(info, &match);
1163 return match; 1163 return match;
1164 } 1164 }
OLDNEW
« no previous file with comments | « AUTHORS ('k') | chrome/browser/autocomplete/history_url_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698