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 "chrome/browser/ui/app_list/search/arc/arc_playstore_search_provider.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/strings/utf_string_conversions.h" | |
10 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | |
11 #include "chrome/browser/ui/app_list/search/arc/arc_playstore_search_result.h" | |
12 #include "components/arc/arc_bridge_service.h" | |
13 #include "components/arc/arc_service_manager.h" | |
14 | |
15 namespace app_list { | |
16 | |
17 ArcPlayStoreSearchProvider::ArcPlayStoreSearchProvider( | |
18 int max_results, | |
19 Profile* profile, | |
20 AppListControllerDelegate* list_controller) | |
21 : max_results_(max_results), | |
22 profile_(profile), | |
23 list_controller_(list_controller), | |
24 weak_ptr_factory_(this) {} | |
25 | |
26 ArcPlayStoreSearchProvider::~ArcPlayStoreSearchProvider() = default; | |
27 | |
28 void ArcPlayStoreSearchProvider::Start(bool is_voice_query, | |
29 const base::string16& query) { | |
30 // TODO(crbug.com/736027): should search for voice? | |
31 arc::mojom::AppInstance* app_instance = | |
32 arc::ArcServiceManager::Get() | |
33 ? ARC_GET_INSTANCE_FOR_METHOD( | |
34 arc::ArcServiceManager::Get()->arc_bridge_service()->app(), | |
35 GetRecentAndSuggestedAppsFromPlayStore) | |
36 : nullptr; | |
37 | |
38 if (app_instance == nullptr) | |
39 return; | |
40 | |
41 ClearResults(); | |
42 app_instance->GetRecentAndSuggestedAppsFromPlayStore( | |
43 UTF16ToUTF8(query), max_results_, | |
44 base::Bind(&ArcPlayStoreSearchProvider::OnResults, | |
45 weak_ptr_factory_.GetWeakPtr())); | |
46 } | |
47 | |
48 void ArcPlayStoreSearchProvider::Stop() {} | |
49 | |
50 void ArcPlayStoreSearchProvider::OnResults( | |
51 std::vector<arc::mojom::AppDiscoveryResultPtr> results) { | |
52 for (auto& result : results) { | |
53 Add(base::MakeUnique<ArcPlayStoreSearchResult>(std::move(result), profile_, | |
dcheng
2017/06/24 00:16:47
Is it a problem if results.size() > max_results_?
Jiaquan He
2017/06/24 00:48:08
The Play Store service guarantees that the amount
dcheng
2017/06/24 00:58:28
Right, but we don't trust the ARC++ process as muc
| |
54 list_controller_)); | |
55 } | |
56 } | |
57 | |
58 } // namespace app_list | |
OLD | NEW |