0

Gets ash_shell_with_content bringing up WindowService as a library

This patch makes Ash, when run with ash_shell_with_content, start the
WindowService. It also forces quick_launch to start to make sure
something can be displayed. Lastly, I moved what was
EmbeddedAshService to ash. I would like to make ash create this as
well.

BUG=837689
TEST=most of this change doesn't effect production code

Change-Id: Ia9f651b16a94d5db07dd5dc17e0619c442685597
Reviewed-on: https://chromium-review.googlesource.com/1043392
Reviewed-by: James Cook <jamescook@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556094}
This commit is contained in:
Scott Violet
2018-05-04 17:12:18 +00:00
committed by Commit Bot
parent 86dafb9088
commit 7eb50d2e3e
28 changed files with 491 additions and 57 deletions

@ -93,6 +93,8 @@ component("ash") {
"ash_export.h",
"ash_layout_constants.cc",
"ash_layout_constants.h",
"ash_service.cc",
"ash_service.h",
"ash_view_ids.h",
"assistant/ash_assistant_controller.cc",
"assistant/ash_assistant_controller.h",
@ -1178,6 +1180,8 @@ component("ash") {
"wm/workspace/workspace_window_resizer.h",
"wm/workspace_controller.cc",
"wm/workspace_controller.h",
"ws/window_service_delegate_impl.cc",
"ws/window_service_delegate_impl.h",
]
configs += [ "//build/config:precompiled_headers" ]
@ -1190,13 +1194,16 @@ component("ash") {
"//ash/resources/vector_icons",
"//ash/strings",
"//ash/wayland",
"//components/discardable_memory/public/interfaces",
"//mash/public/mojom",
"//mojo/public/cpp/system",
"//services/service_manager/embedder",
"//services/ui/common:mus_common",
"//services/ui/public/cpp",
"//services/ui/public/cpp/input_devices",
"//services/ui/public/interfaces",
"//services/ui/public/interfaces/display",
"//services/ui/ws2:lib",
"//skia",
"//ui/aura",
"//ui/events",
@ -1313,6 +1320,8 @@ component("ash") {
component("ash_with_content") {
sources = [
"content/ash_with_content_export.h",
"content/content_gpu_support.cc",
"content/content_gpu_support.h",
"content/keyboard_overlay/keyboard_overlay_delegate.cc",
"content/keyboard_overlay/keyboard_overlay_delegate.h",
"content/keyboard_overlay/keyboard_overlay_view.cc",
@ -1332,6 +1341,7 @@ component("ash_with_content") {
"//ash/public/cpp",
"//base",
"//base/third_party/dynamic_annotations",
"//components/discardable_memory/public/interfaces",
"//content/public/browser",
"//gpu/config",
"//ipc",
@ -1425,14 +1435,21 @@ static_library("ash_shell_lib_with_content") {
":ash_with_content",
":test_support_without_content",
"//ash/app_list/presenter:test_support",
"//ash/components/quick_launch:lib",
"//ash/components/quick_launch/public/mojom",
"//ash/public/cpp",
"//ash/shell:resources",
"//base:i18n",
"//chrome:packed_resources",
"//chromeos",
"//components/discardable_memory/public/interfaces",
"//components/services/font:lib",
"//components/services/font/public/interfaces",
"//content",
"//content/shell:content_shell_lib",
"//device/bluetooth",
"//net",
"//services/ui/ws2:lib",
"//skia",
"//ui/aura",
"//ui/base",

@ -25,9 +25,11 @@ include_rules = [
"+mojo/public",
"+services/catalog/public",
"+services/preferences/public",
"+services/service_manager/embedder",
"+services/service_manager/public",
"+services/ui/common",
"+services/ui/public",
"+services/ui/ws2",
"+services/viz/public",
"+skia/ext",
"+third_party/cros_system_api",

44
ash/ash_service.cc Normal file

@ -0,0 +1,44 @@
// 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 "ash/ash_service.h"
#include "ash/mojo_interface_factory.h"
#include "base/threading/thread_task_runner_handle.h"
#include "services/service_manager/embedder/embedded_service_info.h"
namespace ash {
namespace {
std::unique_ptr<service_manager::Service> CreateAshService() {
return std::make_unique<AshService>();
}
} // namespace
AshService::AshService() = default;
AshService::~AshService() = default;
// static
service_manager::EmbeddedServiceInfo AshService::CreateEmbeddedServiceInfo() {
service_manager::EmbeddedServiceInfo info;
info.factory = base::BindRepeating(&CreateAshService);
info.task_runner = base::ThreadTaskRunnerHandle::Get();
return info;
}
void AshService::OnStart() {
mojo_interface_factory::RegisterInterfaces(
&registry_, base::ThreadTaskRunnerHandle::Get());
}
void AshService::OnBindInterface(
const service_manager::BindSourceInfo& remote_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle handle) {
registry_.BindInterface(interface_name, std::move(handle));
}
} // namespace ash

43
ash/ash_service.h Normal file

@ -0,0 +1,43 @@
// 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 ASH_ASH_SERVICE_H_
#define ASH_ASH_SERVICE_H_
#include "ash/ash_export.h"
#include "base/macros.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
namespace service_manager {
struct EmbeddedServiceInfo;
}
namespace ash {
// Used to export Ash's mojo services. Specifically the interfaces defined in
// Ash's manifest.json.
class ASH_EXPORT AshService : public service_manager::Service {
public:
AshService();
~AshService() override;
// Returns an appropriate EmbeddedServiceInfo that creates AshService.
static service_manager::EmbeddedServiceInfo CreateEmbeddedServiceInfo();
// service_manager::Service:
void OnStart() override;
void OnBindInterface(const service_manager::BindSourceInfo& remote_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle handle) override;
private:
service_manager::BinderRegistry registry_;
DISALLOW_COPY_AND_ASSIGN(AshService);
};
} // namespace ash
#endif // ASH_ASH_SERVICE_H_

@ -1,4 +1,7 @@
specific_include_rules = {
"content_gpu_support.*": [
"+content/public/browser",
],
"screen_orientation_delegate_chromeos.cc": [
"+content/public/browser/screen_orientation_provider.h",
"+content/public/browser/web_contents.h",

@ -0,0 +1,44 @@
// 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 "ash/content/content_gpu_support.h"
#include "base/containers/unique_ptr_adapters.h"
#include "content/public/browser/gpu_client.h"
#include "content/public/browser/gpu_service_registry.h"
namespace ash {
ContentGpuSupport::ContentGpuSupport() = default;
ContentGpuSupport::~ContentGpuSupport() = default;
scoped_refptr<base::SingleThreadTaskRunner>
ContentGpuSupport::GetGpuTaskRunner() {
return content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO);
}
void ContentGpuSupport::BindDiscardableSharedMemoryManagerOnGpuTaskRunner(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request) {
content::BindInterfaceInGpuProcess(std::move(request));
}
void ContentGpuSupport::BindGpuRequestOnGpuTaskRunner(
ui::mojom::GpuRequest request) {
auto gpu_client = content::GpuClient::Create(
std::move(request),
base::BindOnce(&ContentGpuSupport::OnGpuClientConnectionError,
base::Unretained(this)));
gpu_clients_.push_back(std::move(gpu_client));
}
void ContentGpuSupport::OnGpuClientConnectionError(content::GpuClient* client) {
base::EraseIf(
gpu_clients_,
base::UniquePtrMatcher<content::GpuClient,
content::BrowserThread::DeleteOnIOThread>(client));
}
} // namespace ash

@ -0,0 +1,48 @@
// 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 ASH_CONTENT_CONTENT_GPU_SUPPORT_H_
#define ASH_CONTENT_CONTENT_GPU_SUPPORT_H_
#include <memory>
#include <vector>
#include "ash/content/ash_with_content_export.h"
#include "base/macros.h"
#include "content/public/browser/browser_thread.h"
#include "services/ui/ws2/gpu_support.h"
namespace content {
class GpuClient;
}
namespace ash {
// An implementation of GpuSupport that forwards to the Gpu implementation in
// content.
class ASH_WITH_CONTENT_EXPORT ContentGpuSupport : public ui::ws2::GpuSupport {
public:
ContentGpuSupport();
~ContentGpuSupport() override;
// ui::ws2::GpuSupport:
scoped_refptr<base::SingleThreadTaskRunner> GetGpuTaskRunner() override;
void BindDiscardableSharedMemoryManagerOnGpuTaskRunner(
discardable_memory::mojom::DiscardableSharedMemoryManagerRequest request)
override;
void BindGpuRequestOnGpuTaskRunner(ui::mojom::GpuRequest request) override;
private:
void OnGpuClientConnectionError(content::GpuClient* client);
std::vector<std::unique_ptr<content::GpuClient,
content::BrowserThread::DeleteOnIOThread>>
gpu_clients_;
DISALLOW_COPY_AND_ASSIGN(ContentGpuSupport);
};
} // namespace ash
#endif // ASH_CONTENT_CONTENT_GPU_SUPPORT_H_

@ -85,9 +85,11 @@ ash_test_resources("200_percent") {
ash_test_resources("with_content_100_percent") {
percent = "100"
sources = [
"$root_gen_dir/ash/shell/ash_shell_resources.pak",
"$root_gen_dir/content/content_resources.pak",
]
deps = [
"//ash/shell:resources",
"//content:resources",
]
}

@ -150,6 +150,7 @@
#include "ash/wm/window_util.h"
#include "ash/wm/wm_shadow_controller_delegate.h"
#include "ash/wm/workspace_controller.h"
#include "ash/ws/window_service_delegate_impl.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
@ -699,6 +700,7 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate,
vpn_list_(std::make_unique<VpnList>()),
window_cycle_controller_(std::make_unique<WindowCycleController>()),
window_selector_controller_(std::make_unique<WindowSelectorController>()),
window_service_delegate_(std::make_unique<WindowServiceDelegateImpl>()),
tray_bluetooth_helper_(std::make_unique<TrayBluetoothHelper>()),
display_configurator_(new display::DisplayConfigurator()),
native_cursor_manager_(nullptr),

@ -185,6 +185,7 @@ class WebNotificationTray;
class WindowCycleController;
class WindowPositioner;
class WindowSelectorController;
class WindowServiceDelegateImpl;
class WindowTreeHostManager;
enum class Config;
@ -536,6 +537,9 @@ class ASH_EXPORT Shell : public SessionObserver,
WindowSelectorController* window_selector_controller() {
return window_selector_controller_.get();
}
WindowServiceDelegateImpl* window_service_delegate() {
return window_service_delegate_.get();
}
WindowTreeHostManager* window_tree_host_manager() {
return window_tree_host_manager_.get();
}
@ -755,6 +759,7 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<WallpaperController> wallpaper_controller_;
std::unique_ptr<WindowCycleController> window_cycle_controller_;
std::unique_ptr<WindowSelectorController> window_selector_controller_;
std::unique_ptr<WindowServiceDelegateImpl> window_service_delegate_;
std::unique_ptr<::wm::ShadowController> shadow_controller_;
std::unique_ptr<::wm::VisibilityController> visibility_controller_;
std::unique_ptr<::wm::WindowModalityController> window_modality_controller_;

33
ash/shell/BUILD.gn Normal file

@ -0,0 +1,33 @@
# 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("//services/service_manager/public/service_manifest.gni")
import("//tools/grit/grit_rule.gni")
assert(is_chromeos)
grit("resources") {
source = "ash_shell_resources.grd"
outputs = [
"grit/ash_shell_resources.h",
"ash_shell_resources.pak",
]
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
]
deps = [
":ash_content_packaged_services_manifest_overlay",
]
}
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",
"//components/services/font:manifest",
"//services/ui:manifest",
]
}

@ -1 +1,4 @@
per-file *app_list*=xiyuan@chromium.org
per-file ash_content_packaged_services_manifest_overlay.json=set noparent
per-file ash_content_packaged_services_manifest_overlay.json=file://ipc/SECURITY_OWNERS

@ -0,0 +1,5 @@
{
"name": "content_packaged_services",
"display_name": "Ash Packaged Services",
"interface_provider_specs": {}
}

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<grit latest_public_release="0" current_release="1" output_all_resource_defines="false">
<outputs>
<output filename="grit/ash_shell_resources.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="ash_shell_resources.pak" type="data_package" />
</outputs>
<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_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>
</release>
</grit>

@ -1,4 +1,7 @@
include_rules = [
"+ash/components/quick_launch",
"+components/discardable_memory/public/interfaces",
"+components/services/font",
"+content/public",
"+content/shell",
"+storage/browser/quota",

@ -7,6 +7,7 @@
#include <memory>
#include <utility>
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/content/shell_content_state.h"
#include "ash/login_status.h"
#include "ash/shell.h"
@ -27,13 +28,16 @@
#include "base/threading/thread_restrictions.h"
#include "chromeos/audio/cras_audio_handler.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_policy_controller.h"
#include "components/exo/file_helper.h"
#include "content/public/browser/context_factory.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/service_manager_connection.h"
#include "content/shell/browser/shell_browser_context.h"
#include "content/shell/browser/shell_net_log.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "net/base/net_module.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
@ -76,6 +80,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
bluez::BluezDBusManager::Initialize(nullptr, true /* use stub */);
chromeos::PowerPolicyController::Initialize(
chromeos::DBusThreadManager::Get()->GetPowerManagerClient());
ShellContentState::SetInstance(
new ShellContentStateImpl(browser_context_.get()));
ui::MaterialDesignController::Initialize();
@ -102,6 +109,9 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
ash::Shell::GetPrimaryRootWindow()->GetHost()->Show();
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->StartService(quick_launch::mojom::kServiceName);
ash::Shell::Get()->InitWaylandServer(nullptr);
}
@ -112,6 +122,8 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() {
chromeos::CrasAudioHandler::Shutdown();
chromeos::PowerPolicyController::Shutdown();
views_delegate_.reset();
// The keyboard may have created a WebContents. The WebContents is destroyed

@ -6,15 +6,44 @@
#include <utility>
#include "ash/ash_service.h"
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/content/content_gpu_support.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "ash/shell.h"
#include "ash/shell/content/client/shell_browser_main_parts.h"
#include "ash/shell/grit/ash_shell_resources.h"
#include "ash/ws/window_service_delegate_impl.h"
#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/services/font/public/interfaces/constants.mojom.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/service_names.mojom.h"
#include "content/public/utility/content_utility_client.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "services/ui/ws2/window_service.h"
#include "services/ui/ws2/window_service_delegate.h"
#include "storage/browser/quota/quota_settings.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_features.h"
namespace ash {
namespace shell {
namespace {
std::unique_ptr<service_manager::Service> CreateWindowService() {
return std::make_unique<ui::ws2::WindowService>(
Shell::Get()->window_service_delegate(),
std::make_unique<ContentGpuSupport>());
}
} // namespace
ShellContentBrowserClient::ShellContentBrowserClient()
: shell_browser_main_parts_(nullptr) {}
@ -35,5 +64,54 @@ void ShellContentBrowserClient::GetQuotaSettings(
partition->GetPath(), context->IsOffTheRecord(), std::move(callback));
}
} // namespace examples
} // namespace views
std::unique_ptr<base::Value>
ShellContentBrowserClient::GetServiceManifestOverlay(base::StringPiece name) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (name != content::mojom::kPackagedServicesServiceName)
return nullptr;
base::StringPiece manifest_contents = rb.GetRawDataResourceForScale(
IDR_ASH_SHELL_CONTENT_PACKAGED_SERVICES_MANIFEST_OVERLAY,
ui::ScaleFactor::SCALE_FACTOR_NONE);
return base::JSONReader::Read(manifest_contents);
}
std::vector<content::ContentBrowserClient::ServiceManifestInfo>
ShellContentBrowserClient::GetExtraServiceManifests() {
return {
{quick_launch::mojom::kServiceName, IDR_ASH_SHELL_QUICK_LAUNCH_MANIFEST},
{font_service::mojom::kServiceName, IDR_ASH_SHELL_FONT_SERVICE_MANIFEST}};
}
void ShellContentBrowserClient::RegisterOutOfProcessServices(
OutOfProcessServiceMap* services) {
(*services)[quick_launch::mojom::kServiceName] = OutOfProcessServiceInfo(
base::ASCIIToUTF16(quick_launch::mojom::kServiceName));
(*services)[font_service::mojom::kServiceName] = OutOfProcessServiceInfo(
base::ASCIIToUTF16(font_service::mojom::kServiceName));
}
void ShellContentBrowserClient::RegisterInProcessServices(
StaticServiceMap* services) {
services->insert(std::make_pair(ash::mojom::kServiceName,
AshService::CreateEmbeddedServiceInfo()));
service_manager::EmbeddedServiceInfo ws_service_info;
ws_service_info.factory = base::BindRepeating(&CreateWindowService);
ws_service_info.task_runner = base::ThreadTaskRunnerHandle::Get();
services->insert(std::make_pair(ui::mojom::kServiceName, ws_service_info));
}
void ShellContentBrowserClient::AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) {
if (identity.name() == quick_launch::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,
features::kMash.name);
}
}
} // namespace shell
} // namespace ash

@ -32,6 +32,14 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
content::BrowserContext* context,
content::StoragePartition* partition,
storage::OptionalQuotaSettingsCallback callback) override;
std::unique_ptr<base::Value> GetServiceManifestOverlay(
base::StringPiece name) override;
std::vector<ServiceManifestInfo> GetExtraServiceManifests() override;
void RegisterOutOfProcessServices(OutOfProcessServiceMap* services) override;
void RegisterInProcessServices(StaticServiceMap* services) override;
void AdjustUtilityServiceProcessCommandLine(
const service_manager::Identity& identity,
base::CommandLine* command_line) override;
private:
ShellBrowserMainParts* shell_browser_main_parts_;

@ -4,16 +4,56 @@
#include "ash/shell/content/client/shell_main_delegate.h"
#include "ash/components/quick_launch/public/mojom/constants.mojom.h"
#include "ash/components/quick_launch/quick_launch_application.h"
#include "ash/shell/content/client/shell_content_browser_client.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "components/services/font/font_service_app.h"
#include "components/services/font/public/interfaces/constants.mojom.h"
#include "content/public/common/content_switches.h"
#include "content/public/utility/content_utility_client.h"
#include "services/service_manager/public/cpp/service.h"
#include "ui/base/ime/input_method_initializer.h"
#include "ui/base/resource/resource_bundle.h"
namespace ash {
namespace shell {
namespace {
std::unique_ptr<service_manager::Service> CreateQuickLaunch() {
return std::make_unique<quick_launch::QuickLaunchApplication>();
}
std::unique_ptr<service_manager::Service> CreateFontService() {
return std::make_unique<font_service::FontServiceApp>();
}
class ShellContentUtilityClient : public content::ContentUtilityClient {
public:
ShellContentUtilityClient() = default;
~ShellContentUtilityClient() override = default;
// ContentUtilityClient:
void RegisterServices(StaticServiceMap* services) override {
{
service_manager::EmbeddedServiceInfo info;
info.factory = base::BindRepeating(&CreateQuickLaunch);
(*services)[quick_launch::mojom::kServiceName] = info;
}
{
service_manager::EmbeddedServiceInfo info;
info.factory = base::BindRepeating(&CreateFontService);
(*services)[font_service::mojom::kServiceName] = info;
}
}
private:
DISALLOW_COPY_AND_ASSIGN(ShellContentUtilityClient);
};
} // namespace
ShellMainDelegate::ShellMainDelegate() = default;
@ -61,5 +101,10 @@ void ShellMainDelegate::InitializeResourceBundle() {
}
}
content::ContentUtilityClient* ShellMainDelegate::CreateContentUtilityClient() {
utility_client_ = std::make_unique<ShellContentUtilityClient>();
return utility_client_.get();
}
} // namespace shell
} // namespace ash

@ -25,12 +25,14 @@ class ShellMainDelegate : public content::ContentMainDelegate {
bool BasicStartupComplete(int* exit_code) override;
void PreSandboxStartup() override;
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
private:
void InitializeResourceBundle();
std::unique_ptr<ShellContentBrowserClient> browser_client_;
content::ShellContentClient content_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_;
DISALLOW_COPY_AND_ASSIGN(ShellMainDelegate);
};

@ -0,0 +1,27 @@
// 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 "ash/ws/window_service_delegate_impl.h"
#include "ash/wm/container_finder.h"
#include "ui/aura/window.h"
namespace ash {
WindowServiceDelegateImpl::WindowServiceDelegateImpl() = default;
WindowServiceDelegateImpl::~WindowServiceDelegateImpl() = default;
std::unique_ptr<aura::Window> WindowServiceDelegateImpl::NewTopLevel(
const base::flat_map<std::string, std::vector<uint8_t>>& properties) {
// TODO: this needs to call CreateAndParentTopLevelWindow();
std::unique_ptr<aura::Window> window =
std::make_unique<aura::Window>(nullptr);
window->SetType(aura::client::WINDOW_TYPE_NORMAL);
window->Init(ui::LAYER_NOT_DRAWN);
ash::wm::GetDefaultParent(window.get(), gfx::Rect())->AddChild(window.get());
return window;
}
} // namespace ash

@ -0,0 +1,30 @@
// 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 ASH_WS_WINDOW_SERVICE_DELEGATE_IMPL_H_
#define ASH_WS_WINDOW_SERVICE_DELEGATE_IMPL_H_
#include <memory>
#include "services/ui/ws2/window_service_delegate.h"
namespace ash {
class WindowServiceDelegateImpl : public ui::ws2::WindowServiceDelegate {
public:
WindowServiceDelegateImpl();
~WindowServiceDelegateImpl() override;
// ui::ws2::WindowServiceDelegate:
std::unique_ptr<aura::Window> NewTopLevel(
const base::flat_map<std::string, std::vector<uint8_t>>& properties)
override;
private:
DISALLOW_COPY_AND_ASSIGN(WindowServiceDelegateImpl);
};
} // namespace ash
#endif // ASH_WS_WINDOW_SERVICE_DELEGATE_IMPL_H_

@ -209,6 +209,10 @@ include_rules = [
]
specific_include_rules = {
"browser_process_platform_part_chromeos\.cc": [
# AshService is necessary while Ash runs in process.
"+ash/ash_service.h",
],
# TODO(mash): see bugs 768439 and 768395.
"exo_parts\.cc": [
"+ash/shell.h",

@ -6,6 +6,7 @@
#include <utility>
#include "ash/ash_service.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/logging.h"
#include "base/time/default_tick_clock.h"
@ -193,11 +194,9 @@ void BrowserProcessPlatformPart::RegisterInProcessServices(
}
if (!ash_util::IsRunningInMash()) {
service_manager::EmbeddedServiceInfo info;
info.factory = base::Bind(&ash_util::CreateEmbeddedAshService,
base::ThreadTaskRunnerHandle::Get());
info.task_runner = base::ThreadTaskRunnerHandle::Get();
services->insert(std::make_pair(ash::mojom::kServiceName, info));
services->insert(
std::make_pair(ash::mojom::kServiceName,
ash::AshService::CreateEmbeddedServiceInfo()));
}
}

@ -5,7 +5,6 @@
#include "chrome/browser/ui/ash/ash_util.h"
#include "ash/accelerators/accelerator_controller.h"
#include "ash/mojo_interface_factory.h"
#include "ash/public/cpp/config.h"
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/interfaces/event_properties.mojom.h"
@ -13,9 +12,6 @@
#include "base/macros.h"
#include "chrome/browser/chromeos/ash_config.h"
#include "mojo/public/cpp/bindings/type_converter.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/mojom/interface_provider_spec.mojom.h"
#include "services/ui/public/cpp/property_type_converters.h"
#include "services/ui/public/interfaces/window_manager.mojom.h"
#include "ui/aura/window_event_dispatcher.h"
@ -24,40 +20,6 @@
namespace ash_util {
namespace {
class EmbeddedAshService : public service_manager::Service {
public:
explicit EmbeddedAshService(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: task_runner_(task_runner) {}
~EmbeddedAshService() override {}
// service_manager::Service:
void OnStart() override {
ash::mojo_interface_factory::RegisterInterfaces(&interfaces_, task_runner_);
}
void OnBindInterface(const service_manager::BindSourceInfo& remote_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle handle) override {
interfaces_.BindInterface(interface_name, std::move(handle));
}
private:
const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
service_manager::BinderRegistry interfaces_;
DISALLOW_COPY_AND_ASSIGN(EmbeddedAshService);
};
} // namespace
std::unique_ptr<service_manager::Service> CreateEmbeddedAshService(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) {
return std::make_unique<EmbeddedAshService>(task_runner);
}
bool ShouldOpenAshOnStartup() {
return !IsRunningInMash();
}

@ -8,14 +8,8 @@
#include <memory>
#include "ash/public/cpp/config.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
#include "ui/views/widget/widget.h"
namespace service_manager {
class Service;
}
namespace ui {
class Accelerator;
class KeyEvent;
@ -23,11 +17,6 @@ class KeyEvent;
namespace ash_util {
// Creates an in-process Service instance of which can host common ash
// interfaces.
std::unique_ptr<service_manager::Service> CreateEmbeddedAshService(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
// Returns true if Ash should be run at startup.
bool ShouldOpenAshOnStartup();

@ -296,7 +296,9 @@
"ash/resources/ash_resources.grd": {
"structures": [24280],
},
"ash/shell/ash_shell_resources.grd": {
"includes": [24290],
},
"chromecast/browser/cast_browser_resources.grd": {
"includes": [24300],
},

@ -178,6 +178,12 @@ Env::Env(Mode mode, bool create_mouse_location_manager)
context_factory_private_(nullptr) {
DCHECK(lazy_tls_ptr.Pointer()->Get() == NULL);
lazy_tls_ptr.Pointer()->Set(this);
#if defined(OS_CHROMEOS)
// TODO(sky): this isn't quite right. Really the MouseLocationManager should
// be created only when this process is hosting the WindowService. Clean this
// up.
create_mouse_location_manager = true;
#endif
if (create_mouse_location_manager)
mouse_location_manager_ = std::make_unique<MouseLocationManager>();
}