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

Side by Side Diff: Source/core/dom/StyleElement.cpp

Issue 353873003: Clean up usage of CSP functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix to apply Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ScriptLoader.cpp ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Rob Buis 2 * Copyright (C) 2006, 2007 Rob Buis
3 * Copyright (C) 2008 Apple, Inc. All rights reserved. 3 * Copyright (C) 2008 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 { 145 {
146 ASSERT(e); 146 ASSERT(e);
147 ASSERT(e->inDocument()); 147 ASSERT(e->inDocument());
148 Document& document = e->document(); 148 Document& document = e->document();
149 if (m_sheet) 149 if (m_sheet)
150 clearSheet(e); 150 clearSheet(e);
151 151
152 // Inline style added from an isolated world should bypass the main world's 152 // Inline style added from an isolated world should bypass the main world's
153 // CSP just as an inline script would. 153 // CSP just as an inline script would.
154 LocalFrame* frame = document.frame(); 154 LocalFrame* frame = document.frame();
155 bool shouldBypassMainWorldContentSecurityPolicy = frame && frame->script().s houldBypassMainWorldContentSecurityPolicy(); 155 bool shouldBypassMainWorldCSP = frame && frame->script().shouldBypassMainWor ldCSP();
156
157 const ContentSecurityPolicy* csp = document.contentSecurityPolicy();
158 bool passesContentSecurityPolicyChecks = shouldBypassMainWorldCSP
159 || csp->allowStyleWithHash(text)
160 || csp->allowStyleWithNonce(e->fastGetAttribute(HTMLNames::nonceAttr))
161 || csp->allowInlineStyle(e->document().url(), m_startPosition.m_line);
156 162
157 // If type is empty or CSS, this is a CSS style sheet. 163 // If type is empty or CSS, this is a CSS style sheet.
158 const AtomicString& type = this->type(); 164 const AtomicString& type = this->type();
159 bool passesContentSecurityPolicyChecks = shouldBypassMainWorldContentSecurit yPolicy || document.contentSecurityPolicy()->allowStyleHash(text) || document.co ntentSecurityPolicy()->allowStyleNonce(e->fastGetAttribute(HTMLNames::nonceAttr) ) || document.contentSecurityPolicy()->allowInlineStyle(e->document().url(), m_s tartPosition.m_line);
160 if (isCSS(e, type) && passesContentSecurityPolicyChecks) { 165 if (isCSS(e, type) && passesContentSecurityPolicyChecks) {
161 RefPtrWillBeRawPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(m edia()); 166 RefPtrWillBeRawPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(m edia());
162 167
163 MediaQueryEvaluator screenEval("screen", true); 168 MediaQueryEvaluator screenEval("screen", true);
164 MediaQueryEvaluator printEval("print", true); 169 MediaQueryEvaluator printEval("print", true);
165 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g et())) { 170 if (screenEval.eval(mediaQueries.get()) || printEval.eval(mediaQueries.g et())) {
166 m_loading = true; 171 m_loading = true;
167 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition; 172 TextPosition startPosition = m_startPosition == TextPosition::belowR angePosition() ? TextPosition::minimumPosition() : m_startPosition;
168 m_sheet = document.styleEngine()->createSheet(e, text, startPosition , m_createdByParser); 173 m_sheet = document.styleEngine()->createSheet(e, text, startPosition , m_createdByParser);
169 m_sheet->setMediaQueries(mediaQueries.release()); 174 m_sheet->setMediaQueries(mediaQueries.release());
(...skipping 25 matching lines...) Expand all
195 { 200 {
196 document.styleEngine()->addPendingSheet(); 201 document.styleEngine()->addPendingSheet();
197 } 202 }
198 203
199 void StyleElement::trace(Visitor* visitor) 204 void StyleElement::trace(Visitor* visitor)
200 { 205 {
201 visitor->trace(m_sheet); 206 visitor->trace(m_sheet);
202 } 207 }
203 208
204 } 209 }
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptLoader.cpp ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698