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

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

Issue 2376293004: Don't show media controls download button on local files. (Closed)
Patch Set: rebaseline again \o/ Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/media/video-zoom-controls-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/media/video-zoom-controls-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698