Chromium Code Reviews| Index: chrome/browser/ui/app_list/search/launcher_search/launcher_search_provider.cc |
| diff --git a/chrome/browser/ui/app_list/search/launcher_search/launcher_search_provider.cc b/chrome/browser/ui/app_list/search/launcher_search/launcher_search_provider.cc |
| index 103c4b76bd8b8a0037618f4286aa1f37793c1449..34b326e6d1bfb6d258f0b3871acd4f93e75fa72b 100644 |
| --- a/chrome/browser/ui/app_list/search/launcher_search/launcher_search_provider.cc |
| +++ b/chrome/browser/ui/app_list/search/launcher_search/launcher_search_provider.cc |
| @@ -36,6 +36,9 @@ void LauncherSearchProvider::Stop() { |
| // order not to start query after Stop() is called. |
| query_timer_.Stop(); |
| + // Clear all search results of the previous query. |
| + extension_results_.clear(); |
| + |
| Service* service = Service::Get(profile_); |
| // Since we delay queries and filter out empty string queries, it can happen |
| @@ -44,6 +47,28 @@ void LauncherSearchProvider::Stop() { |
| service->OnQueryEnded(); |
| } |
| +void LauncherSearchProvider::SetSearchResults( |
| + const extensions::ExtensionId& extension_id, |
| + std::vector<linked_ptr<LauncherSearchResult>> extension_results) { |
| + DCHECK(Service::Get(profile_)->IsQueryRunning()); |
| + |
| + // If it already has the results of this extension, delete it first. |
| + if (ContainsKey(extension_results_, extension_id)) |
| + extension_results_.erase(extension_id); |
| + |
| + // Adds this extension's results. |
| + extension_results_.insert(std::make_pair(extension_id, extension_results)); |
| + |
| + // Updates results with other extension results. |
| + ClearResults(); |
| + for (const auto& it : extension_results_) { |
| + std::vector<linked_ptr<LauncherSearchResult>> results = it.second; |
|
Matt Giuca
2015/04/10 13:29:13
const std::vector<...>&
Or else it will copy the
yawano
2015/04/13 07:30:52
Done. Changed to use pointer here.
|
| + for (const auto& result : results) { |
|
Matt Giuca
2015/04/10 13:29:13
nit: Don't need curly braces.
yawano
2015/04/13 07:30:52
Done.
|
| + Add(result->Duplicate()); |
| + } |
| + } |
| +} |
| + |
| void LauncherSearchProvider::DelayQuery(const base::Closure& closure) { |
| base::TimeDelta delay = |
| base::TimeDelta::FromMilliseconds(kLauncherSearchProviderQueryDelayInMs); |
| @@ -58,7 +83,7 @@ void LauncherSearchProvider::DelayQuery(const base::Closure& closure) { |
| void LauncherSearchProvider::StartInternal(const base::string16& query) { |
| if (!query.empty()) { |
| - Service::Get(profile_)->OnQueryStarted(base::UTF16ToUTF8(query), |
| + Service::Get(profile_)->OnQueryStarted(this, base::UTF16ToUTF8(query), |
| kLauncherSearchProviderMaxResults); |
| } |
| } |