Skip to content

Commit

Permalink
Add CobaltContentRendererClient
Browse files Browse the repository at this point in the history
  • Loading branch information
sideb0ard committed Jan 7, 2025
1 parent 387b23b commit 06481de
Show file tree
Hide file tree
Showing 11 changed files with 513 additions and 138 deletions.
1 change: 1 addition & 0 deletions cobalt/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if (!is_android) {
defines = []

deps = [
"//cobalt/renderer:renderer",
"//cobalt/user_agent",
"//content/public/app",
"//content/shell:content_shell_app",
Expand Down
1 change: 1 addition & 0 deletions cobalt/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ shared_library("libcobalt_content_shell_content_view") {
# TODO(b/375655377): remove testonly
testonly = true
deps = [
"//cobalt/renderer:renderer",
"//cobalt/user_agent",

# TODO: what can be removed in the dependencies?
Expand Down
7 changes: 7 additions & 0 deletions cobalt/cobalt_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "cobalt/cobalt_main_delegate.h"
#include "cobalt/cobalt_content_browser_client.h"
#include "cobalt/renderer/cobalt_content_renderer_client.h"
#include "content/public/browser/render_frame_host.h"

namespace cobalt {
Expand All @@ -29,6 +30,12 @@ CobaltMainDelegate::CreateContentBrowserClient() {
return browser_client_.get();
}

content::ContentRendererClient*
CobaltMainDelegate::CreateContentRendererClient() {
renderer_client_ = std::make_unique<CobaltContentRendererClient>();
return renderer_client_.get();
}

absl::optional<int> CobaltMainDelegate::PostEarlyInitialization(
InvokedIn invoked_in) {
content::RenderFrameHost::AllowInjectingJavaScript();
Expand Down
5 changes: 5 additions & 0 deletions cobalt/cobalt_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define COBALT_COBALT_MAIN_DELEGATE_H_

#include "build/build_config.h"
#include "cobalt/renderer/cobalt_content_renderer_client.h"
#include "content/shell/app/shell_main_delegate.h"

namespace cobalt {
Expand All @@ -29,9 +30,13 @@ class CobaltMainDelegate : public content::ShellMainDelegate {

// ContentMainDelegate implementation:
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
absl::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;

~CobaltMainDelegate() override;

private:
std::unique_ptr<CobaltContentRendererClient> renderer_client_;
};

} // namespace cobalt
Expand Down
59 changes: 59 additions & 0 deletions cobalt/common/shell_switches.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2025 The Cobalt Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cobalt/common/shell_switches.h"

#include "base/command_line.h"

namespace switches {

// Makes Content Shell use the given path for its data directory.
// NOTE: If changing this value, change the corresponding Java-side value in
// ContentShellBrowserTestActivity.java#getUserDataDirectoryCommandLineSwitch()
// to match.
const char kContentShellDataPath[] = "data-path";

// The directory breakpad should store minidumps in.
const char kCrashDumpsDir[] = "crash-dumps-dir";

// Disables the check for the system font when specified.
const char kDisableSystemFontCheck[] = "disable-system-font-check";

// Exposes the window.internals object to JavaScript for interactive development
// and debugging of web tests that rely on it.
const char kExposeInternalsForTesting[] = "expose-internals-for-testing";

// Size for the content_shell's host window (i.e. "800x600").
const char kContentShellHostWindowSize[] = "content-shell-host-window-size";

// Hides toolbar from content_shell's host window.
const char kContentShellHideToolbar[] = "content-shell-hide-toolbar";

#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
// Let DevTools front-end talk to the target of type "tab" rather than
// "frame" when inspecting a WebContents.
const char kContentShellDevToolsTabTarget[] =
"content-shell-devtools-tab-target";
#endif

// Enables APIs guarded with the [IsolatedContext] IDL attribute for the given
// comma-separated list of origins.
const char kIsolatedContextOrigins[] = "isolated-context-origins";

// Use the given address instead of the default loopback for accepting remote
// debugging connections. Note that the remote debugging protocol does not
// perform any authentication, so exposing it too widely can be a security
// risk.
const char kRemoteDebuggingAddress[] = "remote-debugging-address";

// Runs Content Shell in web test mode, injecting test-only behaviour for
// blink web tests.
const char kRunWebTests[] = "run-web-tests";

bool IsRunWebTestsSwitchPresent() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kRunWebTests);
}

} // namespace switches
33 changes: 33 additions & 0 deletions cobalt/common/shell_switches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2025 The Cobalt Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Defines all the Cobalt command-line switches.

#ifndef COBALT_COMMON_SHELL_SWITCHES_H_
#define COBALT_COMMON_SHELL_SWITCHES_H_

#include "build/build_config.h"

namespace switches {

extern const char kContentShellDataPath[];
extern const char kCrashDumpsDir[];
extern const char kDisableSystemFontCheck[];
extern const char kExposeInternalsForTesting[];
extern const char kContentShellHostWindowSize[];
extern const char kContentShellHideToolbar[];
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
extern const char kContentShellDevToolsTabTarget[];
#endif
extern const char kIsolatedContextOrigins[];
extern const char kRemoteDebuggingAddress[];
extern const char kRunWebTests[];

// Helper that returns true if kRunWebTests is present in the command line,
// meaning Content Shell is running in web test mode.
bool IsRunWebTestsSwitchPresent();

} // namespace switches

#endif // COBALT_COMMON_SHELL_SWITCHES_H_
32 changes: 32 additions & 0 deletions cobalt/renderer/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

source_set("renderer") {
sources = [
"cobalt_content_renderer_client.cc",
"cobalt_content_renderer_client.h",
]

deps = [
"//components/cdm/renderer",
"//components/network_hints/renderer",
"//components/web_cache/renderer",
"//content/public/common",
"//content/public/renderer",
"//content/test:content_test_mojo_bindings",
"//media/mojo:buildflags",
"//starboard:starboard_headers_only",
"//v8",
]
}
Loading

0 comments on commit 06481de

Please sign in to comment.