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

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

Issue 158053002: Part 4 of search provider refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't copy suggestion Created 6 years, 10 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 | 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 static const int kDefaultProviderURLFetcherID; 50 static const int kDefaultProviderURLFetcherID;
51 51
52 // ID used in creating URLFetcher for keyword provider's suggest results. 52 // ID used in creating URLFetcher for keyword provider's suggest results.
53 static const int kKeywordProviderURLFetcherID; 53 static const int kKeywordProviderURLFetcherID;
54 54
55 // ID used in creating URLFetcher for deleting suggestion results. 55 // ID used in creating URLFetcher for deleting suggestion results.
56 static const int kDeletionURLFetcherID; 56 static const int kDeletionURLFetcherID;
57 57
58 SearchProvider(AutocompleteProviderListener* listener, Profile* profile); 58 SearchProvider(AutocompleteProviderListener* listener, Profile* profile);
59 59
60 // Returns whether the SearchProvider previously flagged |match| as a query
61 // that should be prefetched.
62 static bool ShouldPrefetch(const AutocompleteMatch& match);
63
64 // Extracts the suggest response metadata which SearchProvider previously 60 // Extracts the suggest response metadata which SearchProvider previously
65 // stored for |match|. 61 // stored for |match|.
66 static std::string GetSuggestMetadata(const AutocompleteMatch& match); 62 static std::string GetSuggestMetadata(const AutocompleteMatch& match);
67 63
68 // AutocompleteProvider: 64 // AutocompleteProvider:
69 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE; 65 virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
70 virtual void ResetSession() OVERRIDE; 66 virtual void ResetSession() OVERRIDE;
71 67
72 // This URL may be sent with suggest requests; see comments on CanSendURL(). 68 // This URL may be sent with suggest requests; see comments on CanSendURL().
73 void set_current_page_url(const GURL& current_page_url) { 69 void set_current_page_url(const GURL& current_page_url) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 bool prefer_keyword); 156 bool prefer_keyword);
161 157
162 // AutocompleteProvider: 158 // AutocompleteProvider:
163 virtual void Start(const AutocompleteInput& input, 159 virtual void Start(const AutocompleteInput& input,
164 bool minimal_changes) OVERRIDE; 160 bool minimal_changes) OVERRIDE;
165 virtual void Stop(bool clear_cached_results) OVERRIDE; 161 virtual void Stop(bool clear_cached_results) OVERRIDE;
166 162
167 // net::URLFetcherDelegate: 163 // net::URLFetcherDelegate:
168 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 164 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
169 165
166 // BaseSearchProvider:
167 virtual const TemplateURL* GetTemplateURL(
168 const SuggestResult& result) const OVERRIDE;
169 virtual const AutocompleteInput GetInput(
170 const SuggestResult& result) const OVERRIDE;
171 virtual bool ShouldAppendExtraParams(
172 const SuggestResult& result) const OVERRIDE;
173
170 // This gets called when we have requested a suggestion deletion from the 174 // This gets called when we have requested a suggestion deletion from the
171 // server to handle the results of the deletion. 175 // server to handle the results of the deletion.
172 void OnDeletionComplete(bool success, 176 void OnDeletionComplete(bool success,
173 SuggestionDeletionHandler* handler); 177 SuggestionDeletionHandler* handler);
174 178
175 // Records in UMA whether the deletion request resulted in success. 179 // Records in UMA whether the deletion request resulted in success.
176 // This is virtual so test code can override it to check that we 180 // This is virtual so test code can override it to check that we
177 // correctly handle the request result. 181 // correctly handle the request result.
178 virtual void RecordDeletionResult(bool success); 182 virtual void RecordDeletionResult(bool success);
179 183
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // indicates whether the results correspond to the keyword provider or default 309 // indicates whether the results correspond to the keyword provider or default
306 // provider. |use_aggressive_method| says whether this function can use a 310 // provider. |use_aggressive_method| says whether this function can use a
307 // method that gives high scores (1200+) rather than one that gives lower 311 // method that gives high scores (1200+) rather than one that gives lower
308 // scores. When using the aggressive method, scores may exceed 1300 312 // scores. When using the aggressive method, scores may exceed 1300
309 // unless |prevent_search_history_inlining| is set. 313 // unless |prevent_search_history_inlining| is set.
310 int CalculateRelevanceForHistory(const base::Time& time, 314 int CalculateRelevanceForHistory(const base::Time& time,
311 bool is_keyword, 315 bool is_keyword,
312 bool use_aggressive_method, 316 bool use_aggressive_method,
313 bool prevent_search_history_inlining) const; 317 bool prevent_search_history_inlining) const;
314 318
315 // Creates an AutocompleteMatch for "Search <engine> for |query_string|" with
316 // the supplied details. Adds this match to |map|; if such a match already
317 // exists, whichever one has lower relevance is eliminated.
318 void AddMatchToMap(const SuggestResult& result,
319 const base::string16& input_text,
320 const std::string& metadata,
321 int accepted_suggestion,
322 MatchMap* map);
323
324 // Returns an AutocompleteMatch for a navigational suggestion. 319 // Returns an AutocompleteMatch for a navigational suggestion.
325 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation); 320 AutocompleteMatch NavigationToMatch(const NavigationResult& navigation);
326 321
327 // Resets the scores of all |keyword_navigation_results_| matches to 322 // Resets the scores of all |keyword_navigation_results_| matches to
328 // be below that of the top keyword query match (the verbatim match 323 // be below that of the top keyword query match (the verbatim match
329 // as expressed by |keyword_verbatim_relevance_| or keyword query 324 // as expressed by |keyword_verbatim_relevance_| or keyword query
330 // suggestions stored in |keyword_suggest_results_|). If there 325 // suggestions stored in |keyword_suggest_results_|). If there
331 // are no keyword suggestions and keyword verbatim is suppressed, 326 // are no keyword suggestions and keyword verbatim is suppressed,
332 // then drops the suggested relevance scores for the navsuggestions 327 // then drops the suggested relevance scores for the navsuggestions
333 // and drops the request to suppress verbatim, thereby introducing the 328 // and drops the request to suppress verbatim, thereby introducing the
334 // keyword verbatim match which will naturally outscore the navsuggestions. 329 // keyword verbatim match which will naturally outscore the navsuggestions.
335 void DemoteKeywordNavigationMatchesPastTopQuery(); 330 void DemoteKeywordNavigationMatchesPastTopQuery();
336 331
337 // Updates the value of |done_| from the internal state. 332 // Updates the value of |done_| from the internal state.
338 void UpdateDone(); 333 void UpdateDone();
339 334
340 // The amount of time to wait before sending a new suggest request after the 335 // The amount of time to wait before sending a new suggest request after the
341 // previous one. Non-const because some unittests modify this value. 336 // previous one. Non-const because some unittests modify this value.
342 static int kMinimumTimeBetweenSuggestQueriesMs; 337 static int kMinimumTimeBetweenSuggestQueriesMs;
343 338
344 // The following keys are used to record additional information on matches.
345
346 // We annotate our AutocompleteMatches with whether their relevance scores
347 // were server-provided using this key in the |additional_info| field.
348 static const char kRelevanceFromServerKey[];
349
350 // Indicates whether the server said a match should be prefetched.
351 static const char kShouldPrefetchKey[];
352
353 // Used to store metadata from the server response, which is needed for
354 // prefetching.
355 static const char kSuggestMetadataKey[];
356
357 // Used to store a deletion request url for server-provided suggestions.
358 static const char kDeletionUrlKey[];
359
360 // These are the values for the above keys.
361 static const char kTrue[];
362 static const char kFalse[];
363
364 // Maintains the TemplateURLs used. 339 // Maintains the TemplateURLs used.
365 Providers providers_; 340 Providers providers_;
366 341
367 // The user's input. 342 // The user's input.
368 AutocompleteInput input_; 343 AutocompleteInput input_;
369 344
370 // Input when searching against the keyword provider. 345 // Input when searching against the keyword provider.
371 AutocompleteInput keyword_input_; 346 AutocompleteInput keyword_input_;
372 347
373 // Searches in the user's history that begin with the input text. 348 // Searches in the user's history that begin with the input text.
(...skipping 23 matching lines...) Expand all
397 // that a server delete a personalized suggestion. Making this a ScopedVector 372 // that a server delete a personalized suggestion. Making this a ScopedVector
398 // causes us to auto-cancel all such requests on shutdown. 373 // causes us to auto-cancel all such requests on shutdown.
399 SuggestionDeletionHandlers deletion_handlers_; 374 SuggestionDeletionHandlers deletion_handlers_;
400 375
401 GURL current_page_url_; 376 GURL current_page_url_;
402 377
403 DISALLOW_COPY_AND_ASSIGN(SearchProvider); 378 DISALLOW_COPY_AND_ASSIGN(SearchProvider);
404 }; 379 };
405 380
406 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ 381 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/base_search_provider.cc ('k') | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698