Files
electron/shell/browser/electron_web_ui_controller_factory.cc
electron-roller[bot] 471a14432f chore: bump chromium to 143.0.7469.0 (main) (#48548)
* chore: bump chromium in DEPS to 143.0.7469.0

* 7021651: [//gpu] Fold handle creation into D3DImageBackingFactory

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7021651

* 7013047: Fix various C++23 build errors in //chrome

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7013047

* 7010850: [//ui] Port screen_mac.mm's calls to DisplayColorSpaces

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7010850

* 7007933: Remove superfluous mojom includes in //content/public headers

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7007933

* 7023196: Trim os_crypt/sync visibility list

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7023196

* 7008912: Remove GURL::*_piece() method

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7008912

* 7003989: Add wrapper struct for CopyFromSurface output

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7003989

* 7017889: [MemoryPressureListener] Remove type aliases

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7017889

* 7027780: Delete viz::ResourceSizes

Refs https://chromium-review.googlesource.com/c/chromium/src/+/7027780
Refs https://chromium-review.googlesource.com/c/chromium/src/+/6989572

* 6495189: [api] Delete old String::Write* APIs

Refs https://chromium-review.googlesource.com/c/v8/v8/+/6495189

* chore: update patches

* chore: run script/gen-libc++-filenames.js

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-10-15 14:10:10 -07:00

61 lines
1.9 KiB
C++

// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/electron_web_ui_controller_factory.h"
#include "base/memory/singleton.h"
#include "chrome/common/webui_url_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_controller.h"
#include "shell/browser/ui/devtools_ui.h"
#include "shell/browser/ui/webui/accessibility_ui.h"
namespace electron {
// static
ElectronWebUIControllerFactory* ElectronWebUIControllerFactory::GetInstance() {
return base::Singleton<ElectronWebUIControllerFactory>::get();
}
ElectronWebUIControllerFactory::ElectronWebUIControllerFactory() = default;
ElectronWebUIControllerFactory::~ElectronWebUIControllerFactory() = default;
content::WebUI::TypeID ElectronWebUIControllerFactory::GetWebUIType(
content::BrowserContext* browser_context,
const GURL& url) {
if (const std::string_view host = url.host();
host == chrome::kChromeUIDevToolsHost ||
host == chrome::kChromeUIAccessibilityHost) {
return this;
}
return content::WebUI::kNoWebUI;
}
bool ElectronWebUIControllerFactory::UseWebUIForURL(
content::BrowserContext* browser_context,
const GURL& url) {
return GetWebUIType(browser_context, url) != content::WebUI::kNoWebUI;
}
std::unique_ptr<content::WebUIController>
ElectronWebUIControllerFactory::CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) {
const std::string_view host = url.host();
if (host == chrome::kChromeUIDevToolsHost) {
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
return std::make_unique<DevToolsUI>(browser_context, web_ui);
}
if (host == chrome::kChromeUIAccessibilityHost)
return std::make_unique<ElectronAccessibilityUI>(web_ui);
return {};
}
} // namespace electron