Commit bb9e9ac8 authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

Revert "[web_engine] Add "web_engine_shell" standalone executable."

This reverts commit 3692f7b0.

Reason for revert: compile failure https://ci.chromium.org/p/chromium/builders/ci/fuchsia-x64-dbg/1638

Original change's description:
> [web_engine] Add "web_engine_shell" standalone executable.
> 
> Implements a simple standalone executable which will launch a fullscreen
> browsing session and navigate it to a given URL. Similar to
> content_shell, but using Web Engine instead.
> 
> The flow is kept deliberately simple and linear so it can serve as a
> functioning code sample for aspiring embedders of Web Engine.
> 
> The shell can be used to test arbitrary static data, which is sourced
> from //fuchsia/engine/test/shell_data and hosted under the content URL
> fuchsia-dir://shell-data/ .
> 
> The shell can also optionally request that the DevTools server be
> started at a port specified on the command line.
> 
> Bug: 1016485
> Change-Id: I09ad56f20553acc83fbf38924fa3e8d8a98a1200
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1869887
> Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
> Reviewed-by: David Dorwin <ddorwin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#707911}

TBR=ddorwin@chromium.org,kmarshall@chromium.org

Change-Id: Ib38a55b43411e01d49fffdf92f268fdf3c4db187
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1016485
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872719Reviewed-by: default avatarElla Ge <eirage@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707914}
parent 7e5ce319
...@@ -99,7 +99,6 @@ group("gn_all") { ...@@ -99,7 +99,6 @@ group("gn_all") {
"base:cr_fuchsia_base_unittests", "base:cr_fuchsia_base_unittests",
"engine:web_engine", "engine:web_engine",
"engine:web_engine_browsertests", "engine:web_engine_browsertests",
"engine:web_engine_shell",
"engine:web_engine_unittests", "engine:web_engine_unittests",
"http:http_service_tests", "http:http_service_tests",
"mojom:fuchsia_mojo_unittests", "mojom:fuchsia_mojo_unittests",
......
...@@ -317,42 +317,6 @@ test("web_engine_integration_tests") { ...@@ -317,42 +317,6 @@ test("web_engine_integration_tests") {
] ] ] ]
} }
fuchsia_package("web_engine_shell_pkg") {
testonly = true
manifest = "test/web_engine_shell.cmx"
binary = ":web_engine_shell_exec"
package_name_override = "web_engine_shell"
}
fuchsia_package_runner("web_engine_shell") {
testonly = true
package = ":web_engine_shell_pkg"
package_name_override = "web_engine_shell"
package_deps = [ [
":web_engine",
"chromium",
] ]
}
executable("web_engine_shell_exec") {
sources = [
"test/web_engine_shell.cc",
]
data = [
"test/shell_data",
]
deps = [
"//base",
"//fuchsia/base",
"//third_party/fuchsia-sdk/sdk:scenic_cpp",
"//third_party/fuchsia-sdk/sdk:ui_policy",
"//third_party/fuchsia-sdk/sdk:web",
"//url",
]
}
if (is_official_build) { if (is_official_build) {
symbol_archive("symbol_archive") { symbol_archive("symbol_archive") {
deps = [ deps = [
......
*Web Engine Shell*
The Web Engine Shell is a simple command-line executable which will create a
fullscreen browsing session and navigate it to a specified URL. It can be used
for validating web platform features, or it can serve as example code for
embedding Web Engine in C++ applications.
**Usage**
To build and run Web Engine Shell, execute the following commands:
```
$ autoninja -C $OUTDIR web_engine_shell
$ $OUTDIR/bin/install_web_engine_shell --fuchsia-out-dir $FUCHSIA_OUTDIR
$ cd $FUCHSIA
$ fx shell
$ run fuchsia-pkg://fuchsia.com/web_engine_shell#meta/web_engine_shell.cmx --remote-debugging-port=1234 http://www.example.com
```
Local files can be deployed with the Web Engine Shell and accessed via the
URL `fuchsia-dir://shell-data/PATH/TO/FILE`. Files may be added to the directory
by placing them under the path `//fuchsia/engine/test/shell_data`.
Here is an example command line which loads a local file:
```
$ run fuchsia-pkg://fuchsia.com/web_engine_shell#meta/web_engine_shell.cmx fuchsia-dir://shell-data/index.html
```
<html><body><h1>It works!</h1>
<p>This is a test of content hosted at the URL
<a href="fuchsia-pkg://shell-data/index.html">
fuchsia-pkg://shell-data/index.html
</a></p>
</body></html>
// Copyright 2019 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 <fuchsia/ui/policy/cpp/fidl.h>
#include <fuchsia/ui/views/cpp/fidl.h>
#include <fuchsia/web/cpp/fidl.h>
#include <lib/sys/cpp/component_context.h>
#include <lib/ui/scenic/cpp/view_token_pair.h>
#include "base/base_paths_fuchsia.h"
#include "base/command_line.h"
#include "base/fuchsia/default_context.h"
#include "base/fuchsia/file_utils.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "fuchsia/base/init_logging.h"
#include "url/gurl.h"
constexpr char kRemoteDebuggingPortSwitch[] = "remote-debugging-port";
constexpr char kEnableLoggingSwitch[] = "enable-logging";
void PrintUsage() {
LOG(INFO) << "Usage: "
<< base::CommandLine::ForCurrentProcess()->GetProgram().BaseName()
<< " [--" << kRemoteDebuggingPortSwitch << "] URL";
}
int main(int argc, char** argv) {
// Set up a MessageLoop for async task execution.
base::MessageLoopForIO message_loop;
// Parse the command line arguments and set up logging.
CHECK(base::CommandLine::Init(argc, argv));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitchNative(kEnableLoggingSwitch, "stderr");
CHECK(cr_fuchsia::InitLoggingFromCommandLine(*command_line));
base::CommandLine::StringVector args =
base::CommandLine::ForCurrentProcess()->GetArgs();
if (args.empty()) {
LOG(ERROR) << "No URL provided.";
PrintUsage();
return 1;
}
if (args.size() == 0) {
LOG(ERROR) << "No URL provided.";
PrintUsage();
return 1;
}
GURL url(args.front());
if (!url.is_valid()) {
LOG(ERROR) << "URL is not valid: " << url.spec();
PrintUsage();
return 1;
}
base::Optional<uint16_t> remote_debugging_port;
if (command_line->HasSwitch(kRemoteDebuggingPortSwitch)) {
std::string port_str =
command_line->GetSwitchValueNative(kRemoteDebuggingPortSwitch);
int port_parsed;
if (!base::StringToInt(port_str, &port_parsed) || port_parsed <= 0 ||
port_parsed > 65535) {
LOG(ERROR) << "Invalid value for --remote-debugging-port (must be in the "
"range 1-65535).";
PrintUsage();
return 1;
}
remote_debugging_port = base::checked_cast<uint16_t>(port_parsed);
}
auto web_context_provider = base::fuchsia::ComponentContextForCurrentProcess()
->svc()
->Connect<fuchsia::web::ContextProvider>();
// Set up the content directory fuchsia-pkg://shell-data/, which will host
// the files stored under //fuchsia/engine/test/shell_data.
fuchsia::web::CreateContextParams create_context_params;
fuchsia::web::ContentDirectoryProvider content_directory;
base::FilePath pkg_path;
base::PathService::Get(base::DIR_ASSETS, &pkg_path);
content_directory.set_directory(base::fuchsia::OpenDirectory(
pkg_path.AppendASCII("fuchsia/engine/test/shell_data")));
content_directory.set_name("shell-data");
std::vector<fuchsia::web::ContentDirectoryProvider> content_directories;
content_directories.emplace_back(std::move(content_directory));
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::fuchsia::OpenDirectory(
base::FilePath(base::fuchsia::kServiceDirectoryPath)));
// Enable other Web Engine features.
create_context_params.set_features(
fuchsia::web::ContextFeatureFlags::AUDIO |
fuchsia::web::ContextFeatureFlags::VULKAN |
fuchsia::web::ContextFeatureFlags::HARDWARE_VIDEO_DECODER |
fuchsia::web::ContextFeatureFlags::WIDEVINE_CDM);
if (remote_debugging_port)
create_context_params.set_remote_debugging_port(*remote_debugging_port);
base::RunLoop run_loop;
// Create the browser |context|.
fuchsia::web::ContextPtr context;
web_context_provider->Create(std::move(create_context_params),
context.NewRequest());
context.set_error_handler(
[quit_run_loop = run_loop.QuitClosure()](zx_status_t status) {
ZX_LOG(ERROR, status) << "Context connection lost:";
quit_run_loop.Run();
});
// Create the browser |frame| which will contain the webpage.
fuchsia::web::CreateFrameParams frame_params;
if (remote_debugging_port)
frame_params.set_enable_remote_debugging(true);
fuchsia::web::FramePtr frame;
context->CreateFrameWithParams(std::move(frame_params), frame.NewRequest());
frame.set_error_handler(
[quit_run_loop = run_loop.QuitClosure()](zx_status_t status) {
ZX_LOG(ERROR, status) << "Frame connection lost:";
quit_run_loop.Run();
});
// Navigate |frame| to |url|.
fuchsia::web::LoadUrlParams load_params;
load_params.set_type(fuchsia::web::LoadUrlReason::TYPED);
load_params.set_was_user_activated(true);
fuchsia::web::NavigationControllerPtr nav_controller;
frame->GetNavigationController(nav_controller.NewRequest());
nav_controller->LoadUrl(
url.spec(), std::move(load_params),
[quit_run_loop = run_loop.QuitClosure()](
fuchsia::web::NavigationController_LoadUrl_Result result) {
if (result.is_err()) {
LOG(ERROR) << "LoadUrl failed.";
quit_run_loop.Run();
}
});
// Present a fullscreen view of |frame|.
fuchsia::ui::views::ViewToken view_token;
fuchsia::ui::views::ViewHolderToken view_holder_token;
std::tie(view_token, view_holder_token) = scenic::NewViewTokenPair();
frame->CreateView(std::move(view_token));
auto presenter = base::fuchsia::ComponentContextForCurrentProcess()
->svc()
->Connect<::fuchsia::ui::policy::Presenter>();
presenter->PresentView(std::move(view_holder_token), nullptr);
LOG(INFO) << "Launched browser at URL " << url.spec();
// Run until the process is killed with CTRL-C or the connections to Web
// Engine interfaces are dropped.
run_loop.Run();
return 0;
}
{
"sandbox": {
"features": [
"isolated-persistent-storage",
"deprecated-ambient-replace-as-executable"
],
"services": [
"fuchsia.deprecatedtimezone.Timezone",
"fuchsia.device.NameProvider",
"fuchsia.fonts.Provider",
"fuchsia.logger.LogSink",
"fuchsia.media.Audio",
"fuchsia.media.drm.Widevine",
"fuchsia.mediacodec.CodecFactory",
"fuchsia.net.NameLookup",
"fuchsia.netstack.Netstack",
"fuchsia.posix.socket.Provider",
"fuchsia.process.Launcher",
"fuchsia.sysmem.Allocator",
"fuchsia.ui.input.ImeService",
"fuchsia.ui.input.ImeVisibilityService",
"fuchsia.ui.policy.Presenter",
"fuchsia.ui.scenic.Scenic",
"fuchsia.vulkan.loader.Loader",
"fuchsia.web.ContextProvider"
]
}
}
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