Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 if (!HTMLMediaElement::isMediaStreamURL(url.getString()) && !url.protocolIs( "blob") && !HTMLMediaSource::lookup(url)) { |
| 654 return true; | 655 return true; |
| 655 } | 656 } |
| 656 return false; | 657 return false; |
| 657 } | 658 } |
| 658 | 659 |
| 659 void MediaControlDownloadButtonElement::defaultEventHandler(Event* event) | 660 void MediaControlDownloadButtonElement::defaultEventHandler(Event* event) |
| 660 { | 661 { |
| 661 // TODO(kdsilva): The implementation will be finished as part of | 662 const KURL& url = mediaElement().currentSrc(); |
| 662 // https://crbug.com/601247 | 663 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.
| |
| 664 if (!m_anchor) { | |
| 665 HTMLAnchorElement* anchor = HTMLAnchorElement::create(document()); | |
| 666 anchor->setAttribute(HTMLNames::downloadAttr, ""); | |
| 667 m_anchor = anchor; | |
| 668 } | |
| 669 m_anchor->setURL(url); | |
| 670 m_anchor->dispatchSimulatedClick(event); | |
| 671 } | |
| 672 MediaControlInputElement::defaultEventHandler(event); | |
| 673 } | |
| 674 | |
| 675 DEFINE_TRACE(MediaControlDownloadButtonElement) | |
| 676 { | |
| 677 visitor->trace(m_anchor); | |
| 678 MediaControlInputElement::trace(visitor); | |
| 663 } | 679 } |
| 664 | 680 |
| 665 // ---------------------------- | 681 // ---------------------------- |
| 666 | 682 |
| 667 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) | 683 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaCon trols) |
| 668 : MediaControlInputElement(mediaControls, MediaSlider) | 684 : MediaControlInputElement(mediaControls, MediaSlider) |
| 669 { | 685 { |
| 670 } | 686 } |
| 671 | 687 |
| 672 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) | 688 MediaControlTimelineElement* MediaControlTimelineElement::create(MediaControls& mediaControls) |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 } | 992 } |
| 977 | 993 |
| 978 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) | 994 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr eate(MediaControls& mediaControls) |
| 979 { | 995 { |
| 980 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); | 996 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime DisplayElement(mediaControls); |
| 981 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); | 997 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time -display")); |
| 982 return element; | 998 return element; |
| 983 } | 999 } |
| 984 | 1000 |
| 985 } // namespace blink | 1001 } // namespace blink |
| OLD | NEW |