Chromium Code Reviews| 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 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_PROVIDER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_PROVIDER_H_ |
| 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_PROVIDER_H_ | 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 // is, synchronously) do not cause any notifications to be sent. The | 149 // is, synchronously) do not cause any notifications to be sent. The |
| 150 // controller is expected to check for these without prompting (since | 150 // controller is expected to check for these without prompting (since |
| 151 // otherwise, starting each provider running would result in a flurry of | 151 // otherwise, starting each provider running would result in a flurry of |
| 152 // notifications). | 152 // notifications). |
| 153 // | 153 // |
| 154 // Once Stop() has been called, no more notifications should be sent. | 154 // Once Stop() has been called, no more notifications should be sent. |
| 155 // | 155 // |
| 156 // |minimal_changes| is an optimization that lets the provider do less work | 156 // |minimal_changes| is an optimization that lets the provider do less work |
| 157 // when the |input|'s text hasn't changed. See the body of | 157 // when the |input|'s text hasn't changed. See the body of |
| 158 // OmniboxPopupModel::StartAutocomplete(). | 158 // OmniboxPopupModel::StartAutocomplete(). |
| 159 virtual void Start(const AutocompleteInput& input, bool minimal_changes) = 0; | 159 // |
| 160 // |on_focus| is set to true when autocomplete provider is triggered through | |
| 161 // omnibox focus rather than input and should only return matches expected | |
| 162 // on focus. | |
|
Peter Kasting
2015/01/07 20:16:36
How about this:
// |called_due_to_focus| is tru
Maria
2015/01/08 07:52:38
Done.
| |
| 163 virtual void Start(const AutocompleteInput& input, | |
| 164 bool minimal_changes, | |
| 165 bool on_focus) = 0; | |
| 160 | 166 |
| 161 // Called when a provider must not make any more callbacks for the current | 167 // Called when a provider must not make any more callbacks for the current |
| 162 // query. This will be called regardless of whether the provider is already | 168 // query. This will be called regardless of whether the provider is already |
| 163 // done. If the provider caches any results, it should clear the cache based | 169 // done. If the provider caches any results, it should clear the cache based |
| 164 // on the value of |clear_cached_results|. | 170 // on the value of |clear_cached_results|. |
| 165 virtual void Stop(bool clear_cached_results); | 171 virtual void Stop(bool clear_cached_results); |
| 166 | 172 |
| 167 // Returns the enum equivalent to the name of this provider. | 173 // Returns the enum equivalent to the name of this provider. |
| 168 // TODO(derat): Make metrics use AutocompleteProvider::Type directly, or at | 174 // TODO(derat): Make metrics use AutocompleteProvider::Type directly, or at |
| 169 // least move this method to the metrics directory. | 175 // least move this method to the metrics directory. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 190 | 196 |
| 191 // Returns the set of matches for the current query. | 197 // Returns the set of matches for the current query. |
| 192 const ACMatches& matches() const { return matches_; } | 198 const ACMatches& matches() const { return matches_; } |
| 193 | 199 |
| 194 // Returns whether the provider is done processing the query. | 200 // Returns whether the provider is done processing the query. |
| 195 bool done() const { return done_; } | 201 bool done() const { return done_; } |
| 196 | 202 |
| 197 // Returns this provider's type. | 203 // Returns this provider's type. |
| 198 Type type() const { return type_; } | 204 Type type() const { return type_; } |
| 199 | 205 |
| 200 // Returns whether the provider wants to provide matches in response to the | |
| 201 // omnibox being focused. | |
| 202 virtual bool ProvidesMatchesOnOmniboxFocus() const; | |
| 203 | |
| 204 // Returns a string describing this provider's type. | 206 // Returns a string describing this provider's type. |
| 205 const char* GetName() const; | 207 const char* GetName() const; |
| 206 | 208 |
| 207 // A suggested upper bound for how many matches a provider should return. | 209 // A suggested upper bound for how many matches a provider should return. |
| 208 // TODO(pkasting): http://b/1111299 , http://b/933133 This should go away once | 210 // TODO(pkasting): http://b/1111299 , http://b/933133 This should go away once |
| 209 // we have good relevance heuristics; the controller should handle all | 211 // we have good relevance heuristics; the controller should handle all |
| 210 // culling. | 212 // culling. |
| 211 static const size_t kMaxMatches; | 213 static const size_t kMaxMatches; |
| 212 | 214 |
| 213 protected: | 215 protected: |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 243 ACMatches matches_; | 245 ACMatches matches_; |
| 244 bool done_; | 246 bool done_; |
| 245 | 247 |
| 246 Type type_; | 248 Type type_; |
| 247 | 249 |
| 248 private: | 250 private: |
| 249 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); | 251 DISALLOW_COPY_AND_ASSIGN(AutocompleteProvider); |
| 250 }; | 252 }; |
| 251 | 253 |
| 252 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_PROVIDER_H_ | 254 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_PROVIDER_H_ |
| OLD | NEW |