Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp

Issue 2251013002: Fixing crash in AutoplayUmaHelper when registering unload event listener (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
diff --git a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
index 0951ad198a57711fb53470157fdb8a3d86dd8859..b359769b8a007dbf862405f1673040b029a7fa7a 100644
--- a/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
+++ b/third_party/WebKit/Source/core/html/AutoplayUmaHelper.cpp
@@ -73,8 +73,10 @@ void AutoplayUmaHelper::didMoveToNewDocument(Document& oldDocument)
if (!m_videoMutedPlayMethodVisibilityObserver)
return;
- oldDocument.domWindow()->removeEventListener(EventTypeNames::unload, this, false);
- m_element->document().domWindow()->addEventListener(EventTypeNames::unload, this, false);
+ if (oldDocument.domWindow())
+ oldDocument.domWindow()->removeEventListener(EventTypeNames::unload, this, false);
+ if (m_element && m_element->document().domWindow())
+ m_element->document().domWindow()->addEventListener(EventTypeNames::unload, this, false);
}
void AutoplayUmaHelper::onVisibilityChangedForVideoMutedPlayMethod(bool isVisible)
@@ -85,7 +87,8 @@ void AutoplayUmaHelper::onVisibilityChangedForVideoMutedPlayMethod(bool isVisibl
recordVideoAutoplayMutedPlayMethodBecomesVisibleUma(true);
m_videoMutedPlayMethodVisibilityObserver->stop();
m_videoMutedPlayMethodVisibilityObserver = nullptr;
- m_element->document().domWindow()->removeEventListener(EventTypeNames::unload, this, false);
+ if (m_element && m_element->document().domWindow())
+ m_element->document().domWindow()->removeEventListener(EventTypeNames::unload, this, false);
}
void AutoplayUmaHelper::handleEvent(ExecutionContext* executionContext, Event* event)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698