Commit 7774f1d9 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Remove obsolete AppRegistry.GetApps method

Bug: 826982
Change-Id: I19e9c4af2f3e53952d8ff8d697a43509d23eb809
Reviewed-on: https://chromium-review.googlesource.com/c/1334668
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607841}
parent 57d0e2c1
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
#include <utility> #include <utility>
#include <vector>
#include "chrome/services/app_service/app_registry/app_registry.h" #include "chrome/services/app_service/app_registry/app_registry.h"
...@@ -47,29 +46,6 @@ void AppRegistry::BindRequest(apps::mojom::AppRegistryRequest request) { ...@@ -47,29 +46,6 @@ void AppRegistry::BindRequest(apps::mojom::AppRegistryRequest request) {
bindings_.AddBinding(this, std::move(request)); bindings_.AddBinding(this, std::move(request));
} }
void AppRegistry::GetApps(GetAppsCallback callback) {
std::vector<apps::mojom::AppInfoPtr> app_infos;
const base::DictionaryValue* apps =
pref_service_->GetDictionary(kAppRegistryPrefNameSynced);
for (const auto& item : apps->DictItems()) {
auto state = apps::mojom::AppPreferred::kUnknown;
const base::Value* value = item.second.FindPathOfType(
{kAppRegistryPrefNamePrefs, kAppRegistryPrefKeyPreferred},
base::Value::Type::INTEGER);
if (value)
state = static_cast<apps::mojom::AppPreferred>(value->GetInt());
auto app_info = apps::mojom::AppInfo::New();
app_info->id = item.first;
app_info->type = apps::mojom::AppType::kUnknown;
app_info->preferred = state;
app_infos.push_back(std::move(app_info));
}
std::move(callback).Run(std::move(app_infos));
}
apps::mojom::AppPreferred AppRegistry::GetIfAppPreferredForTesting( apps::mojom::AppPreferred AppRegistry::GetIfAppPreferredForTesting(
const std::string& app_id) const { const std::string& app_id) const {
const base::Value* value = const base::Value* value =
......
...@@ -32,7 +32,6 @@ class AppRegistry : public apps::mojom::AppRegistry { ...@@ -32,7 +32,6 @@ class AppRegistry : public apps::mojom::AppRegistry {
const std::string& app_id) const; const std::string& app_id) const;
// mojom::apps::AppRegistry overrides. // mojom::apps::AppRegistry overrides.
void GetApps(GetAppsCallback callback) override;
void SetAppPreferred(const std::string& app_id, void SetAppPreferred(const std::string& app_id,
apps::mojom::AppPreferred state) override; apps::mojom::AppPreferred state) override;
......
...@@ -27,36 +27,6 @@ class AppRegistryTest : public testing::Test { ...@@ -27,36 +27,6 @@ class AppRegistryTest : public testing::Test {
AppRegistry::RegisterPrefs(pref_service->registry()); AppRegistry::RegisterPrefs(pref_service->registry());
return std::make_unique<AppRegistry>(std::move(pref_service)); return std::make_unique<AppRegistry>(std::move(pref_service));
} }
void GetAppInfos(AppRegistry* app_registry) {
base::RunLoop run_loop;
app_registry->GetApps(base::BindOnce(&AppRegistryTest::GetAppsCallback,
base::Unretained(this),
run_loop.QuitClosure()));
run_loop.Run();
}
void GetAppsCallback(base::OnceClosure quit_closure,
std::vector<apps::mojom::AppInfoPtr> app_infos) {
app_infos_ = std::move(app_infos);
std::move(quit_closure).Run();
}
const std::vector<apps::mojom::AppInfoPtr>& app_infos() const {
return app_infos_;
}
const apps::mojom::AppInfoPtr& FindWithId(const std::string& id) const {
return *(std::find_if(
app_infos_.begin(), app_infos_.end(),
[&id](const apps::mojom::AppInfoPtr& info) { return info->id == id; }));
}
private:
// Required for RunLoop waiting.
base::MessageLoop message_loop_;
std::vector<apps::mojom::AppInfoPtr> app_infos_;
}; };
TEST_F(AppRegistryTest, SetAppPreferred) { TEST_F(AppRegistryTest, SetAppPreferred) {
...@@ -94,43 +64,4 @@ TEST_F(AppRegistryTest, SetAppPreferred) { ...@@ -94,43 +64,4 @@ TEST_F(AppRegistryTest, SetAppPreferred) {
registry->GetIfAppPreferredForTesting(kTestAppId2)); registry->GetIfAppPreferredForTesting(kTestAppId2));
} }
TEST_F(AppRegistryTest, GetPreferredApps) {
auto app_registry = CreateAppRegistry();
GetAppInfos(app_registry.get());
EXPECT_EQ(std::vector<apps::mojom::AppInfoPtr>{}, app_infos());
app_registry->SetAppPreferred(kTestAppId1,
apps::mojom::AppPreferred::kPreferred);
GetAppInfos(app_registry.get());
EXPECT_EQ(1u, app_infos().size());
EXPECT_EQ(apps::mojom::AppPreferred::kPreferred, app_infos()[0]->preferred);
app_registry->SetAppPreferred(kTestAppId2,
apps::mojom::AppPreferred::kPreferred);
GetAppInfos(app_registry.get());
EXPECT_EQ(2u, app_infos().size());
EXPECT_EQ(apps::mojom::AppPreferred::kPreferred,
FindWithId(kTestAppId1)->preferred);
EXPECT_EQ(apps::mojom::AppPreferred::kPreferred,
FindWithId(kTestAppId2)->preferred);
app_registry->SetAppPreferred(kTestAppId1,
apps::mojom::AppPreferred::kNotPreferred);
GetAppInfos(app_registry.get());
EXPECT_EQ(2u, app_infos().size());
EXPECT_EQ(apps::mojom::AppPreferred::kNotPreferred,
FindWithId(kTestAppId1)->preferred);
EXPECT_EQ(apps::mojom::AppPreferred::kPreferred,
FindWithId(kTestAppId2)->preferred);
app_registry->SetAppPreferred(kTestAppId2,
apps::mojom::AppPreferred::kNotPreferred);
GetAppInfos(app_registry.get());
EXPECT_EQ(2u, app_infos().size());
EXPECT_EQ(apps::mojom::AppPreferred::kNotPreferred,
FindWithId(kTestAppId1)->preferred);
EXPECT_EQ(apps::mojom::AppPreferred::kNotPreferred,
FindWithId(kTestAppId2)->preferred);
}
} // namespace apps } // namespace apps
...@@ -9,9 +9,6 @@ import "chrome/services/app_service/public/mojom/types.mojom"; ...@@ -9,9 +9,6 @@ import "chrome/services/app_service/public/mojom/types.mojom";
// The interface through which clients of the App Service can query for data on // The interface through which clients of the App Service can query for data on
// installed apps. // installed apps.
interface AppRegistry { interface AppRegistry {
// Returns a list of all apps persisted in the registry.
GetApps() => (array<AppInfo> app_infos);
// Sets the preferred value for the app represented by |app_id| to |state|. // Sets the preferred value for the app represented by |app_id| to |state|.
// TODO(crbug.com/826982): mandate that |app_id| must exist in the registry, // TODO(crbug.com/826982): mandate that |app_id| must exist in the registry,
// or decide that this method no-ops. // or decide that this method no-ops.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment