Commit d9cebd34 authored by James Cook's avatar James Cook Committed by Commit Bot

cros: Run touch HUD mojo app in ash_shell_with_content

The touch HUD mojo app is a new way to support the "Show taps"
ash UI feature. Previously it only worked with out-of-process
ash ("mash") but we're getting it working with in-process ash
("classic"). This CL adds support for the touch hud app to
the ash_shell_with_content executable, which is used by
developers to work on ash without building chrome.

Introduce --show-taps-app so it can run without turning on ash's
built-in touch hud impl.

Make the app open its window on startup so it can run without the
mash:launchable mojo interface, similar to quick launch. This avoids
//mash dependencies.

Introduce a constant for "touch_hud_app".

TODO: Remove the launchable interface from touch_hud_app entirely

Bug: 840380
Test: ash_shell_with_content --show-taps-app opens a window
Change-Id: Ief7433e61916025c1dff349142ea9802a7238963
Reviewed-on: https://chromium-review.googlesource.com/1055208Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557983}
parent 71361dc9
......@@ -1243,6 +1243,7 @@ component("ash") {
"//ash/components/cursor",
"//ash/components/fast_ink",
"//ash/components/quick_launch/public/mojom",
"//ash/components/touch_hud/public/mojom",
"//ash/touch_hud",
"//base",
"//base:i18n",
......@@ -1458,6 +1459,8 @@ static_library("ash_shell_lib_with_content") {
"//ash/app_list/presenter:test_support",
"//ash/components/quick_launch:lib",
"//ash/components/quick_launch/public/mojom",
"//ash/components/touch_hud:lib",
"//ash/components/touch_hud/public/mojom",
"//ash/public/cpp",
"//ash/shell:resources",
"//base:i18n",
......
......@@ -49,6 +49,7 @@ include_rules = [
# Ash can talk to public interfaces for mini-apps.
"+ash/components/autoclick/public",
"+ash/components/quick_launch/public",
"+ash/components/touch_hud/public",
# Ash sits above content. Exceptions live in //ash/content.
"-content",
......
# 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.
import("//mojo/public/tools/bindings/mojom.gni")
group("mojom") {
public_deps = [
":constants",
]
}
mojom("constants") {
sources = [
"constants.mojom",
]
}
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
// 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.
module touch_hud.mojom;
const string kServiceName = "touch_hud_app";
......@@ -74,8 +74,11 @@ void TouchHudApplication::OnStart() {
context()->connector(), context()->identity(), "views_mus_resources.pak",
std::string(), nullptr, views::AuraInit::Mode::AURA_MUS,
register_path_provider);
if (!aura_init_)
if (!aura_init_) {
context()->QuitNow();
return;
}
Launch(mash::mojom::kWindow, mash::mojom::LaunchMode::DEFAULT);
}
void TouchHudApplication::OnBindInterface(
......@@ -101,8 +104,7 @@ void TouchHudApplication::Launch(uint32_t what, mash::mojom::LaunchMode how) {
widget_->Init(params);
widget_->Show();
} else {
widget_->Close();
context()->QuitNow();
widget_->Activate();
}
}
......
......@@ -129,6 +129,10 @@ const char kHasInternalStylus[] = "has-internal-stylus";
// option "Show taps".
const char kShowTaps[] = "show-taps";
// Uses a mojo app to implement the "Show taps" feature. Exists so the mojo app
// version can be tested independently from the classic version.
const char kShowTapsApp[] = "show-taps-app";
// Forces the views login implementation.
const char kShowViewsLogin[] = "show-views-login";
......
......@@ -55,6 +55,7 @@ ASH_PUBLIC_EXPORT extern const char kAshTouchHud[];
ASH_PUBLIC_EXPORT extern const char kAuraLegacyPowerButton[];
ASH_PUBLIC_EXPORT extern const char kHasInternalStylus[];
ASH_PUBLIC_EXPORT extern const char kShowTaps[];
ASH_PUBLIC_EXPORT extern const char kShowTapsApp[];
ASH_PUBLIC_EXPORT extern const char kShowViewsLogin[];
ASH_PUBLIC_EXPORT extern const char kShowWebUiLock[];
ASH_PUBLIC_EXPORT extern const char kShowWebUiLogin[];
......
......@@ -537,17 +537,16 @@ void RootWindowController::UpdateShelfVisibility() {
}
void RootWindowController::InitTouchHuds() {
if (Shell::GetAshConfig() == Config::MASH)
return;
// Enable touch debugging features when each display is initialized.
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kAshTouchHud))
set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
// TouchHudProjection manages its own lifetime.
if (command_line->HasSwitch(switches::kShowTaps))
if (command_line->HasSwitch(switches::kShowTaps) &&
!command_line->HasSwitch(switches::kShowTapsApp)) {
touch_hud_projection_ = new TouchHudProjection(GetRootWindow());
}
}
aura::Window* RootWindowController::GetWindowForFullscreenMode() {
......
......@@ -22,6 +22,7 @@
#include "ash/assistant/assistant_controller.h"
#include "ash/autoclick/autoclick_controller.h"
#include "ash/cast_config_controller.h"
#include "ash/components/touch_hud/public/mojom/constants.mojom.h"
#include "ash/dbus/ash_dbus_services.h"
#include "ash/detachable_base/detachable_base_handler.h"
#include "ash/detachable_base/detachable_base_notification_controller.h"
......@@ -1274,14 +1275,14 @@ void Shell::Init(ui::ContextFactory* context_factory,
// is started.
display_manager_->CreateMirrorWindowAsyncIfAny();
// Mash implements the show taps feature with a separate mojo app.
// The show taps feature can be implemented with a separate mojo app.
// GetShellConnector() is null in unit tests.
if (config == Config::MASH && shell_delegate_->GetShellConnector() &&
base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowTaps)) {
mash::mojom::LaunchablePtr launchable;
shell_delegate_->GetShellConnector()->BindInterface("touch_hud_app",
&launchable);
launchable->Launch(mash::mojom::kWindow, mash::mojom::LaunchMode::DEFAULT);
// TODO(jamescook): Make this work in ash_shell_with_content.
if (shell_delegate_->GetShellConnector() &&
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kShowTapsApp)) {
shell_delegate_->GetShellConnector()->StartService(
touch_hud::mojom::kServiceName);
}
for (auto& observer : shell_observers_)
......
......@@ -27,6 +27,7 @@ service_manifest("ash_content_packaged_services_manifest_overlay") {
source = "//ash/shell/ash_content_packaged_services_manifest_overlay.json"
packaged_services = [
"//ash/components/quick_launch:manifest",
"//ash/components/touch_hud:manifest",
"//components/services/font:manifest",
"//services/ui:manifest",
]
......
......@@ -9,6 +9,7 @@
<release seq="1">
<includes>
<include name="IDR_ASH_SHELL_QUICK_LAUNCH_MANIFEST" file="../../ash/components/quick_launch/manifest.json" type="BINDATA" use_base_dir="false" />
<include name="IDR_ASH_SHELL_TOUCH_HUD_MANIFEST" file="../../ash/components/touch_hud/manifest.json" type="BINDATA" use_base_dir="false" />
<include name="IDR_ASH_SHELL_FONT_SERVICE_MANIFEST" file="../../components/services/font/manifest.json" type="BINDATA" use_base_dir="false" />
<include name="IDR_ASH_SHELL_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY" file="${root_gen_dir}\ash\shell\ash_content_packaged_services_manifest_overlay.json" type="BINDATA" use_base_dir="false"/>
</includes>
......
include_rules = [
"+ash/components/quick_launch",
"+ash/components/touch_hud",
"+components/discardable_memory/public/interfaces",
"+components/services/font",
"+content/public",
......
......@@ -8,8 +8,10 @@
#include <utility>
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/touch_hud/public/mojom/constants.mojom.h"
#include "ash/content/shell_content_state.h"
#include "ash/login_status.h"
#include "ash/public/cpp/ash_switches.h"
#include "ash/shell.h"
#include "ash/shell/content/shell_content_state_impl.h"
#include "ash/shell/example_session_controller_client.h"
......@@ -112,6 +114,12 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->StartService(quick_launch::mojom::kServiceName);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kShowTapsApp)) {
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->StartService(touch_hud::mojom::kServiceName);
}
ash::Shell::Get()->InitWaylandServer(nullptr);
}
......
......@@ -8,6 +8,7 @@
#include "ash/ash_service.h"
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/touch_hud/public/mojom/constants.mojom.h"
#include "ash/content/content_gpu_support.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/public/interfaces/constants.mojom.h"
......@@ -79,6 +80,7 @@ std::vector<content::ContentBrowserClient::ServiceManifestInfo>
ShellContentBrowserClient::GetExtraServiceManifests() {
return {
{quick_launch::mojom::kServiceName, IDR_ASH_SHELL_QUICK_LAUNCH_MANIFEST},
{touch_hud::mojom::kServiceName, IDR_ASH_SHELL_TOUCH_HUD_MANIFEST},
{font_service::mojom::kServiceName, IDR_ASH_SHELL_FONT_SERVICE_MANIFEST}};
}
......@@ -86,6 +88,8 @@ void ShellContentBrowserClient::RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) {
(*services)[quick_launch::mojom::kServiceName] = OutOfProcessServiceInfo(
base::ASCIIToUTF16(quick_launch::mojom::kServiceName));
(*services)[touch_hud::mojom::kServiceName] = OutOfProcessServiceInfo(
base::ASCIIToUTF16(touch_hud::mojom::kServiceName));
(*services)[font_service::mojom::kServiceName] = OutOfProcessServiceInfo(
base::ASCIIToUTF16(font_service::mojom::kServiceName));
}
......@@ -105,7 +109,8 @@ void ShellContentBrowserClient::RegisterInProcessServices(
void ShellContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
if (identity.name() == quick_launch::mojom::kServiceName) {
if (identity.name() == quick_launch::mojom::kServiceName ||
identity.name() == touch_hud::mojom::kServiceName) {
// TODO(sky): this is necessary because WindowTreeClient only connects to
// the gpu related interfaces if Mash is set.
command_line->AppendSwitchASCII(switches::kEnableFeatures,
......
......@@ -6,6 +6,8 @@
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/quick_launch/quick_launch_application.h"
#include "ash/components/touch_hud/public/mojom/constants.mojom.h"
#include "ash/components/touch_hud/touch_hud_application.h"
#include "ash/shell/content/client/shell_content_browser_client.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
......@@ -26,6 +28,10 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunch() {
return std::make_unique<quick_launch::QuickLaunchApplication>();
}
std::unique_ptr<service_manager::Service> CreateTouchHud() {
return std::make_unique<touch_hud::TouchHudApplication>();
}
std::unique_ptr<service_manager::Service> CreateFontService() {
return std::make_unique<font_service::FontServiceApp>();
}
......@@ -42,6 +48,11 @@ class ShellContentUtilityClient : public content::ContentUtilityClient {
info.factory = base::BindRepeating(&CreateQuickLaunch);
(*services)[quick_launch::mojom::kServiceName] = info;
}
{
service_manager::EmbeddedServiceInfo info;
info.factory = base::BindRepeating(&CreateTouchHud);
(*services)[touch_hud::mojom::kServiceName] = info;
}
{
service_manager::EmbeddedServiceInfo info;
info.factory = base::BindRepeating(&CreateFontService);
......
......@@ -92,6 +92,7 @@ include_rules = [
"-ash",
"+ash/public",
"+ash/components/quick_launch/public/mojom",
"+ash/components/touch_hud/public/mojom",
# The message center may not exist, or may run out of process (in mash).
"-ui/message_center",
......
......@@ -6,6 +6,7 @@
#include "ash/ash_service.h"
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/touch_hud/public/mojom/constants.mojom.h"
#include "ash/content/content_gpu_support.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/public/interfaces/constants.mojom.h"
......@@ -37,7 +38,7 @@ struct Service {
constexpr Service kCommonServices[] = {
{quick_launch::mojom::kServiceName, "Quick Launch", nullptr},
{"autoclick_app", "Accessibility Autoclick", nullptr},
{"touch_hud_app", "Touch HUD", nullptr},
{touch_hud::mojom::kServiceName, "Touch HUD", nullptr},
{font_service::mojom::kServiceName, "Font Service", nullptr},
};
......
......@@ -149,6 +149,7 @@ static_library("utility") {
"//ash/components/quick_launch:lib",
"//ash/components/quick_launch/public/mojom",
"//ash/components/touch_hud:lib",
"//ash/components/touch_hud/public/mojom",
"//chrome/services/file_util:lib",
"//components/services/font:lib",
"//components/services/font/public/interfaces",
......
......@@ -48,6 +48,7 @@ specific_include_rules = {
"+ash/components/autoclick/autoclick_application.h",
"+ash/components/quick_launch/public",
"+ash/components/quick_launch/quick_launch_application.h",
"+ash/components/touch_hud/public",
"+ash/components/touch_hud/touch_hud_application.h",
"+ash/public/interfaces",
"+ash/window_manager_service.h",
......
......@@ -9,6 +9,7 @@
#include "ash/components/autoclick/autoclick_application.h"
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/quick_launch/quick_launch_application.h"
#include "ash/components/touch_hud/public/mojom/constants.mojom.h"
#include "ash/components/touch_hud/touch_hud_application.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/window_manager_service.h"
......@@ -98,7 +99,8 @@ void MashServiceFactory::RegisterOutOfProcessServices(
&CreateQuickLaunchApp);
RegisterMashService(services, ash::mojom::kServiceName, &CreateAshService);
RegisterMashService(services, "autoclick_app", &CreateAutoclickApp);
RegisterMashService(services, "touch_hud_app", &CreateTouchHudApp);
RegisterMashService(services, touch_hud::mojom::kServiceName,
&CreateTouchHudApp);
RegisterMashService(services, font_service::mojom::kServiceName,
&CreateFontService);
}
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