| 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" | |
| 16 #include "components/omnibox/browser/autocomplete_provider.h" | 15 #include "components/omnibox/browser/autocomplete_provider.h" |
| 17 #include "components/query_parser/snippet.h" | |
| 18 | 16 |
| 19 class AutocompleteProviderClient; | 17 class AutocompleteProviderClient; |
| 20 | 18 |
| 21 namespace bookmarks { | 19 namespace bookmarks { |
| 22 class BookmarkModel; | 20 class BookmarkModel; |
| 23 struct TitledUrlMatch; | 21 struct TitledUrlMatch; |
| 24 } | 22 } |
| 25 | 23 |
| 26 // This class is an autocomplete provider which quickly (and synchronously) | 24 // This class is an autocomplete provider which quickly (and synchronously) |
| 27 // provides autocomplete suggestions based on the titles of bookmarks. Page | 25 // provides autocomplete suggestions based on the titles of bookmarks. Page |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 | 46 |
| 49 private: | 47 private: |
| 50 FRIEND_TEST_ALL_PREFIXES(BookmarkProviderTest, InlineAutocompletion); | 48 FRIEND_TEST_ALL_PREFIXES(BookmarkProviderTest, InlineAutocompletion); |
| 51 | 49 |
| 52 ~BookmarkProvider() override; | 50 ~BookmarkProvider() override; |
| 53 | 51 |
| 54 // Performs the actual matching of |input| over the bookmarks and fills in | 52 // Performs the actual matching of |input| over the bookmarks and fills in |
| 55 // |matches_|. | 53 // |matches_|. |
| 56 void DoAutocomplete(const AutocompleteInput& input); | 54 void DoAutocomplete(const AutocompleteInput& input); |
| 57 | 55 |
| 58 // Compose an AutocompleteMatch based on |match| that has 1) the URL of | 56 // Calculates the relevance score for |match|. |
| 59 // |match|'s bookmark, and 2) the bookmark's title, not the URL's page | 57 int CalculateBookmarkMatchRelevance(const bookmarks::TitledUrlMatch& match); |
| 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; | |
| 62 // it's passed separately so this function doesn't have to compute it. | |
| 63 AutocompleteMatch TitledUrlMatchToACMatch( | |
| 64 const AutocompleteInput& input, | |
| 65 const base::string16& fixed_up_input_text, | |
| 66 const bookmarks::TitledUrlMatch& match); | |
| 67 | |
| 68 // Converts |positions| into ACMatchClassifications and returns the | |
| 69 // classifications. |text_length| is used to determine the need to add an | |
| 70 // 'unhighlighted' classification span so the tail of the source string | |
| 71 // properly highlighted. | |
| 72 static ACMatchClassifications ClassificationsFromMatch( | |
| 73 const query_parser::Snippet::MatchPositions& positions, | |
| 74 size_t text_length, | |
| 75 bool is_url); | |
| 76 | 58 |
| 77 AutocompleteProviderClient* client_; | 59 AutocompleteProviderClient* client_; |
| 78 bookmarks::BookmarkModel* bookmark_model_; | 60 bookmarks::BookmarkModel* bookmark_model_; |
| 79 | 61 |
| 80 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); | 62 DISALLOW_COPY_AND_ASSIGN(BookmarkProvider); |
| 81 }; | 63 }; |
| 82 | 64 |
| 83 #endif // COMPONENTS_OMNIBOX_BROWSER_BOOKMARK_PROVIDER_H_ | 65 #endif // COMPONENTS_OMNIBOX_BROWSER_BOOKMARK_PROVIDER_H_ |
| OLD | NEW |