Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | |
| 2 #define CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | |
| 3 | |
| 4 #include "chrome/browser/autocomplete/autocomplete_input.h" | |
| 5 #include "chrome/browser/autocomplete/autocomplete_match.h" | |
| 6 #include "chrome/browser/autocomplete/autocomplete_provider.h" | |
| 7 #include "chrome/browser/bookmarks/bookmark_utils.h" | |
| 8 #include "chrome/browser/history/snippet.h" | |
| 9 | |
| 10 class BookmarkModel; | |
| 11 class Profile; | |
| 12 | |
| 13 // This class is an autocomplete provider which quickly (and synchronously) | |
| 14 // provides autocomplete suggestions based on matches between the search terms | |
| 15 // entered by the user into the omnibox and the titles of bookmarks. Page | |
| 16 // titles and URLs of the bookmarks are not matched. | |
| 17 class BookmarkProvider : public AutocompleteProvider { | |
| 18 public: | |
| 19 BookmarkProvider(AutocompleteProviderListener* listener, Profile* profile); | |
| 20 | |
| 21 // AutocompleteProvider. |minimal_changes| is ignored since there is no | |
| 22 // asynch completion performed. | |
| 23 virtual void Start(const AutocompleteInput& input, | |
| 24 bool minimal_changes) OVERRIDE; | |
| 25 | |
| 26 // Sets the BookmarkModel for unit tests. | |
| 27 void set_bookmark_model_for_testing(BookmarkModel* bookmark_model) { | |
|
Mark P
2012/09/28 00:55:13
Should this be private and a friend to your test c
mrossetti
2012/10/02 00:44:16
Not necessarily. There is no style guidance for th
Mark P
2012/10/03 20:40:14
You can make a function a friend without having to
| |
| 28 bookmark_model_ = bookmark_model; | |
| 29 } | |
| 30 | |
| 31 private: | |
| 32 virtual ~BookmarkProvider(); | |
| 33 | |
| 34 // Performs the actual matching of |input| over the bookmarks and fills in | |
| 35 // matches. If |best_match| then only return the single best match, otherwise | |
|
Mark P
2012/09/28 00:55:13
matches -> |matches_|
mrossetti
2012/10/02 00:44:16
Done.
| |
| 36 // return the top |kMaxMatches| matches. | |
|
Mark P
2012/09/28 00:55:13
Using return (both times) in the above sentence is
mrossetti
2012/10/02 00:44:16
Done.
| |
| 37 void DoAutocomplete(const AutocompleteInput& input, bool best_match); | |
| 38 | |
| 39 // Converts |title_match| to an AutocompleteMatch and returns the converted | |
| 40 // match. | |
| 41 AutocompleteMatch TitleMatchToACMatch( | |
|
Mark P
2012/09/28 00:55:13
Can this be static or at least const?
mrossetti
2012/10/02 00:44:16
Unfortunately, neither. Can't be static because it
| |
| 42 const bookmark_utils::TitleMatch& title_match); | |
| 43 | |
| 44 // Converts |positions| into ACMatchClassifications and returns the | |
| 45 // classifications. |text_length| is used to determine the need for a | |
| 46 // terminating classification. | |
|
Mark P
2012/09/28 00:55:13
I don't understand the last sentence. (What is a
mrossetti
2012/10/02 00:44:16
I've updated the comment a bit, but for your edifi
| |
| 47 static ACMatchClassifications SpansFromMatch( | |
| 48 const Snippet::MatchPositions& positions, | |
| 49 size_t text_length); | |
| 50 | |
| 51 BookmarkModel* bookmark_model_; | |
| 52 | |
| 53 // Languages used during the URL formatting. | |
| 54 std::string languages_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); | |
| 57 }; | |
| 58 | |
| 59 #endif // CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | |
| OLD | NEW |