Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1602)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 2439273002: Clean up ownership in WebUI creation. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 3157d734c03d3331e6ae42b7f79b8282020788f2..a5fec3021112f14f83cc771dd2f7f4e245c59423 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1028,8 +1028,9 @@ void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) {
GetView()->GetScreenInfo(screen_info);
}
-WebUI* WebContentsImpl::CreateSubframeWebUI(const GURL& url,
- const std::string& frame_name) {
+std::unique_ptr<WebUI> WebContentsImpl::CreateSubframeWebUI(
+ const GURL& url,
+ const std::string& frame_name) {
DCHECK(!frame_name.empty());
return CreateWebUI(url, frame_name);
}
@@ -4819,8 +4820,7 @@ NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost(
const GURL& url) {
- return std::unique_ptr<WebUIImpl>(
- static_cast<WebUIImpl*>(CreateWebUI(url, std::string())));
+ return CreateWebUI(url, std::string());
}
NavigationEntry*
@@ -5060,19 +5060,21 @@ void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) {
delegate_->UpdatePreferredSize(this, new_size);
}
-WebUI* WebContentsImpl::CreateWebUI(const GURL& url,
- const std::string& frame_name) {
- WebUIImpl* web_ui = new WebUIImpl(this, frame_name);
- WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()->
- CreateWebUIControllerForURL(web_ui, url);
+std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUI(
+ const GURL& url,
+ const std::string& frame_name) {
+ std::unique_ptr<WebUIImpl> web_ui =
+ base::MakeUnique<WebUIImpl>(this, frame_name);
+ WebUIController* controller =
+ WebUIControllerFactoryRegistry::GetInstance()
+ ->CreateWebUIControllerForURL(web_ui.get(), url);
if (controller) {
web_ui->AddMessageHandler(new GenericHandler());
web_ui->SetController(controller);
return web_ui;
}
- delete web_ui;
- return NULL;
+ return nullptr;
}
FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() {
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/browser/web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698