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

Unified Diff: Source/core/loader/LinkLoader.cpp

Issue 1135203002: Add <link rel=preconnect> crossorigin attribute (take 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Todo Created 5 years, 7 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/core/loader/LinkHeaderTest.cpp ('k') | Source/platform/network/NetworkHints.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/LinkLoader.cpp
diff --git a/Source/core/loader/LinkLoader.cpp b/Source/core/loader/LinkLoader.cpp
index d881324fe70b25463a01434edb9eb0675bbc718b..2567794051a958b5d0a81bf1959c545d7655a589 100644
--- a/Source/core/loader/LinkLoader.cpp
+++ b/Source/core/loader/LinkLoader.cpp
@@ -37,6 +37,7 @@
#include "core/fetch/FetchRequest.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/Settings.h"
+#include "core/html/CrossOriginAttribute.h"
#include "core/html/LinkRelAttribute.h"
#include "core/inspector/ConsoleMessage.h"
#include "core/loader/LinkHeader.h"
@@ -128,14 +129,19 @@ static void dnsPrefetchIfNeeded(const LinkRelAttribute& relAttribute, const KURL
}
}
-static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document)
+static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL& href, Document& document, const CrossOriginAttributeValue crossOrigin)
{
if (relAttribute.isPreconnect() && href.isValid()) {
ASSERT(RuntimeEnabledFeatures::linkPreconnectEnabled());
Settings* settings = document.settings();
- if (settings && settings->logDnsPrefetchAndPreconnect())
+ if (settings && settings->logDnsPrefetchAndPreconnect()) {
document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, DebugMessageLevel, String("Preconnect triggered for " + href.host())));
- preconnect(href);
+ if (crossOrigin != CrossOriginAttributeNotSet) {
+ document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, DebugMessageLevel,
+ String("Preconnect CORS setting is ") + String((crossOrigin == CrossOriginAttributeAnonymous) ? "anonymous" : "use-credentials")));
+ }
+ }
+ preconnect(href, crossOrigin);
}
}
@@ -185,7 +191,7 @@ bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
dnsPrefetchIfNeeded(relAttribute, url, *document);
if (RuntimeEnabledFeatures::linkPreconnectEnabled())
- preconnectIfNeeded(relAttribute, url, *document);
+ preconnectIfNeeded(relAttribute, url, *document, header.crossOrigin());
// FIXME: Add more supported headers as needed.
}
@@ -194,10 +200,11 @@ bool LinkLoader::loadLinkFromHeader(const String& headerValue, Document* documen
bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const AtomicString& crossOriginMode, const String& type, const String& as, const KURL& href, Document& document)
{
+ // TODO(yoav): Convert all uses of the CrossOriginAttribute to CrossOriginAttributeValue. crbug.com/486689
// FIXME(crbug.com/463266): We're ignoring type here. Maybe we shouldn't.
dnsPrefetchIfNeeded(relAttribute, href, document);
- preconnectIfNeeded(relAttribute, href, document);
+ preconnectIfNeeded(relAttribute, href, document, crossOriginAttributeValue(crossOriginMode));
preloadIfNeeded(relAttribute, href, document, as);
« no previous file with comments | « Source/core/loader/LinkHeaderTest.cpp ('k') | Source/platform/network/NetworkHints.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698