Skip to content

Commit

Permalink
[Media Controls] Avoid SECURITY_DCHECK when casting events
Browse files Browse the repository at this point in the history
Both MediaControlsOrientationLockDelegate and
MediaControlsRotateToFullscreenDelegate would incorrectly call
ToDeviceOrientationEvent on synthetic events created by the webpage
whose type name was "deviceorientation", even if they weren't
instances of DeviceOrientationEvent.

This patch fixes that. It also checks that the events are trusted, to
avoid using deviceorientation values synthesized by the webpage (other
event listeners in these classes don't use values from the event
object, so it's less important for them to be trusted).

Bug: 761613,760737
Change-Id: I318d10e3b6dd84277a47b06546fd4c3ebcdb03cb
Reviewed-on: https://chromium-review.googlesource.com/647929
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Commit-Queue: John Mellor <johnme@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499515}
  • Loading branch information
johnmellor authored and Commit Bot committed Sep 4, 2017
1 parent b70fe76 commit cd76873
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,11 @@ void MediaControlsOrientationLockDelegate::handleEvent(
}

if (event->type() == EventTypeNames::deviceorientation) {
MaybeLockToAnyIfDeviceOrientationMatchesVideo(
ToDeviceOrientationEvent(event));
if (event->isTrusted() &&
event->InterfaceName() == EventNames::DeviceOrientationEvent) {
MaybeLockToAnyIfDeviceOrientationMatchesVideo(
ToDeviceOrientationEvent(event));
}

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ void MediaControlsRotateToFullscreenDelegate::handleEvent(
return;
}
if (event->type() == EventTypeNames::deviceorientation) {
OnDeviceOrientationAvailable(ToDeviceOrientationEvent(event));
if (event->isTrusted() &&
event->InterfaceName() == EventNames::DeviceOrientationEvent) {
OnDeviceOrientationAvailable(ToDeviceOrientationEvent(event));
}
return;
}
if (event->type() == EventTypeNames::orientationchange) {
Expand Down

0 comments on commit cd76873

Please sign in to comment.