Chromium Code Reviews| 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..6fb04a9299080ed3316a826b797acee71fba2436 |
| --- /dev/null |
| +++ b/chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc |
| @@ -0,0 +1,57 @@ |
| +// 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 "playstore_search_provider.h" |
| + |
| +#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() {} |
|
Luis Héctor Chávez
2017/06/22 15:42:09
nit: = default
Jiaquan He
2017/06/22 19:12:40
Done.
|
| + |
| +void PlayStoreSearchProvider::Start(bool is_voice_query, |
| + const base::string16& query) { |
| + // TODO: should search for voice? |
|
Luis Héctor Chávez
2017/06/22 15:42:09
please file a (Chromium) bug for this.
Jiaquan He
2017/06/22 19:12:41
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<PlayStoreSearchResultUniquePtr> results) { |
| + for (unsigned long i = 0; i < results.size(); i++) { |
|
Luis Héctor Chávez
2017/06/22 15:42:09
for (const auto& result : results)
(you should al
Jiaquan He
2017/06/22 19:12:41
Done.
|
| + results[i]->set_profile(profile_); |
| + results[i]->set_list_controller(list_controller_); |
| + Add(std::move(results[i])); |
| + } |
| +} |
| + |
| +} // namespace app_list |