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 non-keyword autocomplete entries that start with | 6 // responsible for all non-keyword autocomplete entries that start with |
7 // "Search <engine> for ...", including searching for the current input string, | 7 // "Search <engine> for ...", including searching for the current input string, |
8 // search history, and search suggestions. An instance of it gets created and | 8 // search 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 DCHECK(valid_keyword_provider()); | 113 DCHECK(valid_keyword_provider()); |
114 return cached_keyword_provider_; | 114 return cached_keyword_provider_; |
115 } | 115 } |
116 | 116 |
117 // Returns true of the keyword provider is valid. | 117 // Returns true of the keyword provider is valid. |
118 bool valid_keyword_provider() const { return !!keyword_provider_; } | 118 bool valid_keyword_provider() const { return !!keyword_provider_; } |
119 | 119 |
120 // Returns true if the keyword provider is valid and has a valid suggest | 120 // Returns true if the keyword provider is valid and has a valid suggest |
121 // url. | 121 // url. |
122 bool valid_suggest_for_keyword_provider() const { | 122 bool valid_suggest_for_keyword_provider() const { |
123 return keyword_provider_ && | 123 return keyword_provider_ && cached_keyword_provider_.suggestions_url(); |
124 !cached_keyword_provider_.suggestions_url().empty(); | |
125 } | 124 } |
126 | 125 |
127 // Returns true of the default provider is valid. | 126 // Returns true of the default provider is valid. |
128 bool valid_default_provider() const { return !!default_provider_; } | 127 bool valid_default_provider() const { return !!default_provider_; } |
129 | 128 |
130 // Returns true if the default provider is valid and has a valid suggest | 129 // Returns true if the default provider is valid and has a valid suggest |
131 // url. | 130 // url. |
132 bool valid_suggest_for_default_provider() const { | 131 bool valid_suggest_for_default_provider() const { |
133 return default_provider_ && | 132 return default_provider_ && cached_default_provider_.suggestions_url(); |
134 !cached_default_provider_.suggestions_url().empty(); | |
135 } | 133 } |
136 | 134 |
137 // Returns true if |from_keyword_provider| is true, or | 135 // Returns true if |from_keyword_provider| is true, or |
138 // the keyword provider is not valid. | 136 // the keyword provider is not valid. |
139 bool is_primary_provider(bool from_keyword_provider) const { | 137 bool is_primary_provider(bool from_keyword_provider) const { |
140 return from_keyword_provider || !valid_keyword_provider(); | 138 return from_keyword_provider || !valid_keyword_provider(); |
141 } | 139 } |
142 | 140 |
143 private: | 141 private: |
144 // Cached across the life of a query so we behave consistently even if the | 142 // Cached across the life of a query so we behave consistently even if the |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // Has FinalizeInstantQuery been invoked since the last |Start|? | 328 // Has FinalizeInstantQuery been invoked since the last |Start|? |
331 bool instant_finalized_; | 329 bool instant_finalized_; |
332 | 330 |
333 // The |suggest_text| parameter passed to FinalizeInstantQuery. | 331 // The |suggest_text| parameter passed to FinalizeInstantQuery. |
334 string16 default_provider_suggest_text_; | 332 string16 default_provider_suggest_text_; |
335 | 333 |
336 DISALLOW_COPY_AND_ASSIGN(SearchProvider); | 334 DISALLOW_COPY_AND_ASSIGN(SearchProvider); |
337 }; | 335 }; |
338 | 336 |
339 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ | 337 #endif // CHROME_BROWSER_AUTOCOMPLETE_SEARCH_PROVIDER_H_ |
OLD | NEW |