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

Side by Side Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 1861243002: Check the mime type of cross-origin CSS fetched via the Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2006, 2007, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 const AtomicString& StyleSheetContents::namespaceURIFromPrefix(const AtomicStrin g& prefix) 315 const AtomicString& StyleSheetContents::namespaceURIFromPrefix(const AtomicStrin g& prefix)
316 { 316 {
317 return m_namespaces.get(prefix); 317 return m_namespaces.get(prefix);
318 } 318 }
319 319
320 void StyleSheetContents::parseAuthorStyleSheet(const CSSStyleSheetResource* cach edStyleSheet, const SecurityOrigin* securityOrigin) 320 void StyleSheetContents::parseAuthorStyleSheet(const CSSStyleSheetResource* cach edStyleSheet, const SecurityOrigin* securityOrigin)
321 { 321 {
322 TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", Ins pectorParseAuthorStyleSheetEvent::data(cachedStyleSheet)); 322 TRACE_EVENT1("blink,devtools.timeline", "ParseAuthorStyleSheet", "data", Ins pectorParseAuthorStyleSheetEvent::data(cachedStyleSheet));
323 323
324 bool isSameOriginRequest = securityOrigin && securityOrigin->canRequest(base URL()); 324 bool isSameOriginRequest = securityOrigin && securityOrigin->canRequest(base URL());
325
326 // When the response was fetched via the Service Worker, the original URL ma y not be same as the base URL.
327 // FIXME: When we will use the original URL as the base URL, we can remove t his check. crbug.com/553535
Mike West 2016/04/06 06:54:16 Nit: s/FIXME/TODO(horo)/
horo 2016/04/06 08:13:50 Done.
328 if (cachedStyleSheet->response().wasFetchedViaServiceWorker() && !securityOr igin->canRequest(cachedStyleSheet->response().originalURLViaServiceWorker()))
Mike West 2016/04/06 06:54:16 What do we do for purely synthetic responses? It s
horo 2016/04/06 08:13:50 Done. Added isEmpty() checking.
329 isSameOriginRequest = false;
330
325 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_ parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCh eck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict; 331 CSSStyleSheetResource::MIMETypeCheck mimeTypeCheck = isQuirksModeBehavior(m_ parserContext.mode()) && isSameOriginRequest ? CSSStyleSheetResource::MIMETypeCh eck::Lax : CSSStyleSheetResource::MIMETypeCheck::Strict;
326 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck); 332 String sheetText = cachedStyleSheet->sheetText(mimeTypeCheck);
327 333
328 const ResourceResponse& response = cachedStyleSheet->response(); 334 const ResourceResponse& response = cachedStyleSheet->response();
329 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap); 335 m_sourceMapURL = response.httpHeaderField(HTTPNames::SourceMap);
330 if (m_sourceMapURL.isEmpty()) { 336 if (m_sourceMapURL.isEmpty()) {
331 // Try to get deprecated header. 337 // Try to get deprecated header.
332 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap); 338 m_sourceMapURL = response.httpHeaderField(HTTPNames::X_SourceMap);
333 } 339 }
334 340
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 visitor->trace(m_ownerRule); 671 visitor->trace(m_ownerRule);
666 visitor->trace(m_importRules); 672 visitor->trace(m_importRules);
667 visitor->trace(m_namespaceRules); 673 visitor->trace(m_namespaceRules);
668 visitor->trace(m_childRules); 674 visitor->trace(m_childRules);
669 visitor->trace(m_loadingClients); 675 visitor->trace(m_loadingClients);
670 visitor->trace(m_completedClients); 676 visitor->trace(m_completedClients);
671 visitor->trace(m_ruleSet); 677 visitor->trace(m_ruleSet);
672 } 678 }
673 679
674 } // namespace blink 680 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698