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