Commit 50735fdc authored by erikchen's avatar erikchen Committed by Commit Bot

Update WebContentsImpl::CreateWithOpener to return a unique_ptr.

This CL is a refactor with no intended behavior change.

Bug: 832879
Change-Id: I18a970240c9abcf38879c8b4d15aae848d2dd893
TBR: avi@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/1040471Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556331}
parent ad79ef9d
......@@ -266,8 +266,7 @@ class CloseDialogCallbackWrapper
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 @@ WebContentsImpl::~WebContentsImpl() {
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 @@ WebContentsImpl* WebContentsImpl::CreateWithOpener(
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 @@ std::unique_ptr<WebContents> WebContentsImpl::Clone() {
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());
......
......@@ -137,7 +137,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
~WebContentsImpl() override;
static WebContentsImpl* CreateWithOpener(
static std::unique_ptr<WebContentsImpl> CreateWithOpener(
const WebContents::CreateParams& params,
RenderFrameHostImpl* opener_rfh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment