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

Unified Diff: components/omnibox/browser/zero_suggest_provider.cc

Issue 2738003002: Add title to current page in zero suggest. (Closed)
Patch Set: Sync to head Created 3 years, 8 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: components/omnibox/browser/zero_suggest_provider.cc
diff --git a/components/omnibox/browser/zero_suggest_provider.cc b/components/omnibox/browser/zero_suggest_provider.cc
index 17569a21d1196495bdfca53fec4452877ed13055..f41aa25c9e6f6a2dd4a8f78070b62e8c4523c42a 100644
--- a/components/omnibox/browser/zero_suggest_provider.cc
+++ b/components/omnibox/browser/zero_suggest_provider.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include "base/callback.h"
+#include "base/feature_list.h"
#include "base/i18n/case_conversion.h"
#include "base/json/json_string_value_serializer.h"
#include "base/metrics/histogram_macros.h"
@@ -115,6 +116,7 @@ void ZeroSuggestProvider::Start(const AutocompleteInput& input,
results_from_cache_ = false;
permanent_text_ = input.text();
current_query_ = input.current_url().spec();
+ current_title_ = input.current_title();
current_page_classification_ = input.current_page_classification();
current_url_match_ = MatchForCurrentURL();
@@ -174,6 +176,7 @@ void ZeroSuggestProvider::Start(const AutocompleteInput& input,
// These may be useful on the NTP or more relevant to the user than server
// suggestions, if based on local browsing history.
MaybeUseCachedSuggestions();
+ LOG(ERROR) << suggest_url.possibly_invalid_spec();
Mark P 2017/04/27 05:44:08 Did you intend to keep this here? Please reconsid
gcomanici 2017/04/27 17:29:30 Removed.
Run(suggest_url);
}
@@ -193,6 +196,7 @@ void ZeroSuggestProvider::Stop(bool clear_cached_results,
results_.suggest_results.clear();
results_.navigation_results.clear();
current_query_.clear();
+ current_title_.clear();
most_visited_urls_.clear();
}
}
@@ -264,7 +268,7 @@ const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const {
// The callers of this method won't look at the AutocompleteInput's
// |from_omnibox_focus| member, so we can set its value to false.
return AutocompleteInput(base::string16(), base::string16::npos,
- std::string(), GURL(current_query_),
+ std::string(), GURL(current_query_), current_title_,
current_page_classification_, true, false, false,
true, false, client()->GetSchemeClassifier());
}
@@ -512,7 +516,11 @@ AutocompleteMatch ZeroSuggestProvider::MatchForCurrentURL() {
// gets dropped as soon as the user types something.
AutocompleteInput tmp(GetInput(false));
tmp.UpdateText(permanent_text_, base::string16::npos, tmp.parts());
- return VerbatimMatchForURL(client(), tmp, GURL(current_query_),
+ const base::string16 description =
+ (base::FeatureList::IsEnabled(omnibox::kDisplayTitleForCurrentUrl))
+ ? current_title_
+ : base::string16();
+ return VerbatimMatchForURL(client(), tmp, GURL(current_query_), description,
history_url_provider_,
results_.verbatim_relevance);
}

Powered by Google App Engine
This is Rietveld 408576698