Revert "[fuchsia] Launch web_instance.cm from context_provider.cm"
This reverts commit 5e3215ba14
.
Reason for revert: Appears to fail upstream E2E tests, due to various
capabilities not being available to the web_instances.
Original change's description:
> [fuchsia] Launch web_instance.cm from context_provider.cm
>
> In so doing:
>
> - Add support for CreateContextParams.service_directory in
> WebInstanceHost.
> - Add support to WebInstanceHost for running within a process with
> `--with-webui` on its command line to launch child instances in the
> `web_engine_with_webui` package rather than the `web_engine`
> package. This feature is used by `web_engine_shell` in test scenarios.
>
> Bug: 1280703
> Fuchsia-Binary-Size: Size increase is unavoidable.
> Change-Id: I08d65492c4c670e67cca88beb223d1d8c8eed76f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4194689
> Reviewed-by: Rohan Pavone <rohpavone@chromium.org>
> Reviewed-by: Wez <wez@chromium.org>
> Commit-Queue: Greg Thompson <grt@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1108989}
Bug: 1280703
Bug: b/270955577
Change-Id: Ifc61fc5ec781f5624551310f7a0b968c2d1ad348
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4294973
Reviewed-by: Rohan Pavone <rohpavone@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1111658}
This commit is contained in:
build/config/fuchsia
fuchsia_web
shell
webengine
BUILD.gncontext_provider.cmlcontext_provider_impl.cccontext_provider_impl.hcontext_provider_impl_unittest.cccontext_provider_main.ccfake_context.ccfake_context.h
test
web_engine_integration_tests.shard.test-cmlweb_instance-common.shard.cmlweb_instance.cmlweb_instance_with_svc_directory.cmlwebinstance_host
48
build/config/fuchsia/build_cmx_from_fragment.py
Normal file
48
build/config/fuchsia/build_cmx_from_fragment.py
Normal file
@ -0,0 +1,48 @@
|
||||
# Copyright 2020 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
"""Creates a complete CMX (v1) component manifest, from a program name and
|
||||
manifest fragment file."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def BuildCmxFromFragment(output_file, fragment_file, program_binary):
|
||||
"""Reads a CMX fragment specifying e.g. features & sandbox, and a program
|
||||
binary's filename, and writes out the full CMX.
|
||||
|
||||
output_file: Build-relative filename at which to write the full CMX.
|
||||
fragment_file: Build-relative filename of the CMX fragment to read from.
|
||||
program_binary: Package-relative filename of the program binary.
|
||||
"""
|
||||
|
||||
with open(output_file, 'w') as component_manifest_file:
|
||||
component_manifest = json.load(open(fragment_file, 'r'))
|
||||
component_manifest.update({
|
||||
'program': {
|
||||
'binary': program_binary
|
||||
},
|
||||
})
|
||||
json.dump(component_manifest, component_manifest_file)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--cmx-fragment',
|
||||
required=True,
|
||||
help='Path to the CMX fragment to read from')
|
||||
parser.add_argument('--cmx',
|
||||
required=True,
|
||||
help='Path to write the complete CMX file to')
|
||||
parser.add_argument('--program',
|
||||
required=True,
|
||||
help='Package-relative path to the program binary')
|
||||
args = parser.parse_args()
|
||||
|
||||
return BuildCmxFromFragment(args.cmx, args.cmx_fragment, args.program)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
@ -149,6 +149,13 @@ int main(int argc, char** argv) {
|
||||
create_context_params.set_content_directories(
|
||||
{std::move(content_directories)});
|
||||
|
||||
// WebEngine Contexts can only make use of the services provided by the
|
||||
// embedder application. By passing a handle to this process' service
|
||||
// directory to the ContextProvider, we are allowing the Context access to the
|
||||
// same set of services available to this application.
|
||||
create_context_params.set_service_directory(
|
||||
base::OpenDirectoryHandle(base::FilePath(base::kServiceDirectoryPath)));
|
||||
|
||||
// Enable other WebEngine features.
|
||||
fuchsia::web::ContextFeatureFlags features =
|
||||
fuchsia::web::ContextFeatureFlags::AUDIO |
|
||||
@ -187,20 +194,12 @@ int main(int argc, char** argv) {
|
||||
|
||||
if (use_context_provider) {
|
||||
// Connect to the system instance of the ContextProvider.
|
||||
// WebEngine Contexts can only make use of the services provided by the
|
||||
// embedder application. By passing a handle to this process' service
|
||||
// directory to the ContextProvider, we are allowing the Context access to
|
||||
// the same set of services available to this application.
|
||||
create_context_params.set_service_directory(
|
||||
base::OpenDirectoryHandle(base::FilePath(base::kServiceDirectoryPath)));
|
||||
web_context_provider = base::ComponentContextForProcess()
|
||||
->svc()
|
||||
->Connect<fuchsia::web::ContextProvider>();
|
||||
web_context_provider->Create(std::move(create_context_params),
|
||||
context.NewRequest());
|
||||
} else {
|
||||
// Route services dynamically from web_engine_shell's parent down into
|
||||
// created web_instances.
|
||||
web_instance_host = std::make_unique<WebInstanceHost>(
|
||||
*base::ComponentContextForProcess()->outgoing());
|
||||
if (enable_web_instance_tmp) {
|
||||
|
@ -388,7 +388,7 @@ source_set("context_provider") {
|
||||
"//base",
|
||||
"//components/fuchsia_component_support",
|
||||
"//fuchsia_web/common",
|
||||
"//fuchsia_web/webinstance_host:webinstance_host",
|
||||
"//fuchsia_web/webinstance_host:webinstance_host_v1",
|
||||
"//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
|
||||
"//third_party/fuchsia-sdk/sdk/pkg/sys_inspect_cpp",
|
||||
]
|
||||
@ -451,11 +451,6 @@ fuchsia_component("web_instance_component") {
|
||||
data_deps = [ ":web_engine_exe" ]
|
||||
}
|
||||
|
||||
fuchsia_component("web_instance_with_svc_directory_component") {
|
||||
manifest = "web_instance_with_svc_directory.cml"
|
||||
data_deps = [ ":web_engine_exe" ]
|
||||
}
|
||||
|
||||
fuchsia_component("web_instance_component_cfv1") {
|
||||
manifest = "web_instance.cmx"
|
||||
data_deps = [ ":web_engine_exe" ]
|
||||
@ -475,7 +470,6 @@ fuchsia_package("web_engine") {
|
||||
":context_provider_component",
|
||||
":web_instance_component",
|
||||
":web_instance_component_cfv1",
|
||||
":web_instance_with_svc_directory_component",
|
||||
]
|
||||
excluded_files = _web_engine_excluded_files
|
||||
excluded_dirs = FUCHSIA_PACKAGED_CONTENT_EMBEDDER_EXCLUDED_DIRS
|
||||
@ -624,6 +618,27 @@ test("web_engine_browsertests") {
|
||||
}
|
||||
}
|
||||
|
||||
# Creates a component manifest based on the production web_instance.cmx, with
|
||||
# the program name replaced with the web_engine_unittests binary name.
|
||||
action("web_engine_unittests_fake_instance_manifest") {
|
||||
_manifest_input = "web_instance.cmx"
|
||||
_manifest_output = "$target_gen_dir/web_engine_unittests_fake_instance.cmx"
|
||||
|
||||
script = "//build/config/fuchsia/build_cmx_from_fragment.py"
|
||||
|
||||
inputs = [ _manifest_input ]
|
||||
outputs = [ _manifest_output ]
|
||||
|
||||
args = [
|
||||
"--cmx-fragment",
|
||||
rebase_path(_manifest_input),
|
||||
"--cmx",
|
||||
rebase_path(_manifest_output),
|
||||
"--program",
|
||||
"web_engine_unittests__exec",
|
||||
]
|
||||
}
|
||||
|
||||
test("web_engine_unittests") {
|
||||
sources = [
|
||||
"browser/cookie_manager_impl_unittest.cc",
|
||||
@ -636,6 +651,8 @@ test("web_engine_unittests") {
|
||||
"browser/url_request_rewrite_type_converters_unittest.cc",
|
||||
"browser/web_engine_config_unittest.cc",
|
||||
"context_provider_impl_unittest.cc",
|
||||
"fake_context.cc",
|
||||
"fake_context.h",
|
||||
"renderer/web_engine_audio_output_device_test.cc",
|
||||
"renderer/web_engine_audio_renderer_test.cc",
|
||||
"test/run_all_unittests.cc",
|
||||
@ -644,11 +661,9 @@ test("web_engine_unittests") {
|
||||
":context_provider",
|
||||
":switches",
|
||||
":web_engine_core",
|
||||
"//base",
|
||||
":web_engine_unittests_fake_instance_manifest",
|
||||
"//base/test:test_support",
|
||||
"//build:chromecast_buildflags",
|
||||
"//components/fuchsia_component_support",
|
||||
"//components/fuchsia_component_support:test_support",
|
||||
"//components/url_rewrite/browser",
|
||||
"//components/url_rewrite/common",
|
||||
"//components/url_rewrite/mojom",
|
||||
@ -663,9 +678,7 @@ test("web_engine_unittests") {
|
||||
"//testing/gmock",
|
||||
"//testing/gtest",
|
||||
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.web:fuchsia.web_hlcpp",
|
||||
"//third_party/fuchsia-sdk/sdk/pkg/fdio",
|
||||
"//third_party/fuchsia-sdk/sdk/pkg/scenic_cpp",
|
||||
"//third_party/fuchsia-sdk/sdk/pkg/vfs_cpp",
|
||||
"//third_party/widevine/cdm:buildflags",
|
||||
"//ui/events:test_support",
|
||||
"//ui/ozone",
|
||||
@ -676,6 +689,10 @@ test("web_engine_unittests") {
|
||||
"//build/config/fuchsia/test/network.shard.test-cml",
|
||||
"//build/config/fuchsia/test/sysmem.shard.test-cml",
|
||||
]
|
||||
additional_manifests = [
|
||||
# Required by ContextProvider unit-tests to launch the FakeContext process.
|
||||
"$target_gen_dir/web_engine_unittests_fake_instance.cmx",
|
||||
]
|
||||
}
|
||||
|
||||
test("web_engine_integration_tests") {
|
||||
|
@ -2,32 +2,41 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
{
|
||||
include: [
|
||||
"//fuchsia_web/webinstance_host/web_instance_host_with_svc_directory.shard.cml",
|
||||
"syslog/client.shard.cml",
|
||||
],
|
||||
program: {
|
||||
runner: "elf",
|
||||
binary: "web_engine_exe",
|
||||
args: [
|
||||
"--context-provider",
|
||||
include: [
|
||||
"syslog/client.shard.cml",
|
||||
],
|
||||
},
|
||||
capabilities: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.ContextProvider",
|
||||
"fuchsia.web.Debug",
|
||||
],
|
||||
program: {
|
||||
runner: "elf",
|
||||
binary: "web_engine_exe",
|
||||
args: [
|
||||
"--context-provider",
|
||||
],
|
||||
},
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.ContextProvider",
|
||||
"fuchsia.web.Debug",
|
||||
],
|
||||
from: "self",
|
||||
},
|
||||
],
|
||||
capabilities: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.ContextProvider",
|
||||
"fuchsia.web.Debug",
|
||||
],
|
||||
},
|
||||
],
|
||||
use: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.feedback.ComponentDataRegister",
|
||||
"fuchsia.feedback.CrashReportingProductRegister",
|
||||
"fuchsia.sys.Environment",
|
||||
"fuchsia.sys.Loader",
|
||||
],
|
||||
},
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.ContextProvider",
|
||||
"fuchsia.web.Debug",
|
||||
],
|
||||
from: "self",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
@ -10,9 +10,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/logging.h"
|
||||
|
||||
ContextProviderImpl::ContextProviderImpl(
|
||||
sys::OutgoingDirectory& outgoing_directory)
|
||||
: web_instance_host_(outgoing_directory) {}
|
||||
ContextProviderImpl::ContextProviderImpl() = default;
|
||||
|
||||
ContextProviderImpl::~ContextProviderImpl() = default;
|
||||
|
||||
@ -42,5 +40,5 @@ void ContextProviderImpl::Create(
|
||||
}
|
||||
|
||||
fuchsia::web::Debug* ContextProviderImpl::debug_api() {
|
||||
return &web_instance_host_.debug_api();
|
||||
return web_instance_host_.debug_api();
|
||||
}
|
||||
|
@ -8,20 +8,12 @@
|
||||
#include <fuchsia/web/cpp/fidl.h>
|
||||
|
||||
#include "fuchsia_web/webengine/web_engine_export.h"
|
||||
#include "fuchsia_web/webinstance_host/web_instance_host.h"
|
||||
|
||||
namespace sys {
|
||||
class OutgoingDirectory;
|
||||
} // namespace sys
|
||||
#include "fuchsia_web/webinstance_host/web_instance_host_v1.h"
|
||||
|
||||
class WEB_ENGINE_EXPORT ContextProviderImpl
|
||||
: public fuchsia::web::ContextProvider {
|
||||
public:
|
||||
// The impl will offer capabilities to child instances via
|
||||
// `outgoing_directory`. ContextProviderImpl owners must serve the directory
|
||||
// before creating web instances, and must ensure that the directory outlives
|
||||
// the ContextProviderImpl instance.
|
||||
explicit ContextProviderImpl(sys::OutgoingDirectory& outgoing_directory);
|
||||
ContextProviderImpl();
|
||||
~ContextProviderImpl() override;
|
||||
|
||||
ContextProviderImpl(const ContextProviderImpl&) = delete;
|
||||
@ -37,7 +29,7 @@ class WEB_ENGINE_EXPORT ContextProviderImpl
|
||||
|
||||
private:
|
||||
// Manages an isolated Environment, and the web instances hosted within it.
|
||||
WebInstanceHost web_instance_host_;
|
||||
WebInstanceHostV1 web_instance_host_;
|
||||
};
|
||||
|
||||
#endif // FUCHSIA_WEB_WEBENGINE_CONTEXT_PROVIDER_IMPL_H_
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -49,12 +49,11 @@ int ContextProviderMain() {
|
||||
|
||||
LogComponentStartWithVersion("WebEngine context_provider");
|
||||
|
||||
sys::OutgoingDirectory* const directory =
|
||||
base::ComponentContextForProcess()->outgoing().get();
|
||||
|
||||
ContextProviderImpl context_provider(*directory);
|
||||
ContextProviderImpl context_provider;
|
||||
|
||||
// Publish the ContextProvider and Debug services.
|
||||
sys::OutgoingDirectory* const directory =
|
||||
base::ComponentContextForProcess()->outgoing().get();
|
||||
base::ScopedServiceBinding<fuchsia::web::ContextProvider> context_binding(
|
||||
directory, &context_provider);
|
||||
base::ScopedServiceBinding<fuchsia::web::Debug> debug_hub_binding(
|
||||
|
61
fuchsia_web/webengine/fake_context.cc
Normal file
61
fuchsia_web/webengine/fake_context.cc
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright 2018 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "fuchsia_web/webengine/fake_context.h"
|
||||
|
||||
#include "base/fuchsia/fuchsia_logging.h"
|
||||
#include "base/notreached.h"
|
||||
|
||||
FakeFrame::FakeFrame(fidl::InterfaceRequest<fuchsia::web::Frame> request)
|
||||
: binding_(this, std::move(request)) {
|
||||
binding_.set_error_handler([this](zx_status_t status) {
|
||||
ZX_CHECK(status == ZX_ERR_PEER_CLOSED, status);
|
||||
delete this;
|
||||
});
|
||||
}
|
||||
|
||||
FakeFrame::~FakeFrame() = default;
|
||||
|
||||
void FakeFrame::GetNavigationController(
|
||||
fidl::InterfaceRequest<fuchsia::web::NavigationController> controller) {
|
||||
if (navigation_controller_) {
|
||||
navigation_controller_bindings_.AddBinding(navigation_controller_,
|
||||
std::move(controller));
|
||||
}
|
||||
}
|
||||
|
||||
void FakeFrame::SetNavigationEventListener(
|
||||
fidl::InterfaceHandle<fuchsia::web::NavigationEventListener> listener) {
|
||||
SetNavigationEventListener2(std::move(listener), /*flags=*/{});
|
||||
}
|
||||
|
||||
void FakeFrame::SetNavigationEventListener2(
|
||||
fidl::InterfaceHandle<fuchsia::web::NavigationEventListener> listener,
|
||||
fuchsia::web::NavigationEventListenerFlags flags) {
|
||||
listener_.Bind(std::move(listener));
|
||||
if (on_set_listener_callback_) {
|
||||
std::move(on_set_listener_callback_).Run();
|
||||
}
|
||||
}
|
||||
|
||||
void FakeFrame::NotImplemented_(const std::string& name) {
|
||||
NOTREACHED() << name;
|
||||
}
|
||||
|
||||
FakeContext::FakeContext() = default;
|
||||
FakeContext::~FakeContext() = default;
|
||||
|
||||
void FakeContext::CreateFrame(
|
||||
fidl::InterfaceRequest<fuchsia::web::Frame> frame_request) {
|
||||
FakeFrame* new_frame = new FakeFrame(std::move(frame_request));
|
||||
if (on_create_frame_callback_) {
|
||||
on_create_frame_callback_.Run(new_frame);
|
||||
}
|
||||
|
||||
// |new_frame| owns itself, so we intentionally leak the pointer.
|
||||
}
|
||||
|
||||
void FakeContext::NotImplemented_(const std::string& name) {
|
||||
NOTREACHED() << name;
|
||||
}
|
92
fuchsia_web/webengine/fake_context.h
Normal file
92
fuchsia_web/webengine/fake_context.h
Normal file
@ -0,0 +1,92 @@
|
||||
// Copyright 2018 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef FUCHSIA_WEB_WEBENGINE_FAKE_CONTEXT_H_
|
||||
#define FUCHSIA_WEB_WEBENGINE_FAKE_CONTEXT_H_
|
||||
|
||||
#include <fuchsia/web/cpp/fidl.h>
|
||||
#include <fuchsia/web/cpp/fidl_test_base.h>
|
||||
#include <lib/fidl/cpp/binding.h>
|
||||
#include <lib/fidl/cpp/binding_set.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/callback.h"
|
||||
|
||||
// A fake Frame implementation that manages its own lifetime.
|
||||
class FakeFrame : public fuchsia::web::testing::Frame_TestBase {
|
||||
public:
|
||||
explicit FakeFrame(fidl::InterfaceRequest<fuchsia::web::Frame> request);
|
||||
|
||||
FakeFrame(const FakeFrame&) = delete;
|
||||
FakeFrame& operator=(const FakeFrame&) = delete;
|
||||
|
||||
~FakeFrame() override;
|
||||
|
||||
void set_on_set_listener_callback(base::OnceClosure callback) {
|
||||
on_set_listener_callback_ = std::move(callback);
|
||||
}
|
||||
|
||||
// Tests can provide e.g a mock NavigationController, which the FakeFrame will
|
||||
// pass bind GetNavigationController() requests to.
|
||||
void set_navigation_controller(
|
||||
fuchsia::web::NavigationController* controller) {
|
||||
navigation_controller_ = controller;
|
||||
}
|
||||
|
||||
fuchsia::web::NavigationEventListener* listener() { return listener_.get(); }
|
||||
|
||||
// fuchsia::web::Frame implementation.
|
||||
void GetNavigationController(
|
||||
fidl::InterfaceRequest<fuchsia::web::NavigationController> controller)
|
||||
override;
|
||||
void SetNavigationEventListener(
|
||||
fidl::InterfaceHandle<fuchsia::web::NavigationEventListener> listener)
|
||||
override;
|
||||
void SetNavigationEventListener2(
|
||||
fidl::InterfaceHandle<fuchsia::web::NavigationEventListener> listener,
|
||||
fuchsia::web::NavigationEventListenerFlags flags) override;
|
||||
|
||||
// fuchsia::web::testing::Frame_TestBase implementation.
|
||||
void NotImplemented_(const std::string& name) override;
|
||||
|
||||
private:
|
||||
fidl::Binding<fuchsia::web::Frame> binding_;
|
||||
fuchsia::web::NavigationEventListenerPtr listener_;
|
||||
base::OnceClosure on_set_listener_callback_;
|
||||
|
||||
fuchsia::web::NavigationController* navigation_controller_ = nullptr;
|
||||
fidl::BindingSet<fuchsia::web::NavigationController>
|
||||
navigation_controller_bindings_;
|
||||
};
|
||||
|
||||
// An implementation of Context that creates and binds FakeFrames.
|
||||
class FakeContext : public fuchsia::web::testing::Context_TestBase {
|
||||
public:
|
||||
using CreateFrameCallback = base::RepeatingCallback<void(FakeFrame*)>;
|
||||
|
||||
FakeContext();
|
||||
|
||||
FakeContext(const FakeContext&) = delete;
|
||||
FakeContext& operator=(const FakeContext&) = delete;
|
||||
|
||||
~FakeContext() override;
|
||||
|
||||
// Sets a callback that is invoked whenever new Frames are bound.
|
||||
void set_on_create_frame_callback(CreateFrameCallback callback) {
|
||||
on_create_frame_callback_ = callback;
|
||||
}
|
||||
|
||||
// fuchsia::web::Context implementation.
|
||||
void CreateFrame(
|
||||
fidl::InterfaceRequest<fuchsia::web::Frame> frame_request) override;
|
||||
|
||||
// fuchsia::web::testing::Context_TestBase implementation.
|
||||
void NotImplemented_(const std::string& name) override;
|
||||
|
||||
private:
|
||||
CreateFrameCallback on_create_frame_callback_;
|
||||
};
|
||||
|
||||
#endif // FUCHSIA_WEB_WEBENGINE_FAKE_CONTEXT_H_
|
@ -38,29 +38,9 @@ namespace {
|
||||
|
||||
realm_builder
|
||||
.AddRoute(::component_testing::Route{
|
||||
.capabilities =
|
||||
{// Capabilities used/routed by WebInstanceHost:
|
||||
::component_testing::Directory{"config-data-for-web-instance"},
|
||||
// Required capabilities offered to web-instance.cm:
|
||||
::component_testing::Directory{"root-ssl-certificates"},
|
||||
::component_testing::Protocol{"fuchsia.buildinfo.Provider"},
|
||||
::component_testing::Protocol{"fuchsia.device.NameProvider"},
|
||||
::component_testing::Protocol{"fuchsia.fonts.Provider"},
|
||||
::component_testing::Protocol{"fuchsia.hwinfo.Product"},
|
||||
::component_testing::Protocol{"fuchsia.intl.PropertyProvider"},
|
||||
::component_testing::Protocol{"fuchsia.kernel.VmexResource"},
|
||||
::component_testing::Protocol{"fuchsia.logger.LogSink"},
|
||||
::component_testing::Protocol{"fuchsia.memorypressure.Provider"},
|
||||
::component_testing::Protocol{"fuchsia.process.Launcher"},
|
||||
::component_testing::Protocol{"fuchsia.sysmem.Allocator"},
|
||||
// Optional capabilities offered to web-instance.cm:
|
||||
::component_testing::Protocol{"fuchsia.camera3.DeviceWatcher"},
|
||||
::component_testing::Protocol{"fuchsia.media.ProfileProvider"},
|
||||
::component_testing::Protocol{"fuchsia.settings.Display"},
|
||||
::component_testing::Protocol{
|
||||
"fuchsia.tracing.perfetto.ProducerConnector"},
|
||||
::component_testing::Protocol{
|
||||
"fuchsia.tracing.provider.Registry"}},
|
||||
.capabilities = {::component_testing::Protocol{
|
||||
"fuchsia.sys.Environment"},
|
||||
::component_testing::Protocol{"fuchsia.sys.Loader"}},
|
||||
.source = ::component_testing::ParentRef{},
|
||||
.targets = {::component_testing::ChildRef{kContextProviderService}}})
|
||||
.AddRoute(::component_testing::Route{
|
||||
|
@ -8,53 +8,15 @@
|
||||
url: "fuchsia-pkg://fuchsia.com/flatland-scene-manager-test-ui-stack#meta/test-ui-stack.cm",
|
||||
},
|
||||
],
|
||||
use: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.accessibility.semantics.SemanticsManager",
|
||||
"fuchsia.ui.composition.Allocator",
|
||||
"fuchsia.ui.composition.Flatland",
|
||||
"fuchsia.ui.input3.Keyboard",
|
||||
"fuchsia.ui.scenic.Scenic",
|
||||
],
|
||||
from: "#test_ui_stack",
|
||||
},
|
||||
{ protocol: "fuchsia.memorypressure.Provider" },
|
||||
],
|
||||
offer: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.buildinfo.Provider",
|
||||
"fuchsia.camera3.DeviceWatcher",
|
||||
"fuchsia.device.NameProvider",
|
||||
"fuchsia.fonts.Provider",
|
||||
"fuchsia.hwinfo.Product",
|
||||
"fuchsia.intl.PropertyProvider",
|
||||
"fuchsia.kernel.VmexResource",
|
||||
"fuchsia.logger.LogSink",
|
||||
"fuchsia.media.ProfileProvider",
|
||||
"fuchsia.memorypressure.Provider",
|
||||
"fuchsia.process.Launcher",
|
||||
"fuchsia.settings.Display",
|
||||
"fuchsia.sysmem.Allocator",
|
||||
"fuchsia.tracing.perfetto.ProducerConnector",
|
||||
"fuchsia.tracing.provider.Registry",
|
||||
"fuchsia.sys.Environment",
|
||||
"fuchsia.sys.Loader",
|
||||
],
|
||||
from: "parent",
|
||||
to: "#realm_builder",
|
||||
},
|
||||
{
|
||||
directory: "root-ssl-certificates",
|
||||
from: "parent",
|
||||
to: "#realm_builder",
|
||||
},
|
||||
{
|
||||
directory: "config-data",
|
||||
from: "parent",
|
||||
as: "config-data-for-web-instance",
|
||||
to: "#realm_builder",
|
||||
subdir: "web_engine",
|
||||
},
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.logger.LogSink",
|
||||
@ -67,12 +29,29 @@
|
||||
to: "#test_ui_stack",
|
||||
},
|
||||
],
|
||||
use: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.accessibility.semantics.SemanticsManager",
|
||||
"fuchsia.ui.composition.Allocator",
|
||||
"fuchsia.ui.composition.Flatland",
|
||||
"fuchsia.ui.input3.Keyboard",
|
||||
"fuchsia.ui.scenic.Scenic",
|
||||
],
|
||||
from: "#test_ui_stack",
|
||||
},
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.memorypressure.Provider",
|
||||
],
|
||||
},
|
||||
],
|
||||
facets: {
|
||||
"fuchsia.test": {
|
||||
"deprecated-allowed-packages": [
|
||||
"cursor",
|
||||
"flatland-scene-manager-test-ui-stack",
|
||||
"web_engine",
|
||||
"cursor",
|
||||
"flatland-scene-manager-test-ui-stack",
|
||||
"web_engine",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -1,92 +0,0 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
{
|
||||
program: {
|
||||
runner: "elf",
|
||||
binary: "web_engine_exe",
|
||||
|
||||
// Required to allow JIT in child processes such as renderers.
|
||||
job_policy_ambient_mark_vmo_exec: "true",
|
||||
},
|
||||
capabilities: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.Context",
|
||||
"fuchsia.web.Debug",
|
||||
"fuchsia.web.FrameHost",
|
||||
],
|
||||
},
|
||||
],
|
||||
use: [
|
||||
// fuchsia.web/CreateContextParams.cdm_data_directory.
|
||||
{
|
||||
directory: "cdm_data",
|
||||
rights: [ "rw*" ],
|
||||
path: "/cdm_data",
|
||||
availability: "optional",
|
||||
},
|
||||
|
||||
// Holds optional .json config files.
|
||||
{
|
||||
directory: "config-data",
|
||||
rights: [ "r*" ],
|
||||
path: "/config/data",
|
||||
availability: "optional",
|
||||
},
|
||||
|
||||
// fuchsia.web/CreateContextParams.content_directories.
|
||||
{
|
||||
directory: "content-directories",
|
||||
rights: [ "r*" ],
|
||||
path: "/content-directories",
|
||||
availability: "optional",
|
||||
},
|
||||
|
||||
// Expected to host an "argv.json" file containing command line args.
|
||||
{
|
||||
directory: "command-line-config",
|
||||
rights: [ "r*" ],
|
||||
path: "/config/command-line",
|
||||
availability: "optional",
|
||||
},
|
||||
|
||||
// fuchsia.web/CreateContextParams.data_directory.
|
||||
{
|
||||
directory: "data",
|
||||
rights: [ "rw*" ],
|
||||
path: "/data",
|
||||
availability: "optional",
|
||||
},
|
||||
|
||||
// Holds cert.pem; the system root certificate store.
|
||||
{
|
||||
directory: "root-ssl-certificates",
|
||||
rights: [ "r*" ],
|
||||
path: "/config/ssl",
|
||||
availability: "optional",
|
||||
},
|
||||
|
||||
// Temporary directory specified by WebInstanceHost.set_tmp_dir.
|
||||
{
|
||||
directory: "tmp",
|
||||
rights: [ "rw*" ],
|
||||
path: "/tmp",
|
||||
availability: "optional",
|
||||
},
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.Context",
|
||||
"fuchsia.web.Debug",
|
||||
"fuchsia.web.FrameHost",
|
||||
],
|
||||
from: "self",
|
||||
},
|
||||
{
|
||||
protocol: "fuchsia.component.Binder",
|
||||
from: "framework",
|
||||
},
|
||||
],
|
||||
}
|
@ -1,17 +1,91 @@
|
||||
// Copyright 2022 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// A component manifest used by WebInstanceHost when creating a Context for
|
||||
// which the caller does not provide a service_directory in its
|
||||
// CreateContextParams.
|
||||
{
|
||||
include: [
|
||||
"inspect/client.shard.cml",
|
||||
"syslog/client.shard.cml",
|
||||
"//fuchsia_web/webengine/web_instance-common.shard.cml",
|
||||
],
|
||||
program: {
|
||||
runner: "elf",
|
||||
binary: "web_engine_exe",
|
||||
|
||||
// Required to allow JIT in child processes such as renderers.
|
||||
job_policy_ambient_mark_vmo_exec: "true",
|
||||
},
|
||||
capabilities: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.Context",
|
||||
"fuchsia.web.Debug",
|
||||
"fuchsia.web.FrameHost",
|
||||
]
|
||||
}
|
||||
],
|
||||
expose: [
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.web.Context",
|
||||
"fuchsia.web.Debug",
|
||||
"fuchsia.web.FrameHost",
|
||||
],
|
||||
from: "self",
|
||||
},
|
||||
{
|
||||
protocol: "fuchsia.component.Binder",
|
||||
from: "framework",
|
||||
}
|
||||
],
|
||||
use: [
|
||||
// fuchsia.web/CreateContextParams.cdm_data_directory.
|
||||
{
|
||||
directory: "cdm_data",
|
||||
path: "/cdm_data",
|
||||
rights: [ "rw*" ],
|
||||
availability: "optional",
|
||||
},
|
||||
// Holds optional .json config files.
|
||||
{
|
||||
directory: "config-data",
|
||||
rights: [ "r*" ],
|
||||
path: "/config/data",
|
||||
availability: "optional",
|
||||
},
|
||||
// fuchsia.web/CreateContextParams.data_directory.
|
||||
{
|
||||
directory: "data",
|
||||
path: "/data",
|
||||
rights: [ "rw*" ],
|
||||
availability: "optional",
|
||||
},
|
||||
// Holds cert.pem; the system root certificate store.
|
||||
{
|
||||
directory: "root-ssl-certificates",
|
||||
rights: [ "r*" ],
|
||||
path: "/config/ssl",
|
||||
availability: "optional",
|
||||
},
|
||||
// fuchsia.web/CreateContextParams.content_directories.
|
||||
{
|
||||
directory: "content-directories",
|
||||
rights: [ "r*" ],
|
||||
path: "/content-directories",
|
||||
availability: "optional",
|
||||
},
|
||||
// Expected to host an "argv.json" file containing command line args.
|
||||
{
|
||||
directory: "command-line-config",
|
||||
rights: [ "r*" ],
|
||||
path: "/config/command-line",
|
||||
availability: "optional",
|
||||
},
|
||||
// Temporary directory specified by WebInstanceHost.set_tmp_dir.
|
||||
{
|
||||
directory: "tmp",
|
||||
path: "/tmp",
|
||||
rights: [ "rw*" ],
|
||||
availability: "optional",
|
||||
},
|
||||
{
|
||||
// Required capabilities for all configurations.
|
||||
protocol: [
|
||||
|
@ -1,17 +0,0 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// A component manifest used by WebInstanceHost when creating a Context for
|
||||
// which the caller provides a service_directory in its CreateContextParams.
|
||||
{
|
||||
include: [ "//fuchsia_web/webengine/web_instance-common.shard.cml" ],
|
||||
use: [
|
||||
// fuchsia.web/CreateContextParams.service_directory.
|
||||
{
|
||||
directory: "svc",
|
||||
rights: [ "rw*" ],
|
||||
path: "/svc",
|
||||
},
|
||||
],
|
||||
}
|
@ -41,22 +41,18 @@ namespace {
|
||||
|
||||
namespace fcdecl = ::fuchsia::component::decl;
|
||||
|
||||
// Production URL for web hosting Component instances.
|
||||
// The URL cannot be obtained programmatically - see fxbug.dev/51490.
|
||||
constexpr char kWebInstanceComponentUrl[] =
|
||||
"fuchsia-pkg://fuchsia.com/web_engine#meta/web_instance.cm";
|
||||
|
||||
// Test-only URL for web hosting Component instances with WebUI resources.
|
||||
const char kWebInstanceWithWebUiComponentUrl[] =
|
||||
"fuchsia-pkg://fuchsia.com/web_engine_with_webui#meta/web_instance.cm";
|
||||
|
||||
// The name of the component collection hosting the instances.
|
||||
constexpr char kCollectionName[] = "web_instances";
|
||||
|
||||
// Returns the URL of the WebInstance component to be launched.
|
||||
std::string MakeWebInstanceComponentUrl(bool with_webui,
|
||||
bool with_service_directory) {
|
||||
// TODO(crbug.com/1010222): Use a relative component URL when the hosting
|
||||
// component is in the same package as web_instance.cm and remove this
|
||||
// workaround.
|
||||
return base::StrCat(
|
||||
{"fuchsia-pkg://fuchsia.com/",
|
||||
(with_webui ? "web_engine_with_webui" : "web_engine"), "#meta/",
|
||||
(with_service_directory ? "web_instance_with_svc_directory.cm"
|
||||
: "web_instance.cm")});
|
||||
}
|
||||
|
||||
// Returns the "/web_instances" dir from the component's outgoing directory,
|
||||
// creating it if necessary.
|
||||
vfs::PseudoDir* GetWebInstancesCollectionDir(
|
||||
@ -109,11 +105,6 @@ class InstanceBuilder {
|
||||
// protocol offers.
|
||||
void AppendOffersForServices(const std::vector<std::string>& services);
|
||||
|
||||
// Serves `service_directory` to the instance as the 'svc' read-write
|
||||
// directory.
|
||||
void ServeServiceDirectory(
|
||||
fidl::InterfaceHandle<fuchsia::io::Directory> service_directory);
|
||||
|
||||
// Offers the read-only root-ssl-certificates directory from the parent.
|
||||
void ServeRootSslCertificates();
|
||||
|
||||
@ -142,7 +133,6 @@ class InstanceBuilder {
|
||||
|
||||
// Builds and returns the instance, or an error status value.
|
||||
Instance Build(
|
||||
const std::string& instance_component_url,
|
||||
fidl::InterfaceRequest<fuchsia::io::Directory> services_request);
|
||||
|
||||
private:
|
||||
@ -288,14 +278,6 @@ void InstanceBuilder::AppendOffersForServices(
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceBuilder::ServeServiceDirectory(
|
||||
fidl::InterfaceHandle<fuchsia::io::Directory> service_directory) {
|
||||
DCHECK(instance_dir_);
|
||||
ServeDirectory("svc",
|
||||
std::make_unique<vfs::RemoteDir>(std::move(service_directory)),
|
||||
/*writeable=*/true);
|
||||
}
|
||||
|
||||
void InstanceBuilder::ServeRootSslCertificates() {
|
||||
DCHECK(instance_dir_);
|
||||
OfferDirectoryFromParent("root-ssl-certificates");
|
||||
@ -354,7 +336,6 @@ void InstanceBuilder::SetDebugRequest(
|
||||
}
|
||||
|
||||
Instance InstanceBuilder::Build(
|
||||
const std::string& instance_component_url,
|
||||
fidl::InterfaceRequest<fuchsia::io::Directory> services_request) {
|
||||
ServeCommandLine();
|
||||
|
||||
@ -364,7 +345,14 @@ Instance InstanceBuilder::Build(
|
||||
|
||||
fcdecl::Child child_decl;
|
||||
child_decl.set_name(name_);
|
||||
child_decl.set_url(instance_component_url);
|
||||
// TODO(crbug.com/1010222): Make kWebInstanceComponentUrl a relative
|
||||
// component URL and remove this workaround.
|
||||
// TODO(crbug.com/1395054): Better yet, replace the with_webui component with
|
||||
// direct routing of the resources from web_engine_shell.
|
||||
child_decl.set_url(
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kWithWebui)
|
||||
? kWebInstanceWithWebUiComponentUrl
|
||||
: kWebInstanceComponentUrl);
|
||||
child_decl.set_startup(fcdecl::StartupMode::LAZY);
|
||||
|
||||
::fuchsia::component::CreateChildArgs create_child_args;
|
||||
@ -518,9 +506,8 @@ void InstanceBuilder::OfferDirectoryFromParent(base::StringPiece name) {
|
||||
// Route `root-ssl-certificates` from parent if networking is requested.
|
||||
void HandleRootSslCertificates(InstanceBuilder& builder,
|
||||
fuchsia::web::CreateContextParams& params) {
|
||||
if (!params.has_features() ||
|
||||
(params.features() & fuchsia::web::ContextFeatureFlags::NETWORK) !=
|
||||
fuchsia::web::ContextFeatureFlags::NETWORK) {
|
||||
if ((params.features() & fuchsia::web::ContextFeatureFlags::NETWORK) !=
|
||||
fuchsia::web::ContextFeatureFlags::NETWORK) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -583,7 +570,11 @@ bool HandleContentDirectoriesParam(InstanceBuilder& builder,
|
||||
} // namespace
|
||||
|
||||
WebInstanceHost::WebInstanceHost(sys::OutgoingDirectory& outgoing_directory)
|
||||
: outgoing_directory_(outgoing_directory) {}
|
||||
: outgoing_directory_(outgoing_directory) {
|
||||
// Ensure WebInstance is registered before launching it.
|
||||
// TODO(crbug.com/1211174): Replace with a different mechanism when available.
|
||||
RegisterWebInstanceProductData(kWebInstanceComponentUrl);
|
||||
}
|
||||
|
||||
WebInstanceHost::~WebInstanceHost() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
@ -595,21 +586,6 @@ zx_status_t WebInstanceHost::CreateInstanceForContextWithCopiedArgs(
|
||||
fidl::InterfaceRequest<fuchsia::io::Directory> services_request,
|
||||
base::CommandLine extra_args) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
const bool with_service_directory = params.has_service_directory();
|
||||
|
||||
// True if the process includes `--with-webui` on its command line. This is a
|
||||
// test-only feature for `web_engine_shell` that causes `web_instance.cm` to
|
||||
// be run from the `web_engine_with_webui` package rather than the production
|
||||
// `web_engine` package.
|
||||
const bool with_webui =
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kWithWebui);
|
||||
|
||||
// Web UI resources are not supported with a service directory.
|
||||
if (with_webui && with_service_directory) {
|
||||
return ZX_ERR_INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!is_initialized()) {
|
||||
Initialize();
|
||||
}
|
||||
@ -626,15 +602,13 @@ zx_status_t WebInstanceHost::CreateInstanceForContextWithCopiedArgs(
|
||||
return status;
|
||||
}
|
||||
|
||||
if (with_service_directory) {
|
||||
builder->ServeServiceDirectory(
|
||||
std::move(*params.mutable_service_directory()));
|
||||
} else {
|
||||
// TODO(grt): What to do about `params.service_directory`? At the moment, we
|
||||
// require that all of web_instance's required and optional protocols are
|
||||
// routed from the embedding component's parent.
|
||||
|
||||
{
|
||||
std::vector<std::string> services;
|
||||
const auto features = params.has_features()
|
||||
? params.features()
|
||||
: fuchsia::web::ContextFeatureFlags();
|
||||
AppendDynamicServices(features, params.has_playready_key_system(),
|
||||
AppendDynamicServices(params.features(), params.has_playready_key_system(),
|
||||
services);
|
||||
builder->AppendOffersForServices(services);
|
||||
}
|
||||
@ -664,17 +638,7 @@ zx_status_t WebInstanceHost::CreateInstanceForContextWithCopiedArgs(
|
||||
debug_proxy_.RegisterInstance(std::move(debug_handle));
|
||||
}
|
||||
|
||||
const auto instance_component_url =
|
||||
MakeWebInstanceComponentUrl(with_webui, with_service_directory);
|
||||
|
||||
// Ensure WebInstance is registered before launching it.
|
||||
// TODO(crbug.com/1211174): Replace with a different mechanism when available.
|
||||
RegisterWebInstanceProductData(instance_component_url);
|
||||
|
||||
// TODO(crbug.com/1395054): Replace the with_webui component with direct
|
||||
// routing of the resources from web_engine_shell.
|
||||
auto instance =
|
||||
builder->Build(instance_component_url, std::move(services_request));
|
||||
auto instance = builder->Build(std::move(services_request));
|
||||
// Monitor the instance's Binder to track its destruction.
|
||||
instance.binder_ptr.set_error_handler(
|
||||
[this, id = instance.id](zx_status_t status) {
|
||||
|
@ -1,44 +0,0 @@
|
||||
// Copyright 2022 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
{
|
||||
collections: [
|
||||
// The collection in which child instances are dynamically created.
|
||||
{
|
||||
name: "web_instances",
|
||||
durability: "transient",
|
||||
allowed_offers: "static_and_dynamic",
|
||||
persistent_storage: false,
|
||||
},
|
||||
],
|
||||
capabilities: [
|
||||
// The root of a directory tree through which directory capabilities are
|
||||
// dynamically routed to child instances.
|
||||
{
|
||||
directory: "web_instances",
|
||||
rights: [ "rw*" ],
|
||||
path: "/web_instances",
|
||||
},
|
||||
],
|
||||
use: [
|
||||
{
|
||||
protocol: "fuchsia.component.Realm",
|
||||
from: "framework",
|
||||
},
|
||||
{
|
||||
protocol: [
|
||||
"fuchsia.feedback.ComponentDataRegister",
|
||||
"fuchsia.feedback.CrashReportingProductRegister",
|
||||
],
|
||||
},
|
||||
],
|
||||
offer: [
|
||||
{
|
||||
directory: "config-data-for-web-instance",
|
||||
from: "parent",
|
||||
as: "config-data",
|
||||
to: "#web_instances",
|
||||
availability: "optional",
|
||||
},
|
||||
],
|
||||
}
|
Reference in New Issue
Block a user