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

Unified Diff: Source/WebCore/html/HTMLAnchorElement.cpp

Issue 7521007: Merge 91797 - Add support for download='filename' attribute in anchors. (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 5 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
« no previous file with comments | « Source/WebCore/html/HTMLAnchorElement.h ('k') | Source/WebCore/html/HTMLAnchorElement.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/html/HTMLAnchorElement.cpp
===================================================================
--- Source/WebCore/html/HTMLAnchorElement.cpp (revision 91866)
+++ Source/WebCore/html/HTMLAnchorElement.cpp (working copy)
@@ -27,6 +27,7 @@
#include "Attribute.h"
#include "EventNames.h"
#include "Frame.h"
+#include "FrameLoaderClient.h"
#include "FrameLoaderTypes.h"
#include "HTMLImageElement.h"
#include "HTMLNames.h"
@@ -147,10 +148,7 @@
}
if (isLinkClick(event) && treatLinkAsLiveForEventType(eventType(event))) {
- String url = stripLeadingAndTrailingHTMLSpaces(getAttribute(hrefAttr));
- appendServerMapMousePosition(url, event);
- handleLinkClick(event, document(), url, getAttribute(targetAttr), hasRel(RelationNoReferrer));
- sendPings(document()->completeURL(url));
+ handleClick(event);
return;
}
@@ -492,6 +490,37 @@
PingLoader::sendPing(document()->frame(), document()->completeURL(pingURLs[i]), destinationURL);
}
+void HTMLAnchorElement::handleClick(Event* event)
+{
+ event->setDefaultHandled();
+
+ Frame* frame = document()->frame();
+ if (!frame)
+ return;
+
+ String url = stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr));
+ appendServerMapMousePosition(url, event);
+ KURL kurl = document()->completeURL(url);
+
+#if ENABLE(DOWNLOAD_ATTRIBUTE)
+ if (hasAttribute(downloadAttr)) {
+ ResourceRequest request(kurl);
+
+ if (!hasRel(RelationNoReferrer)) {
+ String referrer = frame->loader()->outgoingReferrer();
+ if (!referrer.isEmpty() && !SecurityOrigin::shouldHideReferrer(kurl, referrer))
+ request.setHTTPReferrer(referrer);
+ frame->loader()->addExtraFieldsToMainResourceRequest(request);
+ }
+
+ frame->loader()->client()->startDownload(request, fastGetAttribute(downloadAttr));
+ } else
+#endif
+ frame->loader()->urlSelected(kurl, target(), event, false, false, hasRel(RelationNoReferrer) ? NoReferrer : SendReferrer);
+
+ sendPings(kurl);
+}
+
HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event)
{
if (!event->isMouseEvent())
« no previous file with comments | « Source/WebCore/html/HTMLAnchorElement.h ('k') | Source/WebCore/html/HTMLAnchorElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698