OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights | 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
6 * reserved. | 6 * reserved. |
7 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) | 7 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) |
8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 m_loading = false; | 422 m_loading = false; |
423 removePendingSheet(); | 423 removePendingSheet(); |
424 if (m_sheet) | 424 if (m_sheet) |
425 clearSheet(); | 425 clearSheet(); |
426 return; | 426 return; |
427 } | 427 } |
428 | 428 |
429 // See the comment in PendingScript.cpp about why this check is necessary | 429 // See the comment in PendingScript.cpp about why this check is necessary |
430 // here, instead of in the resource fetcher. https://crbug.com/500701. | 430 // here, instead of in the resource fetcher. https://crbug.com/500701. |
431 if (!cachedStyleSheet->errorOccurred() && | 431 if (!cachedStyleSheet->errorOccurred() && |
432 m_owner->fastHasAttribute(HTMLNames::integrityAttr) && | 432 !m_owner->fastGetAttribute(HTMLNames::integrityAttr).isEmpty() && |
433 cachedStyleSheet->resourceBuffer() && | 433 !cachedStyleSheet->integrityMetadata().isEmpty()) { |
434 !SubresourceIntegrity::CheckSubresourceIntegrity( | 434 ResourceIntegrityDisposition disposition = |
435 *m_owner, cachedStyleSheet->resourceBuffer()->data(), | 435 cachedStyleSheet->integrityDisposition(); |
436 cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), | 436 |
437 *cachedStyleSheet)) { | 437 DCHECK(disposition != ResourceIntegrityDisposition::NotChecked || |
438 m_loading = false; | 438 !cachedStyleSheet->sheetText().isNull()); |
439 removePendingSheet(); | 439 |
440 notifyLoadedSheetAndAllCriticalSubresources( | 440 if (disposition == ResourceIntegrityDisposition::NotChecked && |
441 Node::ErrorOccurredLoadingSubresource); | 441 !cachedStyleSheet->loadFailedOrCanceled()) { |
442 return; | 442 DCHECK(cachedStyleSheet->resourceBuffer()); |
| 443 if (SubresourceIntegrity::CheckSubresourceIntegrity( |
| 444 *m_owner, cachedStyleSheet->resourceBuffer()->data(), |
| 445 cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), |
| 446 *cachedStyleSheet)) |
| 447 disposition = ResourceIntegrityDisposition::Passed; |
| 448 else |
| 449 disposition = ResourceIntegrityDisposition::Failed; |
| 450 |
| 451 // TODO(kouhei): Remove this const_cast crbug.com/653502 |
| 452 const_cast<CSSStyleSheetResource*>(cachedStyleSheet) |
| 453 ->setIntegrityDisposition(disposition); |
| 454 } |
| 455 |
| 456 if (disposition == ResourceIntegrityDisposition::Failed) { |
| 457 m_loading = false; |
| 458 removePendingSheet(); |
| 459 notifyLoadedSheetAndAllCriticalSubresources( |
| 460 Node::ErrorOccurredLoadingSubresource); |
| 461 return; |
| 462 } |
443 } | 463 } |
444 | 464 |
445 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, | 465 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, |
446 charset); | 466 charset); |
447 | 467 |
448 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram, | 468 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram, |
449 ("Blink.RestoredCachedStyleSheet", 2)); | 469 ("Blink.RestoredCachedStyleSheet", 2)); |
450 DEFINE_STATIC_LOCAL( | 470 DEFINE_STATIC_LOCAL( |
451 EnumerationHistogram, restoredCachedStyleSheet2Histogram, | 471 EnumerationHistogram, restoredCachedStyleSheet2Histogram, |
452 ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); | 472 ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 removePendingSheet(); | 762 removePendingSheet(); |
743 } | 763 } |
744 | 764 |
745 DEFINE_TRACE(LinkStyle) { | 765 DEFINE_TRACE(LinkStyle) { |
746 visitor->trace(m_sheet); | 766 visitor->trace(m_sheet); |
747 LinkResource::trace(visitor); | 767 LinkResource::trace(visitor); |
748 ResourceOwner<StyleSheetResource>::trace(visitor); | 768 ResourceOwner<StyleSheetResource>::trace(visitor); |
749 } | 769 } |
750 | 770 |
751 } // namespace blink | 771 } // namespace blink |
OLD | NEW |