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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 public net::URLFetcherDelegate { | 53 public net::URLFetcherDelegate { |
54 public: | 54 public: |
55 // ID used in creating URLFetcher for default provider's suggest results. | 55 // ID used in creating URLFetcher for default provider's suggest results. |
56 static const int kDefaultProviderURLFetcherID; | 56 static const int kDefaultProviderURLFetcherID; |
57 | 57 |
58 // ID used in creating URLFetcher for keyword provider's suggest results. | 58 // ID used in creating URLFetcher for keyword provider's suggest results. |
59 static const int kKeywordProviderURLFetcherID; | 59 static const int kKeywordProviderURLFetcherID; |
60 | 60 |
61 SearchProvider(AutocompleteProviderListener* listener, Profile* profile); | 61 SearchProvider(AutocompleteProviderListener* listener, Profile* profile); |
62 | 62 |
63 // Returns an AutocompleteMatch representing a search for |query_string| | 63 // Returns an AutocompleteMatch with the given |autocomplete_provider|, |
64 // using the provider identified by |keyword|. |is_keyword| should be true if | 64 // |relevance|, and |type|, which represents a search via |template_url| for |
65 // |input| represents a keyword search (even if it's for the default search | 65 // |query_string|. If |template_url| is NULL, returns a match with an invalid |
66 // provider). |input_text| (the original input text) and |accepted_suggestion| | 66 // destination URL. |
67 // are used to generate Assisted Query Stats. | 67 // |
68 // Returns a match with an invalid destination_url in case of any errors. | 68 // |input_text| is the original user input, which may differ from |
| 69 // |query_string|; e.g. the user typed "foo" and got a search suggestion of |
| 70 // "food", which we're now marking up. This is used to highlight portions of |
| 71 // the match contents to distinguish locally-typed text from suggested text. |
| 72 // |
| 73 // |input| and |is_keyword| are necessary for various other details, like |
| 74 // whether we should allow inline autocompletion and what the transition type |
| 75 // should be. |accepted_suggestion| and |omnibox_start_margin| are used along |
| 76 // with |input_text| to generate Assisted Query Stats. |
69 static AutocompleteMatch CreateSearchSuggestion( | 77 static AutocompleteMatch CreateSearchSuggestion( |
70 Profile* profile, | |
71 AutocompleteProvider* autocomplete_provider, | 78 AutocompleteProvider* autocomplete_provider, |
72 const AutocompleteInput& input, | 79 int relevance, |
| 80 AutocompleteMatch::Type type, |
| 81 const TemplateURL* template_url, |
73 const string16& query_string, | 82 const string16& query_string, |
74 const string16& input_text, | 83 const string16& input_text, |
75 int relevance, | 84 const AutocompleteInput& input, |
76 AutocompleteMatch::Type type, | 85 bool is_keyword, |
77 int accepted_suggestion, | 86 int accepted_suggestion, |
78 bool is_keyword, | |
79 const string16& keyword, | |
80 int omnibox_start_margin); | 87 int omnibox_start_margin); |
81 | 88 |
82 // AutocompleteProvider: | 89 // AutocompleteProvider: |
83 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; | 90 virtual void AddProviderInfo(ProvidersInfo* provider_info) const OVERRIDE; |
84 virtual void ResetSession() OVERRIDE; | 91 virtual void ResetSession() OVERRIDE; |
85 | 92 |
86 // Update the omnibox start margin used to generate search suggestion URLs. | 93 // Update the omnibox start margin used to generate search suggestion URLs. |
87 void SetOmniboxStartMargin(int omnibox_start_margin); | 94 void SetOmniboxStartMargin(int omnibox_start_margin); |
88 | 95 |
89 bool field_trial_triggered_in_session() const { | 96 bool field_trial_triggered_in_session() const { |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 // session. | 520 // session. |
514 bool field_trial_triggered_in_session_; | 521 bool field_trial_triggered_in_session_; |
515 | 522 |
516 // Start margin of the omnibox. Used to construct search URLs. | 523 // Start margin of the omnibox. Used to construct search URLs. |
517 int omnibox_start_margin_; | 524 int omnibox_start_margin_; |
518 | 525 |
519 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 526 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
520 }; | 527 }; |
521 | 528 |
522 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 529 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |