Index: chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc |
diff --git a/chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc b/chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6d183fea34ce6fc81402a6539254a96c4441b8de |
--- /dev/null |
+++ b/chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc |
@@ -0,0 +1,62 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/app_list/search/playstore/playstore_search_provider.h" |
+ |
+#include <memory> |
Luis Héctor Chávez
2017/06/22 19:49:17
Remove memory and vector.
Jiaquan He
2017/06/22 19:59:36
Done.
|
+#include <utility> |
+#include <vector> |
+ |
+#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
+#include "chrome/browser/ui/app_list/search/playstore/playstore_search_result.h" |
+#include "components/arc/arc_bridge_service.h" |
+#include "components/arc/arc_service_manager.h" |
+ |
+namespace app_list { |
+ |
+PlayStoreSearchProvider::PlayStoreSearchProvider( |
+ int max_results, |
+ Profile* profile, |
+ AppListControllerDelegate* list_controller) |
+ : max_results_(max_results), |
+ profile_(profile), |
+ list_controller_(list_controller), |
+ weak_ptr_factory_(this) {} |
+ |
+PlayStoreSearchProvider::~PlayStoreSearchProvider() = default; |
+ |
+void PlayStoreSearchProvider::Start(bool is_voice_query, |
+ const base::string16& query) { |
+ // TODO(crbug/736027): should search for voice? |
Luis Héctor Chávez
2017/06/22 19:49:17
nit: crbug.com/736027
Jiaquan He
2017/06/22 19:59:36
Done.
|
+ arc::mojom::AppInstance* app_instance = |
+ arc::ArcServiceManager::Get() |
+ ? ARC_GET_INSTANCE_FOR_METHOD( |
+ arc::ArcServiceManager::Get()->arc_bridge_service()->app(), |
+ GetRecentAndSuggestedAppsFromPlayStore) |
+ : nullptr; |
+ |
+ if (app_instance == nullptr) |
+ return; |
+ |
+ ClearResults(); |
+ app_instance->GetRecentAndSuggestedAppsFromPlayStore( |
+ UTF16ToUTF8(query), max_results_, |
+ base::Bind(&PlayStoreSearchProvider::OnResults, |
+ weak_ptr_factory_.GetWeakPtr())); |
+} |
+ |
+void PlayStoreSearchProvider::Stop() {} |
+ |
+void PlayStoreSearchProvider::OnResults( |
+ std::vector<std::unique_ptr<PlayStoreSearchResult>> results) { |
+ // for (size_t i = 0; i < results.size(); i++) { |
Luis Héctor Chávez
2017/06/22 19:49:17
Never leave commented-out code.
Jiaquan He
2017/06/22 19:59:36
Oh my negligence.
|
+ for (auto& result : results) { |
+ result->set_profile(profile_); |
+ result->set_list_controller(list_controller_); |
+ Add(std::move(result)); |
+ } |
+} |
+ |
+} // namespace app_list |