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

Unified Diff: chrome/browser/autocomplete/autocomplete_result.cc

Issue 14698028: Omnibox refactor. OmniboxController now holds an AutocompleteMatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed failing browser tests. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/autocomplete_result.cc
diff --git a/chrome/browser/autocomplete/autocomplete_result.cc b/chrome/browser/autocomplete/autocomplete_result.cc
index dda6ec58339463d3196f7966e1aad66dc86682b7..c723d3f4d47e5b5b14f3c8c99b2aca63c2595fa0 100644
--- a/chrome/browser/autocomplete/autocomplete_result.cc
+++ b/chrome/browser/autocomplete/autocomplete_result.cc
@@ -134,13 +134,8 @@ void AutocompleteResult::SortAndCull(const AutocompleteInput& input,
default_match_ = begin();
// Set the alternate nav URL.
- alternate_nav_url_ = GURL();
- if (input.type() == AutocompleteInput::UNKNOWN &&
- default_match_ != end() &&
- AutocompleteMatch::IsSearchType(default_match_->type) &&
- default_match_->transition != content::PAGE_TRANSITION_KEYWORD &&
- input.canonicalized_url() != default_match_->destination_url)
- alternate_nav_url_ = input.canonicalized_url();
+ alternate_nav_url_ = default_match_ == end() ? GURL() :
+ ComputeAlternateNavUrl(input, *default_match_);
}
bool AutocompleteResult::HasCopiedMatches() const {
@@ -208,6 +203,17 @@ void AutocompleteResult::Validate() const {
}
#endif
+// static
+GURL AutocompleteResult::ComputeAlternateNavUrl(
+ const AutocompleteInput& input,
+ const AutocompleteMatch& match) {
+ return (input.type() == AutocompleteInput::UNKNOWN &&
+ AutocompleteMatch::IsSearchType(match.type) &&
+ match.transition != content::PAGE_TRANSITION_KEYWORD &&
+ input.canonicalized_url() != match.destination_url) ?
+ input.canonicalized_url() : GURL();
+}
+
void AutocompleteResult::BuildProviderToMatches(
ProviderToMatches* provider_to_matches) const {
for (ACMatches::const_iterator i(begin()); i != end(); ++i)
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_result.h ('k') | chrome/browser/extensions/api/omnibox/omnibox_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698