| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 | 646 |
| 647 WebLocalizedString::Name MediaControlDownloadButtonElement::getOverflowStringNam
e() | 647 WebLocalizedString::Name MediaControlDownloadButtonElement::getOverflowStringNam
e() |
| 648 { | 648 { |
| 649 return WebLocalizedString::OverflowMenuDownload; | 649 return WebLocalizedString::OverflowMenuDownload; |
| 650 } | 650 } |
| 651 | 651 |
| 652 bool MediaControlDownloadButtonElement::shouldDisplayDownloadButton() | 652 bool MediaControlDownloadButtonElement::shouldDisplayDownloadButton() |
| 653 { | 653 { |
| 654 const KURL& url = mediaElement().currentSrc(); | 654 const KURL& url = mediaElement().currentSrc(); |
| 655 | 655 |
| 656 if (!url.isNull() && !url.isEmpty() && !HTMLMediaElement::isMediaStreamURL(u
rl.getString()) && !url.protocolIs("blob") && !HTMLMediaSource::lookup(url)) { | 656 // URLs that lead to nowhere are ignored. |
| 657 return true; | 657 if (url.isNull() || url.isEmpty()) |
| 658 } | 658 return false; |
| 659 return false; | 659 |
| 660 // Local files and blobs should not have a download button. |
| 661 if (url.isLocalFile() || url.protocolIs("blob")) |
| 662 return false; |
| 663 |
| 664 // MediaStream can't be downloaded. |
| 665 if (HTMLMediaElement::isMediaStreamURL(url.getString())) |
| 666 return false; |
| 667 |
| 668 // MediaSource can't be downloaded. |
| 669 if (HTMLMediaSource::lookup(url)) |
| 670 return false; |
| 671 |
| 672 return true; |
| 660 } | 673 } |
| 661 | 674 |
| 662 void MediaControlDownloadButtonElement::defaultEventHandler(Event* event) | 675 void MediaControlDownloadButtonElement::defaultEventHandler(Event* event) |
| 663 { | 676 { |
| 664 const KURL& url = mediaElement().currentSrc(); | 677 const KURL& url = mediaElement().currentSrc(); |
| 665 if (event->type() == EventTypeNames::click && !(url.isNull() || url.isEmpty(
))) { | 678 if (event->type() == EventTypeNames::click && !(url.isNull() || url.isEmpty(
))) { |
| 666 Platform::current()->recordAction(UserMetricsAction("Media.Controls.Down
load")); | 679 Platform::current()->recordAction(UserMetricsAction("Media.Controls.Down
load")); |
| 667 if (!m_anchor) { | 680 if (!m_anchor) { |
| 668 HTMLAnchorElement* anchor = HTMLAnchorElement::create(document()); | 681 HTMLAnchorElement* anchor = HTMLAnchorElement::create(document()); |
| 669 anchor->setAttribute(HTMLNames::downloadAttr, ""); | 682 anchor->setAttribute(HTMLNames::downloadAttr, ""); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 } | 1008 } |
| 996 | 1009 |
| 997 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr
eate(MediaControls& mediaControls) | 1010 MediaControlCurrentTimeDisplayElement* MediaControlCurrentTimeDisplayElement::cr
eate(MediaControls& mediaControls) |
| 998 { | 1011 { |
| 999 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime
DisplayElement(mediaControls); | 1012 MediaControlCurrentTimeDisplayElement* element = new MediaControlCurrentTime
DisplayElement(mediaControls); |
| 1000 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display")); | 1013 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display")); |
| 1001 return element; | 1014 return element; |
| 1002 } | 1015 } |
| 1003 | 1016 |
| 1004 } // namespace blink | 1017 } // namespace blink |
| OLD | NEW |