| 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..f2c9ec103a6449b62383433f5864236a001acd9e 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
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_provider.h"
|
|
|
| +#include "base/stl_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "chrome/browser/chromeos/launcher_search_provider/service.h"
|
|
|
| @@ -19,7 +20,9 @@ const int kLauncherSearchProviderMaxResults = 6;
|
| } // namespace
|
|
|
| LauncherSearchProvider::LauncherSearchProvider(Profile* profile)
|
| - : profile_(profile), weak_ptr_factory_(this) {
|
| + : extension_results_deleter_(&extension_results_),
|
| + profile_(profile),
|
| + weak_ptr_factory_(this) {
|
| }
|
|
|
| LauncherSearchProvider::~LauncherSearchProvider() {
|
| @@ -36,6 +39,9 @@ void LauncherSearchProvider::Stop() {
|
| // order not to start query after Stop() is called.
|
| query_timer_.Stop();
|
|
|
| + // Clear all search results of the previous query.
|
| + STLDeleteValues(&extension_results_);
|
| +
|
| Service* service = Service::Get(profile_);
|
|
|
| // Since we delay queries and filter out empty string queries, it can happen
|
| @@ -44,6 +50,29 @@ void LauncherSearchProvider::Stop() {
|
| service->OnQueryEnded();
|
| }
|
|
|
| +void LauncherSearchProvider::SetSearchResults(
|
| + const extensions::ExtensionId& extension_id,
|
| + ScopedVector<LauncherSearchResult> results) {
|
| + DCHECK(Service::Get(profile_)->IsQueryRunning());
|
| +
|
| + // If it already has the results of this extension, delete it first.
|
| + if (ContainsKey(extension_results_, extension_id)) {
|
| + delete extension_results_[extension_id];
|
| + extension_results_.erase(extension_id);
|
| + }
|
| +
|
| + // Add this extension's results.
|
| + extension_results_.insert(std::make_pair(
|
| + extension_id, new ScopedVector<LauncherSearchResult>(results.Pass())));
|
| +
|
| + // Update results with other extension results.
|
| + ClearResults();
|
| + for (const auto& item : extension_results_) {
|
| + for (const auto* result : *item.second)
|
| + Add(result->Duplicate());
|
| + }
|
| +}
|
| +
|
| void LauncherSearchProvider::DelayQuery(const base::Closure& closure) {
|
| base::TimeDelta delay =
|
| base::TimeDelta::FromMilliseconds(kLauncherSearchProviderQueryDelayInMs);
|
| @@ -58,7 +87,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);
|
| }
|
| }
|
|
|