diff options
author | raymes <raymes@chromium.org> | 2015-12-16 21:28:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-17 05:30:27 +0000 |
commit | f1d0d6cd58239a58092c7761f4181c6c8cf2a3a1 (patch) | |
tree | 021f1e1fd83257889fc33b717c41549ae390eb0b /extensions | |
parent | fcfffcfcf25003c2293b921e8c1c53437a3235ce (diff) | |
download | chromium_src-f1d0d6cd58239a58092c7761f4181c6c8cf2a3a1.zip chromium_src-f1d0d6cd58239a58092c7761f4181c6c8cf2a3a1.tar.gz chromium_src-f1d0d6cd58239a58092c7761f4181c6c8cf2a3a1.tar.bz2 |
Only send MimeHandlerViewGuestOnLoadCompleted messages when the guest is attached.
Even though DocumentOnLoadCompletedInMainFrame should never be called before
the MimeHandlerViewGuest has been attached, it may be called after it has
become detached from its embedder. In this case we need to be careful not to
access the embedder.
A CHECK has also been added to confirm that the crash in the associated bug
isn't because the MimeHandlerViewGuests embedder has been destroyed. (I believe
it should be alive at this point).
BUG=569990
Review URL: https://codereview.chromium.org/1531173002
Cr-Commit-Position: refs/heads/master@{#365756}
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc index 1f9ebfb..2341db12 100644 --- a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc +++ b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc @@ -225,9 +225,18 @@ bool MimeHandlerViewGuest::SaveFrame(const GURL& url, } void MimeHandlerViewGuest::DocumentOnLoadCompletedInMainFrame() { - embedder_web_contents()->Send( - new ExtensionsGuestViewMsg_MimeHandlerViewGuestOnLoadCompleted( - element_instance_id())); + // Assume the embedder WebContents is valid here. Change this to a DCHECK + // after verifying https://crbug.com/569990. + CHECK(owner_web_contents()); + + // Although we should always be attached before loading is complete, the + // MimeHandlerViewGuest may become detached in some cases so we still need + // to check whether we're attached here. + if (attached()) { + embedder_web_contents()->Send( + new ExtensionsGuestViewMsg_MimeHandlerViewGuestOnLoadCompleted( + element_instance_id())); + } } base::WeakPtr<StreamContainer> MimeHandlerViewGuest::GetStream() const { |