| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_PHYSICAL_WEB_PROVIDER_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ |
| 6 #define COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <vector> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "components/bookmarks/browser/titled_url_match.h" | 11 #include "components/bookmarks/browser/titled_url_match.h" |
| 10 #include "components/omnibox/browser/autocomplete_input.h" | 12 #include "components/omnibox/browser/autocomplete_input.h" |
| 11 #include "components/omnibox/browser/autocomplete_provider.h" | 13 #include "components/omnibox/browser/autocomplete_provider.h" |
| 12 | 14 |
| 13 class AutocompleteProviderClient; | 15 class AutocompleteProviderClient; |
| 14 class HistoryURLProvider; | 16 class HistoryURLProvider; |
| 15 | 17 |
| 16 namespace base { | 18 namespace physical_web { |
| 17 class ListValue; | 19 struct Metadata; |
| 20 using MetadataList = std::vector<Metadata>; |
| 18 } | 21 } |
| 19 | 22 |
| 20 class PhysicalWebProvider : public AutocompleteProvider { | 23 class PhysicalWebProvider : public AutocompleteProvider { |
| 21 public: | 24 public: |
| 22 // The maximum number of match results to provide. If the number of nearby | 25 // The maximum number of match results to provide. If the number of nearby |
| 23 // URLs exceeds this limit, an overflow item is created. Tapping the overflow | 26 // URLs exceeds this limit, an overflow item is created. Tapping the overflow |
| 24 // item navigates to a page with the full list of nearby URLs. The overflow | 27 // item navigates to a page with the full list of nearby URLs. The overflow |
| 25 // item is counted as a match result for the purposes of the match limit. | 28 // item is counted as a match result for the purposes of the match limit. |
| 26 // | 29 // |
| 27 // ex: With kPhysicalWebMaxMatches == 1, there should be at most one | 30 // ex: With kPhysicalWebMaxMatches == 1, there should be at most one |
| (...skipping 15 matching lines...) Expand all Loading... |
| 43 PhysicalWebProvider(AutocompleteProviderClient* client, | 46 PhysicalWebProvider(AutocompleteProviderClient* client, |
| 44 HistoryURLProvider* history_url_provider); | 47 HistoryURLProvider* history_url_provider); |
| 45 ~PhysicalWebProvider() override; | 48 ~PhysicalWebProvider() override; |
| 46 | 49 |
| 47 // When the user has focused the omnibox but not yet entered any text (i.e., | 50 // When the user has focused the omnibox but not yet entered any text (i.e., |
| 48 // the Zero Suggest case), calling this method adds a separate match item to | 51 // the Zero Suggest case), calling this method adds a separate match item to |
| 49 // |matches_| for each nearby URL in |metadata_list|, up to the maximum number | 52 // |matches_| for each nearby URL in |metadata_list|, up to the maximum number |
| 50 // of matches allowed. If the total number of nearby URLs exceeds this limit, | 53 // of matches allowed. If the total number of nearby URLs exceeds this limit, |
| 51 // one match is used for an overflow item. | 54 // one match is used for an overflow item. |
| 52 void ConstructZeroSuggestMatches( | 55 void ConstructZeroSuggestMatches( |
| 53 std::unique_ptr<base::ListValue> metadata_list); | 56 std::unique_ptr<physical_web::MetadataList> metadata_list); |
| 54 | 57 |
| 55 // When the user has entered text into the omnibox (i.e., the Query Suggest | 58 // When the user has entered text into the omnibox (i.e., the Query Suggest |
| 56 // case), calling this method adds a separate match item to |matches_| for | 59 // case), calling this method adds a separate match item to |matches_| for |
| 57 // each nearby URL in |metadata_list| that matches all of the query terms in | 60 // each nearby URL in |metadata_list| that matches all of the query terms in |
| 58 // |input|, up to the maximum number of matches allowed. | 61 // |input|, up to the maximum number of matches allowed. |
| 59 void ConstructQuerySuggestMatches( | 62 void ConstructQuerySuggestMatches( |
| 60 std::unique_ptr<base::ListValue> metadata_list, | 63 std::unique_ptr<physical_web::MetadataList> metadata_list, |
| 61 const AutocompleteInput& input); | 64 const AutocompleteInput& input); |
| 62 | 65 |
| 63 // Adds an overflow match item to |matches_| with a relevance score equal to | 66 // Adds an overflow match item to |matches_| with a relevance score equal to |
| 64 // |relevance| and a label indicating there are |additional_url_count| more | 67 // |relevance| and a label indicating there are |additional_url_count| more |
| 65 // nearby URLs. The page |title| of one of the additional nearby URLs will be | 68 // nearby URLs. The page |title| of one of the additional nearby URLs will be |
| 66 // included in the label, truncating if necessary. Selecting the overflow item | 69 // included in the label, truncating if necessary. Selecting the overflow item |
| 67 // navigates to the Physical Web WebUI, which displays the full list of nearby | 70 // navigates to the Physical Web WebUI, which displays the full list of nearby |
| 68 // URLs. | 71 // URLs. |
| 69 void AppendOverflowItem(int additional_url_count, | 72 void AppendOverflowItem(int additional_url_count, |
| 70 int relevance, | 73 int relevance, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 105 |
| 103 // Set to true if at least one suggestion was created since the last time the | 106 // Set to true if at least one suggestion was created since the last time the |
| 104 // omnibox was focused, even if the suggestion could not be displayed due to | 107 // omnibox was focused, even if the suggestion could not be displayed due to |
| 105 // a field trial. | 108 // a field trial. |
| 106 bool had_physical_web_suggestions_at_focus_or_later_; | 109 bool had_physical_web_suggestions_at_focus_or_later_; |
| 107 | 110 |
| 108 DISALLOW_COPY_AND_ASSIGN(PhysicalWebProvider); | 111 DISALLOW_COPY_AND_ASSIGN(PhysicalWebProvider); |
| 109 }; | 112 }; |
| 110 | 113 |
| 111 #endif // COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ | 114 #endif // COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ |
| OLD | NEW |