Commit af67b64d authored by Quan Nguyen's avatar Quan Nguyen Committed by Commit Bot

cros: Add skeleton for ContainedShell feature

This CL includes a new Mojo service for controlling the
ContainedShell, as well as a feature flag for enabling it.

Bug: 902571
Change-Id: I645643270a5e595a0cadb6f781f400d700ae3bed
Reviewed-on: https://chromium-review.googlesource.com/c/1323718
Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612304}
parent a31a68fa
...@@ -262,6 +262,8 @@ component("ash") { ...@@ -262,6 +262,8 @@ component("ash") {
"cancel_mode.h", "cancel_mode.h",
"cast_config_controller.cc", "cast_config_controller.cc",
"cast_config_controller.h", "cast_config_controller.h",
"contained_shell/contained_shell_controller.cc",
"contained_shell/contained_shell_controller.h",
"dbus/ash_dbus_services.cc", "dbus/ash_dbus_services.cc",
"dbus/ash_dbus_services.h", "dbus/ash_dbus_services.h",
"dbus/display_service_provider.cc", "dbus/display_service_provider.cc",
...@@ -1636,6 +1638,8 @@ test("ash_unittests") { ...@@ -1636,6 +1638,8 @@ test("ash_unittests") {
"assistant/util/deep_link_util_unittest.cc", "assistant/util/deep_link_util_unittest.cc",
"autoclick/autoclick_drag_event_rewriter_unittest.cc", "autoclick/autoclick_drag_event_rewriter_unittest.cc",
"autoclick/autoclick_unittest.cc", "autoclick/autoclick_unittest.cc",
"contained_shell/mock_contained_shell_client.cc",
"contained_shell/mock_contained_shell_client.h",
"cursor_unittest.cc", "cursor_unittest.cc",
"detachable_base/detachable_base_handler_unittest.cc", "detachable_base/detachable_base_handler_unittest.cc",
"detachable_base/detachable_base_notification_controller_unittest.cc", "detachable_base/detachable_base_notification_controller_unittest.cc",
......
qnnguyen@chromium.org
michaelpg@chromium.org
jdufault@chromium.org
// 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/contained_shell/contained_shell_controller.h"
#include <utility>
namespace ash {
ContainedShellController::ContainedShellController() = default;
ContainedShellController::~ContainedShellController() = default;
void ContainedShellController::BindRequest(
mojom::ContainedShellControllerRequest request) {
bindings_.AddBinding(this, std::move(request));
}
void ContainedShellController::LaunchContainedShell() {
// TODO(crbug/902571): Implement launch by dispatching to a
// ContainedShellClient method.
NOTIMPLEMENTED();
}
void ContainedShellController::SetClient(
mojom::ContainedShellClientPtr client) {
contained_shell_client_ = std::move(client);
}
} // namespace ash
// 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_CONTAINED_SHELL_CONTAINED_SHELL_CONTROLLER_H_
#define ASH_CONTAINED_SHELL_CONTAINED_SHELL_CONTROLLER_H_
#include "ash/ash_export.h"
#include "ash/public/interfaces/contained_shell.mojom.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding_set.h"
namespace ash {
// ContainedShellController allows a consumer of ash to provide a
// ContainedShellClient, to which we dispatch requests.
// TODO(910226): remove this code once the ContainedShell demo is complete and
// no longer needed.
class ASH_EXPORT ContainedShellController
: public mojom::ContainedShellController {
public:
ContainedShellController();
~ContainedShellController() override;
// Binds the mojom::ContainedShellController interface to this object.
void BindRequest(mojom::ContainedShellControllerRequest request);
// Starts the ContainedShell feature by sending LaunchContainedShell
// request to ContainedShellClient.
void LaunchContainedShell();
// mojom::ContainedShellController:
void SetClient(mojom::ContainedShellClientPtr client) override;
private:
mojom::ContainedShellClientPtr contained_shell_client_;
mojo::BindingSet<mojom::ContainedShellController> bindings_;
DISALLOW_COPY_AND_ASSIGN(ContainedShellController);
};
} // namespace ash
#endif // ASH_CONTAINED_SHELL_CONTAINED_SHELL_CONTROLLER_H
// 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/contained_shell/mock_contained_shell_client.h"
#include "ash/contained_shell/contained_shell_controller.h"
#include "ash/shell.h"
namespace ash {
MockContainedShellClient::MockContainedShellClient() = default;
MockContainedShellClient::~MockContainedShellClient() = default;
mojom::ContainedShellClientPtr
MockContainedShellClient::CreateInterfacePtrAndBind() {
mojom::ContainedShellClientPtr ptr;
binding_.Bind(mojo::MakeRequest(&ptr));
return ptr;
}
std::unique_ptr<MockContainedShellClient> BindMockContainedShellClient() {
auto client = std::make_unique<MockContainedShellClient>();
Shell::Get()->contained_shell_controller()->SetClient(
client->CreateInterfacePtrAndBind());
return client;
}
} // namespace ash
// 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_CONTAINED_SHELL_MOCK_CONTAINED_SHELL_CLIENT_H_
#define ASH_CONTAINED_SHELL_MOCK_CONTAINED_SHELL_CLIENT_H_
#include <memory>
#include "ash/public/interfaces/contained_shell.mojom.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace ash {
class MockContainedShellClient : public mojom::ContainedShellClient {
public:
MockContainedShellClient();
~MockContainedShellClient() override;
mojom::ContainedShellClientPtr CreateInterfacePtrAndBind();
private:
mojo::Binding<mojom::ContainedShellClient> binding_{this};
DISALLOW_COPY_AND_ASSIGN(MockContainedShellClient);
};
// Helper function to bind a ContainedShellClient so that it receives mojo
// calls.
std::unique_ptr<MockContainedShellClient> BindMockContainedShellClient();
} // namespace ash
#endif // ASH_CONTAINED_SHELL_MOCK_CONTAINED_SHELL_CLIENT_H
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"ash.mojom.AssistantSetupController", "ash.mojom.AssistantSetupController",
"ash.mojom.AssistantVolumeControl", "ash.mojom.AssistantVolumeControl",
"ash.mojom.CastConfig", "ash.mojom.CastConfig",
"ash.mojom.ContainedShellController",
"ash.mojom.CrosDisplayConfigController", "ash.mojom.CrosDisplayConfigController",
"ash.mojom.DockedMagnifierController", "ash.mojom.DockedMagnifierController",
"ash.mojom.EventRewriterController", "ash.mojom.EventRewriterController",
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ash/assistant/assistant_screen_context_controller.h" #include "ash/assistant/assistant_screen_context_controller.h"
#include "ash/assistant/assistant_setup_controller.h" #include "ash/assistant/assistant_setup_controller.h"
#include "ash/cast_config_controller.h" #include "ash/cast_config_controller.h"
#include "ash/contained_shell/contained_shell_controller.h"
#include "ash/display/ash_display_controller.h" #include "ash/display/ash_display_controller.h"
#include "ash/display/cros_display_config.h" #include "ash/display/cros_display_config.h"
#include "ash/display/display_output_protection.h" #include "ash/display/display_output_protection.h"
...@@ -122,6 +123,11 @@ void BindCastConfigOnMainThread(mojom::CastConfigRequest request) { ...@@ -122,6 +123,11 @@ void BindCastConfigOnMainThread(mojom::CastConfigRequest request) {
Shell::Get()->cast_config()->BindRequest(std::move(request)); Shell::Get()->cast_config()->BindRequest(std::move(request));
} }
void BindContainedShellControllerRequestOnMainThread(
mojom::ContainedShellControllerRequest request) {
Shell::Get()->contained_shell_controller()->BindRequest(std::move(request));
}
void BindDisplayOutputProtectionRequestOnMainThread( void BindDisplayOutputProtectionRequestOnMainThread(
mojom::DisplayOutputProtectionRequest request) { mojom::DisplayOutputProtectionRequest request) {
Shell::Get()->display_output_protection()->BindRequest(std::move(request)); Shell::Get()->display_output_protection()->BindRequest(std::move(request));
...@@ -281,6 +287,11 @@ void RegisterInterfaces( ...@@ -281,6 +287,11 @@ void RegisterInterfaces(
main_thread_task_runner); main_thread_task_runner);
registry->AddInterface(base::BindRepeating(&BindCastConfigOnMainThread), registry->AddInterface(base::BindRepeating(&BindCastConfigOnMainThread),
main_thread_task_runner); main_thread_task_runner);
if (base::FeatureList::IsEnabled(features::kContainedShell)) {
registry->AddInterface(
base::BindRepeating(&BindContainedShellControllerRequestOnMainThread),
main_thread_task_runner);
}
registry->AddInterface( registry->AddInterface(
base::BindRepeating(&BindDisplayOutputProtectionRequestOnMainThread), base::BindRepeating(&BindDisplayOutputProtectionRequestOnMainThread),
main_thread_task_runner); main_thread_task_runner);
......
...@@ -58,6 +58,9 @@ const base::Feature kTrilinearFiltering{"TrilinearFiltering", ...@@ -58,6 +58,9 @@ const base::Feature kTrilinearFiltering{"TrilinearFiltering",
const base::Feature kUnlockWithExternalBinary{ const base::Feature kUnlockWithExternalBinary{
"UnlockWithExternalBinary", base::FEATURE_DISABLED_BY_DEFAULT}; "UnlockWithExternalBinary", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kContainedShell{"ContainedShell",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kViewsLogin{"ViewsLogin", base::FEATURE_ENABLED_BY_DEFAULT}; const base::Feature kViewsLogin{"ViewsLogin", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kUseBluetoothSystemInAsh{"UseBluetoothSystemInAsh", const base::Feature kUseBluetoothSystemInAsh{"UseBluetoothSystemInAsh",
......
...@@ -76,6 +76,9 @@ ASH_PUBLIC_EXPORT extern const base::Feature kTrilinearFiltering; ...@@ -76,6 +76,9 @@ ASH_PUBLIC_EXPORT extern const base::Feature kTrilinearFiltering;
// Enables running an external binary which provides lock screen authentication. // Enables running an external binary which provides lock screen authentication.
ASH_PUBLIC_EXPORT extern const base::Feature kUnlockWithExternalBinary; ASH_PUBLIC_EXPORT extern const base::Feature kUnlockWithExternalBinary;
// Enables the ContainedShell feature.
ASH_PUBLIC_EXPORT extern const base::Feature kContainedShell;
// Enables views login. // Enables views login.
ASH_PUBLIC_EXPORT extern const base::Feature kViewsLogin; ASH_PUBLIC_EXPORT extern const base::Feature kViewsLogin;
......
...@@ -26,6 +26,7 @@ mojom("interfaces_internal") { ...@@ -26,6 +26,7 @@ mojom("interfaces_internal") {
"assistant_volume_control.mojom", "assistant_volume_control.mojom",
"cast_config.mojom", "cast_config.mojom",
"constants.mojom", "constants.mojom",
"contained_shell.mojom",
"cros_display_config.mojom", "cros_display_config.mojom",
"display_output_protection.mojom", "display_output_protection.mojom",
"docked_magnifier_controller.mojom", "docked_magnifier_controller.mojom",
......
// 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 ash.mojom;
// Performs browser-side functionality for the ContainedShell feature,
// e.g. launching a WebView to host the ContainedShell.
interface ContainedShellClient {
};
// Allows Ash and its consumers to interact with the ContainedShell
// feature, e.g. by requesting to launch the ContainedShell WebView.
// These requests are forwarded to the ContainedShellClient.
interface ContainedShellController {
// Provides a client for dispatching requests.
SetClient(ContainedShellClient client);
};
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "ash/autoclick/autoclick_controller.h" #include "ash/autoclick/autoclick_controller.h"
#include "ash/cast_config_controller.h" #include "ash/cast_config_controller.h"
#include "ash/components/tap_visualizer/public/mojom/constants.mojom.h" #include "ash/components/tap_visualizer/public/mojom/constants.mojom.h"
#include "ash/contained_shell/contained_shell_controller.h"
#include "ash/dbus/ash_dbus_services.h" #include "ash/dbus/ash_dbus_services.h"
#include "ash/detachable_base/detachable_base_handler.h" #include "ash/detachable_base/detachable_base_handler.h"
#include "ash/detachable_base/detachable_base_notification_controller.h" #include "ash/detachable_base/detachable_base_notification_controller.h"
...@@ -656,6 +657,7 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, ...@@ -656,6 +657,7 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate,
std::make_unique<system::BrightnessControllerChromeos>()), std::make_unique<system::BrightnessControllerChromeos>()),
cast_config_(std::make_unique<CastConfigController>()), cast_config_(std::make_unique<CastConfigController>()),
connector_(connector), connector_(connector),
contained_shell_controller_(std::make_unique<ContainedShellController>()),
first_run_helper_(std::make_unique<FirstRunHelper>()), first_run_helper_(std::make_unique<FirstRunHelper>()),
focus_cycler_(std::make_unique<FocusCycler>()), focus_cycler_(std::make_unique<FocusCycler>()),
ime_controller_(std::make_unique<ImeController>()), ime_controller_(std::make_unique<ImeController>()),
...@@ -1427,6 +1429,11 @@ void Shell::OnSessionStateChanged(session_manager::SessionState state) { ...@@ -1427,6 +1429,11 @@ void Shell::OnSessionStateChanged(session_manager::SessionState state) {
// Disable drag-and-drop during OOBE and GAIA login screens by only enabling // Disable drag-and-drop during OOBE and GAIA login screens by only enabling
// the controller when the session is active. https://crbug.com/464118 // the controller when the session is active. https://crbug.com/464118
drag_drop_controller_->set_enabled(is_session_active); drag_drop_controller_->set_enabled(is_session_active);
if (base::FeatureList::IsEnabled(features::kContainedShell) &&
is_session_active) {
contained_shell_controller_->LaunchContainedShell();
}
} }
void Shell::OnLoginStatusChanged(LoginStatus login_status) { void Shell::OnLoginStatusChanged(LoginStatus login_status) {
......
...@@ -103,6 +103,7 @@ class BluetoothPowerController; ...@@ -103,6 +103,7 @@ class BluetoothPowerController;
class BrightnessControlDelegate; class BrightnessControlDelegate;
class CastConfigController; class CastConfigController;
class DisplayOutputProtection; class DisplayOutputProtection;
class ContainedShellController;
class CrosDisplayConfig; class CrosDisplayConfig;
class DetachableBaseHandler; class DetachableBaseHandler;
class DetachableBaseNotificationController; class DetachableBaseNotificationController;
...@@ -357,6 +358,9 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -357,6 +358,9 @@ class ASH_EXPORT Shell : public SessionObserver,
} }
CastConfigController* cast_config() { return cast_config_.get(); } CastConfigController* cast_config() { return cast_config_.get(); }
service_manager::Connector* connector() { return connector_; } service_manager::Connector* connector() { return connector_; }
ContainedShellController* contained_shell_controller() {
return contained_shell_controller_.get();
}
CrosDisplayConfig* cros_display_config() { CrosDisplayConfig* cros_display_config() {
return cros_display_config_.get(); return cros_display_config_.get();
} }
...@@ -720,6 +724,7 @@ class ASH_EXPORT Shell : public SessionObserver, ...@@ -720,6 +724,7 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<CastConfigController> cast_config_; std::unique_ptr<CastConfigController> cast_config_;
std::unique_ptr<CrosDisplayConfig> cros_display_config_; std::unique_ptr<CrosDisplayConfig> cros_display_config_;
service_manager::Connector* const connector_; service_manager::Connector* const connector_;
std::unique_ptr<ContainedShellController> contained_shell_controller_;
std::unique_ptr<DetachableBaseHandler> detachable_base_handler_; std::unique_ptr<DetachableBaseHandler> detachable_base_handler_;
std::unique_ptr<DetachableBaseNotificationController> std::unique_ptr<DetachableBaseNotificationController>
detachable_base_notification_controller_; detachable_base_notification_controller_;
......
...@@ -1336,6 +1336,8 @@ jumbo_split_static_library("ui") { ...@@ -1336,6 +1336,8 @@ jumbo_split_static_library("ui") {
"ash/chrome_screenshot_grabber_test_observer.h", "ash/chrome_screenshot_grabber_test_observer.h",
"ash/chrome_shell_delegate.cc", "ash/chrome_shell_delegate.cc",
"ash/chrome_shell_delegate.h", "ash/chrome_shell_delegate.h",
"ash/contained_shell_client.cc",
"ash/contained_shell_client.h",
"ash/ime_controller_client.cc", "ash/ime_controller_client.cc",
"ash/ime_controller_client.h", "ash/ime_controller_client.h",
"ash/ksv/keyboard_shortcut_viewer_util.cc", "ash/ksv/keyboard_shortcut_viewer_util.cc",
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "chrome/browser/ui/ash/ash_shell_init.h" #include "chrome/browser/ui/ash/ash_shell_init.h"
#include "chrome/browser/ui/ash/cast_config_client_media_router.h" #include "chrome/browser/ui/ash/cast_config_client_media_router.h"
#include "chrome/browser/ui/ash/chrome_new_window_client.h" #include "chrome/browser/ui/ash/chrome_new_window_client.h"
#include "chrome/browser/ui/ash/contained_shell_client.h"
#include "chrome/browser/ui/ash/ime_controller_client.h" #include "chrome/browser/ui/ash/ime_controller_client.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/login_screen_client.h" #include "chrome/browser/ui/ash/login_screen_client.h"
...@@ -283,6 +284,9 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() { ...@@ -283,6 +284,9 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() {
// Initialize TabScrubber after the Ash Shell has been initialized. // Initialize TabScrubber after the Ash Shell has been initialized.
TabScrubber::GetInstance(); TabScrubber::GetInstance();
} }
if (base::FeatureList::IsEnabled(ash::features::kContainedShell))
contained_shell_client_ = std::make_unique<ContainedShellClient>();
} }
void ChromeBrowserMainExtraPartsAsh::PostBrowserStart() { void ChromeBrowserMainExtraPartsAsh::PostBrowserStart() {
...@@ -316,6 +320,7 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { ...@@ -316,6 +320,7 @@ void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() {
media_client_.reset(); media_client_.reset();
login_screen_client_.reset(); login_screen_client_.reset();
cast_config_client_media_router_.reset(); cast_config_client_media_router_.reset();
contained_shell_client_.reset();
// Initialized in PreProfileInit: // Initialized in PreProfileInit:
system_tray_client_.reset(); system_tray_client_.reset();
......
...@@ -36,6 +36,7 @@ class AppListClientImpl; ...@@ -36,6 +36,7 @@ class AppListClientImpl;
class AshShellInit; class AshShellInit;
class CastConfigClientMediaRouter; class CastConfigClientMediaRouter;
class ChromeNewWindowClient; class ChromeNewWindowClient;
class ContainedShellClient;
class DataPromoNotification; class DataPromoNotification;
class ImeControllerClient; class ImeControllerClient;
class ImmersiveContextMus; class ImmersiveContextMus;
...@@ -118,6 +119,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts { ...@@ -118,6 +119,7 @@ class ChromeBrowserMainExtraPartsAsh : public ChromeBrowserMainExtraParts {
// Initialized in PostProfileInit in all configs: // Initialized in PostProfileInit in all configs:
std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_media_router_; std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_media_router_;
std::unique_ptr<ContainedShellClient> contained_shell_client_;
std::unique_ptr<LoginScreenClient> login_screen_client_; std::unique_ptr<LoginScreenClient> login_screen_client_;
std::unique_ptr<MediaClient> media_client_; std::unique_ptr<MediaClient> media_client_;
std::unique_ptr<policy::DisplaySettingsHandler> display_settings_handler_; std::unique_ptr<policy::DisplaySettingsHandler> display_settings_handler_;
......
// 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/browser/ui/ash/contained_shell_client.h"
#include <utility>
#include "ash/public/interfaces/constants.mojom.h"
#include "content/public/common/service_manager_connection.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "services/service_manager/public/cpp/connector.h"
ContainedShellClient::ContainedShellClient() {
ash::mojom::ContainedShellControllerPtr contained_shell_controller;
content::ServiceManagerConnection::GetForProcess()
->GetConnector()
->BindInterface(ash::mojom::kServiceName, &contained_shell_controller);
ash::mojom::ContainedShellClientPtr client;
binding_.Bind(mojo::MakeRequest(&client));
contained_shell_controller->SetClient(std::move(client));
}
ContainedShellClient::~ContainedShellClient() = default;
// 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_BROWSER_UI_ASH_CONTAINED_SHELL_CLIENT_H_
#define CHROME_BROWSER_UI_ASH_CONTAINED_SHELL_CLIENT_H_
#include "ash/public/interfaces/contained_shell.mojom.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h"
class ContainedShellClient : public ash::mojom::ContainedShellClient {
public:
ContainedShellClient();
~ContainedShellClient() override;
private:
mojo::Binding<ash::mojom::ContainedShellClient> binding_{this};
DISALLOW_COPY_AND_ASSIGN(ContainedShellClient);
};
#endif // CHROME_BROWSER_UI_ASH_CONTAINED_SHELL_CLIENT_H_
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