Remove custom chrome scheme handling (see #3685)

- Add CEF info to existing chrome://version WebUI.
- Move chrome://license handling to WebUI.
- Remove chrome://webui-hosts; use chrome://chrome-urls instead.
- Remove chrome://extension-support; navigate to docs directly instead.
This commit is contained in:
Marshall Greenblatt 2024-07-03 13:07:46 -04:00
parent b080705ec8
commit 9b284ec8f7
16 changed files with 536 additions and 911 deletions

View File

@ -601,8 +601,6 @@ source_set("libcef_static") {
"libcef/browser/native/window_delegate_view.h",
"libcef/browser/navigation_entry_impl.cc",
"libcef/browser/navigation_entry_impl.h",
"libcef/browser/net/chrome_scheme_handler.cc",
"libcef/browser/net/chrome_scheme_handler.h",
"libcef/browser/net/crlset_file_util_impl.cc",
"libcef/browser/net/throttle_handler.cc",
"libcef/browser/net/throttle_handler.h",

View File

@ -10,7 +10,6 @@
#include "cef/libcef/browser/chrome/chrome_startup_browser_creator.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/file_dialog_runner.h"
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
#include "cef/libcef/browser/permission_prompt.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/views/chrome_constrained_window_views_client.h"
@ -68,7 +67,6 @@ void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
{base::TaskPriority::USER_BLOCKING,
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
scheme::RegisterWebUIControllerFactory();
context_menu::RegisterCallbacks();
file_dialog_runner::RegisterFactory();
permission_prompt::RegisterCreateCallback();

View File

@ -16,7 +16,6 @@
#include "cef/libcef/browser/certificate_query.h"
#include "cef/libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
#include "cef/libcef/browser/context.h"
#include "cef/libcef/browser/net/chrome_scheme_handler.h"
#include "cef/libcef/browser/net/throttle_handler.h"
#include "cef/libcef/browser/net_service/cookie_manager_impl.h"
#include "cef/libcef/browser/net_service/login_delegate.h"
@ -466,18 +465,6 @@ ChromeContentBrowserClientCef::CreateLoginDelegate(
std::move(auth_required_callback));
}
void ChromeContentBrowserClientCef::BrowserURLHandlerCreated(
content::BrowserURLHandler* handler) {
// Register the Chrome handlers first for proper URL rewriting.
ChromeContentBrowserClient::BrowserURLHandlerCreated(handler);
scheme::BrowserURLHandlerCreated(handler);
}
bool ChromeContentBrowserClientCef::IsWebUIAllowedToMakeNetworkRequests(
const url::Origin& origin) {
return scheme::IsWebUIAllowedToMakeNetworkRequests(origin);
}
void ChromeContentBrowserClientCef::ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,

View File

@ -121,8 +121,6 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override;
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override;
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override;
void ExposeInterfacesToRenderer(
service_manager::BinderRegistry* registry,
blink::AssociatedInterfaceRegistry* associated_registry,

View File

@ -1,639 +0,0 @@
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
// Portions copyright (c) 2012 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 "cef/libcef/browser/net/chrome_scheme_handler.h"
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "cef/grit/cef_resources.h"
#include "cef/include/cef_version.h"
#include "cef/libcef/browser/frame_host_impl.h"
#include "cef/libcef/browser/thread_util.h"
#include "cef/libcef/common/app_manager.h"
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/devtools/devtools_ui_bindings.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_untrusted_web_ui_configs.h"
#include "chrome/browser/ui/webui/chrome_web_ui_configs.h"
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
#include "chrome/browser/ui/webui/theme_source.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "content/browser/renderer_host/debug_urls.h"
#include "content/public/browser/browser_url_handler.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/webui_config_map.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
#include "content/public/common/user_agent.h"
#include "ipc/ipc_channel.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "ui/base/resource/resource_bundle.h"
#include "v8/include/v8.h"
namespace scheme {
const char kChromeURL[] = "chrome://";
namespace {
const char kChromeUIExtensionsSupportHost[] = "extensions-support";
const char kChromeUILicenseHost[] = "license";
const char kChromeUIWebUIHostsHost[] = "webui-hosts";
// TODO(network): Consider handling content::kChromeDevToolsScheme via WebUI
// (DevToolsUI class) with the following changes:
// 1. Add an entry for content::kChromeDevToolsScheme in
// AlloyContentBrowserClient::GetAdditionalWebUISchemes.
// 2. Allow the scheme in CefWebUIControllerFactory::AllowWebUIForURL.
// 3. Add an entry for chrome::kChromeUIDevToolsHost in kAllowedWebUIHosts and
// kUnlistedHosts.
// 4. Remove scheme::RegisterInternalHandlers and related plumbing.
// Chrome hosts implemented by WebUI.
// Some WebUI handlers have Chrome dependencies that may fail in CEF without
// additional changes. Do not add new hosts to this list without also manually
// testing all related functionality in CEF.
const char* kAllowedWebUIHosts[] = {
chrome::kChromeUIAccessibilityHost,
content::kChromeUIBlobInternalsHost,
chrome::kChromeUIChromeURLsHost,
chrome::kChromeUICreditsHost,
kChromeUIExtensionsSupportHost,
content::kChromeUIGpuHost,
content::kChromeUIHistogramHost,
content::kChromeUIIndexedDBInternalsHost,
kChromeUILicenseHost,
content::kChromeUIMediaInternalsHost,
chrome::kChromeUINetExportHost,
chrome::kChromeUINetInternalsHost,
content::kChromeUINetworkErrorHost,
content::kChromeUINetworkErrorsListingHost,
chrome::kChromeUIPrintHost,
content::kChromeUIProcessInternalsHost,
content::kChromeUIResourcesHost,
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
chrome::kChromeUISandboxHost,
#endif
content::kChromeUIServiceWorkerInternalsHost,
chrome::kChromeUISystemInfoHost,
chrome::kChromeUIThemeHost,
content::kChromeUITracingHost,
chrome::kChromeUIVersionHost,
content::kChromeUIWebRTCInternalsHost,
kChromeUIWebUIHostsHost,
};
// Hosts that don't have useful output when linked directly. They'll be excluded
// from the "chrome://webui-hosts" listing.
const char* kUnlistedHosts[] = {
content::kChromeUINetworkErrorHost,
content::kChromeUIResourcesHost,
chrome::kChromeUIThemeHost,
};
enum ChromeHostId {
CHROME_UNKNOWN = 0,
CHROME_EXTENSIONS_SUPPORT,
CHROME_LICENSE,
CHROME_VERSION,
CHROME_WEBUI_HOSTS,
};
// Chrome hosts implemented by CEF.
const struct {
const char* host;
ChromeHostId host_id;
} kAllowedCefHosts[] = {
{chrome::kChromeUIChromeURLsHost, CHROME_WEBUI_HOSTS},
{kChromeUIExtensionsSupportHost, CHROME_EXTENSIONS_SUPPORT},
{kChromeUILicenseHost, CHROME_LICENSE},
{chrome::kChromeUIVersionHost, CHROME_VERSION},
{kChromeUIWebUIHostsHost, CHROME_WEBUI_HOSTS},
};
ChromeHostId GetChromeHostId(const std::string& host) {
for (auto kAllowedCefHost : kAllowedCefHosts) {
if (base::EqualsCaseInsensitiveASCII(kAllowedCefHost.host, host.c_str())) {
return kAllowedCefHost.host_id;
}
}
return CHROME_UNKNOWN;
}
// Returns WebUI hosts. Does not include chrome debug hosts (for crashing, etc).
void GetAllowedHosts(std::vector<std::string>* hosts) {
// Explicitly whitelisted WebUI hosts.
for (auto& kAllowedWebUIHost : kAllowedWebUIHosts) {
hosts->push_back(kAllowedWebUIHost);
}
}
// Returns true if a host should not be listed on "chrome://webui-hosts".
bool IsUnlistedHost(const std::string& host) {
for (auto& kUnlistedHost : kUnlistedHosts) {
if (host == kUnlistedHost) {
return true;
}
}
return false;
}
// Additional debug URLs that are not included in chrome::kChromeDebugURLs.
const char* kAllowedDebugURLs[] = {
blink::kChromeUIBrowserCrashURL,
};
void GetDebugURLs(std::vector<std::string>* urls) {
for (size_t i = 0; i < chrome::kNumberOfChromeDebugURLs; ++i) {
urls->push_back(chrome::kChromeDebugURLs[i]);
}
for (auto& kAllowedDebugURL : kAllowedDebugURLs) {
urls->push_back(kAllowedDebugURL);
}
}
std::string GetOSType() {
#if BUILDFLAG(IS_WIN)
return "Windows";
#elif BUILDFLAG(IS_MAC)
return "Mac OS X";
#elif BUILDFLAG(IS_LINUX)
return "Linux";
#else
return "Unknown";
#endif
}
std::string GetCommandLine() {
#if BUILDFLAG(IS_WIN)
return base::WideToUTF8(
base::CommandLine::ForCurrentProcess()->GetCommandLineString());
#elif BUILDFLAG(IS_POSIX)
std::string command_line = "";
using ArgvList = std::vector<std::string>;
const ArgvList& argv = base::CommandLine::ForCurrentProcess()->argv();
for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end();
iter++) {
command_line += " " + *iter;
}
// TODO(viettrungluu): |command_line| could really have any encoding, whereas
// below we assumes it's UTF-8.
return command_line;
#endif
}
std::string GetModulePath() {
base::FilePath path;
if (base::PathService::Get(base::FILE_MODULE, &path)) {
return CefString(path.value());
}
return std::string();
}
class TemplateParser {
public:
TemplateParser() : ident_start_("$$"), ident_end_("$$") {}
TemplateParser(const std::string& ident_start, const std::string& ident_end)
: ident_start_(ident_start), ident_end_(ident_end) {}
void Add(const std::string& key, const std::string& value) {
values_.insert(std::make_pair(key, value));
}
void Parse(std::string* tmpl) {
int start_pos, end_pos = 0;
int ident_start_len = ident_start_.length();
int ident_end_len = ident_end_.length();
while (true) {
start_pos = tmpl->find(ident_start_, end_pos);
if (start_pos >= 0) {
end_pos = tmpl->find(ident_end_, start_pos + ident_start_len);
if (end_pos >= 0) {
// Found an identifier. Check if a substitution exists.
std::string key = tmpl->substr(start_pos + ident_start_len,
end_pos - start_pos - ident_start_len);
KeyMap::const_iterator it = values_.find(key);
if (it != values_.end()) {
// Peform the substitution.
tmpl->replace(start_pos, end_pos + ident_end_len - start_pos,
it->second);
end_pos = start_pos + it->second.length();
} else {
// Leave the unknown identifier in place.
end_pos += ident_end_len;
}
if (end_pos >= static_cast<int>(tmpl->length()) - ident_start_len -
ident_end_len) {
// Not enough room remaining for more identifiers.
break;
}
} else {
// No end identifier found.
break;
}
} else {
// No start identifier found.
break;
}
}
}
private:
using KeyMap = std::map<std::string, std::string>;
KeyMap values_;
std::string ident_start_;
std::string ident_end_;
};
bool OnExtensionsSupportUI(std::string* mime_type, std::string* output) {
*mime_type = "text/html";
// Redirect to the Chrome documentation.
*output =
"<html><head>\n"
"<meta http-equiv=\"refresh\" "
"content=\"0;URL='https://developer.chrome.com/docs/extensions/'\"/>\n"
"</head></html>\n";
return true;
}
bool OnLicenseUI(std::string* mime_type, std::string* output) {
std::string piece =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_CEF_LICENSE_TXT);
if (piece.empty()) {
DCHECK(false) << "Failed to load license txt resource.";
return false;
}
*mime_type = "text/html";
*output = "<html><head><title>License</title></head><body><pre>" + piece +
"</pre></body></html>";
return true;
}
bool OnVersionUI(Profile* profile,
std::string* mime_type,
std::string* output) {
std::string tmpl =
ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
IDR_CEF_VERSION_HTML);
if (tmpl.empty()) {
DCHECK(false) << "Failed to load version html resource.";
return false;
}
base::FilePath user_data_dir =
base::PathService::CheckedGet(chrome::DIR_USER_DATA);
TemplateParser parser;
parser.Add("YEAR", MAKE_STRING(COPYRIGHT_YEAR));
parser.Add("CEF", CEF_VERSION);
parser.Add("CHROMIUM",
base::StringPrintf("%d.%d.%d.%d", CHROME_VERSION_MAJOR,
CHROME_VERSION_MINOR, CHROME_VERSION_BUILD,
CHROME_VERSION_PATCH));
parser.Add("OS", GetOSType());
parser.Add("WEBKIT", content::GetWebKitVersion());
parser.Add("JAVASCRIPT", v8::V8::GetVersion());
parser.Add(
"USERAGENT",
CefAppManager::Get()->GetContentClient()->browser()->GetUserAgent());
parser.Add("COMMANDLINE", GetCommandLine());
parser.Add("MODULEPATH", GetModulePath());
parser.Add("ROOTCACHEPATH", CefString(user_data_dir.value()));
parser.Add("CACHEPATH", CefString(profile->GetPath().value()));
parser.Parse(&tmpl);
*mime_type = "text/html";
*output = tmpl;
return true;
}
bool OnWebUIHostsUI(std::string* mime_type, std::string* output) {
std::string html =
"<html>\n<head><title>Chrome URLs</title></head>\n"
"<body bgcolor=\"white\"><h3>List of Chrome URLs</h3>\n<ul>\n";
std::vector<std::string> list;
GetAllowedHosts(&list);
std::sort(list.begin(), list.end());
for (const auto& i : list) {
if (IsUnlistedHost(i)) {
continue;
}
html += "<li><a href=\"chrome://" + i + "\">chrome://" + i + "</a></li>\n";
}
list.clear();
GetDebugURLs(&list);
std::sort(list.begin(), list.end());
html +=
"</ul>\n<h3>For Debug</h3>\n"
"<p>The following pages are for debugging purposes only. Because they "
"crash or hang the renderer, they're not linked directly; you can type "
"them into the address bar if you need them.</p>\n<ul>\n";
for (const auto& i : list) {
html += "<li>" + std::string(i) + "</li>\n";
}
html += "</ul>\n";
html += "</body>\n</html>";
*mime_type = "text/html";
*output = html;
return true;
}
const content::WebUI::TypeID kCefWebUITypeID = &kCefWebUITypeID;
class CefURLDataSource : public content::URLDataSource {
public:
CefURLDataSource(const std::string& host,
ChromeHostId host_id,
Profile* profile)
: host_(host), host_id_(host_id), profile_(profile) {
CEF_REQUIRE_UIT();
output_ = new base::RefCountedString();
bool handled = false;
switch (host_id_) {
case CHROME_EXTENSIONS_SUPPORT:
handled = OnExtensionsSupportUI(&mime_type_, &output_->as_string());
break;
case CHROME_LICENSE:
handled = OnLicenseUI(&mime_type_, &output_->as_string());
break;
case CHROME_VERSION:
handled = OnVersionUI(profile_, &mime_type_, &output_->as_string());
break;
case CHROME_WEBUI_HOSTS:
handled = OnWebUIHostsUI(&mime_type_, &output_->as_string());
break;
default:
break;
}
DCHECK(handled) << "Unhandled WebUI host: " << host;
}
CefURLDataSource(const CefURLDataSource&) = delete;
CefURLDataSource& operator=(const CefURLDataSource&) = delete;
~CefURLDataSource() override = default;
// content::URLDataSource implementation.
std::string GetSource() override { return host_; }
void StartDataRequest(
const GURL& path,
const content::WebContents::Getter& wc_getter,
content::URLDataSource::GotDataCallback callback) override {
std::move(callback).Run(output_);
}
std::string GetMimeType(const GURL& url) override { return mime_type_; }
bool AllowCaching() override { return false; }
private:
const std::string host_;
const ChromeHostId host_id_;
const raw_ptr<Profile> profile_;
std::string mime_type_;
scoped_refptr<base::RefCountedString> output_;
};
class CefWebUIController : public content::WebUIController {
public:
CefWebUIController(content::WebUI* web_ui,
const std::string& host,
ChromeHostId host_id)
: content::WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(
profile, std::make_unique<CefURLDataSource>(host, host_id, profile));
}
CefWebUIController(const CefWebUIController&) = delete;
CefWebUIController& operator=(const CefWebUIController&) = delete;
~CefWebUIController() override = default;
};
// Intercepts all WebUI calls and either blocks them or forwards them to the
// Content or Chrome WebUI factory as appropriate.
class CefWebUIControllerFactory : public content::WebUIControllerFactory {
public:
CefWebUIControllerFactory(const CefWebUIControllerFactory&) = delete;
CefWebUIControllerFactory& operator=(const CefWebUIControllerFactory&) =
delete;
// Returns true if WebUI is allowed to handle the specified |url|.
static bool AllowWebUIForURL(const GURL& url) {
if (url.SchemeIs(content::kChromeDevToolsScheme)) {
return DevToolsUIBindings::IsValidFrontendURL(url);
}
if (!url.SchemeIs(content::kChromeUIScheme) &&
!url.SchemeIs(content::kChromeUIUntrustedScheme)) {
return false;
}
return true;
}
// Returns true if WebUI is allowed to make network requests.
static bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) {
if (!AllowWebUIForURL(origin.GetURL())) {
return false;
}
if (ChromeWebUIControllerFactory::IsWebUIAllowedToMakeNetworkRequests(
origin)) {
return true;
}
return false;
}
std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) override {
std::unique_ptr<content::WebUIController> controller;
if (!AllowWebUIForURL(url)) {
return controller;
}
// Set up the chrome://theme/ source. These URLs are referenced from many
// places (WebUI and chrome://resources which live in //ui). WebUI code
// can live in both //content and //chrome. Since ThemeSource lives in
// //chrome the WebUI from //content is not performing this setup despite
// the fact that it's needed for proper handling of theme resource requests.
// See https://crbug.com/1011280.
Profile* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(profile,
std::make_unique<ThemeSource>(profile));
const auto host_id = GetChromeHostId(url.host());
if (host_id != CHROME_UNKNOWN) {
return std::make_unique<CefWebUIController>(web_ui, url.host(), host_id);
}
controller = content::WebUIConfigMap::GetInstance()
.controller_factory()
->CreateWebUIControllerForURL(web_ui, url);
if (controller) {
return controller;
}
return ChromeWebUIControllerFactory::GetInstance()
->CreateWebUIControllerForURL(web_ui, url);
}
content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context,
const GURL& url) override {
content::WebUI::TypeID type = content::WebUI::kNoWebUI;
if (!AllowWebUIForURL(url)) {
return type;
}
const auto host_id = GetChromeHostId(url.host());
if (host_id != CHROME_UNKNOWN) {
return kCefWebUITypeID;
}
type = content::WebUIConfigMap::GetInstance()
.controller_factory()
->GetWebUIType(browser_context, url);
if (type != content::WebUI::kNoWebUI) {
return type;
}
type = ChromeWebUIControllerFactory::GetInstance()->GetWebUIType(
browser_context, url);
if (type != content::WebUI::kNoWebUI) {
return type;
}
return content::WebUI::kNoWebUI;
}
bool UseWebUIForURL(content::BrowserContext* browser_context,
const GURL& url) override {
if (!AllowWebUIForURL(url)) {
return false;
}
const auto host_id = GetChromeHostId(url.host());
if (host_id != CHROME_UNKNOWN) {
return true;
}
if (content::WebUIConfigMap::GetInstance()
.controller_factory()
->UseWebUIForURL(browser_context, url) ||
ChromeWebUIControllerFactory::GetInstance()->UseWebUIForURL(
browser_context, url)) {
return true;
}
return false;
}
static void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) {
// chrome: & friends. The default registration is disabled is
// ChromeContentBrowserClient::BrowserURLHandlerCreated().
handler->AddHandlerPair(&HandleWebUI, &HandleWebUIReverse);
}
static CefWebUIControllerFactory* GetInstance();
protected:
CefWebUIControllerFactory() = default;
~CefWebUIControllerFactory() override = default;
private:
friend struct base::LazyInstanceTraitsBase<CefWebUIControllerFactory>;
// From chrome/browser/chrome_content_browser_client.cc
// Handles rewriting Web UI URLs.
static bool HandleWebUI(GURL* url, content::BrowserContext* browser_context) {
if (!GetInstance()->UseWebUIForURL(browser_context, *url)) {
return false;
}
return true;
}
// Reverse URL handler for Web UI.
static bool HandleWebUIReverse(GURL* url,
content::BrowserContext* browser_context) {
// No need to actually reverse-rewrite the URL.
return false;
}
};
base::LazyInstance<CefWebUIControllerFactory>::Leaky
g_web_ui_controller_factory = LAZY_INSTANCE_INITIALIZER;
// static
CefWebUIControllerFactory* CefWebUIControllerFactory::GetInstance() {
return &g_web_ui_controller_factory.Get();
}
} // namespace
void RegisterWebUIControllerFactory() {
// Channel all WebUI handling through CefWebUIControllerFactory.
content::WebUIControllerFactory::UnregisterFactoryForTesting(
content::WebUIConfigMap::GetInstance().controller_factory());
content::WebUIControllerFactory::RegisterFactory(
CefWebUIControllerFactory::GetInstance());
RegisterChromeWebUIConfigs();
RegisterChromeUntrustedWebUIConfigs();
}
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) {
CefWebUIControllerFactory::BrowserURLHandlerCreated(handler);
}
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) {
return CefWebUIControllerFactory::IsWebUIAllowedToMakeNetworkRequests(origin);
}
} // namespace scheme

View File

@ -1,43 +0,0 @@
// Copyright (c) 2012 The Chromium Embedded Framework 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 CEF_LIBCEF_BROWSER_NET_CHROME_SCHEME_HANDLER_H_
#define CEF_LIBCEF_BROWSER_NET_CHROME_SCHEME_HANDLER_H_
#pragma once
#include <string>
#include "cef/include/cef_browser.h"
#include "cef/include/cef_frame.h"
#include "cef/include/cef_process_message.h"
#include "url/gurl.h"
namespace base {
class ListValue;
}
namespace content {
class BrowserURLHandler;
}
namespace url {
class Origin;
}
namespace scheme {
extern const char kChromeURL[];
// Register the WebUI controller factory.
void RegisterWebUIControllerFactory();
// Register the WebUI handler.
void BrowserURLHandlerCreated(content::BrowserURLHandler* handler);
// Returns true if WebUI is allowed to make network requests.
bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin);
} // namespace scheme
#endif // CEF_LIBCEF_BROWSER_CHROME_SCHEME_HANDLER_H_

View File

@ -1,141 +0,0 @@
<!DOCTYPE HTML>
<!--
about:version template page
-->
<html id="t" i18n-values="dir:textdirection;">
<head>
<title>About Version</title>
<style>/* Copyright (c) 2012 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. */
body {
background-color: white;
color: black;
font-family: Helvetica,Arial,sans-serif;
margin: 0;
}
#outer {
margin-left: auto;
margin-right: auto;
margin-top: 10px;
width: 820px;
}
#inner {
padding-top: 10px;
width: 550px;
}
.label {
-webkit-padding-end: 5px;
font-size: 0.9em;
font-weight: bold;
text-align: end;
white-space: nowrap;
}
.label:after {
content: ':';
}
.footnote {
font-size: 0.8em;
}
#logo {
float: right;
margin-left: 40px;
text-align: right;
width: 200px;
}
#company {
font-size: 0.7em;
text-align: right;
}
#copyright {
font-size: 0.7em;
text-align: right;
}
.value {
font-family: monospace;
max-width: 430px;
padding-left: 5px;
}
</style>
</head>
<body>
<div id="outer">
<div id="logo">
<div id="company">Chromium Embedded Framework (CEF)</div>
<div id="copyright">Copyright &copy; $$YEAR$$ The Chromium Embedded Framework Authors.<br/>All rights reserved.<br/><a href="chrome://license">license</a> | <a href="chrome://credits">credits</a></div>
</div>
<table id="inner" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="label" valign="top">CEF</td>
<td class="value">$$CEF$$</td>
</tr>
<tr>
<td class="label" valign="top">Chromium</td>
<td class="value">$$CHROMIUM$$</td>
</tr>
<tr>
<td class="label" valign="top">OS</td>
<td class="value">$$OS$$</td>
</tr>
<tr>
<td class="label" valign="top">WebKit</td>
<td class="value">$$WEBKIT$$</td>
</tr>
<tr>
<td class="label" valign="top">JavaScript</td>
<td class="value">$$JAVASCRIPT$$</td>
</tr>
<tr>
<td class="label" valign="top">User Agent</td>
<td class="value">$$USERAGENT$$</td>
</tr>
<tr>
<td class="label" valign="top">Command Line</td>
<td class="value">$$COMMANDLINE$$</td>
</tr>
<tr>
<td class="label" valign="top">Module Path</td>
<td class="value">$$MODULEPATH$$</td>
</tr>
<tr>
<td class="label" valign="top">Root Cache Path <sup>[1][2]</sup></td>
<td class="value">$$ROOTCACHEPATH$$</td>
</tr>
<tr>
<td class="label" valign="top">Cache Path <sup>[1]</sup></td>
<td class="value">$$CACHEPATH$$</td>
</tr>
<tr>
<td colspan="2" class="footnote">
<br>[1] In <a href="https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md" target="_new">Chromium terminology</a>,
"Root Cache Path" (<a href="https://cef-builds.spotifycdn.com/docs/beta.html?structcef__settings__t.html#a2e2be03f34ddd93de90e1cf196757a19" target="_new">CefSettings.root_cache_path</a>)
is the "User Data Directory" and "Cache Path" (<a href="https://cef-builds.spotifycdn.com/docs/beta.html?structcef__settings__t.html#ad1644a7eb23cad969181db010f007710" target="_new">CefSettings.cache_path</a>)
is the "Profile Path". An empty "Cache Path" value means that the browser is using an <a href="https://support.google.com/chrome/answer/9845881" target="_new">Incognito Profile</a>.
Even in Incognito mode, some per-installation data will still be written to the "Root Cache Path" directory.
<br/><br/>[2] Chromium's <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/process_singleton.h#35" target="_new">process singleton lock</a>
protects against multiple app instances writing to the same "Root Cache Path" directory.
Implement <a href="https://cef-builds.spotifycdn.com/docs/beta.html?classCefBrowserProcessHandler.html#a052a91639483467c0b546d57a05c2f06" target="_new">CefBrowserProcessHandler:: OnAlreadyRunningAppRelaunch</a>
to handle the case of app relaunch with the same directory.
</td>
</tr>
</table>
</div>
</body>
</html>

View File

@ -10,7 +10,6 @@
<release seq="1">
<includes>
<include name="IDR_CEF_LICENSE_TXT" file="..\..\LICENSE.txt" type="BINDATA" />
<include name="IDR_CEF_VERSION_HTML" file="about_version.html" type="BINDATA" />
</includes>
</release>
</grit>

View File

@ -332,6 +332,14 @@ patches = [
# Fix Jumbo/component build dependency issue.
'name': 'chrome_browser_safe_browsing',
},
{
# Support loading of chrome://license via WebUI.
'name': 'chrome_browser_webui_license',
},
{
# Support customization of chrome://version WebUI.
'name': 'chrome_browser_webui_version',
},
{
# Add BrowserPluginGuest::owner_web_contents() method.
'name': 'chrome_plugins',
@ -466,15 +474,6 @@ patches = [
# This crash was introduced by https://crrev.com/5f6212babf.
'name': 'browser_scheduler',
},
{
# Restore access to WebUIControllerFactory::UnregisterFactoryForTesting
# which was removed in https://crrev.com/5f183d6636. We can't use
# ScopedWebUIControllerFactoryRegistration because it pulls in GTest
# dependencies.
#
# Add accessor for WebUIConfigMap::webui_controller_factory_.
'name': 'browser_web_ui_controller_factory',
},
{
# Add support for OSR rendering with Viz.
# https://github.com/chromiumembedded/cef/issues/2575

View File

@ -1,29 +0,0 @@
diff --git content/public/browser/web_ui_controller_factory.h content/public/browser/web_ui_controller_factory.h
index 9d9c17ffd6474..4eb79c65369af 100644
--- content/public/browser/web_ui_controller_factory.h
+++ content/public/browser/web_ui_controller_factory.h
@@ -47,9 +47,6 @@ class CONTENT_EXPORT WebUIControllerFactory {
virtual bool UseWebUIForURL(BrowserContext* browser_context,
const GURL& url) = 0;
- private:
- friend class ScopedWebUIControllerFactoryRegistration;
-
static void UnregisterFactoryForTesting(WebUIControllerFactory* factory);
};
diff --git content/public/browser/webui_config_map.h content/public/browser/webui_config_map.h
index e7b6a9b841abb..1c98be86c0db1 100644
--- content/public/browser/webui_config_map.h
+++ content/public/browser/webui_config_map.h
@@ -68,6 +68,10 @@ class CONTENT_EXPORT WebUIConfigMap {
std::vector<WebUIConfigInfo> GetWebUIConfigList(
BrowserContext* browser_context);
+ WebUIControllerFactory* controller_factory() const {
+ return webui_controller_factory_.get();
+ }
+
private:
void AddWebUIConfigImpl(std::unique_ptr<WebUIConfig> config);

View File

@ -74,7 +74,7 @@ index 02ff1e580d3a7..7f51115896049 100644
}
diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
index 74460ac479210..8cf70c80a87ad 100644
index 74460ac479210..c484be466eefb 100644
--- chrome/browser/ui/BUILD.gn
+++ chrome/browser/ui/BUILD.gn
@@ -8,6 +8,7 @@ import("//build/config/compiler/compiler.gni")
@ -104,7 +104,18 @@ index 74460ac479210..8cf70c80a87ad 100644
"//chrome:resources",
"//chrome:strings",
"//chrome/app:chrome_dll_resources",
@@ -3040,6 +3046,8 @@ static_library("ui") {
@@ -759,6 +765,10 @@ static_library("ui") {
deps += [ "//components/plus_addresses/resources:vector_icons" ]
}
+ if (enable_cef) {
+ deps += [ "//cef:cef_resources" ]
+ }
+
# TODO(crbug.com/41437292): Remove this circular dependency.
allow_circular_includes_from = [
# TODO(crbug.com/40161499): Remove this circular dependency.
@@ -3040,6 +3050,8 @@ static_library("ui") {
"views/apps/app_dialog/app_local_block_dialog_view.h",
"views/apps/app_dialog/app_pause_dialog_view.cc",
"views/apps/app_dialog/app_pause_dialog_view.h",
@ -113,7 +124,7 @@ index 74460ac479210..8cf70c80a87ad 100644
"views/apps/app_info_dialog/arc_app_info_links_panel.cc",
"views/apps/app_info_dialog/arc_app_info_links_panel.h",
"views/apps/chrome_app_window_client_views_chromeos.cc",
@@ -4249,8 +4257,6 @@ static_library("ui") {
@@ -4249,8 +4261,6 @@ static_library("ui") {
"autofill/payments/webauthn_dialog_model.h",
"autofill/payments/webauthn_dialog_model_observer.h",
"autofill/payments/webauthn_dialog_state.h",
@ -122,7 +133,7 @@ index 74460ac479210..8cf70c80a87ad 100644
"incognito_clear_browsing_data_dialog_interface.h",
"signin/signin_modal_dialog.cc",
"signin/signin_modal_dialog.h",
@@ -5125,8 +5131,6 @@ static_library("ui") {
@@ -5125,8 +5135,6 @@ static_library("ui") {
"views/accessibility/theme_tracking_non_accessible_image_view.h",
"views/apps/app_dialog/app_dialog_view.cc",
"views/apps/app_dialog/app_dialog_view.h",
@ -131,7 +142,7 @@ index 74460ac479210..8cf70c80a87ad 100644
"views/apps/app_info_dialog/app_info_dialog_container.cc",
"views/apps/app_info_dialog/app_info_dialog_container.h",
"views/apps/app_info_dialog/app_info_dialog_views.cc",
@@ -6908,6 +6912,7 @@ static_library("ui") {
@@ -6908,6 +6916,7 @@ static_library("ui") {
if (enable_printing) {
deps += [
"//components/printing/browser",

View File

@ -0,0 +1,120 @@
diff --git chrome/browser/ui/webui/about/about_ui.cc chrome/browser/ui/webui/about/about_ui.cc
index 7d04b86885167..b89b060efc9e0 100644
--- chrome/browser/ui/webui/about/about_ui.cc
+++ chrome/browser/ui/webui/about/about_ui.cc
@@ -34,6 +34,7 @@
#include "base/values.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
@@ -91,6 +92,10 @@
#include "chrome/common/webui_url_constants.h"
#endif // BUILDFLAG(IS_CHROMEOS)
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/grit/cef_resources.h"
+#endif
+
using content::BrowserThread;
namespace {
@@ -692,6 +697,16 @@ void AboutUIHTMLSource::StartDataRequest(
IDS_TERMS_HTML);
#endif
}
+#if BUILDFLAG(ENABLE_CEF)
+ else if (source_name_ == chrome::kChromeUILicenseHost) {
+ response =
+ "<html><head><title>CEF License</title></head>"
+ "<body bgcolor=\"white\"><pre>" +
+ ui::ResourceBundle::GetSharedInstance().LoadDataResourceString(
+ IDR_CEF_LICENSE_TXT) +
+ "</pre></body></html>";
+ }
+#endif
FinishDataRequest(response, std::move(callback));
}
diff --git chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 7b61f43d8c72a..811d075966239 100644
--- chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -18,6 +18,7 @@
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/about_flags.h"
#include "chrome/browser/buildflags.h"
#include "chrome/browser/commerce/shopping_service_factory.h"
@@ -391,6 +392,9 @@ bool IsAboutUI(const GURL& url) {
|| url.host_piece() == chrome::kChromeUIOSCreditsHost ||
url.host_piece() == chrome::kChromeUIBorealisCreditsHost ||
url.host_piece() == chrome::kChromeUICrostiniCreditsHost
+#endif
+#if BUILDFLAG(ENABLE_CEF)
+ || url.host_piece() == chrome::kChromeUILicenseHost
#endif
); // NOLINT
}
@@ -1019,6 +1023,9 @@ ChromeWebUIControllerFactory::GetListOfAcceptableURLs() {
GURL(chrome::kChromeUIGpuURL),
GURL(chrome::kChromeUIHistogramsURL),
GURL(chrome::kChromeUIInspectURL),
+#if BUILDFLAG(ENABLE_CEF)
+ GURL(chrome::kChromeUILicenseURL),
+#endif
GURL(chrome::kChromeUIManagementURL),
GURL(chrome::kChromeUINetExportURL),
GURL(chrome::kChromeUIPrefsInternalsURL),
diff --git chrome/common/webui_url_constants.cc chrome/common/webui_url_constants.cc
index 4604facee295e..acd8857875d6e 100644
--- chrome/common/webui_url_constants.cc
+++ chrome/common/webui_url_constants.cc
@@ -131,6 +131,10 @@ const char kChromeUILauncherInternalsHost[] = "launcher-internals";
const char kChromeUILauncherInternalsURL[] = "chrome://launcher-internals";
const char kChromeUILensSearchBubbleHost[] = "lens-search-bubble";
const char kChromeUILensSearchBubbleURL[] = "chrome://lens-search-bubble/";
+#if BUILDFLAG(ENABLE_CEF)
+const char kChromeUILicenseHost[] = "license";
+const char kChromeUILicenseURL[] = "chrome://license/";
+#endif
const char kChromeUISensorInfoHost[] = "sensor-info";
const char kChromeUISensorInfoURL[] = "chrome://sensor-info/";
const char kChromeUILocalStateHost[] = "local-state";
@@ -704,6 +708,9 @@ const char* const kChromeHostURLs[] = {
kChromeUIHumanPresenceInternalsHost,
#endif
kChromeUIInterstitialHost,
+#if BUILDFLAG(ENABLE_CEF)
+ kChromeUILicenseHost,
+#endif
kChromeUILocalStateHost,
#if !BUILDFLAG(IS_ANDROID)
kChromeUIManagementHost,
diff --git chrome/common/webui_url_constants.h chrome/common/webui_url_constants.h
index b1247ef8ad3ff..a4ebfe2d585a0 100644
--- chrome/common/webui_url_constants.h
+++ chrome/common/webui_url_constants.h
@@ -15,6 +15,7 @@
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/common/buildflags.h"
#include "components/lens/buildflags.h"
#include "content/public/common/url_constants.h"
@@ -123,6 +124,10 @@ extern const char kChromeUILauncherInternalsHost[];
extern const char kChromeUILauncherInternalsURL[];
extern const char kChromeUILensSearchBubbleHost[];
extern const char kChromeUILensSearchBubbleURL[];
+#if BUILDFLAG(ENABLE_CEF)
+extern const char kChromeUILicenseHost[];
+extern const char kChromeUILicenseURL[];
+#endif
extern const char kChromeUISensorInfoURL[];
extern const char kChromeUISensorInfoHost[];
extern const char kChromeUILocalStateHost[];

View File

@ -0,0 +1,381 @@
diff --git chrome/browser/ui/webui/version/version_handler.cc chrome/browser/ui/webui/version/version_handler.cc
index 55541159e5fc8..8021d1d963f59 100644
--- chrome/browser/ui/webui/version/version_handler.cc
+++ chrome/browser/ui/webui/version/version_handler.cc
@@ -27,12 +27,23 @@
#include "ui/base/l10n/l10n_util.h"
#include "url/gurl.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "base/base_paths.h"
+#include "base/path_service.h"
+#include "chrome/common/chrome_paths.h"
+#endif
+
namespace {
// Retrieves the executable and profile paths on the FILE thread.
void GetFilePaths(const base::FilePath& profile_path,
std::u16string* exec_path_out,
- std::u16string* profile_path_out) {
+ std::u16string* profile_path_out
+#if BUILDFLAG(ENABLE_CEF)
+ , std::u16string* module_path_out,
+ std::u16string* user_data_path_out
+#endif
+ ) {
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
base::BlockingType::MAY_BLOCK);
@@ -48,6 +59,19 @@ void GetFilePaths(const base::FilePath& profile_path,
*profile_path_out = profile_path.LossyDisplayName();
else
*profile_path_out = l10n_util::GetStringUTF16(IDS_VERSION_UI_PATH_NOTFOUND);
+
+#if BUILDFLAG(ENABLE_CEF)
+ base::FilePath module_path;
+ if (base::PathService::Get(base::FILE_MODULE, &module_path)) {
+ *module_path_out = module_path.LossyDisplayName();
+ } else {
+ *module_path_out = l10n_util::GetStringUTF16(IDS_VERSION_UI_PATH_NOTFOUND);
+ }
+
+ base::FilePath user_data_dir =
+ base::PathService::CheckedGet(chrome::DIR_USER_DATA);
+ *user_data_path_out = user_data_dir.LossyDisplayName();
+#endif
}
} // namespace
@@ -111,23 +135,46 @@ void VersionHandler::HandleRequestPathInfo(const base::Value::List& args) {
// OnGotFilePaths.
std::u16string* exec_path_buffer = new std::u16string;
std::u16string* profile_path_buffer = new std::u16string;
+#if BUILDFLAG(ENABLE_CEF)
+ std::u16string* module_path_buffer = new std::u16string;
+ std::u16string* user_data_path_buffer = new std::u16string;
+#endif
base::ThreadPool::PostTaskAndReply(
FROM_HERE, {base::TaskPriority::USER_VISIBLE, base::MayBlock()},
base::BindOnce(&GetFilePaths, Profile::FromWebUI(web_ui())->GetPath(),
base::Unretained(exec_path_buffer),
- base::Unretained(profile_path_buffer)),
+ base::Unretained(profile_path_buffer)
+#if BUILDFLAG(ENABLE_CEF)
+ , base::Unretained(module_path_buffer),
+ base::Unretained(user_data_path_buffer)
+#endif
+ ),
base::BindOnce(&VersionHandler::OnGotFilePaths,
weak_ptr_factory_.GetWeakPtr(), callback_id,
base::Owned(exec_path_buffer),
- base::Owned(profile_path_buffer)));
+ base::Owned(profile_path_buffer)
+#if BUILDFLAG(ENABLE_CEF)
+ , base::Owned(module_path_buffer),
+ base::Owned(user_data_path_buffer)
+#endif
+ ));
}
void VersionHandler::OnGotFilePaths(std::string callback_id,
std::u16string* executable_path_data,
- std::u16string* profile_path_data) {
+ std::u16string* profile_path_data
+#if BUILDFLAG(ENABLE_CEF)
+ , std::u16string* module_path_data,
+ std::u16string* user_data_path_data
+#endif
+ ) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
base::Value::Dict response;
response.Set(version_ui::kKeyExecPath, *executable_path_data);
response.Set(version_ui::kKeyProfilePath, *profile_path_data);
+#if BUILDFLAG(ENABLE_CEF)
+ response.Set(version_ui::kKeyModulePath, *module_path_data);
+ response.Set(version_ui::kKeyUserDataPath, *user_data_path_data);
+#endif
ResolveJavascriptCallback(base::Value(callback_id), response);
}
diff --git chrome/browser/ui/webui/version/version_handler.h chrome/browser/ui/webui/version/version_handler.h
index 2f8162d7491d1..b00f0d5bf26ae 100644
--- chrome/browser/ui/webui/version/version_handler.h
+++ chrome/browser/ui/webui/version/version_handler.h
@@ -9,6 +9,7 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
+#include "cef/libcef/features/features.h"
#include "content/public/browser/web_ui_message_handler.h"
// Handler class for Version page operations.
@@ -44,7 +45,12 @@ class VersionHandler : public content::WebUIMessageHandler {
// front end.
void OnGotFilePaths(std::string callback_id,
std::u16string* executable_path_data,
- std::u16string* profile_path_data);
+ std::u16string* profile_path_data
+#if BUILDFLAG(ENABLE_CEF)
+ , std::u16string* module_path_data,
+ std::u16string* user_data_path_data
+#endif
+ );
// Factory for the creating refs in callbacks.
base::WeakPtrFactory<VersionHandler> weak_ptr_factory_{this};
diff --git chrome/browser/ui/webui/version/version_ui.cc chrome/browser/ui/webui/version/version_ui.cc
index 6e205bf700de2..c281769b5cb5c 100644
--- chrome/browser/ui/webui/version/version_ui.cc
+++ chrome/browser/ui/webui/version/version_ui.cc
@@ -17,6 +17,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
#include "chrome/browser/browser_process_impl.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/version/version_handler.h"
@@ -64,6 +65,10 @@
#include "chrome/browser/ui/webui/version/version_util_win.h"
#endif
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/include/cef_version.h"
+#endif
+
using content::WebUIDataSource;
namespace {
@@ -84,6 +89,10 @@ void CreateAndAddVersionUIDataSource(Profile* profile) {
{version_ui::kCommandLineName, IDS_VERSION_UI_COMMAND_LINE},
{version_ui::kExecutablePathName, IDS_VERSION_UI_EXECUTABLE_PATH},
{version_ui::kProfilePathName, IDS_VERSION_UI_PROFILE_PATH},
+#if BUILDFLAG(ENABLE_CEF)
+ {version_ui::kModulePathName, IDS_VERSION_UI_MODULE_PATH},
+ {version_ui::kUserDataPathName, IDS_VERSION_UI_USER_DATA_PATH},
+#endif
{version_ui::kVariationsName, IDS_VERSION_UI_VARIATIONS},
{version_ui::kVariationsCmdName, IDS_VERSION_UI_VARIATIONS_CMD},
{version_ui::kVariationsSeedName, IDS_VERSION_UI_VARIATIONS_SEED_NAME},
@@ -121,6 +130,10 @@ void CreateAndAddVersionUIDataSource(Profile* profile) {
IDR_PRODUCT_LOGO_WHITE);
#endif // BUILDFLAG(IS_ANDROID)
html_source->SetDefaultResource(IDR_VERSION_UI_ABOUT_VERSION_HTML);
+
+#if BUILDFLAG(ENABLE_CEF)
+ html_source->AddString(version_ui::kCefVersion, CEF_VERSION);
+#endif
}
std::string GetProductModifier() {
@@ -241,6 +254,10 @@ void VersionUI::AddVersionDetailStrings(content::WebUIDataSource* html_source) {
// blank.
html_source->AddString(version_ui::kExecutablePath, std::string());
html_source->AddString(version_ui::kProfilePath, std::string());
+#if BUILDFLAG(ENABLE_CEF)
+ html_source->AddString(version_ui::kModulePath, std::string());
+ html_source->AddString(version_ui::kUserDataPath, std::string());
+#endif
#if BUILDFLAG(IS_MAC)
html_source->AddString(version_ui::kOSType, base::mac::GetOSDisplayName());
diff --git components/version_ui/BUILD.gn components/version_ui/BUILD.gn
index 913cf913dca7a..d79c330989149 100644
--- components/version_ui/BUILD.gn
+++ components/version_ui/BUILD.gn
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//cef/libcef/features/features.gni")
+
static_library("version_ui") {
sources = [
"version_handler_helper.cc",
@@ -17,4 +19,8 @@ static_library("version_ui") {
"//components/variations/net",
"//components/variations/service",
]
+
+ if (enable_cef) {
+ configs += [ "//cef/libcef/features:config" ]
+ }
}
diff --git components/version_ui/resources/about_version.css components/version_ui/resources/about_version.css
index 6b753d716b55d..58d6419be0165 100644
--- components/version_ui/resources/about_version.css
+++ components/version_ui/resources/about_version.css
@@ -135,3 +135,7 @@ body {
position: fixed;
width: 1px;
}
+
+#footnote {
+ font-size: 0.8em;
+}
diff --git components/version_ui/resources/about_version.html components/version_ui/resources/about_version.html
index 508c4ecfd790f..fed6933908951 100644
--- components/version_ui/resources/about_version.html
+++ components/version_ui/resources/about_version.html
@@ -62,9 +62,21 @@ about:version template page
</picture>
</if>
<div id="company">$i18n{company}</div>
- <div id="copyright">$i18n{copyright}</div>
+ <div id="copyright">$i18n{copyright}
+<if expr="enable_cef">
+ <br/><a href="chrome://license">license</a> | <a href="chrome://credits">credits</a>
+</if>
+ </div>
</div>
<table id="inner" cellpadding="0" cellspacing="0" border="0">
+<if expr="enable_cef">
+ <tr>
+ <td class="label">CEF</td>
+ <td class="version">
+ <span>$i18n{cef_version}</span>
+ </td>
+ </tr>
+</if>
<tr><td class="label">$i18n{application_label}</td>
<td class="version" id="version">
<span id="copy-content">
@@ -171,7 +183,15 @@ about:version template page
<tr><td class="label">$i18n{executable_path_name}</td>
<td class="version" id="executable_path">$i18n{executable_path}</td>
</tr>
- <tr><td class="label">$i18n{profile_path_name}</td>
+<if expr="enable_cef">
+ <tr><td class="label">$i18n{module_path_name}</td>
+ <td class="version" id="module_path">$i18n{module_path}</td>
+ </tr>
+ <tr><td class="label">$i18n{user_data_path_name} <sup><a href="#footnote">[*]</a></sup></td>
+ <td class="version" id="user_data_path">$i18n{user_data_path}</td>
+ </tr>
+</if>
+ <tr><td class="label">$i18n{profile_path_name} <sup><a href="#footnote">[*]</a></sup></td>
<td class="version" id="profile_path">$i18n{profile_path}</td>
</tr>
</if>
@@ -198,6 +218,17 @@ about:version template page
<td class="version" id="sanitizer">$i18n{sanitizer}</td>
</tr>
</table>
+<if expr="enable_cef">
+ <div id="footnote">
+ <br/><a name="footnote">[*] In <a href="https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md" target="_new">Chromium terminology</a>,
+ <a href="https://cef-builds.spotifycdn.com/docs/stable.html?structcef__settings__t.html#a2e2be03f34ddd93de90e1cf196757a19" target="_new">CefSettings.root_cache_path</a>
+ is the "$i18n{user_data_path_name}" and <a href="https://cef-builds.spotifycdn.com/docs/stable.html?structcef__settings__t.html#ad1644a7eb23cad969181db010f007710" target="_new">CefSettings.cache_path</a>
+ is the "$i18n{profile_path_name}". Chromium's <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/process_singleton.h#35" target="_new">process singleton lock</a>
+ protects against multiple app instances writing to the same "$i18n{user_data_path_name}" directory.
+ Implement <a href="https://cef-builds.spotifycdn.com/docs/stable.html?classCefBrowserProcessHandler.html#a052a91639483467c0b546d57a05c2f06" target="_new">CefBrowserProcessHandler:: OnAlreadyRunningAppRelaunch</a>
+ to handle the case of app relaunch with the same directory.
+ </div>
+</if>
</div>
<div id="messages" role="alert" aria-live="polite" aria-relevant="additions">
diff --git components/version_ui/resources/about_version.ts components/version_ui/resources/about_version.ts
index fcd11ec05dc17..565657694f768 100644
--- components/version_ui/resources/about_version.ts
+++ components/version_ui/resources/about_version.ts
@@ -50,9 +50,21 @@ function handleVariationInfo(
* @param profilePath The profile path to display.
*/
function handlePathInfo(
- {execPath, profilePath}: {execPath: string, profilePath: string}) {
+ {execPath, profilePath
+// <if expr="enable_cef">
+ , modulePath, userDataPath
+// </if>
+ }: {execPath: string, profilePath: string
+// <if expr="enable_cef">
+ , modulePath: string, userDataPath: string
+// </if>
+ }) {
getRequiredElement('executable_path').textContent = execPath;
getRequiredElement('profile_path').textContent = profilePath;
+// <if expr="enable_cef">
+ getRequiredElement('module_path').textContent = modulePath;
+ getRequiredElement('user_data_path').textContent = userDataPath;
+// </if>
}
// <if expr="chromeos_lacros or is_win">
diff --git components/version_ui/version_ui_constants.cc components/version_ui/version_ui_constants.cc
index f33bd808d6d56..75515ffa256b7 100644
--- components/version_ui/version_ui_constants.cc
+++ components/version_ui/version_ui_constants.cc
@@ -6,6 +6,7 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
namespace version_ui {
@@ -90,4 +91,15 @@ const char kVersion[] = "version";
const char kVersionModifier[] = "version_modifier";
const char kVersionProcessorVariation[] = "version_processor_variation";
+#if BUILDFLAG(ENABLE_CEF)
+const char kKeyModulePath[] = "modulePath";
+const char kKeyUserDataPath[] = "userDataPath";
+
+const char kCefVersion[] = "cef_version";
+const char kModulePath[] = "module_path";
+const char kModulePathName[] = "module_path_name";
+const char kUserDataPath[] = "user_data_path";
+const char kUserDataPathName[] = "user_data_path_name";
+#endif
+
} // namespace version_ui
diff --git components/version_ui/version_ui_constants.h components/version_ui/version_ui_constants.h
index 212f7e2114c75..d35549eb15310 100644
--- components/version_ui/version_ui_constants.h
+++ components/version_ui/version_ui_constants.h
@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
+#include "cef/libcef/features/features.h"
namespace version_ui {
@@ -92,6 +93,17 @@ extern const char kVersion[];
extern const char kVersionModifier[];
extern const char kVersionProcessorVariation[];
+#if BUILDFLAG(ENABLE_CEF)
+extern const char kKeyModulePath[];
+extern const char kKeyUserDataPath[];
+
+extern const char kCefVersion[];
+extern const char kModulePath[];
+extern const char kModulePathName[];
+extern const char kUserDataPath[];
+extern const char kUserDataPathName[];
+#endif
+
} // namespace version_ui
#endif // COMPONENTS_VERSION_UI_VERSION_UI_CONSTANTS_H_
diff --git components/version_ui_strings.grdp components/version_ui_strings.grdp
index 9f236e6217ee9..d2b7964c3a09f 100644
--- components/version_ui_strings.grdp
+++ components/version_ui_strings.grdp
@@ -76,6 +76,14 @@
<message name="IDS_VERSION_UI_PROFILE_PATH" desc="label for the profile path on the about:version page">
Profile Path
</message>
+ <if expr="enable_cef">
+ <message name="IDS_VERSION_UI_MODULE_PATH" desc="label for the module path on the about:version page">
+ Module Path
+ </message>
+ <message name="IDS_VERSION_UI_USER_DATA_PATH" desc="label for the user data path on the about:version page">
+ User Data Path
+ </message>
+ </if>
<message name="IDS_VERSION_UI_PATH_NOTFOUND" desc="label for the non-existent path on the about:version page">
No such file or directory
</message>

View File

@ -174,7 +174,7 @@ index 3553377e96017..9f6edc70ef1d4 100644
#if BUILDFLAG(IS_CHROMEOS_LACROS)
std::unique_ptr<chromeos::LacrosService> lacros_service_;
diff --git chrome/browser/chrome_browser_main.cc chrome/browser/chrome_browser_main.cc
index f90f1b8fa54d9..3dc8a9fe49363 100644
index f90f1b8fa54d9..3c1406cc798a7 100644
--- chrome/browser/chrome_browser_main.cc
+++ chrome/browser/chrome_browser_main.cc
@@ -52,6 +52,7 @@
@ -327,22 +327,7 @@ index f90f1b8fa54d9..3dc8a9fe49363 100644
// Desktop construction occurs here, (required before profile creation).
PreProfileInit();
@@ -1624,12 +1636,14 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
browser_process_->local_state());
}
+#if !BUILDFLAG(ENABLE_CEF)
// Needs to be done before PostProfileInit, since login manager on CrOS is
// called inside PostProfileInit.
content::WebUIControllerFactory::RegisterFactory(
ChromeWebUIControllerFactory::GetInstance());
RegisterChromeWebUIConfigs();
RegisterChromeUntrustedWebUIConfigs();
+#endif
#if BUILDFLAG(IS_ANDROID)
page_info::SetPageInfoClient(new ChromePageInfoClient());
@@ -1656,6 +1670,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
@@ -1656,6 +1668,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// Call `PostProfileInit()`and set it up for profiles created later.
profile_init_manager_ = std::make_unique<ProfileInitManager>(this, profile);
@ -350,7 +335,7 @@ index f90f1b8fa54d9..3dc8a9fe49363 100644
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_CHROMEOS_ASH)
// Execute first run specific code after the PrefService has been initialized
// and preferences have been registered since some of the import code depends
@@ -1695,6 +1710,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
@@ -1695,6 +1708,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
*base::CommandLine::ForCurrentProcess());
}
#endif // BUILDFLAG(IS_WIN)
@ -358,7 +343,7 @@ index f90f1b8fa54d9..3dc8a9fe49363 100644
// Configure modules that need access to resources.
net::NetModule::SetResourceProvider(ChromeNetResourceProvider);
@@ -1786,6 +1802,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
@@ -1786,6 +1800,11 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
g_browser_process->profile_manager()->GetLastOpenedProfiles();
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
@ -370,7 +355,7 @@ index f90f1b8fa54d9..3dc8a9fe49363 100644
// This step is costly.
if (browser_creator_->Start(*base::CommandLine::ForCurrentProcess(),
base::FilePath(), profile_info,
@@ -1818,11 +1839,14 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
@@ -1818,11 +1837,14 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
// Create the RunLoop for MainMessageLoopRun() to use and transfer
// ownership of the browser's lifetime to the BrowserProcess.

View File

@ -149,22 +149,25 @@ index 17c3d731e269b..e2caaf2934cdd 100644
outputs = [
"$root_out_dir/chrome.7z",
diff --git tools/grit/grit_args.gni tools/grit/grit_args.gni
index 79d613489bac2..86b82e96b7ec0 100644
index 79d613489bac2..869b682d453ee 100644
--- tools/grit/grit_args.gni
+++ tools/grit/grit_args.gni
@@ -5,6 +5,7 @@
@@ -5,7 +5,9 @@
import("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/devtools.gni")
+import("//build/config/locales.gni")
import("//build/config/ui.gni")
+import("//cef/libcef/features/features.gni")
shared_intermediate_dir = rebase_path(root_gen_dir, root_build_dir)
@@ -36,6 +37,8 @@ _grit_defines = [
devtools_grd_path = "$shared_intermediate_dir/$devtools_grd_location"
@@ -36,6 +38,9 @@ _grit_defines = [
# Mac and iOS want Title Case strings.
"use_titlecase=${is_apple}",
+
+ "enable_cef=${enable_cef}",
+ "enable_pseudolocales=${enable_pseudolocales}",
]

View File

@ -176,7 +176,6 @@ void RunWebUITest(const std::string& url) {
WEBUI_TEST(accessibility)
WEBUI_TEST(blob_internals)
WEBUI_TEST(extensions_support)
WEBUI_TEST(gpu)
WEBUI_TEST(histograms)
WEBUI_TEST(indexeddb_internals)
@ -189,7 +188,6 @@ WEBUI_TEST(system)
WEBUI_TEST(tracing)
WEBUI_TEST(version)
WEBUI_TEST(webrtc_internals)
WEBUI_TEST(webui_hosts)
// Test hosts with multiple URLs.