| 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 29 matching lines...) Expand all Loading... |
| 40 // | 40 // |
| 41 // Because we do prefix matching, user input could match more than one keyword | 41 // Because we do prefix matching, user input could match more than one keyword |
| 42 // at once. (Example: the input "f jazz" matches all keywords starting with | 42 // at once. (Example: the input "f jazz" matches all keywords starting with |
| 43 // "f".) We return the best matches, up to three. | 43 // "f".) We return the best matches, up to three. |
| 44 // | 44 // |
| 45 // The resulting matches are shown with content specified by the keyword | 45 // The resulting matches are shown with content specified by the keyword |
| 46 // (usually "Search [name] for %s"), description "(Keyword: [keyword])", and | 46 // (usually "Search [name] for %s"), description "(Keyword: [keyword])", and |
| 47 // action "[keyword] %s". If the user has typed a (possibly partial) keyword | 47 // action "[keyword] %s". If the user has typed a (possibly partial) keyword |
| 48 // but no search terms, the suggested result is shown greyed out, with | 48 // but no search terms, the suggested result is shown greyed out, with |
| 49 // "<enter term(s)>" as the substituted input, and does nothing when selected. | 49 // "<enter term(s)>" as the substituted input, and does nothing when selected. |
| 50 class KeywordProvider : | 50 class KeywordProvider : public AutocompleteProvider, |
| 51 public AutocompleteProvider, | 51 public NotificationObserver { |
| 52 public NotificationObserver { | |
| 53 public: | 52 public: |
| 54 KeywordProvider(ACProviderListener* listener, Profile* profile); | 53 KeywordProvider(ACProviderListener* listener, Profile* profile); |
| 55 // For testing. | 54 // For testing. |
| 56 KeywordProvider(ACProviderListener* listener, TemplateURLModel* model); | 55 KeywordProvider(ACProviderListener* listener, TemplateURLModel* model); |
| 57 | 56 |
| 58 // Returns the replacement string from the user input. The replacement | 57 // Returns the replacement string from the user input. The replacement |
| 59 // string is the portion of the input that does not contain the keyword. | 58 // string is the portion of the input that does not contain the keyword. |
| 60 // For example, the replacement string for "b blah" is blah. | 59 // For example, the replacement string for "b blah" is blah. |
| 61 static std::wstring SplitReplacementStringFromInput( | 60 static std::wstring SplitReplacementStringFromInput( |
| 62 const std::wstring& input); | 61 const std::wstring& input); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // If non-empty, holds the ID of the extension whose keyword is currently in | 146 // If non-empty, holds the ID of the extension whose keyword is currently in |
| 148 // the URL bar while the autocomplete popup is open. | 147 // the URL bar while the autocomplete popup is open. |
| 149 std::string current_keyword_extension_id_; | 148 std::string current_keyword_extension_id_; |
| 150 | 149 |
| 151 NotificationRegistrar registrar_; | 150 NotificationRegistrar registrar_; |
| 152 | 151 |
| 153 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); | 152 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); |
| 154 }; | 153 }; |
| 155 | 154 |
| 156 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ | 155 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ |
| OLD | NEW |