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

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp

Issue 2334803002: Implementation of media controls download button. (Closed)
Patch Set: --no-find-copies Created 4 years, 3 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/shadow/MediaControlElements.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
index e1ed80c3699d370c24aa5d41402d28839550eef8..b1110471c2a102548bd6c74ee72c9b130b9d9fc4 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp
@@ -36,6 +36,7 @@
#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/MouseEvent.h"
#include "core/frame/LocalFrame.h"
+#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLLabelElement.h"
#include "core/html/HTMLMediaSource.h"
#include "core/html/HTMLSpanElement.h"
@@ -632,7 +633,7 @@ MediaControlDownloadButtonElement::MediaControlDownloadButtonElement(MediaContro
{
}
-MediaControlDownloadButtonElement* MediaControlDownloadButtonElement::create(MediaControls& mediaControls, Document* document)
+MediaControlDownloadButtonElement* MediaControlDownloadButtonElement::create(MediaControls& mediaControls)
{
MediaControlDownloadButtonElement* button = new MediaControlDownloadButtonElement(mediaControls);
button->ensureUserAgentShadowRoot();
@@ -658,8 +659,23 @@ bool MediaControlDownloadButtonElement::shouldDisplayDownloadButton()
void MediaControlDownloadButtonElement::defaultEventHandler(Event* event)
{
- // TODO(kdsilva): The implementation will be finished as part of
- // https://crbug.com/601247
+ const KURL& url = mediaElement().currentSrc();
+ if (event->type() == EventTypeNames::click && url != KURL()) {
whywhat 2016/09/13 15:52:16 nit: perhaps replace url != KURL() with !(url.IsNu
kdsilva 2016/09/13 17:33:01 Done.
+ if (!m_anchor) {
+ HTMLAnchorElement* anchor = HTMLAnchorElement::create(document());
+ anchor->setAttribute(HTMLNames::downloadAttr, "");
+ m_anchor = anchor;
+ }
+ m_anchor->setURL(url);
+ m_anchor->dispatchSimulatedClick(event);
+ }
+ MediaControlInputElement::defaultEventHandler(event);
+}
+
+DEFINE_TRACE(MediaControlDownloadButtonElement)
+{
+ visitor->trace(m_anchor);
+ MediaControlInputElement::trace(visitor);
}
// ----------------------------

Powered by Google App Engine
This is Rietveld 408576698