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

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: Resolve Luis comments. 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 <memory>
Luis Héctor Chávez 2017/06/22 19:49:17 Remove memory and vector.
Jiaquan He 2017/06/22 19:59:36 Done.
8 #include <utility>
9 #include <vector>
10
11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
13 #include "chrome/browser/ui/app_list/search/playstore/playstore_search_result.h"
14 #include "components/arc/arc_bridge_service.h"
15 #include "components/arc/arc_service_manager.h"
16
17 namespace app_list {
18
19 PlayStoreSearchProvider::PlayStoreSearchProvider(
20 int max_results,
21 Profile* profile,
22 AppListControllerDelegate* list_controller)
23 : max_results_(max_results),
24 profile_(profile),
25 list_controller_(list_controller),
26 weak_ptr_factory_(this) {}
27
28 PlayStoreSearchProvider::~PlayStoreSearchProvider() = default;
29
30 void PlayStoreSearchProvider::Start(bool is_voice_query,
31 const base::string16& query) {
32 // TODO(crbug/736027): should search for voice?
Luis Héctor Chávez 2017/06/22 19:49:17 nit: crbug.com/736027
Jiaquan He 2017/06/22 19:59:36 Done.
33 arc::mojom::AppInstance* app_instance =
34 arc::ArcServiceManager::Get()
35 ? ARC_GET_INSTANCE_FOR_METHOD(
36 arc::ArcServiceManager::Get()->arc_bridge_service()->app(),
37 GetRecentAndSuggestedAppsFromPlayStore)
38 : nullptr;
39
40 if (app_instance == nullptr)
41 return;
42
43 ClearResults();
44 app_instance->GetRecentAndSuggestedAppsFromPlayStore(
45 UTF16ToUTF8(query), max_results_,
46 base::Bind(&PlayStoreSearchProvider::OnResults,
47 weak_ptr_factory_.GetWeakPtr()));
48 }
49
50 void PlayStoreSearchProvider::Stop() {}
51
52 void PlayStoreSearchProvider::OnResults(
53 std::vector<std::unique_ptr<PlayStoreSearchResult>> results) {
54 // for (size_t i = 0; i < results.size(); i++) {
Luis Héctor Chávez 2017/06/22 19:49:17 Never leave commented-out code.
Jiaquan He 2017/06/22 19:59:36 Oh my negligence.
55 for (auto& result : results) {
56 result->set_profile(profile_);
57 result->set_list_controller(list_controller_);
58 Add(std::move(result));
59 }
60 }
61
62 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698