Commit 8161c5f4 authored by Wez's avatar Wez Committed by Commit Bot

Start a Cast app Runner based on the web.ContextProvider.

- Add a CastRunner and main() under //webrunner/app/cast.
- Add "castrunner" executable, package and runner targets to GN.

This rudimentary Runner handles caller requests for cast:// URIs,
extracts the application-Id from them, and if the Id matches a dummy
Id for testing, then it instantiates a component hosting a standard
web URL, for now.

Bug: 893229
Change-Id: Ia2cb5d7c1f69ff0a828af9e5c71b7f4422ce58d3
Reviewed-on: https://chromium-review.googlesource.com/c/1303646
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604071}
parent 3bdea881
...@@ -14,6 +14,36 @@ config("webrunner_implementation") { ...@@ -14,6 +14,36 @@ config("webrunner_implementation") {
defines = [ "WEBRUNNER_IMPLEMENTATION" ] defines = [ "WEBRUNNER_IMPLEMENTATION" ]
} }
fuchsia_package("castrunner_pkg") {
binary = ":castrunner_exe"
package_name_override = "cast_runner"
sandbox_policy = "app/cast/sandbox_policy"
}
fuchsia_package_runner("castrunner") {
package = ":castrunner_pkg"
package_name_override = "cast_runner"
install_only = true
package_deps = [ [
":service_pkg",
"chromium",
] ]
}
executable("castrunner_exe") {
sources = [
"app/cast/cast_runner.cc",
"app/cast/cast_runner.h",
"app/cast/main.cc",
]
deps = [
":web_fidl",
":webrunner_common",
"//base",
"//url",
]
}
fuchsia_package("webrunner_pkg") { fuchsia_package("webrunner_pkg") {
binary = ":webrunner_exe" binary = ":webrunner_exe"
package_name_override = "web_runner" package_name_override = "web_runner"
......
// 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 "webrunner/app/cast/cast_runner.h"
#include <fuchsia/sys/cpp/fidl.h>
#include <utility>
#include "base/logging.h"
#include "url/gurl.h"
#include "webrunner/app/common/web_component.h"
#include "webrunner/fidl/chromium/web/cpp/fidl.h"
namespace castrunner {
CastRunner::CastRunner(base::fuchsia::ServiceDirectory* service_directory,
chromium::web::ContextPtr context,
base::OnceClosure on_idle_closure)
: webrunner::WebContentRunner(service_directory,
std::move(context),
std::move(on_idle_closure)) {}
CastRunner::~CastRunner() = default;
void CastRunner::StartComponent(
fuchsia::sys::Package package,
fuchsia::sys::StartupInfo startup_info,
fidl::InterfaceRequest<fuchsia::sys::ComponentController>
controller_request) {
// TODO(https://crbug.com/893229): Define a CastAppConfig FIDL and dummy
// service implementation to hold this logic.
constexpr char kCastPresentationUrlScheme[] = "cast";
GURL cast_url(*package.resolved_url);
if (!cast_url.is_valid() || !cast_url.SchemeIs(kCastPresentationUrlScheme) ||
!cast_url.has_host()) {
LOG(ERROR) << "Rejected invalid URL: " << cast_url;
return;
}
constexpr char kTestCastAppId[] = "00000000";
base::StringPiece cast_app_id(cast_url.host_piece());
if (cast_app_id != kTestCastAppId) {
LOG(ERROR) << "Unknown Cast app Id: " << cast_app_id;
return;
}
GURL cast_app_url("https://www.google.com");
RegisterComponent(webrunner::WebComponent::ForUrlRequest(
this, std::move(cast_app_url), std::move(startup_info),
std::move(controller_request)));
}
} // namespace castrunner
// 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 WEBRUNNER_APP_CAST_CAST_RUNNER_H_
#define WEBRUNNER_APP_CAST_CAST_RUNNER_H_
#include "base/callback.h"
#include "base/macros.h"
#include "webrunner/app/common/web_content_runner.h"
#include "webrunner/fidl/chromium/web/cpp/fidl.h"
namespace castrunner {
// sys::Runner which instantiates Cast activities specified via cast/casts URIs.
class CastRunner : public webrunner::WebContentRunner {
public:
CastRunner(base::fuchsia::ServiceDirectory* service_directory,
chromium::web::ContextPtr context,
base::OnceClosure on_idle_closure);
~CastRunner() override;
// fuchsia::sys::Runner implementation.
void StartComponent(fuchsia::sys::Package package,
fuchsia::sys::StartupInfo startup_info,
fidl::InterfaceRequest<fuchsia::sys::ComponentController>
controller_request) override;
private:
DISALLOW_COPY_AND_ASSIGN(CastRunner);
};
} // namespace castrunner
#endif // WEBRUNNER_APP_CAST_CAST_RUNNER_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 "base/fuchsia/service_directory.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "webrunner/app/cast/cast_runner.h"
int main(int argc, char** argv) {
base::MessageLoopForIO message_loop;
base::RunLoop run_loop;
castrunner::CastRunner runner(
base::fuchsia::ServiceDirectory::GetDefault(),
webrunner::WebContentRunner::CreateDefaultWebContext(),
run_loop.QuitClosure());
// Run until there are no Components, or the last service client channel is
// closed.
run_loop.Run();
return 0;
}
{
"features": [],
"services": [
"chromium.web.ContextProvider",
"fuchsia.fonts.Provider",
"fuchsia.media.Audio",
"fuchsia.net.LegacySocketProvider",
"fuchsia.netstack.Netstack",
"fuchsia.process.Launcher",
"fuchsia.ui.input.ImeService",
"fuchsia.ui.input.ImeVisibilityService",
"fuchsia.ui.scenic.Scenic",
"fuchsia.ui.viewsv1.ViewManager",
"fuchsia.vulkan.loader.Loader"
]
}
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