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

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

Issue 2334803002: Implementation of media controls download button. (Closed)
Patch Set: fixed tests 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 18 matching lines...) Expand all
29 29
30 #include "core/html/shadow/MediaControlElements.h" 30 #include "core/html/shadow/MediaControlElements.h"
31 31
32 #include "bindings/core/v8/ExceptionStatePlaceholder.h" 32 #include "bindings/core/v8/ExceptionStatePlaceholder.h"
33 #include "core/InputTypeNames.h" 33 #include "core/InputTypeNames.h"
34 #include "core/dom/ClientRect.h" 34 #include "core/dom/ClientRect.h"
35 #include "core/dom/Text.h" 35 #include "core/dom/Text.h"
36 #include "core/dom/shadow/ShadowRoot.h" 36 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/events/MouseEvent.h" 37 #include "core/events/MouseEvent.h"
38 #include "core/frame/LocalFrame.h" 38 #include "core/frame/LocalFrame.h"
39 #include "core/html/HTMLAnchorElement.h"
39 #include "core/html/HTMLLabelElement.h" 40 #include "core/html/HTMLLabelElement.h"
40 #include "core/html/HTMLMediaSource.h" 41 #include "core/html/HTMLMediaSource.h"
41 #include "core/html/HTMLSpanElement.h" 42 #include "core/html/HTMLSpanElement.h"
42 #include "core/html/HTMLVideoElement.h" 43 #include "core/html/HTMLVideoElement.h"
43 #include "core/html/TimeRanges.h" 44 #include "core/html/TimeRanges.h"
44 #include "core/html/shadow/MediaControls.h" 45 #include "core/html/shadow/MediaControls.h"
45 #include "core/html/track/TextTrackList.h" 46 #include "core/html/track/TextTrackList.h"
46 #include "core/input/EventHandler.h" 47 #include "core/input/EventHandler.h"
47 #include "core/layout/api/LayoutSliderItem.h" 48 #include "core/layout/api/LayoutSliderItem.h"
48 #include "platform/EventDispatchForbiddenScope.h" 49 #include "platform/EventDispatchForbiddenScope.h"
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 626
626 MediaControlDivElement::defaultEventHandler(event); 627 MediaControlDivElement::defaultEventHandler(event);
627 } 628 }
628 629
629 // ---------------------------- 630 // ----------------------------
630 MediaControlDownloadButtonElement::MediaControlDownloadButtonElement(MediaContro ls& mediaControls) 631 MediaControlDownloadButtonElement::MediaControlDownloadButtonElement(MediaContro ls& mediaControls)
631 : MediaControlInputElement(mediaControls, MediaDownloadButton) 632 : MediaControlInputElement(mediaControls, MediaDownloadButton)
632 { 633 {
633 } 634 }
634 635
635 MediaControlDownloadButtonElement* MediaControlDownloadButtonElement::create(Med iaControls& mediaControls, Document* document) 636 MediaControlDownloadButtonElement* MediaControlDownloadButtonElement::create(Med iaControls& mediaControls)
636 { 637 {
637 MediaControlDownloadButtonElement* button = new MediaControlDownloadButtonEl ement(mediaControls); 638 MediaControlDownloadButtonElement* button = new MediaControlDownloadButtonEl ement(mediaControls);
638 button->ensureUserAgentShadowRoot(); 639 button->ensureUserAgentShadowRoot();
639 button->setType(InputTypeNames::button); 640 button->setType(InputTypeNames::button);
640 button->setShadowPseudoId(AtomicString("-internal-download-button")); 641 button->setShadowPseudoId(AtomicString("-internal-download-button"));
641 button->setIsWanted(false); 642 button->setIsWanted(false);
642 return button; 643 return button;
643 } 644 }
644 645
645 WebLocalizedString::Name MediaControlDownloadButtonElement::getOverflowStringNam e() 646 WebLocalizedString::Name MediaControlDownloadButtonElement::getOverflowStringNam e()
646 { 647 {
647 return WebLocalizedString::OverflowMenuDownload; 648 return WebLocalizedString::OverflowMenuDownload;
648 } 649 }
649 650
650 bool MediaControlDownloadButtonElement::shouldDisplayDownloadButton() 651 bool MediaControlDownloadButtonElement::shouldDisplayDownloadButton()
651 { 652 {
652 const KURL& url = mediaElement().currentSrc(); 653 const KURL& url = mediaElement().currentSrc();
653 if (!HTMLMediaElement::isMediaStreamURL(url.getString()) && !url.protocolIs( "blob") && !HTMLMediaSource::lookup(url)) { 654
655 if (!url.isNull() && !url.isEmpty() && !HTMLMediaElement::isMediaStreamURL(u rl.getString()) && !url.protocolIs("blob") && !HTMLMediaSource::lookup(url)) {
654 return true; 656 return true;
655 } 657 }
656 return false; 658 return false;
657 } 659 }
658 660
659 void MediaControlDownloadButtonElement::defaultEventHandler(Event* event) 661 void MediaControlDownloadButtonElement::defaultEventHandler(Event* event)
660 { 662 {
661 // TODO(kdsilva): The implementation will be finished as part of 663 const KURL& url = mediaElement().currentSrc();
662 // https://crbug.com/601247 664 if (event->type() == EventTypeNames::click && !(url.isNull() || url.isEmpty( ))) {
665 if (!m_anchor) {
666 HTMLAnchorElement* anchor = HTMLAnchorElement::create(document());
667 anchor->setAttribute(HTMLNames::downloadAttr, "");
668 m_anchor = anchor;
669 }
670 m_anchor->setURL(url);
671 m_anchor->dispatchSimulatedClick(event);
672 }
673 MediaControlInputElement::defaultEventHandler(event);
674 }
675
676 DEFINE_TRACE(MediaControlDownloadButtonElement)
677 {
678 visitor->trace(m_anchor);
679 MediaControlInputElement::trace(visitor);
663 } 680 }
664 681
665 // ---------------------------- 682 // ----------------------------
666 683
667 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) 684 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols)
668 : MediaControlInputElement(mediaControls, MediaSlider) 685 : MediaControlInputElement(mediaControls, MediaSlider)
669 { 686 {
670 } 687 }
671 688
672 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) 689 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 } 993 }
977 994
978 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) 995 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls)
979 { 996 {
980 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); 997 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls);
981 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); 998 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display"));
982 return element; 999 return element;
983 } 1000 }
984 1001
985 } // namespace blink 1002 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698