2013-05-14 06:45:34 +00:00
|
|
|
// Copyright (c) 2013 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-CHROMIUM file.
|
|
|
|
|
2017-05-18 22:58:12 +00:00
|
|
|
#include "brightray/browser/web_ui_controller_factory.h"
|
2013-05-14 06:45:34 +00:00
|
|
|
|
2015-08-27 19:54:05 +00:00
|
|
|
#include "base/memory/singleton.h"
|
2017-05-18 22:58:12 +00:00
|
|
|
#include "brightray/browser/devtools_ui.h"
|
2013-05-14 06:45:34 +00:00
|
|
|
#include "content/public/browser/web_contents.h"
|
|
|
|
#include "content/public/browser/web_ui.h"
|
|
|
|
#include "content/public/common/url_constants.h"
|
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
const char kChromeUIDevToolsBundledHost[] = "devtools";
|
|
|
|
|
2017-03-31 18:18:20 +00:00
|
|
|
} // namespace
|
2013-05-14 06:45:34 +00:00
|
|
|
|
2015-08-27 19:54:05 +00:00
|
|
|
// static
|
|
|
|
WebUIControllerFactory* WebUIControllerFactory::GetInstance() {
|
2015-12-07 11:55:01 +00:00
|
|
|
return base::Singleton<WebUIControllerFactory>::get();
|
2015-08-27 19:54:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-18 01:56:12 +00:00
|
|
|
WebUIControllerFactory::WebUIControllerFactory() {}
|
2013-05-14 06:45:34 +00:00
|
|
|
|
2018-04-18 01:56:12 +00:00
|
|
|
WebUIControllerFactory::~WebUIControllerFactory() {}
|
2013-05-14 06:45:34 +00:00
|
|
|
|
|
|
|
content::WebUI::TypeID WebUIControllerFactory::GetWebUIType(
|
2018-04-18 01:56:12 +00:00
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& url) const {
|
2013-05-14 06:45:34 +00:00
|
|
|
if (url.host() == kChromeUIDevToolsBundledHost) {
|
|
|
|
return const_cast<WebUIControllerFactory*>(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return content::WebUI::kNoWebUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebUIControllerFactory::UseWebUIForURL(
|
2018-04-18 01:56:12 +00:00
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& url) const {
|
2013-05-14 06:45:34 +00:00
|
|
|
return GetWebUIType(browser_context, url) != content::WebUI::kNoWebUI;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WebUIControllerFactory::UseWebUIBindingsForURL(
|
2018-04-18 01:56:12 +00:00
|
|
|
content::BrowserContext* browser_context,
|
|
|
|
const GURL& url) const {
|
2013-05-14 06:45:34 +00:00
|
|
|
return UseWebUIForURL(browser_context, url);
|
|
|
|
}
|
|
|
|
|
|
|
|
content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL(
|
2018-04-18 01:56:12 +00:00
|
|
|
content::WebUI* web_ui,
|
|
|
|
const GURL& url) const {
|
2015-08-27 19:54:05 +00:00
|
|
|
if (url.host() == kChromeUIDevToolsBundledHost) {
|
|
|
|
auto browser_context = web_ui->GetWebContents()->GetBrowserContext();
|
|
|
|
return new DevToolsUI(browser_context, web_ui);
|
|
|
|
}
|
2016-07-10 09:56:02 +00:00
|
|
|
return nullptr;
|
2013-05-14 06:45:34 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 23:12:05 +00:00
|
|
|
} // namespace brightray
|