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

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

Issue 2640023008: Enabling autoplay and fullscreen for downloaded media (Closed)
Patch Set: removed include Created 3 years, 10 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
Index: third_party/WebKit/Source/core/html/MediaDocument.cpp
diff --git a/third_party/WebKit/Source/core/html/MediaDocument.cpp b/third_party/WebKit/Source/core/html/MediaDocument.cpp
index 5d36b40caebdd1caa4e416f8f26e4811707f98ba..b5bd08e47af3aae11763afb2691c04dc37475173 100644
--- a/third_party/WebKit/Source/core/html/MediaDocument.cpp
+++ b/third_party/WebKit/Source/core/html/MediaDocument.cpp
@@ -27,6 +27,7 @@
#include "bindings/core/v8/ExceptionState.h"
#include "core/HTMLNames.h"
+#include "core/dom/DocumentUserGestureToken.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/RawDataDocumentParser.h"
#include "core/dom/shadow/ShadowRoot.h"
@@ -34,6 +35,7 @@
#include "core/events/EventListener.h"
#include "core/events/KeyboardEvent.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/Settings.h"
#include "core/frame/UseCounter.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLBodyElement.h"
@@ -50,6 +52,7 @@
#include "core/loader/FrameLoaderClient.h"
#include "platform/Histogram.h"
#include "platform/KeyboardCodes.h"
+#include "platform/UserGestureIndicator.h"
#include "platform/text/PlatformLocale.h"
namespace blink {
@@ -113,6 +116,31 @@ class MediaDownloadEventListener final : public EventListener {
bool m_clicked;
};
+class MediaLoadedEventListener final : public EventListener {
+ WTF_MAKE_NONCOPYABLE(MediaLoadedEventListener);
+
+ public:
+ static MediaLoadedEventListener* create() {
+ return new MediaLoadedEventListener();
+ }
+
+ bool operator==(const EventListener& other) const override {
+ return this == &other;
+ }
+
+ private:
+ MediaLoadedEventListener() : EventListener(CPPEventListenerType) {}
+
+ void handleEvent(ExecutionContext* context, Event* event) override {
+ HTMLVideoElement* media =
+ static_cast<HTMLVideoElement*>(event->target()->toNode());
+ UserGestureIndicator gesture(
+ DocumentUserGestureToken::create(&media->document()));
+ media->webkitEnterFullscreen();
+ media->play();
+ }
+};
+
void MediaDocumentParser::createDocumentStructure() {
DCHECK(document());
HTMLHtmlElement* rootElement = HTMLHtmlElement::create(*document());
@@ -163,6 +191,17 @@ void MediaDocumentParser::createDocumentStructure() {
HTMLContentElement* content = HTMLContentElement::create(*document());
div->appendChild(content);
+ if (document()->settings() &&
+ document()->settings()->getEmbeddedMediaExperienceEnabled()) {
+ EventListener* listener = MediaLoadedEventListener::create();
+ AddEventListenerOptions options;
+ options.setOnce(true);
+ AddEventListenerOptionsOrBoolean optionsOrBoolean;
+ optionsOrBoolean.setAddEventListenerOptions(options);
+ media->addEventListener(EventTypeNames::loadedmetadata, listener,
+ optionsOrBoolean);
+ }
+
if (RuntimeEnabledFeatures::mediaDocumentDownloadButtonEnabled()) {
HTMLAnchorElement* anchor = HTMLAnchorElement::create(*document());
anchor->setAttribute(downloadAttr, "");
« no previous file with comments | « third_party/WebKit/Source/core/frame/Settings.json5 ('k') | third_party/WebKit/Source/web/WebSettingsImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698