OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_APP_LIST_SEARCH_MIXER_H_ | 5 #ifndef UI_APP_LIST_SEARCH_MIXER_H_ |
6 #define UI_APP_LIST_SEARCH_MIXER_H_ | 6 #define UI_APP_LIST_SEARCH_MIXER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 explicit Mixer(AppListModel::SearchResults* ui_results); | 42 explicit Mixer(AppListModel::SearchResults* ui_results); |
43 ~Mixer(); | 43 ~Mixer(); |
44 | 44 |
45 // Creates mixer groups. | 45 // Creates mixer groups. |
46 void Init(); | 46 void Init(); |
47 | 47 |
48 // Associates a provider with a mixer group. | 48 // Associates a provider with a mixer group. |
49 void AddProviderToGroup(GroupId group, SearchProvider* provider); | 49 void AddProviderToGroup(GroupId group, SearchProvider* provider); |
50 | 50 |
51 // Collects the results, sorts and publishes them. | 51 // Collects the results, sorts and publishes them. |
52 void MixAndPublish(const KnownResults& known_results); | 52 void MixAndPublish(bool is_voice_query, const KnownResults& known_results); |
53 | 53 |
54 private: | 54 private: |
55 FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish); | 55 FRIEND_TEST_ALL_PREFIXES(test::MixerTest, Publish); |
56 | 56 |
57 // Used for sorting and mixing results. | 57 // Used for sorting and mixing results. |
58 struct APP_LIST_EXPORT SortData { | 58 struct APP_LIST_EXPORT SortData { |
59 SortData(); | 59 SortData(); |
60 SortData(SearchResult* result, double score); | 60 SortData(SearchResult* result, double score); |
61 | 61 |
62 bool operator<(const SortData& other) const; | 62 bool operator<(const SortData& other) const; |
63 | 63 |
64 SearchResult* result; // Not owned. | 64 SearchResult* result; // Not owned. |
65 double score; | 65 double score; |
66 }; | 66 }; |
67 typedef std::vector<Mixer::SortData> SortedResults; | 67 typedef std::vector<Mixer::SortData> SortedResults; |
68 | 68 |
69 class Group; | 69 class Group; |
70 typedef std::map<GroupId, linked_ptr<Group>> Groups; | 70 typedef std::map<GroupId, linked_ptr<Group>> Groups; |
71 | 71 |
72 // Publishes the given |new_results| to |ui_results|, deleting any existing | 72 // Publishes the given |new_results| to |ui_results|, deleting any existing |
73 // results that are not in |new_results|. Results that already exist in | 73 // results that are not in |new_results|. Results that already exist in |
74 // |ui_results| are reused to avoid flickering caused by icon reload. | 74 // |ui_results| are reused to avoid flickering caused by icon reload. |
75 static void Publish(const SortedResults& results, | 75 static void Publish(const SortedResults& results, |
76 AppListModel::SearchResults* ui_results); | 76 AppListModel::SearchResults* ui_results); |
77 | 77 |
78 // Removes duplicates from |results|. | 78 // Removes duplicates from |results|. |
79 static void RemoveDuplicates(SortedResults* results); | 79 static void RemoveDuplicates(SortedResults* results); |
80 | 80 |
81 void FetchResults(const KnownResults& known_results); | 81 void FetchResults(bool is_voice_query, const KnownResults& known_results); |
82 | 82 |
83 AppListModel::SearchResults* ui_results_; // Not owned. | 83 AppListModel::SearchResults* ui_results_; // Not owned. |
84 Groups groups_; | 84 Groups groups_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(Mixer); | 86 DISALLOW_COPY_AND_ASSIGN(Mixer); |
87 }; | 87 }; |
88 | 88 |
89 } // namespace app_list | 89 } // namespace app_list |
90 | 90 |
91 #endif // UI_APP_LIST_SEARCH_MIXER_H_ | 91 #endif // UI_APP_LIST_SEARCH_MIXER_H_ |
OLD | NEW |