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

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

Issue 1563263002: Add HTMLPreloadScanner support for <link rel=preload> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a test as well as 2 bugs that other tests revealed Created 4 years, 11 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
Index: third_party/WebKit/Source/core/loader/LinkLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/LinkLoader.cpp b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
index 0eaaa24b22f699bb95db54212e6888ba35b07970..7db397a9e10fbb0e983f1319cb5d23ea401af82e 100644
--- a/third_party/WebKit/Source/core/loader/LinkLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/LinkLoader.cpp
@@ -164,7 +164,7 @@ static void preconnectIfNeeded(const LinkRelAttribute& relAttribute, const KURL&
}
}
-static Resource::Type getTypeFromAsAttribute(const String& as, Document& document)
+Resource::Type LinkLoader::getTypeFromAsAttribute(const String& as, Document* document)
{
if (equalIgnoringCase(as, "image"))
return Resource::Image;
@@ -178,8 +178,9 @@ static Resource::Type getTypeFromAsAttribute(const String& as, Document& documen
return Resource::Font;
if (equalIgnoringCase(as, "track"))
return Resource::TextTrack;
- if (!as.isEmpty())
- document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, WarningMessageLevel, String("<link rel=preload> must have a valid `as` value")));
+ if (document && !as.isEmpty())
+ document->addConsoleMessage(ConsoleMessage::create(OtherMessageSource, WarningMessageLevel, String("<link rel=preload> must have a valid `as` value")));
+ // TODO(yoav): Is this correct? If as is missing or invalid, it should be subject to "connect-src" CSP directives.
igrigorik 2016/01/12 22:11:54 (sorry for late review). To answer the question: y
return Resource::LinkSubresource;
}
@@ -195,7 +196,7 @@ static void preloadIfNeeded(const LinkRelAttribute& relAttribute, const KURL& hr
document.addConsoleMessage(ConsoleMessage::create(OtherMessageSource, WarningMessageLevel, String("<link rel=preload> has an invalid `href` value")));
return;
}
- Resource::Type type = getTypeFromAsAttribute(as, document);
+ Resource::Type type = LinkLoader::getTypeFromAsAttribute(as, &document);
ResourceRequest resourceRequest(document.completeURL(href));
ResourceFetcher::determineRequestContext(resourceRequest, type, false);
FetchRequest linkRequest(resourceRequest, FetchInitiatorTypeNames::link);

Powered by Google App Engine
This is Rietveld 408576698