OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 keyword autocomplete provider. The keyword provider | 5 // This file contains the keyword autocomplete provider. The keyword provider |
6 // is responsible for remembering/suggesting user "search keyword queries" | 6 // is responsible for remembering/suggesting user "search keyword queries" |
7 // (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An | 7 // (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An |
8 // instance of it gets created and managed by the autocomplete controller. | 8 // instance of it gets created and managed by the autocomplete controller. |
9 // KeywordProvider uses a TemplateURLModel to find the set of keywords. | 9 // KeywordProvider uses a TemplateURLModel to find the set of keywords. |
10 // | 10 // |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 string16* remaining_input); | 102 string16* remaining_input); |
103 | 103 |
104 // Fills in the "destination_url" and "contents" fields of |match| with the | 104 // Fills in the "destination_url" and "contents" fields of |match| with the |
105 // provided user input and keyword data. | 105 // provided user input and keyword data. |
106 static void FillInURLAndContents( | 106 static void FillInURLAndContents( |
107 const string16& remaining_input, | 107 const string16& remaining_input, |
108 const TemplateURL* element, | 108 const TemplateURL* element, |
109 AutocompleteMatch* match); | 109 AutocompleteMatch* match); |
110 | 110 |
111 // Determines the relevance for some input, given its type, whether the user | 111 // Determines the relevance for some input, given its type, whether the user |
112 // typed the complete keyword, and whether the keyword needs query text (true | 112 // typed the complete keyword, and whether the user is in "prefer keyword |
113 // if the keyword supports replacement and the user isn't in "prefer keyword | 113 // matches" mode, and whether the keyword supports replacement. |
114 // matches" mode). | |
115 // If |allow_exact_keyword_match| is false, the relevance for complete | 114 // If |allow_exact_keyword_match| is false, the relevance for complete |
116 // keywords is degraded. | 115 // keywords that support replacements is degraded. |
117 static int CalculateRelevance(AutocompleteInput::Type type, | 116 static int CalculateRelevance(AutocompleteInput::Type type, |
118 bool complete, | 117 bool complete, |
119 bool no_query_text_needed, | 118 bool prefer_keyword, |
Peter Kasting
2011/01/25 23:20:44
Nit: Super minor, but it might be better to swap |
James Su
2011/01/26 00:53:31
Done.
| |
119 bool support_replacement, | |
120 bool allow_exact_keyword_match); | 120 bool allow_exact_keyword_match); |
121 | 121 |
122 // Creates a fully marked-up AutocompleteMatch from the user's input. | 122 // Creates a fully marked-up AutocompleteMatch from the user's input. |
123 // If |relevance| is negative, calculate a relevance based on heuristics. | 123 // If |relevance| is negative, calculate a relevance based on heuristics. |
124 AutocompleteMatch CreateAutocompleteMatch( | 124 AutocompleteMatch CreateAutocompleteMatch( |
125 TemplateURLModel* model, | 125 TemplateURLModel* model, |
126 const string16& keyword, | 126 const string16& keyword, |
127 const AutocompleteInput& input, | 127 const AutocompleteInput& input, |
128 size_t prefix_length, | 128 size_t prefix_length, |
129 const string16& remaining_input, | 129 const string16& remaining_input, |
(...skipping 27 matching lines...) Expand all Loading... | |
157 // If non-empty, holds the ID of the extension whose keyword is currently in | 157 // If non-empty, holds the ID of the extension whose keyword is currently in |
158 // the URL bar while the autocomplete popup is open. | 158 // the URL bar while the autocomplete popup is open. |
159 std::string current_keyword_extension_id_; | 159 std::string current_keyword_extension_id_; |
160 | 160 |
161 NotificationRegistrar registrar_; | 161 NotificationRegistrar registrar_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); | 163 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); |
164 }; | 164 }; |
165 | 165 |
166 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ | 166 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ |
OLD | NEW |