OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 TemplateURLService to find the set of keywords. | 9 // KeywordProvider uses a TemplateURLService to find the set of keywords. |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 // TemplateURLModel::CleanUserInputKeyword()) to an enabled, substituting | 87 // TemplateURLModel::CleanUserInputKeyword()) to an enabled, substituting |
88 // keyword, returns that keyword; returns the empty string otherwise. | 88 // keyword, returns that keyword; returns the empty string otherwise. |
89 base::string16 GetKeywordForText(const base::string16& text) const; | 89 base::string16 GetKeywordForText(const base::string16& text) const; |
90 | 90 |
91 // Creates a fully marked-up AutocompleteMatch for a specific keyword. | 91 // Creates a fully marked-up AutocompleteMatch for a specific keyword. |
92 AutocompleteMatch CreateVerbatimMatch(const base::string16& text, | 92 AutocompleteMatch CreateVerbatimMatch(const base::string16& text, |
93 const base::string16& keyword, | 93 const base::string16& keyword, |
94 const AutocompleteInput& input); | 94 const AutocompleteInput& input); |
95 | 95 |
96 // AutocompleteProvider: | 96 // AutocompleteProvider: |
97 virtual void Start(const AutocompleteInput& input, | 97 void Start(const AutocompleteInput& input, bool minimal_changes) override; |
98 bool minimal_changes) override; | 98 void Stop(bool clear_cached_results) override; |
99 virtual void Stop(bool clear_cached_results) override; | |
100 | 99 |
101 private: | 100 private: |
102 friend class KeywordExtensionsDelegateImpl; | 101 friend class KeywordExtensionsDelegateImpl; |
103 | 102 |
104 virtual ~KeywordProvider(); | 103 ~KeywordProvider() override; |
105 | 104 |
106 // Extracts the keyword from |input| into |keyword|. Any remaining characters | 105 // Extracts the keyword from |input| into |keyword|. Any remaining characters |
107 // after the keyword are placed in |remaining_input|. Returns true if |input| | 106 // after the keyword are placed in |remaining_input|. Returns true if |input| |
108 // is valid and has a keyword. This makes use of SplitKeywordFromInput to | 107 // is valid and has a keyword. This makes use of SplitKeywordFromInput to |
109 // extract the keyword and remaining string, and uses | 108 // extract the keyword and remaining string, and uses |
110 // TemplateURLService::CleanUserInputKeyword to remove unnecessary characters. | 109 // TemplateURLService::CleanUserInputKeyword to remove unnecessary characters. |
111 // In general use this instead of SplitKeywordFromInput. | 110 // In general use this instead of SplitKeywordFromInput. |
112 // Leading whitespace in |*remaining_input| will be trimmed. | 111 // Leading whitespace in |*remaining_input| will be trimmed. |
113 static bool ExtractKeywordFromInput(const AutocompleteInput& input, | 112 static bool ExtractKeywordFromInput(const AutocompleteInput& input, |
114 base::string16* keyword, | 113 base::string16* keyword, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 TemplateURLService* model_; | 148 TemplateURLService* model_; |
150 | 149 |
151 // Delegate to handle the extensions-only logic for KeywordProvider. | 150 // Delegate to handle the extensions-only logic for KeywordProvider. |
152 // NULL when extensions are not enabled. May be NULL for tests. | 151 // NULL when extensions are not enabled. May be NULL for tests. |
153 scoped_ptr<KeywordExtensionsDelegate> extensions_delegate_; | 152 scoped_ptr<KeywordExtensionsDelegate> extensions_delegate_; |
154 | 153 |
155 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); | 154 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); |
156 }; | 155 }; |
157 | 156 |
158 #endif // COMPONENTS_OMNIBOX_KEYWORD_PROVIDER_H_ | 157 #endif // COMPONENTS_OMNIBOX_KEYWORD_PROVIDER_H_ |
OLD | NEW |