Change CreateWebUIControllerForURL() to return a unique_ptr

https://chromium-review.googlesource.com/c/chromium/src/+/1087627
This commit is contained in:
Jeremy Apthorp 2018-10-02 12:11:56 -07:00
parent c576d442fd
commit 2a3a845262
4 changed files with 14 additions and 9 deletions

View file

@ -52,7 +52,7 @@ bool AtomWebUIControllerFactory::UseWebUIBindingsForURL(
return UseWebUIForURL(browser_context, url);
}
content::WebUIController*
std::unique_ptr<content::WebUIController>
AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
const GURL& url) const {
#if BUILDFLAG(ENABLE_PDF_VIEWER)
@ -78,7 +78,7 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
return new PdfViewerUI(browser_context, web_ui, src);
}
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
return nullptr;
return std::unique_ptr<content::WebUIController>();
}
} // namespace atom

View file

@ -5,8 +5,11 @@
#ifndef ATOM_BROWSER_ATOM_WEB_UI_CONTROLLER_FACTORY_H_
#define ATOM_BROWSER_ATOM_WEB_UI_CONTROLLER_FACTORY_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_controller_factory.h"
namespace atom {
@ -25,7 +28,7 @@ class AtomWebUIControllerFactory : public content::WebUIControllerFactory {
const GURL& url) const override;
bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
const GURL& url) const override;
content::WebUIController* CreateWebUIControllerForURL(
std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) const override;

View file

@ -49,14 +49,14 @@ bool WebUIControllerFactory::UseWebUIBindingsForURL(
return UseWebUIForURL(browser_context, url);
}
content::WebUIController* WebUIControllerFactory::CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) const {
std::unique_ptr<content::WebUIController>
WebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
const GURL& url) const {
if (url.host() == kChromeUIDevToolsBundledHost) {
auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
return new DevToolsUI(browser_context, web_ui);
return std::make_unique<DevToolsUI>(browser_context, web_ui);
}
return nullptr;
return std::unique_ptr<content::WebUIController>();
}
} // namespace brightray

View file

@ -5,6 +5,8 @@
#ifndef BRIGHTRAY_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
#define BRIGHTRAY_BROWSER_WEB_UI_CONTROLLER_FACTORY_H_
#include <memory>
#include "base/macros.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller_factory.h"
@ -31,7 +33,7 @@ class WebUIControllerFactory : public content::WebUIControllerFactory {
const GURL& url) const override;
bool UseWebUIBindingsForURL(content::BrowserContext* browser_context,
const GURL& url) const override;
content::WebUIController* CreateWebUIControllerForURL(
std::unique_ptr<content::WebUIController> CreateWebUIControllerForURL(
content::WebUI* web_ui,
const GURL& url) const override;