Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/ui/app_list/search/playstore/playstore_search_provider.cc

Issue 2929273002: Add the Play Store app search to the launcher. (Closed)
Patch Set: Implement methods in FakeAppInstance. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/playstore/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/playstore/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 PlayStoreSearchProvider::PlayStoreSearchProvider(
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 PlayStoreSearchProvider::~PlayStoreSearchProvider() = default;
27
28 void PlayStoreSearchProvider::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(&PlayStoreSearchProvider::OnResults,
45 weak_ptr_factory_.GetWeakPtr()));
46 }
47
48 void PlayStoreSearchProvider::Stop() {}
49
50 void PlayStoreSearchProvider::OnResults(
51 std::vector<arc::mojom::AppDiscoveryResultPtr> results) {
52 for (auto& result : results) {
53 Add(base::MakeUnique<PlayStoreSearchResult>(
54 result->launch_intent_uri, result->install_intent_uri, result->label,
55 result->is_instant_app, result->is_recent, result->publisher_name,
56 result->formatted_price, result->review_score, result->icon_png_data,
57 profile_, list_controller_));
58 }
59 }
60
61 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698