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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const std::wstring& keyword, | 119 const std::wstring& keyword, |
120 const AutocompleteInput& input, | 120 const AutocompleteInput& input, |
121 size_t prefix_length, | 121 size_t prefix_length, |
122 const std::wstring& remaining_input, | 122 const std::wstring& remaining_input, |
123 int relevance); | 123 int relevance); |
124 | 124 |
125 void EnterExtensionKeywordMode(const std::string& extension_id); | 125 void EnterExtensionKeywordMode(const std::string& extension_id); |
126 void MaybeEndExtensionKeywordMode(); | 126 void MaybeEndExtensionKeywordMode(); |
127 | 127 |
128 // NotificationObserver interface. | 128 // NotificationObserver interface. |
129 void Observe(NotificationType type, | 129 virtual void Observe(NotificationType type, |
130 const NotificationSource& source, | 130 const NotificationSource& source, |
131 const NotificationDetails& details); | 131 const NotificationDetails& details); |
132 | 132 |
133 // Model for the keywords. This is only non-null when testing, otherwise the | 133 // Model for the keywords. This is only non-null when testing, otherwise the |
134 // TemplateURLModel from the Profile is used. | 134 // TemplateURLModel from the Profile is used. |
135 TemplateURLModel* model_; | 135 TemplateURLModel* model_; |
136 | 136 |
137 // Identifies the current input state. This is incremented each time the | 137 // Identifies the current input state. This is incremented each time the |
138 // autocomplete edit's input changes in any way. It is used to tell whether | 138 // autocomplete edit's input changes in any way. It is used to tell whether |
139 // suggest results from the extension are current. | 139 // suggest results from the extension are current. |
140 int current_input_id_; | 140 int current_input_id_; |
141 | 141 |
142 // The input state at the time we last asked the extension for suggest | 142 // The input state at the time we last asked the extension for suggest |
143 // results. | 143 // results. |
144 AutocompleteInput extension_suggest_last_input_; | 144 AutocompleteInput extension_suggest_last_input_; |
145 | 145 |
146 // We remember the last suggestions we've received from the extension in case | 146 // We remember the last suggestions we've received from the extension in case |
147 // we need to reset our matches without asking the extension again. | 147 // we need to reset our matches without asking the extension again. |
148 std::vector<AutocompleteMatch> extension_suggest_matches_; | 148 std::vector<AutocompleteMatch> extension_suggest_matches_; |
149 | 149 |
150 // If non-empty, holds the ID of the extension whose keyword is currently in | 150 // If non-empty, holds the ID of the extension whose keyword is currently in |
151 // the URL bar while the autocomplete popup is open. | 151 // the URL bar while the autocomplete popup is open. |
152 std::string current_keyword_extension_id_; | 152 std::string current_keyword_extension_id_; |
153 | 153 |
154 NotificationRegistrar registrar_; | 154 NotificationRegistrar registrar_; |
155 | 155 |
156 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); | 156 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); |
157 }; | 157 }; |
158 | 158 |
159 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ | 159 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ |
OLD | NEW |