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

Unified Diff: Source/core/css/CSSFontFaceSrcValue.cpp

Issue 230383003: Webfont CORS-enabled fetching with fallback (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase & reverse the enum values Created 6 years, 8 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/css/CSSFontFaceSrcValue.h ('k') | Source/core/css/RemoteFontFaceSource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSFontFaceSrcValue.cpp
diff --git a/Source/core/css/CSSFontFaceSrcValue.cpp b/Source/core/css/CSSFontFaceSrcValue.cpp
index 5ccf7547707efc0f79d2e69841d9ace072da92cb..d54f0deefda13f9baba7b6c47a029033f0652d12 100644
--- a/Source/core/css/CSSFontFaceSrcValue.cpp
+++ b/Source/core/css/CSSFontFaceSrcValue.cpp
@@ -88,10 +88,23 @@ bool CSSFontFaceSrcValue::hasFailedOrCanceledSubresources() const
return m_fetched->loadFailedOrCanceled();
}
+bool CSSFontFaceSrcValue::shouldSetCrossOriginAccessControl(const KURL& resource, SecurityOrigin* securityOrigin)
+{
+ if (resource.isLocalFile() || resource.protocolIsData())
+ return false;
+ if (m_fetched && m_fetched->isCORSFailed())
+ return false;
+ return !securityOrigin->canRequest(resource);
+}
+
FontResource* CSSFontFaceSrcValue::fetch(Document* document)
{
- if (!m_fetched) {
+ if (!m_fetched || m_fetched->isCORSFailed()) {
FetchRequest request(ResourceRequest(document->completeURL(m_resource)), FetchInitiatorTypeNames::css);
+ SecurityOrigin* securityOrigin = document->securityOrigin();
+ if (shouldSetCrossOriginAccessControl(request.url(), securityOrigin)) {
+ request.setCrossOriginAccessControl(securityOrigin, DoNotAllowStoredCredentials);
+ }
m_fetched = document->fetcher()->fetchFont(request);
}
return m_fetched.get();
« no previous file with comments | « Source/core/css/CSSFontFaceSrcValue.h ('k') | Source/core/css/RemoteFontFaceSource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698