Chromium Code Reviews| 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..fb9e0873ba6e4439cd31a0ad169e8061553ac229 100644 |
| --- a/third_party/WebKit/Source/core/html/MediaDocument.cpp |
| +++ b/third_party/WebKit/Source/core/html/MediaDocument.cpp |
| @@ -27,13 +27,16 @@ |
| #include "bindings/core/v8/ExceptionState.h" |
| #include "core/HTMLNames.h" |
| +#include "core/dom/DocumentUserGestureToken.h" |
| #include "core/dom/ElementTraversal.h" |
| +#include "core/dom/GetRootNodeOptions.h" |
|
mlamouri (slow - plz ping)
2017/02/22 12:15:27
I don't think you still need this include.
shaktisahu
2017/02/23 22:43:27
Done.
|
| #include "core/dom/RawDataDocumentParser.h" |
| #include "core/dom/shadow/ShadowRoot.h" |
| #include "core/events/Event.h" |
| #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 +53,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 +117,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 +192,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, ""); |