Commit d1bbceca authored by Rakina Zata Amni's avatar Rakina Zata Amni Committed by Commit Bot

Close FindInPage Binding in WebLocalFrame::WillBeDetached

frame_ in FindInPage might be null when GetWebPluginForFind is called,
causing a crash in crbug.com/875767. We've tried fixing it by making
FindInPage a ContextLifecycleObserver but it seems like it's not
working because we create FindInPage and immediately try to observe
the context. But since FindInPage is constructed in
WebLocalFrameImpl's constructor, before InitializeCoreFrame() has
been called, there is no blink::LocalFrame, and we don't end up
observing anything.

This CL calls FindInPage::Dispose which closes the
mojo binding when WebLocalFrame::WillBeDetached is called, which is
called by LocalFrame::Detach. This CL also removes previous methods to
close binding (the ContextLifeCycleObserver and Pre-finalizer)

Bug: 875767
Change-Id: Idbce982da546f93733893c41f869f7eced2a7f4b
Reviewed-on: https://chromium-review.googlesource.com/1182911
Commit-Queue: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586639}
parent 6f0bbd2d
......@@ -46,10 +46,7 @@ namespace blink {
FindInPage::FindInPage(WebLocalFrameImpl& frame,
InterfaceRegistry* interface_registry)
: ContextLifecycleObserver(
frame.GetFrame() ? frame.GetFrame()->GetDocument() : nullptr),
frame_(&frame),
binding_(this) {
: frame_(&frame), binding_(this) {
// TODO(rakina): Use InterfaceRegistry of |frame| directly rather than passing
// both of them.
if (!interface_registry)
......@@ -319,10 +316,6 @@ void FindInPage::Dispose() {
binding_.Close();
}
void FindInPage::ContextDestroyed(ExecutionContext* context) {
binding_.Close();
}
void FindInPage::ReportFindInPageMatchCount(int request_id,
int count,
bool final_update) {
......
......@@ -25,9 +25,7 @@ struct WebFloatRect;
class CORE_EXPORT FindInPage final
: public GarbageCollectedFinalized<FindInPage>,
public ContextLifecycleObserver,
public mojom::blink::FindInPage {
USING_PRE_FINALIZER(FindInPage, Dispose);
public:
static FindInPage* Create(WebLocalFrameImpl& frame,
......@@ -97,12 +95,9 @@ class CORE_EXPORT FindInPage final
void Dispose();
void ContextDestroyed(ExecutionContext*) override;
void Trace(blink::Visitor* visitor) override {
void Trace(blink::Visitor* visitor) {
visitor->Trace(text_finder_);
visitor->Trace(frame_);
ContextLifecycleObserver::Trace(visitor);
}
private:
......
......@@ -2337,6 +2337,8 @@ WebNode WebLocalFrameImpl::ContextMenuNode() const {
void WebLocalFrameImpl::WillBeDetached() {
if (dev_tools_agent_)
dev_tools_agent_->WillBeDestroyed();
if (find_in_page_)
find_in_page_->Dispose();
}
void WebLocalFrameImpl::WillDetachParent() {
......
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