Chromium Code Reviews| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 static std::string GetSuggestMetadata(const AutocompleteMatch& match); | 102 static std::string GetSuggestMetadata(const AutocompleteMatch& match); |
| 103 | 103 |
| 104 // AutocompleteProvider: | 104 // AutocompleteProvider: |
| 105 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 105 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
| 106 virtual void ResetSession() OVERRIDE; | 106 virtual void ResetSession() OVERRIDE; |
| 107 | 107 |
| 108 bool field_trial_triggered_in_session() const { | 108 bool field_trial_triggered_in_session() const { |
| 109 return field_trial_triggered_in_session_; | 109 return field_trial_triggered_in_session_; |
| 110 } | 110 } |
| 111 | 111 |
| 112 // This URL may be sent with suggest requests; see comments on CanSendURL(). | |
| 113 void set_current_page_url(const GURL& current_page_url) { | |
| 114 current_page_url_ = current_page_url; | |
| 115 } | |
| 116 | |
| 112 private: | 117 private: |
| 113 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after | 118 // TODO(hfung): Remove ZeroSuggestProvider as a friend class after |
| 114 // refactoring common code to a new base class. | 119 // refactoring common code to a new base class. |
| 115 friend class SearchProviderTest; | 120 friend class SearchProviderTest; |
| 116 friend class ZeroSuggestProvider; | 121 friend class ZeroSuggestProvider; |
| 117 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 122 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 118 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 123 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 119 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 124 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 120 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); | 125 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); |
| 121 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 126 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 // suggestions stored in |keyword_suggest_results_|). If there | 516 // suggestions stored in |keyword_suggest_results_|). If there |
| 512 // are no keyword suggestions and keyword verbatim is suppressed, | 517 // are no keyword suggestions and keyword verbatim is suppressed, |
| 513 // then drops the suggested relevance scores for the navsuggestions | 518 // then drops the suggested relevance scores for the navsuggestions |
| 514 // and drops the request to suppress verbatim, thereby introducing the | 519 // and drops the request to suppress verbatim, thereby introducing the |
| 515 // keyword verbatim match which will naturally outscore the navsuggestions. | 520 // keyword verbatim match which will naturally outscore the navsuggestions. |
| 516 void DemoteKeywordNavigationMatchesPastTopQuery(); | 521 void DemoteKeywordNavigationMatchesPastTopQuery(); |
| 517 | 522 |
| 518 // Updates the value of |done_| from the internal state. | 523 // Updates the value of |done_| from the internal state. |
| 519 void UpdateDone(); | 524 void UpdateDone(); |
| 520 | 525 |
| 526 // Whether the URL can be sent in the suggest request. | |
| 527 // Don't allow if Chrome is in incognito, if suggest is disabled, if the user | |
| 528 // doesn't have unencrypted tab sync enabled, if Google is not the user's | |
| 529 // search provider, or the URL is a non-Google HTTPS page. We only want to | |
| 530 // send the current URL to the suggest provider if the user is willing to have | |
| 531 // this data sent. Because tab sync involves sending the same data, we | |
| 532 // currently use "tab sync is enabled and tab sync data is unencrypted" as a | |
| 533 // proxy for "the user is OK with sending this data". We might someday want | |
| 534 // to change this to a standalone setting or part of some other explicit | |
| 535 // general opt-in. Non-Google HTTPS URLs are not sent because it may contain | |
| 536 // sensitive information. Google HTTPS URLs (including Google search result | |
| 537 // pages) are ok because the HTTPS request was already sent to Google earlier. | |
|
Peter Kasting
2013/10/31 21:55:51
Nit: How about making this comment a bulleted list
H Fung
2013/11/01 19:16:50
Done, thanks! I added another bullet that the use
| |
| 538 static bool CanSendURL( | |
| 539 const GURL& current_page_url, | |
| 540 const GURL& suggest_url, | |
| 541 const TemplateURL* template_url, | |
| 542 AutocompleteInput::PageClassification page_classification, | |
| 543 Profile* profile); | |
| 544 | |
| 521 // The amount of time to wait before sending a new suggest request after the | 545 // The amount of time to wait before sending a new suggest request after the |
| 522 // previous one. Non-const because some unittests modify this value. | 546 // previous one. Non-const because some unittests modify this value. |
| 523 static int kMinimumTimeBetweenSuggestQueriesMs; | 547 static int kMinimumTimeBetweenSuggestQueriesMs; |
| 524 | 548 |
| 525 // The following keys are used to record additional information on matches. | 549 // The following keys are used to record additional information on matches. |
| 526 | 550 |
| 527 // We annotate our AutocompleteMatches with whether their relevance scores | 551 // We annotate our AutocompleteMatches with whether their relevance scores |
| 528 // were server-provided using this key in the |additional_info| field. | 552 // were server-provided using this key in the |additional_info| field. |
| 529 static const char kRelevanceFromServerKey[]; | 553 static const char kRelevanceFromServerKey[]; |
| 530 | 554 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 bool field_trial_triggered_; | 604 bool field_trial_triggered_; |
| 581 | 605 |
| 582 // Same as above except that it is maintained across the current Omnibox | 606 // Same as above except that it is maintained across the current Omnibox |
| 583 // session. | 607 // session. |
| 584 bool field_trial_triggered_in_session_; | 608 bool field_trial_triggered_in_session_; |
| 585 | 609 |
| 586 // If true, search history query suggestions will score low enough that | 610 // If true, search history query suggestions will score low enough that |
| 587 // they will not be inlined. | 611 // they will not be inlined. |
| 588 bool prevent_search_history_inlining_; | 612 bool prevent_search_history_inlining_; |
| 589 | 613 |
| 614 GURL current_page_url_; | |
| 615 | |
| 590 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 616 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 591 }; | 617 }; |
| 592 | 618 |
| 593 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 619 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |