Skip to content

Commit

Permalink
Override GetWebUIType/CreateWebUIControllerForURL
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jul 7, 2020
1 parent 21243f2 commit ea345f7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shell/browser/electron_web_ui_controller_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <string>

#include "chrome/browser/accessibility/accessibility_ui.h"
#include "content/public/browser/web_contents.h"
#include "electron/buildflags/buildflags.h"
#include "shell/browser/ui/devtools_ui.h"
Expand All @@ -15,6 +16,7 @@ namespace electron {
namespace {

const char kChromeUIDevToolsBundledHost[] = "devtools";
const char kChromeUIAccessibilityHost[] = "accessibility";

} // namespace

Expand All @@ -30,7 +32,9 @@ ElectronWebUIControllerFactory::~ElectronWebUIControllerFactory() = default;
content::WebUI::TypeID ElectronWebUIControllerFactory::GetWebUIType(
content::BrowserContext* browser_context,
const GURL& url) {
if (url.host() == kChromeUIDevToolsBundledHost) {
if (url.host() == kChromeUIDevToolsBundledHost ||
url.host() == kChromeUIAccessibilityHost) {
LOG(INFO) << "WE ARE HERE";
return const_cast<ElectronWebUIControllerFactory*>(this);
}

Expand All @@ -56,7 +60,10 @@ ElectronWebUIControllerFactory::CreateWebUIControllerForURL(
if (url.host() == kChromeUIDevToolsBundledHost) {
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
return std::make_unique<DevToolsUI>(browser_context, web_ui);
} else if (url.host() == kChromeUIAccessibilityHost) {
return std::make_unique<AccessibilityUI>(web_ui);
}

return std::unique_ptr<content::WebUIController>();
}

Expand Down

0 comments on commit ea345f7

Please sign in to comment.