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

Side by Side Diff: Source/core/html/HTMLAnchorElement.cpp

Issue 1253413003: Implement referrerpolicy attribute for anchor elements (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Simon Hausmann <hausmann@kde.org> 4 * (C) 2000 Simon Hausmann <hausmann@kde.org>
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
6 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) 6 * (C) 2006 Graham Dennis (graham.dennis@gmail.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 19 matching lines...) Expand all
30 #include "core/frame/FrameHost.h" 30 #include "core/frame/FrameHost.h"
31 #include "core/frame/Settings.h" 31 #include "core/frame/Settings.h"
32 #include "core/html/HTMLImageElement.h" 32 #include "core/html/HTMLImageElement.h"
33 #include "core/html/parser/HTMLParserIdioms.h" 33 #include "core/html/parser/HTMLParserIdioms.h"
34 #include "core/layout/LayoutImage.h" 34 #include "core/layout/LayoutImage.h"
35 #include "core/loader/FrameLoadRequest.h" 35 #include "core/loader/FrameLoadRequest.h"
36 #include "core/loader/FrameLoaderClient.h" 36 #include "core/loader/FrameLoaderClient.h"
37 #include "core/loader/PingLoader.h" 37 #include "core/loader/PingLoader.h"
38 #include "core/page/ChromeClient.h" 38 #include "core/page/ChromeClient.h"
39 #include "platform/network/NetworkHints.h" 39 #include "platform/network/NetworkHints.h"
40 #include "platform/weborigin/SecurityPolicy.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 using namespace HTMLNames; 44 using namespace HTMLNames;
44 45
45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) 46 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument)
46 : HTMLElement(tagName, document) 47 : HTMLElement(tagName, document)
47 , m_linkRelations(0) 48 , m_linkRelations(0)
48 , m_cachedVisitedLinkHash(0) 49 , m_cachedVisitedLinkHash(0)
49 , m_wasFocusedByMouse(false) 50 , m_wasFocusedByMouse(false)
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 appendServerMapMousePosition(url, event); 342 appendServerMapMousePosition(url, event);
342 KURL completedURL = document().completeURL(url.toString()); 343 KURL completedURL = document().completeURL(url.toString());
343 344
344 // Schedule the ping before the frame load. Prerender in Chrome may kill the renderer as soon as the navigation is 345 // Schedule the ping before the frame load. Prerender in Chrome may kill the renderer as soon as the navigation is
345 // sent out. 346 // sent out.
346 sendPings(completedURL); 347 sendPings(completedURL);
347 348
348 ResourceRequest request(completedURL); 349 ResourceRequest request(completedURL);
349 request.setUIStartTime(event->uiCreateTime()); 350 request.setUIStartTime(event->uiCreateTime());
350 request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::Re portLink); 351 request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::Re portLink);
352
353 ReferrerPolicy policy;
354 if (hasAttribute(referrerpolicyAttr) && SecurityPolicy::referrerPolicyFromSt ring(fastGetAttribute(referrerpolicyAttr), &policy)) {
355 request.setHTTPReferrer(SecurityPolicy::generateReferrer(policy, complet edURL, document().outgoingReferrer()));
356 }
357
351 if (hasAttribute(downloadAttr)) { 358 if (hasAttribute(downloadAttr)) {
352 request.setRequestContext(WebURLRequest::RequestContextDownload); 359 request.setRequestContext(WebURLRequest::RequestContextDownload);
353 bool isSameOrigin = completedURL.protocolIsData() || document().security Origin()->canRequest(completedURL); 360 bool isSameOrigin = completedURL.protocolIsData() || document().security Origin()->canRequest(completedURL);
354 const AtomicString& suggestedName = (isSameOrigin ? fastGetAttribute(dow nloadAttr) : nullAtom); 361 const AtomicString& suggestedName = (isSameOrigin ? fastGetAttribute(dow nloadAttr) : nullAtom);
355 362
356 frame->loader().client()->loadURLExternally(request, NavigationPolicyDow nload, suggestedName); 363 frame->loader().client()->loadURLExternally(request, NavigationPolicyDow nload, suggestedName);
357 } else { 364 } else {
358 request.setRequestContext(WebURLRequest::RequestContextHyperlink); 365 request.setRequestContext(WebURLRequest::RequestContextHyperlink);
359 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); 366 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr));
360 frameRequest.setTriggeringEvent(event); 367 frameRequest.setTriggeringEvent(event);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 Vector<String> argv; 399 Vector<String> argv;
393 argv.append("a"); 400 argv.append("a");
394 argv.append(fastGetAttribute(hrefAttr)); 401 argv.append(fastGetAttribute(hrefAttr));
395 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 402 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
396 } 403 }
397 } 404 }
398 return HTMLElement::insertedInto(insertionPoint); 405 return HTMLElement::insertedInto(insertionPoint);
399 } 406 }
400 407
401 } // namespace blink 408 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698