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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/autocomplete/autocomplete_input.h" | 10 #include "chrome/browser/autocomplete/autocomplete_input.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // a complete search for |input| across all bookmark titles. | 33 // a complete search for |input| across all bookmark titles. |
34 virtual void Start(const AutocompleteInput& input, | 34 virtual void Start(const AutocompleteInput& input, |
35 bool minimal_changes) OVERRIDE; | 35 bool minimal_changes) OVERRIDE; |
36 | 36 |
37 // Sets the BookmarkModel for unit tests. | 37 // Sets the BookmarkModel for unit tests. |
38 void set_bookmark_model_for_testing(BookmarkModel* bookmark_model) { | 38 void set_bookmark_model_for_testing(BookmarkModel* bookmark_model) { |
39 bookmark_model_ = bookmark_model; | 39 bookmark_model_ = bookmark_model; |
40 } | 40 } |
41 | 41 |
42 private: | 42 private: |
| 43 FRIEND_TEST_ALL_PREFIXES(BookmarkProviderTest, InlineAutocompletion); |
| 44 |
43 virtual ~BookmarkProvider(); | 45 virtual ~BookmarkProvider(); |
44 | 46 |
45 // Performs the actual matching of |input| over the bookmarks and fills in | 47 // Performs the actual matching of |input| over the bookmarks and fills in |
46 // |matches_|. If |best_match| then only suggest the single best match, | 48 // |matches_|. If |best_match| then only suggest the single best match, |
47 // otherwise suggest the top |kMaxMatches| matches. | 49 // otherwise suggest the top |kMaxMatches| matches. |
48 void DoAutocomplete(const AutocompleteInput& input, bool best_match); | 50 void DoAutocomplete(const AutocompleteInput& input, bool best_match); |
49 | 51 |
50 // Compose an AutocompleteMatch based on |title_match| that has 1) the URL of | 52 // Compose an AutocompleteMatch based on |title_match| that has 1) the URL of |
51 // title_match's bookmark, and 2) the bookmark's title, not the URL's page | 53 // title_match's bookmark, and 2) the bookmark's title, not the URL's page |
52 // title, as the description. | 54 // title, as the description. |input| is used to compute the match's |
53 AutocompleteMatch TitleMatchToACMatch(const BookmarkTitleMatch& title_match); | 55 // inline_autocompletion. |fixed_up_input| is used in that way as well; |
| 56 // it's passed separately so this function doesn't have to compute it. |
| 57 AutocompleteMatch TitleMatchToACMatch( |
| 58 const AutocompleteInput& input, |
| 59 const AutocompleteInput& fixed_up_input, |
| 60 const BookmarkTitleMatch& title_match); |
54 | 61 |
55 // Converts |positions| into ACMatchClassifications and returns the | 62 // Converts |positions| into ACMatchClassifications and returns the |
56 // classifications. |text_length| is used to determine the need to add an | 63 // classifications. |text_length| is used to determine the need to add an |
57 // 'unhighlighted' classification span so the tail of the source string | 64 // 'unhighlighted' classification span so the tail of the source string |
58 // properly highlighted. | 65 // properly highlighted. |
59 static ACMatchClassifications ClassificationsFromMatch( | 66 static ACMatchClassifications ClassificationsFromMatch( |
60 const Snippet::MatchPositions& positions, | 67 const Snippet::MatchPositions& positions, |
61 size_t text_length); | 68 size_t text_length); |
62 | 69 |
63 BookmarkModel* bookmark_model_; | 70 BookmarkModel* bookmark_model_; |
64 | 71 |
65 // Languages used during the URL formatting. | 72 // Languages used during the URL formatting. |
66 std::string languages_; | 73 std::string languages_; |
67 | 74 |
68 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); | 75 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); |
69 }; | 76 }; |
70 | 77 |
71 #endif // CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | 78 #endif // CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ |
OLD | NEW |