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

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: update webexposed layout tests 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 18 matching lines...) Expand all
29 #include "core/events/MouseEvent.h" 29 #include "core/events/MouseEvent.h"
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/RuntimeEnabledFeatures.h"
39 #include "platform/network/NetworkHints.h" 40 #include "platform/network/NetworkHints.h"
41 #include "platform/weborigin/SecurityPolicy.h"
40 42
41 namespace blink { 43 namespace blink {
42 44
43 using namespace HTMLNames; 45 using namespace HTMLNames;
44 46
45 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument) 47 HTMLAnchorElement::HTMLAnchorElement(const QualifiedName& tagName, Document& doc ument)
46 : HTMLElement(tagName, document) 48 : HTMLElement(tagName, document)
47 , m_linkRelations(0) 49 , m_linkRelations(0)
48 , m_cachedVisitedLinkHash(0) 50 , m_cachedVisitedLinkHash(0)
49 , m_wasFocusedByMouse(false) 51 , m_wasFocusedByMouse(false)
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 appendServerMapMousePosition(url, event); 343 appendServerMapMousePosition(url, event);
342 KURL completedURL = document().completeURL(url.toString()); 344 KURL completedURL = document().completeURL(url.toString());
343 345
344 // Schedule the ping before the frame load. Prerender in Chrome may kill the renderer as soon as the navigation is 346 // Schedule the ping before the frame load. Prerender in Chrome may kill the renderer as soon as the navigation is
345 // sent out. 347 // sent out.
346 sendPings(completedURL); 348 sendPings(completedURL);
347 349
348 ResourceRequest request(completedURL); 350 ResourceRequest request(completedURL);
349 request.setUIStartTime(event->uiCreateTime()); 351 request.setUIStartTime(event->uiCreateTime());
350 request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::Re portLink); 352 request.setInputPerfMetricReportPolicy(InputToLoadPerfMetricReportPolicy::Re portLink);
353
354 ReferrerPolicy policy;
355 if (RuntimeEnabledFeatures::referrerPolicyAttributeEnabled() && hasAttribute (referrerpolicyAttr) && SecurityPolicy::referrerPolicyFromString(fastGetAttribut e(referrerpolicyAttr), &policy) && !hasRel(RelationNoReferrer)) {
356 request.setHTTPReferrer(SecurityPolicy::generateReferrer(policy, complet edURL, document().outgoingReferrer()));
357 }
358
351 if (hasAttribute(downloadAttr)) { 359 if (hasAttribute(downloadAttr)) {
352 request.setRequestContext(WebURLRequest::RequestContextDownload); 360 request.setRequestContext(WebURLRequest::RequestContextDownload);
353 bool isSameOrigin = completedURL.protocolIsData() || document().security Origin()->canRequest(completedURL); 361 bool isSameOrigin = completedURL.protocolIsData() || document().security Origin()->canRequest(completedURL);
354 const AtomicString& suggestedName = (isSameOrigin ? fastGetAttribute(dow nloadAttr) : nullAtom); 362 const AtomicString& suggestedName = (isSameOrigin ? fastGetAttribute(dow nloadAttr) : nullAtom);
355 363
356 frame->loader().client()->loadURLExternally(request, NavigationPolicyDow nload, suggestedName); 364 frame->loader().client()->loadURLExternally(request, NavigationPolicyDow nload, suggestedName);
357 } else { 365 } else {
358 request.setRequestContext(WebURLRequest::RequestContextHyperlink); 366 request.setRequestContext(WebURLRequest::RequestContextHyperlink);
359 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr)); 367 FrameLoadRequest frameRequest(&document(), request, getAttribute(targetA ttr));
360 frameRequest.setTriggeringEvent(event); 368 frameRequest.setTriggeringEvent(event);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 Vector<String> argv; 400 Vector<String> argv;
393 argv.append("a"); 401 argv.append("a");
394 argv.append(fastGetAttribute(hrefAttr)); 402 argv.append(fastGetAttribute(hrefAttr));
395 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() ); 403 activityLogger->logEvent("blinkAddElement", argv.size(), argv.data() );
396 } 404 }
397 } 405 }
398 return HTMLElement::insertedInto(insertionPoint); 406 return HTMLElement::insertedInto(insertionPoint);
399 } 407 }
400 408
401 } // namespace blink 409 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/webexposed/global-interface-listing-expected.txt ('k') | Source/core/html/HTMLAnchorElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698