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..9e052d1baf18e74bf194d50c6cf075e0928c25bd 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 |
@@ -19,7 +19,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 +38,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 +49,29 @@ void LauncherSearchProvider::Stop() { |
service->OnQueryEnded(); |
} |
+void LauncherSearchProvider::SetSearchResults( |
+ const extensions::ExtensionId& extension_id, |
+ ScopedVector<LauncherSearchResult> extension_results) { |
Matt Giuca
2015/04/14 03:15:44
It is really confusing having |extension_results|
yawano
2015/04/14 05:42:00
Done.
|
+ 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); |
Matt Giuca
2015/04/14 03:15:43
Unfortunately, I think this will need an explicit
yawano
2015/04/14 05:42:00
Done.
|
+ |
+ // Adds this extension's results. |
Matt Giuca
2015/04/14 03:15:43
Adds -> Add
(use imperative voice for inline comm
yawano
2015/04/14 05:42:00
Done.
|
+ extension_results_.insert(std::make_pair( |
+ extension_id, |
+ new ScopedVector<LauncherSearchResult>(extension_results.Pass()))); |
+ |
+ // Updates results with other extension results. |
Matt Giuca
2015/04/14 03:15:44
Updates -> Update
yawano
2015/04/14 05:42:00
Done.
|
+ ClearResults(); |
+ for (const auto& it : extension_results_) { |
Matt Giuca
2015/04/14 03:15:44
nit: This is not an iterator, so should not be cal
yawano
2015/04/14 05:42:00
Done.
|
+ ScopedVector<LauncherSearchResult>* results = it.second; |
+ for (const auto& result : *results) |
Matt Giuca
2015/04/14 03:15:44
nit: Should use "const auto*" to make it clear tha
yawano
2015/04/14 05:42:00
Done.
|
+ Add(result->Duplicate()); |
+ } |
+} |
+ |
void LauncherSearchProvider::DelayQuery(const base::Closure& closure) { |
base::TimeDelta delay = |
base::TimeDelta::FromMilliseconds(kLauncherSearchProviderQueryDelayInMs); |
@@ -58,7 +86,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); |
} |
} |