-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minimal cobalt target. Works on Linux only (for now). $ autoninja -C out/chrobalt cobalt $ out/chrobalt/cobalt It also enables the devtools listening on 9222. b/374191454
- Loading branch information
Showing
6 changed files
with
281 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|
||
#include <unistd.h> | ||
|
||
#include "build/build_config.h" | ||
#include "cobalt/cobalt_main_delegate.h" | ||
#include "content/public/app/content_main.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) { | ||
cobalt::CobaltMainDelegate delegate; | ||
content::ContentMainParams params(&delegate); | ||
|
||
// TODO: (cobalt b/375241103) Reimplement this in a clean way. | ||
// This defines a list of command-line overrides. When adding or removing | ||
// parameters, also update the my_argc below. | ||
static const char* my_argv[] = { | ||
argv[0], "--disable-fre", "--no-first-run", "--kiosk", | ||
"--force-video-overlays", | ||
// Enable remote devtools access. | ||
"--remote-debugging-port=9222", | ||
"--remote-allow-origins=http://localhost:9222", | ||
// This flag is added specifically for m114 and should be removed after | ||
// rebasing to m120+ | ||
"--user-level-memory-pressure-signal-params", | ||
"https://www.youtube.com/tv", nullptr, nullptr}; | ||
int my_argc = 9; | ||
|
||
// TODO: (cobalt b/375241103) Reimplement this in a clean way. | ||
// This expression exists to ensure that we apply the argument overrides | ||
// only on the main process, not on spawned processes such as the zygote. | ||
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; | ||
} | ||
return content::ContentMain(std::move(params)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// 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 "cobalt/cobalt_content_browser_client.h" | ||
|
||
#include <string> | ||
|
||
#include "content/public/common/user_agent.h" | ||
|
||
namespace cobalt { | ||
|
||
#define COBALT_BRAND_NAME "Cobalt" | ||
#define COBALT_MAJOR_VERSION "26" | ||
#define COBALT_VERSION "26.lts.0-qa" | ||
|
||
std::string GetCobaltUserAgent() { | ||
// TODO: (cobalt b/375243230) Implement platform property fetching and | ||
// sanitization. | ||
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)"); | ||
} | ||
|
||
blink::UserAgentMetadata GetCobaltUserAgentMetadata() { | ||
blink::UserAgentMetadata metadata; | ||
|
||
metadata.brand_version_list.emplace_back(COBALT_BRAND_NAME, | ||
COBALT_MAJOR_VERSION); | ||
metadata.brand_full_version_list.emplace_back(COBALT_BRAND_NAME, | ||
COBALT_VERSION); | ||
metadata.full_version = COBALT_VERSION; | ||
metadata.platform = "Starboard"; | ||
metadata.architecture = content::GetCpuArchitecture(); | ||
metadata.model = content::BuildModelInfo(); | ||
|
||
metadata.bitness = content::GetCpuBitness(); | ||
metadata.wow64 = content::IsWoW64(); | ||
|
||
return metadata; | ||
} | ||
|
||
CobaltContentBrowserClient::CobaltContentBrowserClient() {} | ||
CobaltContentBrowserClient::~CobaltContentBrowserClient() {} | ||
|
||
std::string CobaltContentBrowserClient::GetUserAgent() { | ||
return GetCobaltUserAgent(); | ||
} | ||
|
||
std::string CobaltContentBrowserClient::GetFullUserAgent() { | ||
return GetCobaltUserAgent(); | ||
} | ||
|
||
std::string CobaltContentBrowserClient::GetReducedUserAgent() { | ||
return GetCobaltUserAgent(); | ||
} | ||
|
||
blink::UserAgentMetadata CobaltContentBrowserClient::GetUserAgentMetadata() { | ||
return GetCobaltUserAgentMetadata(); | ||
} | ||
|
||
} // namespace cobalt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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. | ||
|
||
#ifndef COBALT_COBALT_CONTENT_BROWSER_CLIENT_H_ | ||
#define COBALT_COBALT_CONTENT_BROWSER_CLIENT_H_ | ||
|
||
#include "content/shell/browser/shell_content_browser_client.h" | ||
|
||
namespace cobalt { | ||
|
||
class CobaltContentBrowserClient : public content::ShellContentBrowserClient { | ||
public: | ||
CobaltContentBrowserClient(); | ||
~CobaltContentBrowserClient() override; | ||
|
||
// ContentBrowserClient overrides. | ||
std::string GetUserAgent() override; | ||
std::string GetFullUserAgent() override; | ||
std::string GetReducedUserAgent() override; | ||
blink::UserAgentMetadata GetUserAgentMetadata() override; | ||
}; | ||
|
||
} // namespace cobalt | ||
|
||
#endif // COBALT_COBALT_CONTENT_BROWSER_CLIENT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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 "cobalt/cobalt_main_delegate.h" | ||
#include "cobalt/cobalt_content_browser_client.h" | ||
|
||
namespace cobalt { | ||
|
||
CobaltMainDelegate::CobaltMainDelegate(bool is_content_browsertests) | ||
: content::ShellMainDelegate(is_content_browsertests) {} | ||
|
||
CobaltMainDelegate::~CobaltMainDelegate() {} | ||
|
||
content::ContentBrowserClient* | ||
CobaltMainDelegate::CreateContentBrowserClient() { | ||
browser_client_ = std::make_unique<CobaltContentBrowserClient>(); | ||
return browser_client_.get(); | ||
} | ||
|
||
} // namespace cobalt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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. | ||
|
||
#ifndef COBALT_COBALT_MAIN_DELEGATE_H_ | ||
#define COBALT_COBALT_MAIN_DELEGATE_H_ | ||
|
||
#include "build/build_config.h" | ||
#include "content/shell/app/shell_main_delegate.h" | ||
|
||
namespace cobalt { | ||
|
||
class CobaltMainDelegate : public content::ShellMainDelegate { | ||
public: | ||
explicit CobaltMainDelegate(bool is_content_browsertests = false); | ||
|
||
CobaltMainDelegate(const CobaltMainDelegate&) = delete; | ||
CobaltMainDelegate& operator=(const CobaltMainDelegate&) = delete; | ||
|
||
// ContentMainDelegate implementation: | ||
content::ContentBrowserClient* CreateContentBrowserClient() override; | ||
|
||
~CobaltMainDelegate() override; | ||
}; | ||
|
||
} // namespace cobalt | ||
|
||
#endif // COBALT_COBALT_MAIN_DELEGATE_H_ |