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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "components/omnibox/browser/autocomplete_input.h" | 9 #include "components/omnibox/browser/autocomplete_input.h" |
10 #include "components/omnibox/browser/autocomplete_provider.h" | 10 #include "components/omnibox/browser/autocomplete_provider.h" |
11 | 11 |
12 class AutocompleteProviderClient; | 12 class AutocompleteProviderClient; |
13 class HistoryURLProvider; | 13 class HistoryURLProvider; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class ListValue; | 16 class ListValue; |
17 } | 17 } |
18 | 18 |
19 class PhysicalWebProvider : public AutocompleteProvider { | 19 class PhysicalWebProvider : public AutocompleteProvider { |
20 public: | 20 public: |
21 static PhysicalWebProvider* Create(AutocompleteProviderClient* client, | 21 static PhysicalWebProvider* Create(AutocompleteProviderClient* client, |
22 HistoryURLProvider* history_url_provider); | 22 HistoryURLProvider* history_url_provider); |
23 | 23 |
24 // AutocompleteProvider: | 24 // AutocompleteProvider: |
25 void Start(const AutocompleteInput& input, bool minimal_changes) override; | 25 void Start(const AutocompleteInput& input, bool minimal_changes) override; |
26 void Stop(bool clear_cached_results, bool due_to_user_inactivity) override; | 26 void Stop(bool clear_cached_results, bool due_to_user_inactivity) override; |
27 | 27 |
28 // The maximum number of match results to provide. If the number of nearby | |
Mark P
2016/09/14 19:33:11
nit: Should got at the top of the class definition
mattreynolds
2016/09/14 19:42:24
Done.
| |
29 // URLs exceeds this limit, an overflow item is created. Tapping the overflow | |
30 // item navigates to a page with the full list of nearby URLs. The overflow | |
31 // item is counted as a match result for the purposes of the match limit. | |
32 // | |
33 // ex: With kPhysicalWebMaxMatches == 1, there should be at most one | |
34 // suggestion created by this provider. If there is a single nearby URL, then | |
35 // the suggestion will be for that URL. If there are multiple nearby URLs, the | |
36 // suggestion will be the overflow item which navigates to the WebUI when | |
37 // tapped. | |
38 static const size_t kPhysicalWebMaxMatches; | |
39 | |
28 private: | 40 private: |
29 PhysicalWebProvider(AutocompleteProviderClient* client, | 41 PhysicalWebProvider(AutocompleteProviderClient* client, |
30 HistoryURLProvider* history_url_provider); | 42 HistoryURLProvider* history_url_provider); |
31 ~PhysicalWebProvider() override; | 43 ~PhysicalWebProvider() override; |
32 | 44 |
33 // Adds a separate match item to |matches_| for each nearby URL in | 45 // Adds a separate match item to |matches_| for each nearby URL in |
34 // |metadata_list|, up to the maximum number of matches allowed. If the total | 46 // |metadata_list|, up to the maximum number of matches allowed. If the total |
35 // number of nearby URLs exceeds this limit, one match is used for an overflow | 47 // number of nearby URLs exceeds this limit, one match is used for an overflow |
36 // item. | 48 // item. |
37 void ConstructMatches(base::ListValue* metadata_list); | 49 void ConstructMatches(base::ListValue* metadata_list); |
38 | 50 |
39 // Adds an overflow match item to |matches_| with a relevance score equal to | 51 // Adds an overflow match item to |matches_| with a relevance score equal to |
40 // |relevance| and a label indicating there are |additional_url_count| more | 52 // |relevance| and a label indicating there are |additional_url_count| more |
41 // nearby URLs. Selecting the overflow item navigates to the Physical Web | 53 // nearby URLs. The page |title| of one of the additional nearby URLs will be |
42 // WebUI, which displays the full list of nearby URLs. | 54 // included in the label, truncating if necessary. Selecting the overflow item |
43 void AppendOverflowItem(int additional_url_count, int relevance); | 55 // navigates to the Physical Web WebUI, which displays the full list of nearby |
56 // URLs. | |
57 void AppendOverflowItem(int additional_url_count, | |
58 int relevance, | |
59 const base::string16& title); | |
44 | 60 |
45 AutocompleteProviderClient* client_; | 61 AutocompleteProviderClient* client_; |
46 | 62 |
47 // Used for efficiency when creating the verbatim match. Can be null. | 63 // Used for efficiency when creating the verbatim match. Can be null. |
48 HistoryURLProvider* history_url_provider_; | 64 HistoryURLProvider* history_url_provider_; |
49 | 65 |
50 DISALLOW_COPY_AND_ASSIGN(PhysicalWebProvider); | 66 DISALLOW_COPY_AND_ASSIGN(PhysicalWebProvider); |
51 }; | 67 }; |
52 | 68 |
53 #endif // COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ | 69 #endif // COMPONENTS_OMNIBOX_BROWSER_PHYSICAL_WEB_PROVIDER_H_ |
OLD | NEW |