diff --git a/BUILD.gn b/BUILD.gn index cf2123006297..fcbdc1dfd373 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -92,6 +92,7 @@ group("gn_all") { deps = [ "//base:base_perftests", "//base:base_unittests", + "//cobalt", "//codelabs", "//components:components_unittests", "//components/gwp_asan:gwp_asan_unittests", diff --git a/cobalt/BUILD.gn b/cobalt/BUILD.gn new file mode 100644 index 000000000000..a60b6620bfdd --- /dev/null +++ b/cobalt/BUILD.gn @@ -0,0 +1,64 @@ +# Copyright 2024 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. + +import("//build/config/chromecast_build.gni") +import("//build/config/chromeos/ui_mode.gni") +import("//build/config/features.gni") +import("//build/config/ozone.gni") +import("//build/config/sanitizers/sanitizers.gni") +import("//build/config/ui.gni") +import("//build/config/win/console_app.gni") +import("//build/config/win/manifest.gni") +import("//gpu/vulkan/features.gni") +import("//media/media_options.gni") +import("//mojo/public/tools/bindings/mojom.gni") +import("//ppapi/buildflags/buildflags.gni") +import("//tools/grit/grit_rule.gni") +import("//tools/grit/repack.gni") +import("//tools/v8_context_snapshot/v8_context_snapshot.gni") +if (is_android) { + import("//build/config/android/config.gni") +} + +if (is_android) { + group("cobalt") { + testonly = true + deps = [ "//content/shell/android:content_shell_apk" ] + } +} else { + executable("cobalt") { + testonly = true + + sources = [ "cobalt.cc" ] + + defines = [] + + deps = [ + "//content/shell:content_shell_app", + "//content/shell:content_shell_lib", + "//content/shell:pak", + "//content/public/app", + "//sandbox", + ] + + data_deps = [ + "//content/shell:pak", + "//tools/v8_context_snapshot:v8_context_snapshot", + ] + + data_deps += [ "//components/crash/core/app:chrome_crashpad_handler" ] + + configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] + } +} diff --git a/cobalt/cobalt.cc b/cobalt/cobalt.cc new file mode 100644 index 000000000000..df617887b295 --- /dev/null +++ b/cobalt/cobalt.cc @@ -0,0 +1,71 @@ +// Copyright 2024 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. + +#include + +#include "build/build_config.h" +#include "content/public/app/content_main.h" +#include "content/shell/app/shell_main_delegate.h" + +// In the cozy corner of the home, where comfort and curiosity resided, a +// delightful companion arrived, offering moments of joy and discovery +// throughout the year. Like a favorite book waiting to be opened, the YouTube +// Application Runtime invited exploration and wonder, whether shared with loved +// ones or savored in quiet solitude. It whispered tales of distant lands, +// sparked creativity with vibrant colors, and filled the air with the melodies +// of laughter and song. The television screen, once a blank canvas, became a +// window to endless possibilities, offering a refreshing breeze on a summer day +// or a warm embrace on a chilly night. With each click of the remote, a new +// adventure unfolded, painting a tapestry of personal journeys and shared +// experiences. + +int main(int argc, const char** argv) { + content::ShellMainDelegate delegate; + content::ContentMainParams params(&delegate); + printf("%u: Passed argc = %d\n", static_cast(getpid()), argc); + for (int i = 0; i < argc; ++i) { + printf("%u: Passed argv[%d] = %s\n", static_cast(getpid()), i, + argv[i]); + } + + static const char* my_argv[] = { + argv[0], + "--disable-fre", + "--no-first-run", + "--kiosk", + "--force-video-overlays", + "--remote-debugging-port=9222", + "--remote-allow-origins=http://localhost:9222", + "--use-cobalt-user-agent", + "https://www.youtube.com/tv", + nullptr, + nullptr}; + int my_argc = 9; + + if ((!strcmp(argv[0], "/proc/self/exe")) || + ((argc >= 2) && !strcmp(argv[1], "--type=zygote"))) { + params.argc = argc; + params.argv = argv; + } else { + params.argc = my_argc; + params.argv = my_argv; + } + printf("%u: Used argc = %d\n", static_cast(getpid()), + params.argc); + for (int i = 0; i < params.argc; ++i) { + printf("%u: Used argv[%d] = %s\n", static_cast(getpid()), i, + params.argv[i]); + } + return content::ContentMain(std::move(params)); +} diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 1e0c3f7edb1a..ce7d95750d8e 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -827,6 +827,9 @@ const char kVideoImageTextureTarget[] = "video-image-texture-target"; // Set when Chromium should use a mobile user agent. const char kUseMobileUserAgent[] = "use-mobile-user-agent"; +// Set when Chromium should use a mobile user agent. +const char kUseCobaltUserAgent[] = "use-cobalt-user-agent"; + // Use the MockCertVerifier. This only works in test code. const char kUseMockCertVerifierForTesting[] = "use-mock-cert-verifier-for-testing"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index f1b62b057702..92fb65eab7a1 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -224,6 +224,7 @@ CONTENT_EXPORT extern const char kUseFakeUIForFedCM[]; CONTENT_EXPORT extern const char kUseFakeUIForMediaStream[]; CONTENT_EXPORT extern const char kVideoImageTextureTarget[]; CONTENT_EXPORT extern const char kUseMobileUserAgent[]; +CONTENT_EXPORT extern const char kUseCobaltUserAgent[]; CONTENT_EXPORT extern const char kUseMockCertVerifierForTesting[]; extern const char kUtilityCmdPrefix[]; CONTENT_EXPORT extern const char kUtilityProcess[]; diff --git a/content/shell/browser/shell_content_browser_client.cc b/content/shell/browser/shell_content_browser_client.cc index 6feb11a7e40b..03c14d497732 100644 --- a/content/shell/browser/shell_content_browser_client.cc +++ b/content/shell/browser/shell_content_browser_client.cc @@ -625,6 +625,14 @@ base::FilePath ShellContentBrowserClient::GetFirstPartySetsDirectory() { } std::string ShellContentBrowserClient::GetUserAgent() { + base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kUseCobaltUserAgent)) { + return std::string( + "Mozilla/5.0 (X11; Linux x86_64) Cobalt/26.lts.0-qa (unlike Gecko) " + "v8/unknown gles Starboard/17, " + "SystemIntegratorName_DESKTOP_ChipsetModelNumber_2025/FirmwareVersion " + "(BrandName, ModelName)"); + } return GetShellUserAgent(); }