OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "playstore_search_provider.h" | |
6 | |
7 #include "base/strings/utf_string_conversions.h" | |
8 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
9 #include "chrome/browser/ui/app_list/search/playstore/playstore_search_result.h" | |
10 #include "components/arc/arc_bridge_service.h" | |
11 #include "components/arc/arc_service_manager.h" | |
12 | |
13 namespace app_list { | |
14 | |
15 PlayStoreSearchProvider::PlayStoreSearchProvider( | |
16 int max_results, | |
17 Profile* profile, | |
18 AppListControllerDelegate* list_controller) | |
19 : max_results_(max_results), | |
20 profile_(profile), | |
21 list_controller_(list_controller), | |
22 weak_ptr_factory_(this) {} | |
23 | |
24 PlayStoreSearchProvider::~PlayStoreSearchProvider() {} | |
Luis Héctor Chávez
2017/06/22 15:42:09
nit: = default
Jiaquan He
2017/06/22 19:12:40
Done.
| |
25 | |
26 void PlayStoreSearchProvider::Start(bool is_voice_query, | |
27 const base::string16& query) { | |
28 // 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.
| |
29 arc::mojom::AppInstance* app_instance = | |
30 arc::ArcServiceManager::Get() | |
31 ? ARC_GET_INSTANCE_FOR_METHOD( | |
32 arc::ArcServiceManager::Get()->arc_bridge_service()->app(), | |
33 GetRecentAndSuggestedAppsFromPlayStore) | |
34 : nullptr; | |
35 | |
36 if (app_instance == nullptr) | |
37 return; | |
38 | |
39 ClearResults(); | |
40 app_instance->GetRecentAndSuggestedAppsFromPlayStore( | |
41 UTF16ToUTF8(query), max_results_, | |
42 base::Bind(&PlayStoreSearchProvider::OnResults, | |
43 weak_ptr_factory_.GetWeakPtr())); | |
44 } | |
45 | |
46 void PlayStoreSearchProvider::Stop() {} | |
47 | |
48 void PlayStoreSearchProvider::OnResults( | |
49 std::vector<PlayStoreSearchResultUniquePtr> results) { | |
50 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.
| |
51 results[i]->set_profile(profile_); | |
52 results[i]->set_list_controller(list_controller_); | |
53 Add(std::move(results[i])); | |
54 } | |
55 } | |
56 | |
57 } // namespace app_list | |
OLD | NEW |