Skip to content

Commit

Permalink
[Lacros] Create Lacros version AppServiceProxy.
Browse files Browse the repository at this point in the history
This CL splits up the code to have a dedicated AppServiceProxy for
lacros-chrome. This is to prepare to make change of this newly created
AppServiceProxy to talk with the app service in ash-chrome via crosapi
instead of talk with the app service in lacros-chrome. This will be
increamental changes to avoid large breakage of the tests and existing
behaviours.

BUG=1225827

Change-Id: Ieaa66452320e9bb31514eea5e19a024939789b41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3058016
Reviewed-by: Dominick Ng <dominickn@chromium.org>
Commit-Queue: Maggie Cai <mxcai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#906475}
  • Loading branch information
Maggie Cai authored and Chromium LUCI CQ committed Jul 29, 2021
1 parent 0fae704 commit d180523
Show file tree
Hide file tree
Showing 13 changed files with 1,045 additions and 79 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/BUILD.gn
Expand Up @@ -4788,6 +4788,8 @@ static_library("browser") {
if (is_chromeos_lacros) {
assert(enable_system_notifications)
sources += [
"apps/app_service/app_service_proxy_lacros.cc",
"apps/app_service/app_service_proxy_lacros.h",
"apps/app_service/fake_lacros_web_apps_host.cc",
"apps/app_service/fake_lacros_web_apps_host.h",
"chrome_browser_main_parts_lacros.cc",
Expand Down
2 changes: 2 additions & 0 deletions chrome/browser/apps/app_service/app_service_proxy.h
Expand Up @@ -10,6 +10,8 @@

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/apps/app_service/app_service_proxy_chromeos.h"
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/apps/app_service/app_service_proxy_lacros.h"
#else
#include "chrome/browser/apps/app_service/app_service_proxy_desktop.h"
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
Expand Down
40 changes: 0 additions & 40 deletions chrome/browser/apps/app_service/app_service_proxy_desktop.cc
Expand Up @@ -9,19 +9,8 @@
#include "chrome/browser/web_applications/web_app_provider.h"
#include "components/services/app_service/app_service_impl.h"

#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/apps/app_service/fake_lacros_web_apps_host.h"
#include "chrome/browser/web_applications/app_service/web_apps_publisher_host.h"
#endif

namespace apps {

#if BUILDFLAG(IS_CHROMEOS_LACROS)
// TODO(crbug.com/1144877): Remove after the actual lacros web app host code
// completed.
const bool kUseFakeWebAppsHost = false;
#endif

AppServiceProxy::AppServiceProxy(Profile* profile)
: AppServiceProxyBase(profile) {
Initialize();
Expand All @@ -43,20 +32,6 @@ void AppServiceProxy::Initialize() {
web_apps_ = std::make_unique<web_app::WebApps>(app_service_, profile_);
extension_apps_ = std::make_unique<ExtensionApps>(app_service_, profile_);

#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (kUseFakeWebAppsHost) {
// Create a fake lacros web app host in the lacros-chrome for testing lacros
// web app publishing. This will be removed after the actual lacros web app
// host code is created.
fake_lacros_web_apps_host_ = std::make_unique<FakeLacrosWebAppsHost>();
fake_lacros_web_apps_host_->Init();
} else {
web_apps_publisher_host_ =
std::make_unique<web_app::WebAppsPublisherHost>(profile_);
web_apps_publisher_host_->Init();
}
#endif

// Asynchronously add app icon source, so we don't do too much work in the
// constructor.
base::ThreadTaskRunnerHandle::Get()->PostTask(
Expand All @@ -81,24 +56,9 @@ void AppServiceProxy::FlushMojoCallsForTesting() {
receivers_.FlushForTesting();
}

#if BUILDFLAG(IS_CHROMEOS_LACROS)
web_app::WebAppsPublisherHost*
AppServiceProxy::WebAppsPublisherHostForTesting() {
return web_apps_publisher_host_.get();
}
#endif

bool AppServiceProxy::MaybeShowLaunchPreventionDialog(
const apps::AppUpdate& update) {
return false;
}

void AppServiceProxy::Shutdown() {
#if BUILDFLAG(IS_CHROMEOS_LACROS)
if (web_apps_publisher_host_) {
web_apps_publisher_host_->Shutdown();
}
#endif
}

} // namespace apps
19 changes: 0 additions & 19 deletions chrome/browser/apps/app_service/app_service_proxy_desktop.h
Expand Up @@ -17,19 +17,12 @@ class Profile;

namespace web_app {
class WebApps;
#if BUILDFLAG(IS_CHROMEOS_LACROS)
class WebAppsPublisherHost;
#endif
} // namespace web_app

namespace apps {

class ExtensionApps;

#if BUILDFLAG(IS_CHROMEOS_LACROS)
class FakeLacrosWebAppsHost;
#endif

// Singleton (per Profile) proxy and cache of an App Service's apps in Chrome
// browser.
//
Expand All @@ -47,26 +40,14 @@ class AppServiceProxy : public AppServiceProxyBase {
gfx::NativeWindow parent_window) override;
void FlushMojoCallsForTesting() override;

#if BUILDFLAG(IS_CHROMEOS_LACROS)
web_app::WebAppsPublisherHost* WebAppsPublisherHostForTesting();
#endif

private:
// apps::AppServiceProxyBase overrides:
void Initialize() override;
bool MaybeShowLaunchPreventionDialog(const apps::AppUpdate& update) override;

// KeyedService overrides:
void Shutdown() override;

std::unique_ptr<web_app::WebApps> web_apps_;
std::unique_ptr<ExtensionApps> extension_apps_;

#if BUILDFLAG(IS_CHROMEOS_LACROS)
std::unique_ptr<FakeLacrosWebAppsHost> fake_lacros_web_apps_host_;
std::unique_ptr<web_app::WebAppsPublisherHost> web_apps_publisher_host_;
#endif

base::WeakPtrFactory<AppServiceProxy> weak_ptr_factory_{this};
};

Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/apps/app_service/app_service_proxy_factory.h
Expand Up @@ -15,6 +15,9 @@ namespace apps {
#if BUILDFLAG(IS_CHROMEOS_ASH)
class AppServiceProxyChromeOs;
using AppServiceProxy = AppServiceProxyChromeOs;
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
class AppServiceProxyLacros;
using AppServiceProxy = AppServiceProxyLacros;
#else
class AppServiceProxy;
#endif
Expand Down

0 comments on commit d180523

Please sign in to comment.