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..b860fb291f28917f743ef583c3bfffbaddf07837 | 
| --- /dev/null | 
| +++ b/chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc | 
| @@ -0,0 +1,51 @@ | 
| +// 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" | 
| + | 
| +#if defined(OS_CHROMEOS) | 
| 
 
Luis Héctor Chávez
2017/06/16 22:24:32
Can you only include this in the compilation if it
 
Jiaquan He
2017/06/22 04:30:02
Done.
 
 | 
| + | 
| +namespace app_list { | 
| + | 
| +PlaystoreSearchProvider::PlaystoreSearchProvider(int max_results) | 
| + : max_results_(max_results) {} | 
| + | 
| +PlaystoreSearchProvider::~PlaystoreSearchProvider() { | 
| + Stop(); | 
| 
 
Luis Héctor Chávez
2017/06/16 22:24:32
This is a no-op. Why are you adding it?
 
Jiaquan He
2017/06/22 04:30:02
Done. Not needed any more.
 
 | 
| +} | 
| + | 
| +void PlaystoreSearchProvider::Start(bool is_voice_query, | 
| + const base::string16& query) { | 
| + // TODO: should search for voice? | 
| + arc::mojom::AppInstance* app_instance = | 
| + GET_APP_INSTANCE(GetRecentAndSuggestedAppsFromPlayStore); | 
| + | 
| + if (app_instance == nullptr) | 
| + return; | 
| + | 
| + ClearResults(); | 
| + app_instance->GetRecentAndSuggestedAppsFromPlayStore( | 
| + UTF16ToUTF8(query), max_results_, | 
| 
 
Luis Héctor Chávez
2017/06/16 22:24:32
does it make sense to make the .mojom use a string
 
Jiaquan He
2017/06/22 04:30:02
If we use mojo string16, do we have to convert it
 
 | 
| + base::Bind(&PlaystoreSearchProvider::OnResults, base::Unretained(this))); | 
| 
 
Luis Héctor Chávez
2017/06/16 22:24:31
base::Unretained seems to be unsafe here: there's
 
Jiaquan He
2017/06/22 04:30:02
Done.
 
 | 
| +} | 
| + | 
| +void PlaystoreSearchProvider::Stop() {} | 
| + | 
| +void PlaystoreSearchProvider::OnResults( | 
| + std::vector<arc::mojom::AppDiscoveryResultPtr> results) { | 
| + for (unsigned long i = 0; i < results.size(); i++) { | 
| 
 
Luis Héctor Chávez
2017/06/16 22:24:32
for (const auto result : results) {
but it's prob
 
Jiaquan He
2017/06/22 04:30:02
Done.
 
 | 
| + std::unique_ptr<SearchResult> result = | 
| + base::MakeUnique<PlaystoreSearchResult>( | 
| + results[i]->launch_intent_uri, results[i]->install_intent_uri, | 
| + results[i]->label, results[i]->is_instant_app, | 
| + results[i]->is_recent, results[i]->publisher_name, | 
| + results[i]->icon_png_data); | 
| + | 
| + Add(std::move(result)); | 
| + } | 
| +} | 
| + | 
| +} // namespace app_list | 
| + | 
| +#endif |