Skip to content

Commit

Permalink
cros: Move touch_hud mojo app into //ash/components
Browse files Browse the repository at this point in the history
This is a good example mojo mini-app that runs as part of ash.
Move it next to the other mini-apps (quick launch, autoclick).

No functional changes.

Bug: 815334
Test: ash_unittests, run chrome --enable-features=Mash --show-taps
Change-Id: I0044213d3d67c54d97c98ede3526bc33c3e48219
Reviewed-on: https://chromium-review.googlesource.com/937988
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539359}
  • Loading branch information
James Cook authored and Commit Bot committed Feb 27, 2018
1 parent 66d4cb4 commit 2268bef
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ component("ash") {

data_deps = [
"//ash/components/autoclick:autoclick_app",
"//ash/touch_hud/mus:touch_hud",
"//ash/components/touch_hud:touch_hud_app",
]

# Usage of content should be in ash_content_unittests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ source_set("lib") {
]
}

service("touch_hud") {
service("touch_hud_app") {
sources = [
"main.cc",
]
Expand All @@ -45,6 +45,6 @@ service("touch_hud") {
}

service_manifest("manifest") {
name = "touch_hud"
name = "touch_hud_app"
source = "manifest.json"
}
4 changes: 3 additions & 1 deletion ash/touch_hud/mus/DEPS → ash/components/touch_hud/DEPS
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
include_rules = [
"-ash",
"+ash/public",
"+ash/touch_hud",
"+base",
"+mash/public/mojom",
"+mojo/public",
"+services/service_manager/public",
"+services/ui/public",
"+ui/aura",
"+ui/views",
]
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/touch_hud/mus/touch_hud_application.h"
#include "ash/components/touch_hud/touch_hud_application.h"
#include "services/service_manager/public/c/main.h"
#include "services/service_manager/public/cpp/service_runner.h"

MojoResult ServiceMain(MojoHandle service_request_handle) {
ash::touch_hud::TouchHudApplication* app =
new ash::touch_hud::TouchHudApplication;
touch_hud::TouchHudApplication* app = new touch_hud::TouchHudApplication;
app->set_running_standalone(true);
service_manager::ServiceRunner runner(app);
return runner.Run(service_request_handle);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "touch_hud",
"name": "touch_hud_app",
"display_name": "Touch Hud",
"sandbox_type": "none",
"interface_provider_specs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/touch_hud/mus/touch_hud_application.h"
#include "ash/components/touch_hud/touch_hud_application.h"

#include <utility>

#include "ash/public/cpp/shell_window_ids.h"
#include "ash/touch_hud/touch_hud_renderer.h"
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service_context.h"
Expand All @@ -23,7 +22,6 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

namespace ash {
namespace touch_hud {

// TouchHudUI handles events on the widget of the touch-hud app. After
Expand All @@ -33,7 +31,7 @@ class TouchHudUI : public views::WidgetDelegateView,
public views::PointerWatcher {
public:
explicit TouchHudUI(views::Widget* widget)
: touch_hud_renderer_(new TouchHudRenderer(widget)) {
: touch_hud_renderer_(new ash::TouchHudRenderer(widget)) {
views::MusClient::Get()->pointer_watcher_event_router()->AddPointerWatcher(
this, true /* want_moves */);
}
Expand All @@ -58,14 +56,15 @@ class TouchHudUI : public views::WidgetDelegateView,
touch_hud_renderer_->HandleTouchEvent(event);
}

TouchHudRenderer* touch_hud_renderer_;
// TODO(jamescook): Don't leak this.
ash::TouchHudRenderer* touch_hud_renderer_;

DISALLOW_COPY_AND_ASSIGN(TouchHudUI);
};

TouchHudApplication::TouchHudApplication() : binding_(this) {
registry_.AddInterface<mash::mojom::Launchable>(
base::Bind(&TouchHudApplication::Create, base::Unretained(this)));
registry_.AddInterface<mash::mojom::Launchable>(base::BindRepeating(
&TouchHudApplication::Create, base::Unretained(this)));
}
TouchHudApplication::~TouchHudApplication() = default;

Expand Down Expand Up @@ -103,15 +102,13 @@ void TouchHudApplication::Launch(uint32_t what, mash::mojom::LaunchMode how) {
widget_->Show();
} else {
widget_->Close();
base::RunLoop::QuitCurrentWhenIdleDeprecated();
context()->QuitNow();
}
}

void TouchHudApplication::Create(
mash::mojom::LaunchableRequest request) {
void TouchHudApplication::Create(mash::mojom::LaunchableRequest request) {
binding_.Close();
binding_.Bind(std::move(request));
}

} // namespace touch_hud
} // namespace ash
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_TOUCH_HUD_MUS_TOUCH_HUD_APPLICATION_H_
#define ASH_TOUCH_HUD_MUS_TOUCH_HUD_APPLICATION_H_

#include <map>
#ifndef ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_APPLICATION_H_
#define ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_APPLICATION_H_

#include "base/macros.h"
#include "mash/public/mojom/launchable.mojom.h"
Expand All @@ -16,9 +14,8 @@
namespace views {
class AuraInit;
class Widget;
}
} // namespace views

namespace ash {
namespace touch_hud {

class TouchHudApplication : public service_manager::Service,
Expand Down Expand Up @@ -53,6 +50,5 @@ class TouchHudApplication : public service_manager::Service,
};

} // namespace touch_hud
} // namespace ash

#endif // ASH_TOUCH_HUD_MUS_TOUCH_HUD_APPLICATION_H_
#endif // ASH_COMPONENTS_TOUCH_HUD_TOUCH_HUD_APPLICATION_H_
2 changes: 1 addition & 1 deletion ash/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"catalog": [ "directory" ],
"local_state": [ "pref_client" ],
"ui": [ "display_dev", "window_manager", "video_detector" ],
"touch_hud": [ "mash:launchable" ],
"touch_hud_app": [ "mash:launchable" ],
"data_decoder": [ "image_decoder" ]
}
}
Expand Down
2 changes: 1 addition & 1 deletion ash/shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ void Shell::Init(ui::ContextFactory* context_factory,
if (config == Config::MASH && shell_delegate_->GetShellConnector() &&
base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowTaps)) {
mash::mojom::LaunchablePtr launchable;
shell_delegate_->GetShellConnector()->BindInterface("touch_hud",
shell_delegate_->GetShellConnector()->BindInterface("touch_hud_app",
&launchable);
launchable->Launch(mash::mojom::kWindow, mash::mojom::LaunchMode::DEFAULT);
}
Expand Down
2 changes: 1 addition & 1 deletion ash/standalone/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"*": [ "accessibility", "app" ],
"preferences_forwarder": [ "pref_client" ],
"ui": [ "display_dev", "window_manager" ],
"touch_hud": [ "mash:launchable" ]
"touch_hud_app": [ "mash:launchable" ]
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ service_manifest("chrome_content_packaged_services_manifest_overlay") {
packaged_services += [
"//ash/components/autoclick:manifest",
"//ash/components/quick_launch:manifest",
"//ash/components/touch_hud:manifest",
"//ash:manifest",
"//ash/touch_hud/mus:manifest",
"//components/font_service:manifest",
]
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/mash_service_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ constexpr Service kServices[] = {
{ash::mojom::kServiceName, "Ash Window Manager and Shell",
kAshAndUiProcessGroup},
{"autoclick_app", "Accessibility Autoclick", nullptr},
{"touch_hud", "Ash Touch Hud", nullptr},
{"touch_hud_app", "Touch HUD", nullptr},
{font_service::mojom::kServiceName, "Font Service", nullptr},
};

Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static_library("utility") {
"//ash/components/autoclick:lib",
"//ash/components/quick_launch:lib",
"//ash/components/quick_launch/public/mojom",
"//ash/touch_hud/mus:lib",
"//ash/components/touch_hud:lib",
"//chrome/services/file_util:lib",
"//components/font_service:lib",
"//components/font_service/public/interfaces",
Expand Down
2 changes: 1 addition & 1 deletion chrome/utility/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ specific_include_rules = {
"+ash/components/autoclick/autoclick_application.h",
"+ash/components/quick_launch/public",
"+ash/components/quick_launch/quick_launch.h",
"+ash/components/touch_hud/touch_hud_application.h",
"+ash/public/interfaces",
"+ash/touch_hud/mus/touch_hud_application.h",
"+ash/window_manager_service.h",
"+components/font_service/font_service_app.h",
"+components/font_service/public/interfaces",
Expand Down
8 changes: 4 additions & 4 deletions chrome/utility/mash_service_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "ash/components/autoclick/autoclick_application.h"
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/quick_launch/quick_launch.h"
#include "ash/components/touch_hud/touch_hud_application.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/touch_hud/mus/touch_hud_application.h"
#include "ash/window_manager_service.h"
#include "base/bind.h"
#include "build/build_config.h"
Expand Down Expand Up @@ -75,8 +75,8 @@ std::unique_ptr<service_manager::Service> CreateQuickLaunch() {
return std::make_unique<quick_launch::QuickLaunch>();
}

std::unique_ptr<service_manager::Service> CreateTouchHud() {
return std::make_unique<ash::touch_hud::TouchHudApplication>();
std::unique_ptr<service_manager::Service> CreateTouchHudApp() {
return std::make_unique<touch_hud::TouchHudApplication>();
}

std::unique_ptr<service_manager::Service> CreateFontService() {
Expand All @@ -97,7 +97,7 @@ void MashServiceFactory::RegisterOutOfProcessServices(
&CreateQuickLaunch);
RegisterMashService(services, ash::mojom::kServiceName, &CreateAshService);
RegisterMashService(services, "autoclick_app", &CreateAutoclickApp);
RegisterMashService(services, "touch_hud", &CreateTouchHud);
RegisterMashService(services, "touch_hud_app", &CreateTouchHudApp);
RegisterMashService(services, font_service::mojom::kServiceName,
&CreateFontService);
}
2 changes: 1 addition & 1 deletion mash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ group("all") {
deps += [
"//ash/components/autoclick:autoclick_app",
"//ash/components/quick_launch",
"//ash/components/touch_hud:touch_hud_app",
"//ash/standalone:ash_standalone",
"//ash/touch_hud/mus:touch_hud",
"//mash:mash_unittests",
]
}
Expand Down

0 comments on commit 2268bef

Please sign in to comment.