Commit ba508351 authored by Daniel Cheng's avatar Daniel Cheng

Don't leak WebLocalFrame in print preview.

Unfortunately, Blink currently relies on the embedder to make sure these
objects don't leak.

Bug: 735860
Change-Id: Ia213d4360c5f95627de70a1dfe343880144f9ff6
Reviewed-on: https://chromium-review.googlesource.com/544367Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481829}
parent 8a532be1
...@@ -581,7 +581,15 @@ void PrintWebViewHelper::PrintHeaderAndFooter( ...@@ -581,7 +581,15 @@ void PrintWebViewHelper::PrintHeaderAndFooter(
blink::WebView::Create(nullptr, blink::kWebPageVisibilityStateVisible); blink::WebView::Create(nullptr, blink::kWebPageVisibilityStateVisible);
web_view->GetSettings()->SetJavaScriptEnabled(true); web_view->GetSettings()->SetJavaScriptEnabled(true);
blink::WebFrameClient frame_client; class HeaderAndFooterClient final : public blink::WebFrameClient {
public:
void FrameDetached(blink::WebLocalFrame* frame,
DetachType detach_type) override {
frame->FrameWidget()->Close();
frame->Close();
}
};
HeaderAndFooterClient frame_client;
blink::WebLocalFrame* frame = blink::WebLocalFrame::Create( blink::WebLocalFrame* frame = blink::WebLocalFrame::Create(
blink::WebTreeScopeType::kDocument, &frame_client, nullptr, nullptr); blink::WebTreeScopeType::kDocument, &frame_client, nullptr, nullptr);
web_view->SetMainFrame(frame); web_view->SetMainFrame(frame);
...@@ -680,6 +688,8 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient, ...@@ -680,6 +688,8 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient,
blink::WebSandboxFlags sandbox_flags, blink::WebSandboxFlags sandbox_flags,
const blink::WebParsedFeaturePolicy& container_policy, const blink::WebParsedFeaturePolicy& container_policy,
const blink::WebFrameOwnerProperties& frame_owner_properties) override; const blink::WebFrameOwnerProperties& frame_owner_properties) override;
void FrameDetached(blink::WebLocalFrame* frame,
DetachType detach_type) override;
std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override; std::unique_ptr<blink::WebURLLoader> CreateURLLoader() override;
void CallOnReady(); void CallOnReady();
...@@ -848,6 +858,12 @@ blink::WebLocalFrame* PrepareFrameAndViewForPrint::CreateChildFrame( ...@@ -848,6 +858,12 @@ blink::WebLocalFrame* PrepareFrameAndViewForPrint::CreateChildFrame(
return nullptr; return nullptr;
} }
void PrepareFrameAndViewForPrint::FrameDetached(blink::WebLocalFrame* frame,
DetachType detach_type) {
frame->FrameWidget()->Close();
frame->Close();
}
std::unique_ptr<blink::WebURLLoader> std::unique_ptr<blink::WebURLLoader>
PrepareFrameAndViewForPrint::CreateURLLoader() { PrepareFrameAndViewForPrint::CreateURLLoader() {
// TODO(yhirano): Stop using Platform::CreateURLLoader() here. // TODO(yhirano): Stop using Platform::CreateURLLoader() here.
...@@ -887,7 +903,6 @@ void PrepareFrameAndViewForPrint::FinishPrinting() { ...@@ -887,7 +903,6 @@ void PrepareFrameAndViewForPrint::FinishPrinting() {
if (owns_web_view_) { if (owns_web_view_) {
DCHECK(!frame->IsLoading()); DCHECK(!frame->IsLoading());
owns_web_view_ = false; owns_web_view_ = false;
frame->FrameWidget()->Close();
web_view->Close(); web_view->Close();
} }
} }
......
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