summaryrefslogtreecommitdiff
path: root/chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp56
1 files changed, 37 insertions, 19 deletions
diff --git a/chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp b/chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
index e4a3abb3089..0d1e0645ad7 100644
--- a/chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/chromium/third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -29,13 +29,13 @@
#include "core/html/parser/HTMLPreloadScanner.h"
#include "HTMLNames.h"
+#include "InputTypeNames.h"
#include "RuntimeEnabledFeatures.h"
#include "core/html/LinkRelAttribute.h"
-#include "core/html/forms/InputTypeNames.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/html/parser/HTMLSrcsetParser.h"
#include "core/html/parser/HTMLTokenizer.h"
-#include "core/platform/chromium/TraceEvent.h"
+#include "platform/TraceEvent.h"
#include "wtf/MainThread.h"
namespace WebCore {
@@ -47,17 +47,17 @@ static bool match(const StringImpl* impl, const QualifiedName& qName)
return impl == qName.localName().impl();
}
-static bool match(const HTMLIdentifier& name, const QualifiedName& qName)
-{
- return match(name.asStringImpl(), qName);
-}
-
static bool match(const AtomicString& name, const QualifiedName& qName)
{
ASSERT(isMainThread());
return qName.localName() == name;
}
+static bool match(const String& name, const QualifiedName& qName)
+{
+ return threadSafeMatch(name, qName);
+}
+
static const StringImpl* tagImplFor(const HTMLToken::DataVector& data)
{
AtomicString tagName(data);
@@ -67,9 +67,9 @@ static const StringImpl* tagImplFor(const HTMLToken::DataVector& data)
return 0;
}
-static const StringImpl* tagImplFor(const HTMLIdentifier& tagName)
+static const StringImpl* tagImplFor(const String& tagName)
{
- const StringImpl* result = tagName.asStringImpl();
+ const StringImpl* result = tagName.impl();
if (result->isStatic())
return result;
return 0;
@@ -98,6 +98,8 @@ public:
, m_inputIsImage(false)
, m_deviceScaleFactor(deviceScaleFactor)
, m_encounteredImgSrc(false)
+ , m_isCORSEnabled(false)
+ , m_allowCredentials(DoNotAllowStoredCredentials)
{
if (!match(m_tagImpl, imgTag)
&& !match(m_tagImpl, inputTag)
@@ -139,7 +141,8 @@ public:
TRACE_EVENT_INSTANT1("net", "PreloadRequest", "url", m_urlToLoad.ascii());
TextPosition position = TextPosition(source.currentLine(), source.currentColumn());
OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), m_mediaAttribute);
- request->setCrossOriginModeAllowsCookies(crossOriginModeAllowsCookies());
+ if (isCORSEnabled())
+ request->setCrossOriginEnabled(allowCredentials());
request->setCharset(charset());
return request.release();
}
@@ -154,14 +157,14 @@ private:
if (match(m_tagImpl, scriptTag)) {
if (match(attributeName, srcAttr))
setUrlToLoad(attributeValue, DisallowURLReplacement);
- else if (match(attributeName, crossoriginAttr) && !attributeValue.isNull())
- m_crossOriginMode = stripLeadingAndTrailingHTMLSpaces(attributeValue);
+ else if (match(attributeName, crossoriginAttr))
+ setCrossOriginAllowed(attributeValue);
} else if (match(m_tagImpl, imgTag)) {
if (match(attributeName, srcAttr) && !m_encounteredImgSrc) {
m_encounteredImgSrc = true;
setUrlToLoad(bestFitSourceForImageAttributes(m_deviceScaleFactor, attributeValue, m_srcsetImageCandidate), AllowURLReplacement);
- } else if (match(attributeName, crossoriginAttr) && !attributeValue.isNull()) {
- m_crossOriginMode = stripLeadingAndTrailingHTMLSpaces(attributeValue);
+ } else if (match(attributeName, crossoriginAttr)) {
+ setCrossOriginAllowed(attributeValue);
} else if (RuntimeEnabledFeatures::srcsetEnabled()
&& match(attributeName, srcsetAttr)
&& m_srcsetImageCandidate.isEmpty()) {
@@ -179,7 +182,7 @@ private:
if (match(attributeName, srcAttr))
setUrlToLoad(attributeValue, DisallowURLReplacement);
else if (match(attributeName, typeAttr))
- m_inputIsImage = equalIgnoringCase(attributeValue, InputTypeNames::image());
+ m_inputIsImage = equalIgnoringCase(attributeValue, InputTypeNames::image);
}
}
@@ -221,7 +224,7 @@ private:
return Resource::Raw;
}
- bool shouldPreload()
+ bool shouldPreload() const
{
if (m_urlToLoad.isEmpty())
return false;
@@ -232,21 +235,36 @@ private:
return true;
}
- bool crossOriginModeAllowsCookies()
+ bool isCORSEnabled() const
+ {
+ return m_isCORSEnabled;
+ }
+
+ StoredCredentials allowCredentials() const
+ {
+ return m_allowCredentials;
+ }
+
+ void setCrossOriginAllowed(const String& corsSetting)
{
- return m_crossOriginMode.isNull() || equalIgnoringCase(m_crossOriginMode, "use-credentials");
+ m_isCORSEnabled = true;
+ if (!corsSetting.isNull() && equalIgnoringCase(stripLeadingAndTrailingHTMLSpaces(corsSetting), "use-credentials"))
+ m_allowCredentials = AllowStoredCredentials;
+ else
+ m_allowCredentials = DoNotAllowStoredCredentials;
}
const StringImpl* m_tagImpl;
String m_urlToLoad;
ImageCandidate m_srcsetImageCandidate;
String m_charset;
- String m_crossOriginMode;
bool m_linkIsStyleSheet;
String m_mediaAttribute;
bool m_inputIsImage;
float m_deviceScaleFactor;
bool m_encounteredImgSrc;
+ bool m_isCORSEnabled;
+ StoredCredentials m_allowCredentials;
};
TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, float deviceScaleFactor)