Update WebContentsImpl::CreateWithOpener to return a unique_ptr.
This CL is a refactor with no intended behavior change.
Bug: 832879
Change-Id: I18a970240c9abcf38879c8b4d15aae848d2dd893
TBR: [email protected]
Reviewed-on: https://chromium-review.googlesource.com/1040471
Reviewed-by: Erik Chen <[email protected]>
Commit-Queue: Erik Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#556331}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 3a9d68d..3750e32 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -266,8 +266,7 @@
std::unique_ptr<WebContents> WebContents::Create(
const WebContents::CreateParams& params) {
- return base::WrapUnique(
- WebContentsImpl::CreateWithOpener(params, FindOpenerRFH(params)));
+ return WebContentsImpl::CreateWithOpener(params, FindOpenerRFH(params));
}
std::unique_ptr<WebContents> WebContents::CreateWithSessionStorage(
@@ -643,14 +642,15 @@
SetDelegate(nullptr);
}
-WebContentsImpl* WebContentsImpl::CreateWithOpener(
+std::unique_ptr<WebContentsImpl> WebContentsImpl::CreateWithOpener(
const WebContents::CreateParams& params,
RenderFrameHostImpl* opener_rfh) {
TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener");
FrameTreeNode* opener = nullptr;
if (opener_rfh)
opener = opener_rfh->frame_tree_node();
- WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context);
+ std::unique_ptr<WebContentsImpl> new_contents(
+ new WebContentsImpl(params.browser_context));
new_contents->SetOpenerForNewContents(opener, params.opener_suppressed);
// If the opener is sandboxed, a new popup must inherit the opener's sandbox
@@ -684,7 +684,7 @@
if (params.guest_delegate) {
// This makes |new_contents| act as a guest.
// For more info, see comment above class BrowserPluginGuest.
- BrowserPluginGuest::Create(new_contents, params.guest_delegate);
+ BrowserPluginGuest::Create(new_contents.get(), params.guest_delegate);
// We are instantiating a WebContents for browser plugin. Set its subframe
// bit to true.
new_contents->is_subframe_ = true;
@@ -1701,7 +1701,7 @@
if (opener)
opener_rfh = opener->current_frame_host();
std::unique_ptr<WebContentsImpl> tc =
- base::WrapUnique(CreateWithOpener(create_params, opener_rfh));
+ CreateWithOpener(create_params, opener_rfh);
tc->GetController().CopyStateFrom(controller_, true);
for (auto& observer : observers_)
observer.DidCloneToNewWebContents(this, tc.get());