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

Side by Side Diff: chrome/browser/autocomplete/search_provider.h

Issue 54203008: Store xsrf token received with psuggest results. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test case Created 7 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 | Annotate | Revision Log
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 // This file contains the Search autocomplete provider. This provider is 5 // This file contains the Search autocomplete provider. This provider is
6 // responsible for all autocomplete entries that start with "Search <engine> 6 // responsible for all autocomplete entries that start with "Search <engine>
7 // for ...", including searching for the current input string, search 7 // for ...", including searching for the current input string, search
8 // history, and search suggestions. An instance of it gets created and 8 // history, and search suggestions. An instance of it gets created and
9 // managed by the autocomplete controller. 9 // managed by the autocomplete controller.
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 const AutocompleteInput& input, 82 const AutocompleteInput& input,
83 const string16& input_text, 83 const string16& input_text,
84 int relevance, 84 int relevance,
85 AutocompleteMatch::Type type, 85 AutocompleteMatch::Type type,
86 bool is_keyword, 86 bool is_keyword,
87 const string16& match_contents, 87 const string16& match_contents,
88 const string16& annotation, 88 const string16& annotation,
89 const TemplateURL* template_url, 89 const TemplateURL* template_url,
90 const string16& query_string, 90 const string16& query_string,
91 const std::string& suggest_query_params, 91 const std::string& suggest_query_params,
92 const std::string& xsrf_token,
Peter Kasting 2013/10/31 23:54:46 Don't pass this in if no callers but SearchProvide
92 int accepted_suggestion, 93 int accepted_suggestion,
93 int omnibox_start_margin, 94 int omnibox_start_margin,
94 bool append_extra_query_params); 95 bool append_extra_query_params);
95 96
96 // Returns whether the SearchProvider previously flagged |match| as a query 97 // Returns whether the SearchProvider previously flagged |match| as a query
97 // that should be prefetched. 98 // that should be prefetched.
98 static bool ShouldPrefetch(const AutocompleteMatch& match); 99 static bool ShouldPrefetch(const AutocompleteMatch& match);
99 100
100 // Extracts the suggest response metadata which SearchProvider previously 101 // Extracts the suggest response metadata which SearchProvider previously
101 // stored for |match|. 102 // stored for |match|.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // there. 221 // there.
221 bool relevance_from_server_; 222 bool relevance_from_server_;
222 }; 223 };
223 224
224 class SuggestResult : public Result { 225 class SuggestResult : public Result {
225 public: 226 public:
226 SuggestResult(const string16& suggestion, 227 SuggestResult(const string16& suggestion,
227 const string16& match_contents, 228 const string16& match_contents,
228 const string16& annotation, 229 const string16& annotation,
229 const std::string& suggest_query_params, 230 const std::string& suggest_query_params,
231 const std::string& xsrf_token,
230 bool from_keyword_provider, 232 bool from_keyword_provider,
231 int relevance, 233 int relevance,
232 bool relevance_from_server, 234 bool relevance_from_server,
233 bool should_prefetch); 235 bool should_prefetch);
234 virtual ~SuggestResult(); 236 virtual ~SuggestResult();
235 237
236 const string16& suggestion() const { return suggestion_; } 238 const string16& suggestion() const { return suggestion_; }
237 const string16& match_contents() const { return match_contents_; } 239 const string16& match_contents() const { return match_contents_; }
238 const string16& annotation() const { return annotation_; } 240 const string16& annotation() const { return annotation_; }
239 const std::string& suggest_query_params() const { 241 const std::string& suggest_query_params() const {
240 return suggest_query_params_; 242 return suggest_query_params_;
241 } 243 }
244 const std::string& xsrf_token() const { return xsrf_token_; }
242 bool should_prefetch() const { return should_prefetch_; } 245 bool should_prefetch() const { return should_prefetch_; }
243 246
244 // Result: 247 // Result:
245 virtual bool IsInlineable(const string16& input) const OVERRIDE; 248 virtual bool IsInlineable(const string16& input) const OVERRIDE;
246 virtual int CalculateRelevance( 249 virtual int CalculateRelevance(
247 const AutocompleteInput& input, 250 const AutocompleteInput& input,
248 bool keyword_provider_requested) const OVERRIDE; 251 bool keyword_provider_requested) const OVERRIDE;
249 252
250 private: 253 private:
251 // The search terms to be used for this suggestion. 254 // The search terms to be used for this suggestion.
252 string16 suggestion_; 255 string16 suggestion_;
253 256
254 // The contents to be displayed in the autocomplete match. 257 // The contents to be displayed in the autocomplete match.
255 string16 match_contents_; 258 string16 match_contents_;
256 259
257 // Optional annotation for the |match_contents_| for disambiguation. 260 // Optional annotation for the |match_contents_| for disambiguation.
258 // This may be displayed in the autocomplete match contents, but is defined 261 // This may be displayed in the autocomplete match contents, but is defined
259 // separately to facilitate different formatting. 262 // separately to facilitate different formatting.
260 string16 annotation_; 263 string16 annotation_;
261 264
262 // Optional additional parameters to be added to the search URL. 265 // Optional additional parameters to be added to the search URL.
263 std::string suggest_query_params_; 266 std::string suggest_query_params_;
264 267
268 // Optional xsrf token provided with personalized suggestions and needed
269 // for a deletion request.
270 std::string xsrf_token_;
271
265 // Should this result be prefetched? 272 // Should this result be prefetched?
266 bool should_prefetch_; 273 bool should_prefetch_;
267 }; 274 };
268 275
269 class NavigationResult : public Result { 276 class NavigationResult : public Result {
270 public: 277 public:
271 // |provider| is necessary to use StringForURLDisplay() in order to 278 // |provider| is necessary to use StringForURLDisplay() in order to
272 // compute |formatted_url_|. 279 // compute |formatted_url_|.
273 NavigationResult(const AutocompleteProvider& provider, 280 NavigationResult(const AutocompleteProvider& provider,
274 const GURL& url, 281 const GURL& url,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 bool relevance_from_server, 500 bool relevance_from_server,
494 bool should_prefetch, 501 bool should_prefetch,
495 const std::string& metadata, 502 const std::string& metadata,
496 AutocompleteMatch::Type type, 503 AutocompleteMatch::Type type,
497 bool is_keyword, 504 bool is_keyword,
498 const string16& match_contents, 505 const string16& match_contents,
499 const string16& annotation, 506 const string16& annotation,
500 const string16& query_string, 507 const string16& query_string,
501 int accepted_suggestion, 508 int accepted_suggestion,
502 const std::string& suggest_query_params, 509 const std::string& suggest_query_params,
510 const std::string& xsrf_token,
503 MatchMap* map); 511 MatchMap* map);
504 512
505 // Returns an AutocompleteMatch for a navigational suggestion. 513 // Returns an AutocompleteMatch for a navigational suggestion.
506 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); 514 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation);
507 515
508 // Resets the scores of all |keyword_navigation_results_| matches to 516 // Resets the scores of all |keyword_navigation_results_| matches to
509 // be below that of the top keyword query match (the verbatim match 517 // be below that of the top keyword query match (the verbatim match
510 // as expressed by |keyword_verbatim_relevance_| or keyword query 518 // as expressed by |keyword_verbatim_relevance_| or keyword query
511 // suggestions stored in |keyword_suggest_results_|). If there 519 // suggestions stored in |keyword_suggest_results_|). If there
512 // are no keyword suggestions and keyword verbatim is suppressed, 520 // are no keyword suggestions and keyword verbatim is suppressed,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 bool field_trial_triggered_in_session_; 592 bool field_trial_triggered_in_session_;
585 593
586 // If true, search history query suggestions will score low enough that 594 // If true, search history query suggestions will score low enough that
587 // they will not be inlined. 595 // they will not be inlined.
588 bool prevent_search_history_inlining_; 596 bool prevent_search_history_inlining_;
589 597
590 DISALLOW_COPY_AND_ASSIGN(SearchProvider); 598 DISALLOW_COPY_AND_ASSIGN(SearchProvider);
591 }; 599 };
592 600
593 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ 601 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | chrome/browser/search_engines/template_url.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698