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

Side by Side Diff: components/omnibox/browser/zero_suggest_provider.cc

Issue 2738003002: Add title to current page in zero suggest. (Closed)
Patch Set: Fix comments and add title in verbatim_match.cc 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 unified diff | Download patch
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 "components/omnibox/browser/zero_suggest_provider.h" 5 #include "components/omnibox/browser/zero_suggest_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/i18n/case_conversion.h" 10 #include "base/i18n/case_conversion.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!input.from_omnibox_focus() || client()->IsOffTheRecord() || 107 if (!input.from_omnibox_focus() || client()->IsOffTheRecord() ||
108 input.type() == metrics::OmniboxInputType::INVALID) 108 input.type() == metrics::OmniboxInputType::INVALID)
109 return; 109 return;
110 110
111 Stop(true, false); 111 Stop(true, false);
112 set_field_trial_triggered(false); 112 set_field_trial_triggered(false);
113 set_field_trial_triggered_in_session(false); 113 set_field_trial_triggered_in_session(false);
114 results_from_cache_ = false; 114 results_from_cache_ = false;
115 permanent_text_ = input.text(); 115 permanent_text_ = input.text();
116 current_query_ = input.current_url().spec(); 116 current_query_ = input.current_url().spec();
117 current_title_ = input.current_title();
117 current_page_classification_ = input.current_page_classification(); 118 current_page_classification_ = input.current_page_classification();
118 current_url_match_ = MatchForCurrentURL(); 119 current_url_match_ = MatchForCurrentURL();
119 120
120 std::string url_string = GetContextualSuggestionsUrl(); 121 std::string url_string = GetContextualSuggestionsUrl();
121 GURL suggest_url(url_string); 122 GURL suggest_url(url_string);
122 if (!suggest_url.is_valid()) 123 if (!suggest_url.is_valid())
123 return; 124 return;
124 125
125 // No need to send the current page URL in personalized suggest or 126 // No need to send the current page URL in personalized suggest or
126 // most visited field trials. 127 // most visited field trials.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 done_ = true; 186 done_ = true;
186 187
187 if (clear_cached_results) { 188 if (clear_cached_results) {
188 // We do not call Clear() on |results_| to retain |verbatim_relevance| 189 // We do not call Clear() on |results_| to retain |verbatim_relevance|
189 // value in the |results_| object. |verbatim_relevance| is used at the 190 // value in the |results_| object. |verbatim_relevance| is used at the
190 // beginning of the next call to Start() to determine the current url 191 // beginning of the next call to Start() to determine the current url
191 // match relevance. 192 // match relevance.
192 results_.suggest_results.clear(); 193 results_.suggest_results.clear();
193 results_.navigation_results.clear(); 194 results_.navigation_results.clear();
194 current_query_.clear(); 195 current_query_.clear();
196 current_title_.clear();
195 most_visited_urls_.clear(); 197 most_visited_urls_.clear();
196 } 198 }
197 } 199 }
198 200
199 void ZeroSuggestProvider::DeleteMatch(const AutocompleteMatch& match) { 201 void ZeroSuggestProvider::DeleteMatch(const AutocompleteMatch& match) {
200 if (OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) { 202 if (OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) {
201 // Remove the deleted match from the cache, so it is not shown to the user 203 // Remove the deleted match from the cache, so it is not shown to the user
202 // again. Since we cannot remove just one result, blow away the cache. 204 // again. Since we cannot remove just one result, blow away the cache.
203 client()->GetPrefs()->SetString(omnibox::kZeroSuggestCachedResults, 205 client()->GetPrefs()->SetString(omnibox::kZeroSuggestCachedResults,
204 std::string()); 206 std::string());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 const TemplateURL* ZeroSuggestProvider::GetTemplateURL(bool is_keyword) const { 258 const TemplateURL* ZeroSuggestProvider::GetTemplateURL(bool is_keyword) const {
257 // Zero suggest provider should not receive keyword results. 259 // Zero suggest provider should not receive keyword results.
258 DCHECK(!is_keyword); 260 DCHECK(!is_keyword);
259 return client()->GetTemplateURLService()->GetDefaultSearchProvider(); 261 return client()->GetTemplateURLService()->GetDefaultSearchProvider();
260 } 262 }
261 263
262 const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const { 264 const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const {
263 // The callers of this method won't look at the AutocompleteInput's 265 // The callers of this method won't look at the AutocompleteInput's
264 // |from_omnibox_focus| member, so we can set its value to false. 266 // |from_omnibox_focus| member, so we can set its value to false.
265 return AutocompleteInput(base::string16(), base::string16::npos, 267 return AutocompleteInput(base::string16(), base::string16::npos,
266 std::string(), GURL(current_query_), 268 std::string(), GURL(current_query_), current_title_,
267 current_page_classification_, true, false, false, 269 current_page_classification_, true, false, false,
268 true, false, client()->GetSchemeClassifier()); 270 true, false, client()->GetSchemeClassifier());
269 } 271 }
270 272
271 bool ZeroSuggestProvider::ShouldAppendExtraParams( 273 bool ZeroSuggestProvider::ShouldAppendExtraParams(
272 const SearchSuggestionParser::SuggestResult& result) const { 274 const SearchSuggestionParser::SuggestResult& result) const {
273 // We always use the default provider for search, so append the params. 275 // We always use the default provider for search, so append the params.
274 return true; 276 return true;
275 } 277 }
276 278
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if (!json_data.empty()) { 550 if (!json_data.empty()) {
549 std::unique_ptr<base::Value> data( 551 std::unique_ptr<base::Value> data(
550 SearchSuggestionParser::DeserializeJsonData(json_data)); 552 SearchSuggestionParser::DeserializeJsonData(json_data));
551 if (data && ParseSuggestResults( 553 if (data && ParseSuggestResults(
552 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 554 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
553 ConvertResultsToAutocompleteMatches(); 555 ConvertResultsToAutocompleteMatches();
554 results_from_cache_ = !matches_.empty(); 556 results_from_cache_ = !matches_.empty();
555 } 557 }
556 } 558 }
557 } 559 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698