OLD | NEW |
---|---|
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 static std::string GetSuggestMetadata(const AutocompleteMatch& match); | 99 static std::string GetSuggestMetadata(const AutocompleteMatch& match); |
100 | 100 |
101 // AutocompleteProvider: | 101 // AutocompleteProvider: |
102 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 102 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
103 virtual void ResetSession() OVERRIDE; | 103 virtual void ResetSession() OVERRIDE; |
104 | 104 |
105 bool field_trial_triggered_in_session() const { | 105 bool field_trial_triggered_in_session() const { |
106 return field_trial_triggered_in_session_; | 106 return field_trial_triggered_in_session_; |
107 } | 107 } |
108 | 108 |
109 // This URL may be sent with suggest requests; see comments on CanSendURL(). | |
110 void set_current_page_url(const GURL& url) { | |
Peter Kasting
2013/10/08 01:10:25
Tiny nit: Name the arg |current_page_url|
H Fung
2013/10/30 23:56:15
Done.
| |
111 current_page_url_ = url; | |
112 } | |
113 | |
109 private: | 114 private: |
110 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after | 115 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after |
111 // refactoring common code to a new base class. | 116 // refactoring common code to a new base class. |
112 friend class SearchProviderTest; | 117 friend class SearchProviderTest; |
113 friend class ZeroSuggestProvider; | 118 friend class ZeroSuggestProvider; |
114 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 119 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
115 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 120 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
116 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 121 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
117 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); | 122 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); |
118 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 123 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 // suggestions stored in |keyword_suggest_results_|). If there | 490 // suggestions stored in |keyword_suggest_results_|). If there |
486 // are no keyword suggestions and keyword verbatim is suppressed, | 491 // are no keyword suggestions and keyword verbatim is suppressed, |
487 // then drops the suggested relevance scores for the navsuggestions | 492 // then drops the suggested relevance scores for the navsuggestions |
488 // and drops the request to suppress verbatim, thereby introducing the | 493 // and drops the request to suppress verbatim, thereby introducing the |
489 // keyword verbatim match which will naturally outscore the navsuggestions. | 494 // keyword verbatim match which will naturally outscore the navsuggestions. |
490 void DemoteKeywordNavigationMatchesPastTopQuery(); | 495 void DemoteKeywordNavigationMatchesPastTopQuery(); |
491 | 496 |
492 // Updates the value of |done_| from the internal state. | 497 // Updates the value of |done_| from the internal state. |
493 void UpdateDone(); | 498 void UpdateDone(); |
494 | 499 |
500 // Whether the URL can be sent in the suggest request. Don't send the URL of | |
501 // non-Google HTTPS requests because it may contain sensitive information. | |
Peter Kasting
2013/10/08 01:10:25
Nit: This sentence is kinda redundant with the one
H Fung
2013/10/30 23:56:15
Done.
| |
502 // Don't allow incognito, if suggest is disabled, if they don't have | |
Peter Kasting
2013/10/08 01:10:25
Nit: incognito -> if Chrome is incognito?
H Fung
2013/10/30 23:56:15
Done.
| |
503 // unencrypted tab sync enabled, or if Google is not their search provider. | |
Peter Kasting
2013/10/08 01:10:25
Nit: their -> the user's
H Fung
2013/10/30 23:56:15
Done.
| |
504 // Checking that the user is in a field trial is done elsewhere. | |
Peter Kasting
2013/10/08 01:10:25
This line seems to be false now.
H Fung
2013/10/30 23:56:15
Done.
| |
505 static bool CanSendURL(const GURL& url, const TemplateURL* template_url, | |
Peter Kasting
2013/10/08 01:10:25
Nit: One arg per line
H Fung
2013/10/30 23:56:15
Done.
| |
506 Profile* profile); | |
507 | |
495 // The amount of time to wait before sending a new suggest request after the | 508 // The amount of time to wait before sending a new suggest request after the |
496 // previous one. Non-const because some unittests modify this value. | 509 // previous one. Non-const because some unittests modify this value. |
497 static int kMinimumTimeBetweenSuggestQueriesMs; | 510 static int kMinimumTimeBetweenSuggestQueriesMs; |
498 | 511 |
499 // The following keys are used to record additional information on matches. | 512 // The following keys are used to record additional information on matches. |
500 | 513 |
501 // We annotate our AutocompleteMatches with whether their relevance scores | 514 // We annotate our AutocompleteMatches with whether their relevance scores |
502 // were server-provided using this key in the |additional_info| field. | 515 // were server-provided using this key in the |additional_info| field. |
503 static const char kRelevanceFromServerKey[]; | 516 static const char kRelevanceFromServerKey[]; |
504 | 517 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 bool field_trial_triggered_; | 567 bool field_trial_triggered_; |
555 | 568 |
556 // Same as above except that it is maintained across the current Omnibox | 569 // Same as above except that it is maintained across the current Omnibox |
557 // session. | 570 // session. |
558 bool field_trial_triggered_in_session_; | 571 bool field_trial_triggered_in_session_; |
559 | 572 |
560 // If true, search history query suggestions will score low enough that | 573 // If true, search history query suggestions will score low enough that |
561 // they will not be inlined. | 574 // they will not be inlined. |
562 bool prevent_search_history_inlining_; | 575 bool prevent_search_history_inlining_; |
563 | 576 |
577 GURL current_page_url_; | |
578 | |
564 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 579 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
565 }; | 580 }; |
566 | 581 |
567 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 582 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |