Commit 3e80ed4d authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Factor AppServiceProxy into two parts

One part (in chrome/services/app_service) is the interface.

The other part (in chrome/browser/apps/app_service) is the
implementation, including profile-specific implementation. For example,
App Publisher implementations depend on the profile, and the App Service
Proxy is a convenient place to initialize those App Publishers.

The latter subclasses (implements) the former.

Future commits may add further subclasses of the former, especially
fakes or mocks to use within tests.

BUG=826982

Change-Id: Ia23c3e2a3836e56749673f2f6792e5ef160da87a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1552211Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649743}
parent b046ba5c
...@@ -2757,10 +2757,10 @@ jumbo_split_static_library("browser") { ...@@ -2757,10 +2757,10 @@ jumbo_split_static_library("browser") {
"apps/app_service/app_icon_factory.h", "apps/app_service/app_icon_factory.h",
"apps/app_service/app_icon_source.cc", "apps/app_service/app_icon_source.cc",
"apps/app_service/app_icon_source.h", "apps/app_service/app_icon_source.h",
"apps/app_service/app_service_proxy.cc",
"apps/app_service/app_service_proxy.h",
"apps/app_service/app_service_proxy_factory.cc", "apps/app_service/app_service_proxy_factory.cc",
"apps/app_service/app_service_proxy_factory.h", "apps/app_service/app_service_proxy_factory.h",
"apps/app_service/app_service_proxy_impl.cc",
"apps/app_service/app_service_proxy_impl.h",
"apps/app_service/dip_px_util.cc", "apps/app_service/dip_px_util.cc",
"apps/app_service/dip_px_util.h", "apps/app_service/dip_px_util.h",
"apps/intent_helper/apps_navigation_throttle.cc", "apps/intent_helper/apps_navigation_throttle.cc",
...@@ -3319,6 +3319,7 @@ jumbo_split_static_library("browser") { ...@@ -3319,6 +3319,7 @@ jumbo_split_static_library("browser") {
"//chrome/browser/search:generated", "//chrome/browser/search:generated",
"//chrome/common/importer:interfaces", "//chrome/common/importer:interfaces",
"//chrome/services/app_service:lib", "//chrome/services/app_service:lib",
"//chrome/services/app_service/public/cpp:app_service_proxy",
"//chrome/services/app_service/public/cpp:app_update", "//chrome/services/app_service/public/cpp:app_update",
"//chrome/services/app_service/public/cpp:icon_loader", "//chrome/services/app_service/public/cpp:icon_loader",
"//components/feedback", "//components/feedback",
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/dip_px_util.h" #include "chrome/browser/apps/app_service/dip_px_util.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "extensions/grit/extensions_browser_resources.h" #include "extensions/grit/extensions_browser_resources.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -80,7 +81,7 @@ void AppIconSource::StartDataRequest( ...@@ -80,7 +81,7 @@ void AppIconSource::StartDataRequest(
int size_in_dip = apps_util::ConvertPxToDip(size); int size_in_dip = apps_util::ConvertPxToDip(size);
apps::AppServiceProxy* app_service_proxy = apps::AppServiceProxy* app_service_proxy =
apps::AppServiceProxy::Get(profile_); apps::AppServiceProxyFactory::GetForProfile(profile_);
if (!app_service_proxy) { if (!app_service_proxy) {
LoadDefaultImage(callback); LoadDefaultImage(callback);
return; return;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_impl.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
...@@ -26,7 +26,7 @@ AppServiceProxy* AppServiceProxyFactory::GetForProfile(Profile* profile) { ...@@ -26,7 +26,7 @@ AppServiceProxy* AppServiceProxyFactory::GetForProfile(Profile* profile) {
// is branched from (i.e. "inherit" the parent service), // is branched from (i.e. "inherit" the parent service),
// - return a temporary service just for the incognito session (probably // - return a temporary service just for the incognito session (probably
// the least sensible option). // the least sensible option).
return static_cast<AppServiceProxy*>( return static_cast<AppServiceProxyImpl*>(
AppServiceProxyFactory::GetInstance()->GetServiceForBrowserContext( AppServiceProxyFactory::GetInstance()->GetServiceForBrowserContext(
profile, true /* create */)); profile, true /* create */));
} }
...@@ -57,7 +57,7 @@ AppServiceProxyFactory::~AppServiceProxyFactory() = default; ...@@ -57,7 +57,7 @@ AppServiceProxyFactory::~AppServiceProxyFactory() = default;
KeyedService* AppServiceProxyFactory::BuildServiceInstanceFor( KeyedService* AppServiceProxyFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { content::BrowserContext* context) const {
return new AppServiceProxy(Profile::FromBrowserContext(context)); return new AppServiceProxyImpl(Profile::FromBrowserContext(context));
} }
bool AppServiceProxyFactory::ServiceIsCreatedWithBrowserContext() const { bool AppServiceProxyFactory::ServiceIsCreatedWithBrowserContext() const {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_impl.h"
#include <utility> #include <utility>
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
namespace apps { namespace apps {
AppServiceProxy::InnerIconLoader::InnerIconLoader(AppServiceProxy* host) AppServiceProxyImpl::InnerIconLoader::InnerIconLoader(AppServiceProxyImpl* host)
: host_(host), overriding_icon_loader_for_testing_(nullptr) {} : host_(host), overriding_icon_loader_for_testing_(nullptr) {}
apps::mojom::IconKeyPtr AppServiceProxy::InnerIconLoader::GetIconKey( apps::mojom::IconKeyPtr AppServiceProxyImpl::InnerIconLoader::GetIconKey(
const std::string& app_id) { const std::string& app_id) {
if (overriding_icon_loader_for_testing_) { if (overriding_icon_loader_for_testing_) {
return overriding_icon_loader_for_testing_->GetIconKey(app_id); return overriding_icon_loader_for_testing_->GetIconKey(app_id);
...@@ -35,7 +35,7 @@ apps::mojom::IconKeyPtr AppServiceProxy::InnerIconLoader::GetIconKey( ...@@ -35,7 +35,7 @@ apps::mojom::IconKeyPtr AppServiceProxy::InnerIconLoader::GetIconKey(
} }
std::unique_ptr<IconLoader::Releaser> std::unique_ptr<IconLoader::Releaser>
AppServiceProxy::InnerIconLoader::LoadIconFromIconKey( AppServiceProxyImpl::InnerIconLoader::LoadIconFromIconKey(
apps::mojom::AppType app_type, apps::mojom::AppType app_type,
const std::string& app_id, const std::string& app_id,
apps::mojom::IconKeyPtr icon_key, apps::mojom::IconKeyPtr icon_key,
...@@ -69,11 +69,12 @@ AppServiceProxy::InnerIconLoader::LoadIconFromIconKey( ...@@ -69,11 +69,12 @@ AppServiceProxy::InnerIconLoader::LoadIconFromIconKey(
} }
// static // static
AppServiceProxy* AppServiceProxy::Get(Profile* profile) { AppServiceProxyImpl* AppServiceProxyImpl::GetImplForTesting(Profile* profile) {
return AppServiceProxyFactory::GetForProfile(profile); return static_cast<AppServiceProxyImpl*>(
AppServiceProxyFactory::GetForProfile(profile));
} }
AppServiceProxy::AppServiceProxy(Profile* profile) AppServiceProxyImpl::AppServiceProxyImpl(Profile* profile)
: inner_icon_loader_(this), : inner_icon_loader_(this),
outer_icon_loader_(&inner_icon_loader_, outer_icon_loader_(&inner_icon_loader_,
apps::IconCache::GarbageCollectionPolicy::kEager) { apps::IconCache::GarbageCollectionPolicy::kEager) {
...@@ -88,16 +89,16 @@ AppServiceProxy::AppServiceProxy(Profile* profile) ...@@ -88,16 +89,16 @@ AppServiceProxy::AppServiceProxy(Profile* profile)
connector->BindInterface(apps::mojom::kServiceName, connector->BindInterface(apps::mojom::kServiceName,
mojo::MakeRequest(&app_service_)); mojo::MakeRequest(&app_service_));
// The AppServiceProxy is a subscriber: something that wants to be able to // The AppServiceProxyImpl is a subscriber: something that wants to be able
// list all known apps. // to list all known apps.
apps::mojom::SubscriberPtr subscriber; apps::mojom::SubscriberPtr subscriber;
bindings_.AddBinding(this, mojo::MakeRequest(&subscriber)); bindings_.AddBinding(this, mojo::MakeRequest(&subscriber));
app_service_->RegisterSubscriber(std::move(subscriber), nullptr); app_service_->RegisterSubscriber(std::move(subscriber), nullptr);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// The AppServiceProxy is also a publisher, of a variety of app types. That // The AppServiceProxyImpl is also a publisher, of a variety of app types.
// responsibility isn't intrinsically part of the AppServiceProxy, but doing // That responsibility isn't intrinsically part of the AppServiceProxyImpl,
// that here, for each such app type, is as good a place as any. // but doing that here, for each such app type, is as good a place as any.
built_in_chrome_os_apps_.Initialize(app_service_, profile); built_in_chrome_os_apps_.Initialize(app_service_, profile);
crostini_apps_.Initialize(app_service_, profile); crostini_apps_.Initialize(app_service_, profile);
extension_apps_.Initialize(app_service_, profile, extension_apps_.Initialize(app_service_, profile,
...@@ -107,22 +108,15 @@ AppServiceProxy::AppServiceProxy(Profile* profile) ...@@ -107,22 +108,15 @@ AppServiceProxy::AppServiceProxy(Profile* profile)
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
} }
AppServiceProxy::~AppServiceProxy() = default; AppServiceProxyImpl::~AppServiceProxyImpl() = default;
apps::mojom::AppServicePtr& AppServiceProxy::AppService() { apps::mojom::IconKeyPtr AppServiceProxyImpl::GetIconKey(
return app_service_; const std::string& app_id) {
}
apps::AppRegistryCache& AppServiceProxy::AppRegistryCache() {
return cache_;
}
apps::mojom::IconKeyPtr AppServiceProxy::GetIconKey(const std::string& app_id) {
return outer_icon_loader_.GetIconKey(app_id); return outer_icon_loader_.GetIconKey(app_id);
} }
std::unique_ptr<apps::IconLoader::Releaser> std::unique_ptr<apps::IconLoader::Releaser>
AppServiceProxy::LoadIconFromIconKey( AppServiceProxyImpl::LoadIconFromIconKey(
apps::mojom::AppType app_type, apps::mojom::AppType app_type,
const std::string& app_id, const std::string& app_id,
apps::mojom::IconKeyPtr icon_key, apps::mojom::IconKeyPtr icon_key,
...@@ -135,7 +129,7 @@ AppServiceProxy::LoadIconFromIconKey( ...@@ -135,7 +129,7 @@ AppServiceProxy::LoadIconFromIconKey(
allow_placeholder_icon, std::move(callback)); allow_placeholder_icon, std::move(callback));
} }
void AppServiceProxy::Launch(const std::string& app_id, void AppServiceProxyImpl::Launch(const std::string& app_id,
int32_t event_flags, int32_t event_flags,
apps::mojom::LaunchSource launch_source, apps::mojom::LaunchSource launch_source,
int64_t display_id) { int64_t display_id) {
...@@ -148,7 +142,7 @@ void AppServiceProxy::Launch(const std::string& app_id, ...@@ -148,7 +142,7 @@ void AppServiceProxy::Launch(const std::string& app_id,
} }
} }
void AppServiceProxy::SetPermission(const std::string& app_id, void AppServiceProxyImpl::SetPermission(const std::string& app_id,
apps::mojom::PermissionPtr permission) { apps::mojom::PermissionPtr permission) {
if (app_service_.is_bound()) { if (app_service_.is_bound()) {
cache_.ForOneApp( cache_.ForOneApp(
...@@ -159,7 +153,7 @@ void AppServiceProxy::SetPermission(const std::string& app_id, ...@@ -159,7 +153,7 @@ void AppServiceProxy::SetPermission(const std::string& app_id,
} }
} }
void AppServiceProxy::Uninstall(const std::string& app_id) { void AppServiceProxyImpl::Uninstall(const std::string& app_id) {
if (app_service_.is_bound()) { if (app_service_.is_bound()) {
cache_.ForOneApp(app_id, [this](const apps::AppUpdate& update) { cache_.ForOneApp(app_id, [this](const apps::AppUpdate& update) {
app_service_->Uninstall(update.AppType(), update.AppId()); app_service_->Uninstall(update.AppType(), update.AppId());
...@@ -167,7 +161,7 @@ void AppServiceProxy::Uninstall(const std::string& app_id) { ...@@ -167,7 +161,7 @@ void AppServiceProxy::Uninstall(const std::string& app_id) {
} }
} }
void AppServiceProxy::OpenNativeSettings(const std::string& app_id) { void AppServiceProxyImpl::OpenNativeSettings(const std::string& app_id) {
if (app_service_.is_bound()) { if (app_service_.is_bound()) {
cache_.ForOneApp(app_id, [this](const apps::AppUpdate& update) { cache_.ForOneApp(app_id, [this](const apps::AppUpdate& update) {
app_service_->OpenNativeSettings(update.AppType(), update.AppId()); app_service_->OpenNativeSettings(update.AppType(), update.AppId());
...@@ -175,7 +169,7 @@ void AppServiceProxy::OpenNativeSettings(const std::string& app_id) { ...@@ -175,7 +169,7 @@ void AppServiceProxy::OpenNativeSettings(const std::string& app_id) {
} }
} }
apps::IconLoader* AppServiceProxy::OverrideInnerIconLoaderForTesting( apps::IconLoader* AppServiceProxyImpl::OverrideInnerIconLoaderForTesting(
apps::IconLoader* icon_loader) { apps::IconLoader* icon_loader) {
apps::IconLoader* old = apps::IconLoader* old =
inner_icon_loader_.overriding_icon_loader_for_testing_; inner_icon_loader_.overriding_icon_loader_for_testing_;
...@@ -183,7 +177,7 @@ apps::IconLoader* AppServiceProxy::OverrideInnerIconLoaderForTesting( ...@@ -183,7 +177,7 @@ apps::IconLoader* AppServiceProxy::OverrideInnerIconLoaderForTesting(
return old; return old;
} }
void AppServiceProxy::Shutdown() { void AppServiceProxyImpl::Shutdown() {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (app_service_.is_bound()) { if (app_service_.is_bound()) {
extension_apps_.Shutdown(); extension_apps_.Shutdown();
...@@ -192,11 +186,11 @@ void AppServiceProxy::Shutdown() { ...@@ -192,11 +186,11 @@ void AppServiceProxy::Shutdown() {
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
} }
void AppServiceProxy::OnApps(std::vector<apps::mojom::AppPtr> deltas) { void AppServiceProxyImpl::OnApps(std::vector<apps::mojom::AppPtr> deltas) {
cache_.OnApps(std::move(deltas)); cache_.OnApps(std::move(deltas));
} }
void AppServiceProxy::Clone(apps::mojom::SubscriberRequest request) { void AppServiceProxyImpl::Clone(apps::mojom::SubscriberRequest request) {
bindings_.AddBinding(this, std::move(request)); bindings_.AddBinding(this, std::move(request));
} }
......
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_H_ #ifndef CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_IMPL_H_
#define CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_H_ #define CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_IMPL_H_
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "chrome/services/app_service/public/cpp/app_registry_cache.h" #include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "chrome/services/app_service/public/cpp/icon_cache.h" #include "chrome/services/app_service/public/cpp/icon_cache.h"
#include "chrome/services/app_service/public/mojom/app_service.mojom.h"
#include "chrome/services/app_service/public/mojom/types.mojom.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "mojo/public/cpp/bindings/binding_set.h" #include "mojo/public/cpp/bindings/binding_set.h"
...@@ -31,20 +29,23 @@ namespace apps { ...@@ -31,20 +29,23 @@ namespace apps {
// proxy for a given Profile, and therefore share its caches. // proxy for a given Profile, and therefore share its caches.
// //
// See chrome/services/app_service/README.md. // See chrome/services/app_service/README.md.
class AppServiceProxy : public KeyedService, class AppServiceProxyImpl : public KeyedService,
public apps::IconLoader, public apps::AppServiceProxy,
public apps::mojom::Subscriber { public apps::mojom::Subscriber {
public: public:
static AppServiceProxy* Get(Profile* profile); // This method returns an AppServiceProxyImpl, not just an AppServiceProxy, so
// that callers (which are presumably in test code) can then call other
explicit AppServiceProxy(Profile* profile); // XxxForTesting methods.
//
// For regular (non-test) code, use AppServiceProxyFactory::GetForProfile
// instead.
static AppServiceProxyImpl* GetImplForTesting(Profile* profile);
~AppServiceProxy() override; explicit AppServiceProxyImpl(Profile* profile);
apps::mojom::AppServicePtr& AppService(); ~AppServiceProxyImpl() override;
apps::AppRegistryCache& AppRegistryCache();
// apps::IconLoader overrides. // apps::AppServiceProxy (including apps::IconLoader) overrides.
apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override; apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override;
std::unique_ptr<IconLoader::Releaser> LoadIconFromIconKey( std::unique_ptr<IconLoader::Releaser> LoadIconFromIconKey(
apps::mojom::AppType app_type, apps::mojom::AppType app_type,
...@@ -54,18 +55,14 @@ class AppServiceProxy : public KeyedService, ...@@ -54,18 +55,14 @@ class AppServiceProxy : public KeyedService,
int32_t size_hint_in_dip, int32_t size_hint_in_dip,
bool allow_placeholder_icon, bool allow_placeholder_icon,
apps::mojom::Publisher::LoadIconCallback callback) override; apps::mojom::Publisher::LoadIconCallback callback) override;
void Launch(const std::string& app_id, void Launch(const std::string& app_id,
int32_t event_flags, int32_t event_flags,
apps::mojom::LaunchSource launch_source, apps::mojom::LaunchSource launch_source,
int64_t display_id); int64_t display_id) override;
void SetPermission(const std::string& app_id, void SetPermission(const std::string& app_id,
apps::mojom::PermissionPtr permission); apps::mojom::PermissionPtr permission) override;
void Uninstall(const std::string& app_id) override;
void Uninstall(const std::string& app_id); void OpenNativeSettings(const std::string& app_id) override;
void OpenNativeSettings(const std::string& app_id);
apps::IconLoader* OverrideInnerIconLoaderForTesting( apps::IconLoader* OverrideInnerIconLoaderForTesting(
apps::IconLoader* icon_loader); apps::IconLoader* icon_loader);
...@@ -74,8 +71,8 @@ class AppServiceProxy : public KeyedService, ...@@ -74,8 +71,8 @@ class AppServiceProxy : public KeyedService,
// An adapter, presenting an IconLoader interface based on the underlying // An adapter, presenting an IconLoader interface based on the underlying
// Mojo service (or on a fake implementation for testing). // Mojo service (or on a fake implementation for testing).
// //
// Conceptually, the ASP (the AppServiceProxy) is itself such an adapter: UI // Conceptually, the ASP (the AppServiceProxyImpl) is itself such an adapter:
// clients call the IconLoader::LoadIconFromIconKey method (which the ASP // UI clients call the IconLoader::LoadIconFromIconKey method (which the ASP
// implements) and the ASP translates (i.e. adapts) these to Mojo calls (or // implements) and the ASP translates (i.e. adapts) these to Mojo calls (or
// C++ calls to the Fake). This diagram shows control flow going left to // C++ calls to the Fake). This diagram shows control flow going left to
// right (with "=c=>" and "=m=>" denoting C++ and Mojo calls), and the // right (with "=c=>" and "=m=>" denoting C++ and Mojo calls), and the
...@@ -104,7 +101,7 @@ class AppServiceProxy : public KeyedService, ...@@ -104,7 +101,7 @@ class AppServiceProxy : public KeyedService,
// component: the one that ultimately talks to the Mojo service. // component: the one that ultimately talks to the Mojo service.
// //
// The outer_icon_loader_ field (of type IconCache) is the "Outer" component: // The outer_icon_loader_ field (of type IconCache) is the "Outer" component:
// the entry point for calls into the AppServiceProxy. // the entry point for calls into the AppServiceProxyImpl.
// //
// Note that even if the ASP provides some icon caching, upstream UI clients // Note that even if the ASP provides some icon caching, upstream UI clients
// may want to introduce further icon caching. See the commentary where // may want to introduce further icon caching. See the commentary where
...@@ -113,7 +110,7 @@ class AppServiceProxy : public KeyedService, ...@@ -113,7 +110,7 @@ class AppServiceProxy : public KeyedService,
// IPC coalescing would be one of the "MoreDecorators". // IPC coalescing would be one of the "MoreDecorators".
class InnerIconLoader : public apps::IconLoader { class InnerIconLoader : public apps::IconLoader {
public: public:
explicit InnerIconLoader(AppServiceProxy* host); explicit InnerIconLoader(AppServiceProxyImpl* host);
// apps::IconLoader overrides. // apps::IconLoader overrides.
apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override; apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override;
...@@ -126,8 +123,9 @@ class AppServiceProxy : public KeyedService, ...@@ -126,8 +123,9 @@ class AppServiceProxy : public KeyedService,
bool allow_placeholder_icon, bool allow_placeholder_icon,
apps::mojom::Publisher::LoadIconCallback callback) override; apps::mojom::Publisher::LoadIconCallback callback) override;
// |host_| owns |this|, as the InnerIconLoader is an AppServiceProxy field. // |host_| owns |this|, as the InnerIconLoader is an AppServiceProxyImpl
AppServiceProxy* host_; // field.
AppServiceProxyImpl* host_;
apps::IconLoader* overriding_icon_loader_for_testing_; apps::IconLoader* overriding_icon_loader_for_testing_;
}; };
...@@ -139,9 +137,7 @@ class AppServiceProxy : public KeyedService, ...@@ -139,9 +137,7 @@ class AppServiceProxy : public KeyedService,
void OnApps(std::vector<apps::mojom::AppPtr> deltas) override; void OnApps(std::vector<apps::mojom::AppPtr> deltas) override;
void Clone(apps::mojom::SubscriberRequest request) override; void Clone(apps::mojom::SubscriberRequest request) override;
apps::mojom::AppServicePtr app_service_;
mojo::BindingSet<apps::mojom::Subscriber> bindings_; mojo::BindingSet<apps::mojom::Subscriber> bindings_;
apps::AppRegistryCache cache_;
// The LoadIconFromIconKey implementation sends a chained series of requests // The LoadIconFromIconKey implementation sends a chained series of requests
// through each icon loader, starting from the outer and working back to the // through each icon loader, starting from the outer and working back to the
...@@ -158,9 +154,9 @@ class AppServiceProxy : public KeyedService, ...@@ -158,9 +154,9 @@ class AppServiceProxy : public KeyedService,
ExtensionApps extension_web_apps_; ExtensionApps extension_web_apps_;
#endif // OS_CHROMEOS #endif // OS_CHROMEOS
DISALLOW_COPY_AND_ASSIGN(AppServiceProxy); DISALLOW_COPY_AND_ASSIGN(AppServiceProxyImpl);
}; };
} // namespace apps } // namespace apps
#endif // CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_H_ #endif // CHROME_BROWSER_APPS_APP_SERVICE_APP_SERVICE_PROXY_IMPL_H_
...@@ -6,12 +6,12 @@ ...@@ -6,12 +6,12 @@
#include <vector> #include <vector>
#include "base/callback.h" #include "base/callback.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_impl.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia_rep.h" #include "ui/gfx/image/image_skia_rep.h"
class AppServiceProxyTest : public testing::Test { class AppServiceProxyImplTest : public testing::Test {
protected: protected:
using UniqueReleaser = std::unique_ptr<apps::IconLoader::Releaser>; using UniqueReleaser = std::unique_ptr<apps::IconLoader::Releaser>;
...@@ -66,11 +66,11 @@ class AppServiceProxyTest : public testing::Test { ...@@ -66,11 +66,11 @@ class AppServiceProxyTest : public testing::Test {
return loader->LoadIcon(app_type, app_id, icon_compression, return loader->LoadIcon(app_type, app_id, icon_compression,
size_hint_in_dip, allow_placeholder_icon, size_hint_in_dip, allow_placeholder_icon,
base::BindOnce(&AppServiceProxyTest::OnLoadIcon, base::BindOnce(&AppServiceProxyImplTest::OnLoadIcon,
base::Unretained(this))); base::Unretained(this)));
} }
void OverrideAppServiceProxyInnerIconLoader(apps::AppServiceProxy* proxy, void OverrideAppServiceProxyInnerIconLoader(apps::AppServiceProxyImpl* proxy,
apps::IconLoader* icon_loader) { apps::IconLoader* icon_loader) {
proxy->OverrideInnerIconLoaderForTesting(icon_loader); proxy->OverrideInnerIconLoaderForTesting(icon_loader);
} }
...@@ -84,8 +84,8 @@ class AppServiceProxyTest : public testing::Test { ...@@ -84,8 +84,8 @@ class AppServiceProxyTest : public testing::Test {
int num_outer_finished_callbacks_ = 0; int num_outer_finished_callbacks_ = 0;
}; };
TEST_F(AppServiceProxyTest, IconCache) { TEST_F(AppServiceProxyImplTest, IconCache) {
apps::AppServiceProxy proxy(nullptr); apps::AppServiceProxyImpl proxy(nullptr);
FakeIconLoader fake; FakeIconLoader fake;
OverrideAppServiceProxyInnerIconLoader(&proxy, &fake); OverrideAppServiceProxyInnerIconLoader(&proxy, &fake);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/arc_apps_factory.h" #include "chrome/browser/apps/app_service/arc_apps_factory.h"
#include "chrome/browser/apps/app_service/dip_px_util.h" #include "chrome/browser/apps/app_service/dip_px_util.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "chrome/browser/ui/app_list/arc/arc_app_icon_descriptor.h" #include "chrome/browser/ui/app_list/arc/arc_app_icon_descriptor.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/grit/component_extension_resources.h" #include "chrome/grit/component_extension_resources.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "components/arc/app_permissions/arc_app_permissions_bridge.h" #include "components/arc/app_permissions/arc_app_permissions_bridge.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
#include "components/arc/common/app.mojom.h" #include "components/arc/common/app.mojom.h"
...@@ -172,8 +173,9 @@ ArcApps::ArcApps(Profile* profile) ...@@ -172,8 +173,9 @@ ArcApps::ArcApps(Profile* profile)
apps::mojom::PublisherPtr publisher; apps::mojom::PublisherPtr publisher;
binding_.Bind(mojo::MakeRequest(&publisher)); binding_.Bind(mojo::MakeRequest(&publisher));
apps::AppServiceProxy::Get(profile)->AppService()->RegisterPublisher( apps::AppServiceProxyFactory::GetForProfile(profile)
std::move(publisher), apps::mojom::AppType::kArc); ->AppService()
->RegisterPublisher(std::move(publisher), apps::mojom::AppType::kArc);
} }
ArcApps::~ArcApps() { ArcApps::~ArcApps() {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <utility> #include <utility>
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/dip_px_util.h" #include "chrome/browser/apps/app_service/dip_px_util.h"
#include "chrome/browser/apps/app_service/launch_util.h" #include "chrome/browser/apps/app_service/launch_util.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
......
...@@ -71,6 +71,7 @@ source_set("chromeos") { ...@@ -71,6 +71,7 @@ source_set("chromeos") {
"//chrome/common", "//chrome/common",
"//chrome/common/extensions/api", "//chrome/common/extensions/api",
"//chrome/services/app_service:lib", "//chrome/services/app_service:lib",
"//chrome/services/app_service/public/cpp:app_service_proxy",
"//chrome/services/app_service/public/cpp:app_update", "//chrome/services/app_service/public/cpp:app_update",
"//chrome/services/diagnosticsd/public/mojom", "//chrome/services/diagnosticsd/public/mojom",
"//chrome/services/file_util/public/cpp", "//chrome/services/file_util/public/cpp",
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
#include "base/optional.h" #include "base/optional.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "chrome/browser/apps/app_service/app_icon_source.h" #include "chrome/browser/apps/app_service/app_icon_source.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/kiosk_next_home/app_controller_service_factory.h" #include "chrome/browser/chromeos/kiosk_next_home/app_controller_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "chrome/services/app_service/public/mojom/types.mojom.h" #include "chrome/services/app_service/public/mojom/types.mojom.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "components/arc/arc_service_manager.h" #include "components/arc/arc_service_manager.h"
...@@ -43,7 +44,7 @@ AppControllerService* AppControllerService::Get( ...@@ -43,7 +44,7 @@ AppControllerService* AppControllerService::Get(
AppControllerService::AppControllerService(Profile* profile) AppControllerService::AppControllerService(Profile* profile)
: profile_(profile), : profile_(profile),
app_service_proxy_(apps::AppServiceProxy::Get(profile)) { app_service_proxy_(apps::AppServiceProxyFactory::GetForProfile(profile)) {
DCHECK(profile); DCHECK(profile);
app_service_proxy_->AppRegistryCache().AddObserver(this); app_service_proxy_->AppRegistryCache().AddObserver(this);
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/optional.h" #include "base/optional.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_test.h" #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "chrome/services/app_service/public/cpp/app_registry_cache.h" #include "chrome/services/app_service/public/cpp/app_registry_cache.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "chrome/services/app_service/public/cpp/app_update.h" #include "chrome/services/app_service/public/cpp/app_update.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
...@@ -67,7 +67,7 @@ class AppControllerServiceTest : public testing::Test { ...@@ -67,7 +67,7 @@ class AppControllerServiceTest : public testing::Test {
profile_ = std::make_unique<TestingProfile>(); profile_ = std::make_unique<TestingProfile>();
arc_test_.SetUp(profile()); arc_test_.SetUp(profile());
proxy_ = apps::AppServiceProxy::Get(profile()); proxy_ = apps::AppServiceProxyFactory::GetForProfile(profile());
app_controller_service_ = AppControllerService::Get(profile()); app_controller_service_ = AppControllerService::Get(profile());
......
...@@ -1292,6 +1292,7 @@ jumbo_split_static_library("ui") { ...@@ -1292,6 +1292,7 @@ jumbo_split_static_library("ui") {
"//chrome/browser/ui/webui/app_management:mojo_bindings", "//chrome/browser/ui/webui/app_management:mojo_bindings",
"//chrome/common:buildflags", "//chrome/common:buildflags",
"//chrome/common:search_mojom", "//chrome/common:search_mojom",
"//chrome/services/app_service/public/cpp:app_service_proxy",
"//chrome/services/app_service/public/cpp:app_update", "//chrome/services/app_service/public/cpp:app_update",
"//chrome/services/app_service/public/mojom", "//chrome/services/app_service/public/mojom",
"//components/feedback/proto", "//components/feedback/proto",
......
...@@ -6,11 +6,12 @@ ...@@ -6,11 +6,12 @@
#include "ash/public/cpp/app_list/app_list_config.h" #include "ash/public/cpp/app_list/app_list_config.h"
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h" #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/arc/arc_app_context_menu.h" #include "chrome/browser/ui/app_list/arc/arc_app_context_menu.h"
#include "chrome/browser/ui/app_list/crostini/crostini_app_context_menu.h" #include "chrome/browser/ui/app_list/crostini/crostini_app_context_menu.h"
#include "chrome/browser/ui/app_list/extension_app_context_menu.h" #include "chrome/browser/ui/app_list/extension_app_context_menu.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
// static // static
const char AppServiceAppItem::kItemType[] = "AppServiceAppItem"; const char AppServiceAppItem::kItemType[] = "AppServiceAppItem";
...@@ -118,7 +119,8 @@ void AppServiceAppItem::ExecuteLaunchCommand(int event_flags) { ...@@ -118,7 +119,8 @@ void AppServiceAppItem::ExecuteLaunchCommand(int event_flags) {
void AppServiceAppItem::Launch(int event_flags, void AppServiceAppItem::Launch(int event_flags,
apps::mojom::LaunchSource launch_source) { apps::mojom::LaunchSource launch_source) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile()); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
if (proxy) { if (proxy) {
proxy->Launch(id(), event_flags, launch_source, proxy->Launch(id(), event_flags, launch_source,
GetController()->GetAppListDisplayId()); GetController()->GetAppListDisplayId());
...@@ -126,7 +128,8 @@ void AppServiceAppItem::Launch(int event_flags, ...@@ -126,7 +128,8 @@ void AppServiceAppItem::Launch(int event_flags,
} }
void AppServiceAppItem::CallLoadIcon(bool allow_placeholder_icon) { void AppServiceAppItem::CallLoadIcon(bool allow_placeholder_icon) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile()); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
if (proxy) { if (proxy) {
proxy->LoadIcon(app_type_, id(), proxy->LoadIcon(app_type_, id(),
apps::mojom::IconCompression::kUncompressed, apps::mojom::IconCompression::kUncompressed,
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
#include "chrome/browser/ui/app_list/app_service_app_model_builder.h" #include "chrome/browser/ui/app_list/app_service_app_model_builder.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/ui/app_list/app_service_app_item.h" #include "chrome/browser/ui/app_list/app_service_app_item.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
AppServiceAppModelBuilder::AppServiceAppModelBuilder( AppServiceAppModelBuilder::AppServiceAppModelBuilder(
AppListControllerDelegate* controller) AppListControllerDelegate* controller)
...@@ -14,7 +15,8 @@ AppServiceAppModelBuilder::AppServiceAppModelBuilder( ...@@ -14,7 +15,8 @@ AppServiceAppModelBuilder::AppServiceAppModelBuilder(
AppServiceAppModelBuilder::~AppServiceAppModelBuilder() = default; AppServiceAppModelBuilder::~AppServiceAppModelBuilder() = default;
void AppServiceAppModelBuilder::BuildModel() { void AppServiceAppModelBuilder::BuildModel() {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile()); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
if (proxy) { if (proxy) {
proxy->AppRegistryCache().ForEachApp( proxy->AppRegistryCache().ForEachApp(
[this](const apps::AppUpdate& update) { OnAppUpdate(update); }); [this](const apps::AppUpdate& update) { OnAppUpdate(update); });
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/clock.h" #include "base/time/clock.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync_sessions/session_sync_service.h" #include "components/sync_sessions/session_sync_service.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
...@@ -288,9 +289,10 @@ class AppServiceDataSource : public AppSearchProvider::DataSource, ...@@ -288,9 +289,10 @@ class AppServiceDataSource : public AppSearchProvider::DataSource,
public: public:
AppServiceDataSource(Profile* profile, AppSearchProvider* owner) AppServiceDataSource(Profile* profile, AppSearchProvider* owner)
: AppSearchProvider::DataSource(profile, owner), : AppSearchProvider::DataSource(profile, owner),
icon_cache_(apps::AppServiceProxy::Get(profile), icon_cache_(apps::AppServiceProxyFactory::GetForProfile(profile),
apps::IconCache::GarbageCollectionPolicy::kExplicit) { apps::IconCache::GarbageCollectionPolicy::kExplicit) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
if (proxy) { if (proxy) {
Observe(&proxy->AppRegistryCache()); Observe(&proxy->AppRegistryCache());
} }
...@@ -300,7 +302,8 @@ class AppServiceDataSource : public AppSearchProvider::DataSource, ...@@ -300,7 +302,8 @@ class AppServiceDataSource : public AppSearchProvider::DataSource,
// AppSearchProvider::DataSource overrides: // AppSearchProvider::DataSource overrides:
void AddApps(AppSearchProvider::Apps* apps_vector) override { void AddApps(AppSearchProvider::Apps* apps_vector) override {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile()); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
if (!proxy) { if (!proxy) {
return; return;
} }
......
...@@ -7,10 +7,11 @@ ...@@ -7,10 +7,11 @@
#include "ash/public/cpp/app_list/app_list_config.h" #include "ash/public/cpp/app_list/app_list_config.h"
#include "ash/public/cpp/app_list/app_list_types.h" #include "ash/public/cpp/app_list/app_list_types.h"
#include "base/bind.h" #include "base/bind.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/ui/app_list/app_list_client_impl.h" #include "chrome/browser/ui/app_list/app_list_client_impl.h"
#include "chrome/browser/ui/app_list/app_service_app_item.h" #include "chrome/browser/ui/app_list/app_service_app_item.h"
#include "chrome/browser/ui/app_list/search/internal_app_result.h" #include "chrome/browser/ui/app_list/search/internal_app_result.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
namespace app_list { namespace app_list {
...@@ -26,7 +27,8 @@ AppServiceAppResult::AppServiceAppResult(Profile* profile, ...@@ -26,7 +27,8 @@ AppServiceAppResult::AppServiceAppResult(Profile* profile,
is_platform_app_(false), is_platform_app_(false),
show_in_launcher_(false), show_in_launcher_(false),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile);
if (proxy) { if (proxy) {
proxy->AppRegistryCache().ForOneApp( proxy->AppRegistryCache().ForOneApp(
...@@ -117,7 +119,8 @@ void AppServiceAppResult::ExecuteLaunchCommand(int event_flags) { ...@@ -117,7 +119,8 @@ void AppServiceAppResult::ExecuteLaunchCommand(int event_flags) {
void AppServiceAppResult::Launch(int event_flags, void AppServiceAppResult::Launch(int event_flags,
apps::mojom::LaunchSource launch_source) { apps::mojom::LaunchSource launch_source) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile()); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
if (proxy) { if (proxy) {
proxy->Launch(app_id(), event_flags, launch_source, proxy->Launch(app_id(), event_flags, launch_source,
controller()->GetAppListDisplayId()); controller()->GetAppListDisplayId());
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h" #include "base/test/simple_test_clock.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_impl.h"
#include "chrome/browser/chromeos/crostini/crostini_test_helper.h" #include "chrome/browser/chromeos/crostini/crostini_test_helper.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/sync/session_sync_service_factory.h" #include "chrome/browser/sync/session_sync_service_factory.h"
...@@ -795,7 +795,8 @@ TEST_F(AppSearchProviderTest, AppServiceIconCache) { ...@@ -795,7 +795,8 @@ TEST_F(AppSearchProviderTest, AppServiceIconCache) {
return; return;
} }
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile()); apps::AppServiceProxyImpl* proxy =
apps::AppServiceProxyImpl::GetImplForTesting(profile());
ASSERT_NE(proxy, nullptr); ASSERT_NE(proxy, nullptr);
apps::StubIconLoader stub_icon_loader; apps::StubIconLoader stub_icon_loader;
......
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/services/app_service/public/cpp/app_registry_cache.h" #include "chrome/services/app_service/public/cpp/app_registry_cache.h"
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include "chrome/services/app_service/public/mojom/types.mojom.h" #include "chrome/services/app_service/public/mojom/types.mojom.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
...@@ -48,7 +49,8 @@ AppManagementPageHandler::AppManagementPageHandler( ...@@ -48,7 +49,8 @@ AppManagementPageHandler::AppManagementPageHandler(
shelf_delegate_(this) shelf_delegate_(this)
#endif #endif
{ {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in // TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito // incognito
...@@ -62,7 +64,8 @@ AppManagementPageHandler::~AppManagementPageHandler() {} ...@@ -62,7 +64,8 @@ AppManagementPageHandler::~AppManagementPageHandler() {}
void AppManagementPageHandler::OnPinnedChanged(const std::string& app_id, void AppManagementPageHandler::OnPinnedChanged(const std::string& app_id,
bool pinned) { bool pinned) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in // TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito // incognito
...@@ -87,7 +90,8 @@ void AppManagementPageHandler::OnPinnedChanged(const std::string& app_id, ...@@ -87,7 +90,8 @@ void AppManagementPageHandler::OnPinnedChanged(const std::string& app_id,
} }
void AppManagementPageHandler::GetApps(GetAppsCallback callback) { void AppManagementPageHandler::GetApps(GetAppsCallback callback) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in // TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito // incognito
...@@ -136,7 +140,8 @@ void AppManagementPageHandler::SetPinned(const std::string& app_id, ...@@ -136,7 +140,8 @@ void AppManagementPageHandler::SetPinned(const std::string& app_id,
void AppManagementPageHandler::SetPermission( void AppManagementPageHandler::SetPermission(
const std::string& app_id, const std::string& app_id,
apps::mojom::PermissionPtr permission) { apps::mojom::PermissionPtr permission) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in // TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito // incognito
...@@ -147,7 +152,8 @@ void AppManagementPageHandler::SetPermission( ...@@ -147,7 +152,8 @@ void AppManagementPageHandler::SetPermission(
} }
void AppManagementPageHandler::Uninstall(const std::string& app_id) { void AppManagementPageHandler::Uninstall(const std::string& app_id) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in // TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito // incognito
...@@ -158,7 +164,8 @@ void AppManagementPageHandler::Uninstall(const std::string& app_id) { ...@@ -158,7 +164,8 @@ void AppManagementPageHandler::Uninstall(const std::string& app_id) {
} }
void AppManagementPageHandler::OpenNativeSettings(const std::string& app_id) { void AppManagementPageHandler::OpenNativeSettings(const std::string& app_id) {
apps::AppServiceProxy* proxy = apps::AppServiceProxy::Get(profile_); apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile_);
// TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in // TODO(crbug.com/826982): revisit pending decision on AppServiceProxy in
// incognito // incognito
......
...@@ -2,6 +2,18 @@ ...@@ -2,6 +2,18 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
source_set("app_service_proxy") {
sources = [
"app_service_proxy.cc",
"app_service_proxy.h",
]
deps = [
":app_update",
":icon_loader",
]
}
source_set("app_update") { source_set("app_update") {
sources = [ sources = [
"app_registry_cache.cc", "app_registry_cache.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/services/app_service/public/cpp/app_service_proxy.h"
#include <utility>
namespace apps {
AppServiceProxy::AppServiceProxy() = default;
AppServiceProxy::~AppServiceProxy() = default;
apps::mojom::AppServicePtr& AppServiceProxy::AppService() {
return app_service_;
}
apps::AppRegistryCache& AppServiceProxy::AppRegistryCache() {
return cache_;
}
apps::mojom::IconKeyPtr AppServiceProxy::GetIconKey(const std::string& app_id) {
return apps::mojom::IconKey::New();
}
std::unique_ptr<apps::IconLoader::Releaser>
AppServiceProxy::LoadIconFromIconKey(
apps::mojom::AppType app_type,
const std::string& app_id,
apps::mojom::IconKeyPtr icon_key,
apps::mojom::IconCompression icon_compression,
int32_t size_hint_in_dip,
bool allow_placeholder_icon,
apps::mojom::Publisher::LoadIconCallback callback) {
std::move(callback).Run(apps::mojom::IconValue::New());
return nullptr;
}
void AppServiceProxy::Launch(const std::string& app_id,
int32_t event_flags,
apps::mojom::LaunchSource launch_source,
int64_t display_id) {}
void AppServiceProxy::SetPermission(const std::string& app_id,
apps::mojom::PermissionPtr permission) {}
void AppServiceProxy::Uninstall(const std::string& app_id) {}
void AppServiceProxy::OpenNativeSettings(const std::string& app_id) {}
} // namespace apps
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_SERVICES_APP_SERVICE_PUBLIC_CPP_APP_SERVICE_PROXY_H_
#define CHROME_SERVICES_APP_SERVICE_PUBLIC_CPP_APP_SERVICE_PROXY_H_
#include <memory>
#include "base/macros.h"
#include "chrome/services/app_service/public/cpp/app_registry_cache.h"
#include "chrome/services/app_service/public/cpp/icon_loader.h"
#include "chrome/services/app_service/public/mojom/app_service.mojom.h"
namespace apps {
// Abstract superclass (with default no-op methods) for the App Service proxy.
// See chrome/services/app_service/README.md.
//
// Most code, outside of tests, should use an AppServiceProxyImpl.
class AppServiceProxy : public apps::IconLoader {
public:
AppServiceProxy();
~AppServiceProxy() override;
apps::mojom::AppServicePtr& AppService();
apps::AppRegistryCache& AppRegistryCache();
// apps::IconLoader overrides.
apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override;
std::unique_ptr<IconLoader::Releaser> LoadIconFromIconKey(
apps::mojom::AppType app_type,
const std::string& app_id,
apps::mojom::IconKeyPtr icon_key,
apps::mojom::IconCompression icon_compression,
int32_t size_hint_in_dip,
bool allow_placeholder_icon,
apps::mojom::Publisher::LoadIconCallback callback) override;
virtual void Launch(const std::string& app_id,
int32_t event_flags,
apps::mojom::LaunchSource launch_source,
int64_t display_id);
virtual void SetPermission(const std::string& app_id,
apps::mojom::PermissionPtr permission);
virtual void Uninstall(const std::string& app_id);
virtual void OpenNativeSettings(const std::string& app_id);
protected:
apps::mojom::AppServicePtr app_service_;
apps::AppRegistryCache cache_;
private:
DISALLOW_COPY_AND_ASSIGN(AppServiceProxy);
};
} // namespace apps
#endif // CHROME_SERVICES_APP_SERVICE_PUBLIC_CPP_APP_SERVICE_PROXY_H_
...@@ -67,7 +67,7 @@ class IconCache : public IconLoader { ...@@ -67,7 +67,7 @@ class IconCache : public IconLoader {
}; };
IconCache(IconLoader* wrapped_loader, GarbageCollectionPolicy gc_policy); IconCache(IconLoader* wrapped_loader, GarbageCollectionPolicy gc_policy);
~IconCache(); ~IconCache() override;
// IconLoader overrides. // IconLoader overrides.
apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override; apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override;
......
...@@ -60,6 +60,10 @@ bool IconLoader::Key::operator<(const Key& that) const { ...@@ -60,6 +60,10 @@ bool IconLoader::Key::operator<(const Key& that) const {
return this->app_id_ < that.app_id_; return this->app_id_ < that.app_id_;
} }
IconLoader::IconLoader() = default;
IconLoader::~IconLoader() = default;
std::unique_ptr<IconLoader::Releaser> IconLoader::LoadIcon( std::unique_ptr<IconLoader::Releaser> IconLoader::LoadIcon(
apps::mojom::AppType app_type, apps::mojom::AppType app_type,
const std::string& app_id, const std::string& app_id,
......
...@@ -45,6 +45,9 @@ class IconLoader { ...@@ -45,6 +45,9 @@ class IconLoader {
DISALLOW_COPY_AND_ASSIGN(Releaser); DISALLOW_COPY_AND_ASSIGN(Releaser);
}; };
IconLoader();
virtual ~IconLoader();
// Looks up the IconKey for the given app ID. // Looks up the IconKey for the given app ID.
virtual apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) = 0; virtual apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) = 0;
......
...@@ -17,7 +17,7 @@ namespace apps { ...@@ -17,7 +17,7 @@ namespace apps {
class StubIconLoader : public IconLoader { class StubIconLoader : public IconLoader {
public: public:
StubIconLoader(); StubIconLoader();
~StubIconLoader(); ~StubIconLoader() override;
// IconLoader overrides. // IconLoader overrides.
apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override; apps::mojom::IconKeyPtr GetIconKey(const std::string& app_id) override;
......
...@@ -3551,7 +3551,7 @@ test("unit_tests") { ...@@ -3551,7 +3551,7 @@ test("unit_tests") {
if (!is_android) { if (!is_android) {
sources += [ sources += [
"../browser/apps/app_service/app_service_proxy_unittest.cc", "../browser/apps/app_service/app_service_proxy_impl_unittest.cc",
"../browser/apps/intent_helper/apps_navigation_throttle_unittest.cc", "../browser/apps/intent_helper/apps_navigation_throttle_unittest.cc",
"../browser/apps/intent_helper/page_transition_util_unittest.cc", "../browser/apps/intent_helper/page_transition_util_unittest.cc",
"../browser/devtools/devtools_file_system_indexer_unittest.cc", "../browser/devtools/devtools_file_system_indexer_unittest.cc",
......
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