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; |
| 122 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, CanSendURL); | |
| 117 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); | 123 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); |
| 118 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); | 124 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); |
| 119 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); | 125 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); |
| 120 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); | 126 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, RemoveStaleResultsTest); |
| 121 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); | 127 FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); |
| 122 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); | 128 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); |
| 123 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); | 129 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, ClearPrefetchedResults); |
| 124 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); | 130 FRIEND_TEST_ALL_PREFIXES(InstantExtendedPrefetchTest, SetPrefetchQuery); |
| 125 | 131 |
| 126 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers | 132 // Manages the providers (TemplateURLs) used by SearchProvider. Two providers |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 // suggestions stored in |keyword_suggest_results_|). If there | 517 // suggestions stored in |keyword_suggest_results_|). If there |
| 512 // are no keyword suggestions and keyword verbatim is suppressed, | 518 // are no keyword suggestions and keyword verbatim is suppressed, |
| 513 // then drops the suggested relevance scores for the navsuggestions | 519 // then drops the suggested relevance scores for the navsuggestions |
| 514 // and drops the request to suppress verbatim, thereby introducing the | 520 // and drops the request to suppress verbatim, thereby introducing the |
| 515 // keyword verbatim match which will naturally outscore the navsuggestions. | 521 // keyword verbatim match which will naturally outscore the navsuggestions. |
| 516 void DemoteKeywordNavigationMatchesPastTopQuery(); | 522 void DemoteKeywordNavigationMatchesPastTopQuery(); |
| 517 | 523 |
| 518 // Updates the value of |done_| from the internal state. | 524 // Updates the value of |done_| from the internal state. |
| 519 void UpdateDone(); | 525 void UpdateDone(); |
| 520 | 526 |
| 527 // Returns whether we can send the URL of the current page in any suggest | |
| 528 // requests. Doing this requires that all the following hold: | |
| 529 // * The user is not in incognito mode. Incognito disables suggest entirely. | |
| 530 // * The user has suggest enabled in their settings. | |
|
Peter Kasting
2013/11/05 04:17:51
Tiny nit: I'd put this bullet first
H Fung
2013/11/05 07:00:15
Done.
| |
| 531 // * The current URL is HTTP, or HTTPS with the same domain as the suggest | |
| 532 // server. Non-HTTP[S] URLs (e.g. FTP/file URLs) may contain sensitive | |
| 533 // information. HTTPS URLs may also contain sensitive information, but if | |
| 534 // they're on the same domain as the suggest server, then the relevant | |
| 535 // entity could have already seen/logged this data. | |
| 536 // * The suggest request is sent over HTTPS. This avoids leaking the current | |
| 537 // page URL in world-readable network traffic. | |
| 538 // * The user's suggest provider is Google. We might want to allow other | |
| 539 // providers to see this data someday, but for now this has only been | |
| 540 // implemented for Google. Also see next bullet. | |
| 541 // * The user is OK in principle with sending URLs of current pages to their | |
| 542 // provider. Today, there is no explicit setting that controls this, but if | |
| 543 // the user has tab sync enabled and tab sync is unencrypted, then they're | |
| 544 // already sending this data to Google for sync purposes. Thus we use this | |
| 545 // setting as a proxy for "it's OK to send such data". In the future, | |
| 546 // especially if we want to support suggest providers other than Google, we | |
| 547 // may change this to be a standalone setting or part of some explicit | |
| 548 // general opt-in. | |
| 549 | |
|
Peter Kasting
2013/11/05 04:17:51
Nit: Remove blank line
H Fung
2013/11/05 07:00:15
Done.
| |
| 550 static bool CanSendURL( | |
| 551 const GURL& current_page_url, | |
| 552 const GURL& suggest_url, | |
| 553 const TemplateURL* template_url, | |
| 554 AutocompleteInput::PageClassification page_classification, | |
| 555 Profile* profile); | |
| 556 | |
| 521 // The amount of time to wait before sending a new suggest request after the | 557 // 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. | 558 // previous one. Non-const because some unittests modify this value. |
| 523 static int kMinimumTimeBetweenSuggestQueriesMs; | 559 static int kMinimumTimeBetweenSuggestQueriesMs; |
| 524 | 560 |
| 525 // The following keys are used to record additional information on matches. | 561 // The following keys are used to record additional information on matches. |
| 526 | 562 |
| 527 // We annotate our AutocompleteMatches with whether their relevance scores | 563 // We annotate our AutocompleteMatches with whether their relevance scores |
| 528 // were server-provided using this key in the |additional_info| field. | 564 // were server-provided using this key in the |additional_info| field. |
| 529 static const char kRelevanceFromServerKey[]; | 565 static const char kRelevanceFromServerKey[]; |
| 530 | 566 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 bool field_trial_triggered_; | 616 bool field_trial_triggered_; |
| 581 | 617 |
| 582 // Same as above except that it is maintained across the current Omnibox | 618 // Same as above except that it is maintained across the current Omnibox |
| 583 // session. | 619 // session. |
| 584 bool field_trial_triggered_in_session_; | 620 bool field_trial_triggered_in_session_; |
| 585 | 621 |
| 586 // If true, search history query suggestions will score low enough that | 622 // If true, search history query suggestions will score low enough that |
| 587 // they will not be inlined. | 623 // they will not be inlined. |
| 588 bool prevent_search_history_inlining_; | 624 bool prevent_search_history_inlining_; |
| 589 | 625 |
| 626 GURL current_page_url_; | |
| 627 | |
| 590 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 628 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
| 591 }; | 629 }; |
| 592 | 630 |
| 593 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 631 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
| OLD | NEW |