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

Unified Diff: third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp

Issue 2371573002: Fix download attr on anchor allows download without user interaction
Patch Set: Removed unnecessary header 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
« AUTHORS ('K') | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp b/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
index 4957d232290e4a3d99b25b6b4aa05b95c88cff23..f0a6dff4727e9eea8591106658e60b023d72b63f 100644
--- a/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLAnchorElement.cpp
@@ -426,11 +426,15 @@ void HTMLAnchorElement::handleClick(Event* event)
}
if (hasAttribute(downloadAttr)) {
- request.setRequestContext(WebURLRequest::RequestContextDownload);
- bool isSameOrigin = completedURL.protocolIsData() || document().getSecurityOrigin()->canRequest(completedURL);
- const AtomicString& suggestedName = (isSameOrigin ? fastGetAttribute(downloadAttr) : nullAtom);
-
- frame->loader().client()->loadURLExternally(request, NavigationPolicyDownload, suggestedName, false);
+ if (event->isTrusted()) {
+ request.setRequestContext(WebURLRequest::RequestContextDownload);
+ bool isSameOrigin = completedURL.protocolIsData() || document().getSecurityOrigin()->canRequest(completedURL);
+ const AtomicString& suggestedName = (isSameOrigin ? fastGetAttribute(downloadAttr) : nullAtom);
+
+ frame->loader().client()->loadURLExternally(request, NavigationPolicyDownload, suggestedName, false);
+ } else {
+ // TODO: Throw an "InvalidAccessError" DOMException.
Rick Byers 2016/09/28 22:31:56 I'm OK leaving this as follow-up work (it's probab
+ }
} else {
request.setRequestContext(WebURLRequest::RequestContextHyperlink);
FrameLoadRequest frameRequest(&document(), request, getAttribute(targetAttr));
« AUTHORS ('K') | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698