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

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

Issue 2738003002: Add title to current page in zero suggest. (Closed)
Patch Set: Change the place where the title is added and some suggested renaming. 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 std::string url_string = GetContextualSuggestionsUrl(); 120 std::string url_string = GetContextualSuggestionsUrl();
Mark P 2017/04/12 05:07:56 nit: Please restore the blank line you deleted her
gcomanici 2017/04/12 16:16:31 Done.
121 GURL suggest_url(url_string); 121 GURL suggest_url(url_string);
122 if (!suggest_url.is_valid()) 122 if (!suggest_url.is_valid())
123 return; 123 return;
124 124
125 // No need to send the current page URL in personalized suggest or 125 // No need to send the current page URL in personalized suggest or
126 // most visited field trials. 126 // most visited field trials.
127 const TemplateURLService* template_url_service = 127 const TemplateURLService* template_url_service =
128 client()->GetTemplateURLService(); 128 client()->GetTemplateURLService();
129 const TemplateURL* default_provider = 129 const TemplateURL* default_provider =
130 template_url_service->GetDefaultSearchProvider(); 130 template_url_service->GetDefaultSearchProvider();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 waiting_for_most_visited_urls_request_ = false; 184 waiting_for_most_visited_urls_request_ = false;
185 done_ = true; 185 done_ = true;
186 186
187 if (clear_cached_results) { 187 if (clear_cached_results) {
188 // We do not call Clear() on |results_| to retain |verbatim_relevance| 188 // We do not call Clear() on |results_| to retain |verbatim_relevance|
189 // value in the |results_| object. |verbatim_relevance| is used at the 189 // value in the |results_| object. |verbatim_relevance| is used at the
190 // beginning of the next call to Start() to determine the current url 190 // beginning of the next call to Start() to determine the current url
191 // match relevance. 191 // match relevance.
192 results_.suggest_results.clear(); 192 results_.suggest_results.clear();
193 results_.navigation_results.clear(); 193 results_.navigation_results.clear();
194 current_query_.clear(); 194 current_query_.clear();
Mark P 2017/04/12 05:07:57 Please clear the title here as well.
gcomanici 2017/04/12 16:16:31 Done.
195 most_visited_urls_.clear(); 195 most_visited_urls_.clear();
196 } 196 }
197 } 197 }
198 198
199 void ZeroSuggestProvider::DeleteMatch(const AutocompleteMatch& match) { 199 void ZeroSuggestProvider::DeleteMatch(const AutocompleteMatch& match) {
200 if (OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) { 200 if (OmniboxFieldTrial::InZeroSuggestPersonalizedFieldTrial()) {
201 // Remove the deleted match from the cache, so it is not shown to the user 201 // 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. 202 // again. Since we cannot remove just one result, blow away the cache.
203 client()->GetPrefs()->SetString(omnibox::kZeroSuggestCachedResults, 203 client()->GetPrefs()->SetString(omnibox::kZeroSuggestCachedResults,
204 std::string()); 204 std::string());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 const TemplateURL* ZeroSuggestProvider::GetTemplateURL(bool is_keyword) const { 256 const TemplateURL* ZeroSuggestProvider::GetTemplateURL(bool is_keyword) const {
257 // Zero suggest provider should not receive keyword results. 257 // Zero suggest provider should not receive keyword results.
258 DCHECK(!is_keyword); 258 DCHECK(!is_keyword);
259 return client()->GetTemplateURLService()->GetDefaultSearchProvider(); 259 return client()->GetTemplateURLService()->GetDefaultSearchProvider();
260 } 260 }
261 261
262 const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const { 262 const AutocompleteInput ZeroSuggestProvider::GetInput(bool is_keyword) const {
263 // The callers of this method won't look at the AutocompleteInput's 263 // 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. 264 // |from_omnibox_focus| member, so we can set its value to false.
265 return AutocompleteInput(base::string16(), base::string16::npos, 265 return AutocompleteInput(base::string16(), base::string16::npos,
266 std::string(), GURL(current_query_), 266 std::string(), GURL(current_query_), current_title_,
267 current_page_classification_, true, false, false, 267 current_page_classification_, true, false, false,
268 true, false, client()->GetSchemeClassifier()); 268 true, false, client()->GetSchemeClassifier());
269 } 269 }
270 270
271 bool ZeroSuggestProvider::ShouldAppendExtraParams( 271 bool ZeroSuggestProvider::ShouldAppendExtraParams(
272 const SearchSuggestionParser::SuggestResult& result) const { 272 const SearchSuggestionParser::SuggestResult& result) const {
273 // We always use the default provider for search, so append the params. 273 // We always use the default provider for search, so append the params.
274 return true; 274 return true;
275 } 275 }
276 276
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if (!json_data.empty()) { 548 if (!json_data.empty()) {
549 std::unique_ptr<base::Value> data( 549 std::unique_ptr<base::Value> data(
550 SearchSuggestionParser::DeserializeJsonData(json_data)); 550 SearchSuggestionParser::DeserializeJsonData(json_data));
551 if (data && ParseSuggestResults( 551 if (data && ParseSuggestResults(
552 *data, kDefaultZeroSuggestRelevance, false, &results_)) { 552 *data, kDefaultZeroSuggestRelevance, false, &results_)) {
553 ConvertResultsToAutocompleteMatches(); 553 ConvertResultsToAutocompleteMatches();
554 results_from_cache_ = !matches_.empty(); 554 results_from_cache_ = !matches_.empty();
555 } 555 }
556 } 556 }
557 } 557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698