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" |
11 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
12 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 12 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
13 #include "components/query_parser/snippet.h" | 13 #include "components/query_parser/snippet.h" |
14 | 14 |
15 class BookmarkModel; | 15 class BookmarkModel; |
| 16 class Profile; |
| 17 |
| 18 namespace bookmarks { |
16 struct BookmarkMatch; | 19 struct BookmarkMatch; |
17 class Profile; | 20 } |
18 | 21 |
19 // This class is an autocomplete provider which quickly (and synchronously) | 22 // This class is an autocomplete provider which quickly (and synchronously) |
20 // provides autocomplete suggestions based on the titles of bookmarks. Page | 23 // provides autocomplete suggestions based on the titles of bookmarks. Page |
21 // titles, URLs, and typed and visit counts of the bookmarks are not currently | 24 // titles, URLs, and typed and visit counts of the bookmarks are not currently |
22 // taken into consideration as those factors will have been used by the | 25 // taken into consideration as those factors will have been used by the |
23 // HistoryQuickProvider (HQP) while identifying suggestions. | 26 // HistoryQuickProvider (HQP) while identifying suggestions. |
24 // | 27 // |
25 // TODO(mrossetti): Propose a way to coordinate with the HQP the taking of typed | 28 // TODO(mrossetti): Propose a way to coordinate with the HQP the taking of typed |
26 // and visit counts and last visit dates, etc. into consideration while scoring. | 29 // and visit counts and last visit dates, etc. into consideration while scoring. |
27 class BookmarkProvider : public AutocompleteProvider { | 30 class BookmarkProvider : public AutocompleteProvider { |
(...skipping 21 matching lines...) Expand all Loading... |
49 void DoAutocomplete(const AutocompleteInput& input); | 52 void DoAutocomplete(const AutocompleteInput& input); |
50 | 53 |
51 // Compose an AutocompleteMatch based on |match| that has 1) the URL of | 54 // Compose an AutocompleteMatch based on |match| that has 1) the URL of |
52 // |match|'s bookmark, and 2) the bookmark's title, not the URL's page | 55 // |match|'s bookmark, and 2) the bookmark's title, not the URL's page |
53 // title, as the description. |input| is used to compute the match's | 56 // title, as the description. |input| is used to compute the match's |
54 // inline_autocompletion. |fixed_up_input_text| is used in that way as well; | 57 // inline_autocompletion. |fixed_up_input_text| is used in that way as well; |
55 // it's passed separately so this function doesn't have to compute it. | 58 // it's passed separately so this function doesn't have to compute it. |
56 AutocompleteMatch BookmarkMatchToACMatch( | 59 AutocompleteMatch BookmarkMatchToACMatch( |
57 const AutocompleteInput& input, | 60 const AutocompleteInput& input, |
58 const base::string16& fixed_up_input_text, | 61 const base::string16& fixed_up_input_text, |
59 const BookmarkMatch& match); | 62 const bookmarks::BookmarkMatch& match); |
60 | 63 |
61 // Converts |positions| into ACMatchClassifications and returns the | 64 // Converts |positions| into ACMatchClassifications and returns the |
62 // classifications. |text_length| is used to determine the need to add an | 65 // classifications. |text_length| is used to determine the need to add an |
63 // 'unhighlighted' classification span so the tail of the source string | 66 // 'unhighlighted' classification span so the tail of the source string |
64 // properly highlighted. | 67 // properly highlighted. |
65 static ACMatchClassifications ClassificationsFromMatch( | 68 static ACMatchClassifications ClassificationsFromMatch( |
66 const query_parser::Snippet::MatchPositions& positions, | 69 const query_parser::Snippet::MatchPositions& positions, |
67 size_t text_length, | 70 size_t text_length, |
68 bool is_url); | 71 bool is_url); |
69 | 72 |
70 BookmarkModel* bookmark_model_; | 73 BookmarkModel* bookmark_model_; |
71 | 74 |
72 // True if we should use matches in the URL for scoring. | 75 // True if we should use matches in the URL for scoring. |
73 const bool score_using_url_matches_; | 76 const bool score_using_url_matches_; |
74 | 77 |
75 // Languages used during the URL formatting. | 78 // Languages used during the URL formatting. |
76 std::string languages_; | 79 std::string languages_; |
77 | 80 |
78 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); | 81 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); |
79 }; | 82 }; |
80 | 83 |
81 #endif // CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ | 84 #endif // CHROME_BROWSER_AUTOCOMPLETE_BOOKMARK_PROVIDER_H_ |
OLD | NEW |