Changeset 225564 in webkit
- Timestamp:
- Dec 5, 2017 6:41:20 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 27 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r225563 r225564 1 2017-12-05 David Quesada <david_quesada@apple.com> 2 3 [Web App Manifest] Support fetching the app manifest 4 https://bugs.webkit.org/show_bug.cgi?id=180292 5 6 Reviewed by Geoffrey Garen. 7 8 Add support in WebCore for loading and parsing application manifests. This functionality 9 is currently exposed with two methods: DocumentLoader::loadApplicationManifest() to call 10 to start loading the manifest, and FrameLoaderClient::finishedLoadingApplicationManifest() 11 for clients to override in order to be notified of the loaded manifest. 12 13 No new tests, since no functionality is exposed to web content or embedders yet. The 14 needed SPI will be added in an upcoming patch. 15 16 * Sources.txt: 17 * WebCore.xcodeproj/project.pbxproj: 18 Added CachedApplicationManifest and ApplicationManifestLoader. 19 * html/HTMLLinkElement.h: 20 * html/LinkRelAttribute.cpp: 21 (WebCore::LinkRelAttribute::LinkRelAttribute): 22 (WebCore::LinkRelAttribute::isSupported): 23 Add "manifest" as a supported 'rel' type for links. 24 * html/LinkRelAttribute.h: 25 * inspector/agents/InspectorPageAgent.cpp: 26 (WebCore::InspectorPageAgent::resourceTypeJSON): 27 (WebCore::InspectorPageAgent::inspectorResourceType): 28 * inspector/agents/InspectorPageAgent.h: 29 * loader/ApplicationManifestLoader.cpp: Added. 30 Added a class ApplicationManifestLoader which handles creating a ResourceRequest, 31 loading the resource from the CachedResourceLoader, and parsing the resulting text. 32 This class and its relation to DocumentLoader are roughly based on that of IconLoader, 33 which serves a similar purpose - requesting a resource on the page and ultimately 34 providing it to the embedder. 35 (WebCore::ApplicationManifestLoader::ApplicationManifestLoader): 36 (WebCore::ApplicationManifestLoader::~ApplicationManifestLoader): 37 (WebCore::ApplicationManifestLoader::startLoading): 38 (WebCore::ApplicationManifestLoader::stopLoading): 39 (WebCore::ApplicationManifestLoader::processManifest): 40 (WebCore::ApplicationManifestLoader::notifyFinished): 41 * loader/ApplicationManifestLoader.h: Copied from Source/WebCore/page/csp/ContentSecurityPolicyDirectiveNames.h. 42 * loader/DocumentLoader.cpp: 43 (WebCore::DocumentLoader::stopLoading): 44 (WebCore::DocumentLoader::loadApplicationManifest): 45 (WebCore::DocumentLoader::finishedLoadingApplicationManifest): 46 (WebCore::DocumentLoader::notifyFinishedLoadingApplicationManifest): 47 * loader/DocumentLoader.h: 48 * loader/FrameLoaderClient.h: 49 * loader/LinkLoader.cpp: 50 (WebCore::createLinkPreloadResourceClient): 51 (WebCore::LinkLoader::isSupportedType): 52 * loader/ResourceLoadInfo.cpp: 53 (WebCore::toResourceType): 54 * loader/SubresourceLoader.cpp: 55 (WebCore::logResourceLoaded): 56 * loader/cache/CachedApplicationManifest.cpp: Added. 57 (WebCore::CachedApplicationManifest::CachedApplicationManifest): 58 (WebCore::CachedApplicationManifest::finishLoading): 59 (WebCore::CachedApplicationManifest::setEncoding): 60 (WebCore::CachedApplicationManifest::encoding const): 61 (WebCore::CachedApplicationManifest::process): 62 Add a method to process the fetched text into an ApplicationManifest. CachedApplicationManifest 63 does not store the resulting ApplicationManifest because the text of an application 64 manifest can yield a different ApplicationManifest depending on the URL of the document 65 processing it. 66 * loader/cache/CachedApplicationManifest.h: Copied from Source/WebCore/page/csp/ContentSecurityPolicyDirectiveNames.h. 67 * loader/cache/CachedResource.cpp: 68 (WebCore::CachedResource::defaultPriorityForResourceType): 69 * loader/cache/CachedResource.h: 70 * loader/cache/CachedResourceLoader.cpp: 71 (WebCore::createResource): 72 (WebCore::CachedResourceLoader::requestApplicationManifest): 73 (WebCore::contentTypeFromResourceType): 74 (WebCore::CachedResourceLoader::checkInsecureContent const): 75 (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const): 76 * loader/cache/CachedResourceLoader.h: 77 * page/DiagnosticLoggingKeys.cpp: 78 (WebCore::DiagnosticLoggingKeys::applicationManifestKey): 79 * page/DiagnosticLoggingKeys.h: 80 * page/csp/ContentSecurityPolicy.cpp: 81 (WebCore::ContentSecurityPolicy::allowManifestFromSource const): 82 * page/csp/ContentSecurityPolicy.h: 83 * page/csp/ContentSecurityPolicyDirectiveList.cpp: 84 (WebCore::ContentSecurityPolicyDirectiveList::violatedDirectiveForManifest const): 85 (WebCore::ContentSecurityPolicyDirectiveList::addDirective): 86 * page/csp/ContentSecurityPolicyDirectiveList.h: 87 * page/csp/ContentSecurityPolicyDirectiveNames.cpp: 88 * page/csp/ContentSecurityPolicyDirectiveNames.h: 89 1 90 2017-12-05 Stephan Szabo <stephan.szabo@sony.com> 2 91 -
trunk/Source/WebCore/Sources.txt
r225555 r225564 27 27 28 28 Modules/applicationmanifest/ApplicationManifestParser.cpp 29 30 loader/ApplicationManifestLoader.cpp 31 32 loader/cache/CachedApplicationManifest.cpp 29 33 30 34 #endif -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r225555 r225564 1752 1752 62C1217D11AB9E77003C462C /* SuspendableTimer.h in Headers */ = {isa = PBXBuildFile; fileRef = 62C1217B11AB9E77003C462C /* SuspendableTimer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1753 1753 62CD325A1157E57C0063B0A7 /* CustomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 62CD32571157E57C0063B0A7 /* CustomEvent.h */; }; 1754 63152D191F9531EE007A5E4B /* ApplicationManifestLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 63152D171F9531EE007A5E4B /* ApplicationManifestLoader.h */; }; 1754 1755 63189AE30E83A33300012E41 /* NodeRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 63189AE20E83A33300012E41 /* NodeRareData.h */; settings = {ATTRIBUTES = (); }; }; 1756 6353E1E61F91743100A34208 /* CachedApplicationManifest.h in Headers */ = {isa = PBXBuildFile; fileRef = 6353E1E41F91743100A34208 /* CachedApplicationManifest.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1755 1757 6354F4C91F7AFC9400D89DF3 /* ApplicationManifestParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 6354F4C71F7AFC9400D89DF3 /* ApplicationManifestParser.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1756 1758 63BD4A5F1F778E9F00438722 /* ApplicationManifest.h in Headers */ = {isa = PBXBuildFile; fileRef = 63BD4A5D1F778E9F00438722 /* ApplicationManifest.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8383 8385 62CD32571157E57C0063B0A7 /* CustomEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CustomEvent.h; sourceTree = "<group>"; }; 8384 8386 62CD32581157E57C0063B0A7 /* CustomEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CustomEvent.idl; sourceTree = "<group>"; }; 8387 63152D171F9531EE007A5E4B /* ApplicationManifestLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplicationManifestLoader.h; sourceTree = "<group>"; }; 8388 63152D181F9531EE007A5E4B /* ApplicationManifestLoader.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationManifestLoader.cpp; sourceTree = "<group>"; }; 8385 8389 63189AE20E83A33300012E41 /* NodeRareData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeRareData.h; sourceTree = "<group>"; }; 8390 6353E1E41F91743100A34208 /* CachedApplicationManifest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CachedApplicationManifest.h; sourceTree = "<group>"; }; 8391 6353E1E51F91743100A34208 /* CachedApplicationManifest.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CachedApplicationManifest.cpp; sourceTree = "<group>"; }; 8386 8392 6354F4C71F7AFC9400D89DF3 /* ApplicationManifestParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplicationManifestParser.h; sourceTree = "<group>"; }; 8387 8393 6354F4C81F7AFC9400D89DF3 /* ApplicationManifestParser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationManifestParser.cpp; sourceTree = "<group>"; }; … … 21789 21795 isa = PBXGroup; 21790 21796 children = ( 21797 6353E1E51F91743100A34208 /* CachedApplicationManifest.cpp */, 21798 6353E1E41F91743100A34208 /* CachedApplicationManifest.h */, 21791 21799 BCB16C000979C3BD00467741 /* CachedCSSStyleSheet.cpp */, 21792 21800 BCB16C010979C3BD00467741 /* CachedCSSStyleSheet.h */, … … 23300 23308 A15E31F01E0CB075004B371C /* ios */, 23301 23309 93A1EAA20A5634D8006960A0 /* mac */, 23310 63152D181F9531EE007A5E4B /* ApplicationManifestLoader.cpp */, 23311 63152D171F9531EE007A5E4B /* ApplicationManifestLoader.h */, 23302 23312 A149786C1ABAF33800CEF7E4 /* ContentFilter.cpp */, 23303 23313 A149786D1ABAF33800CEF7E4 /* ContentFilter.h */, … … 26081 26091 1A2AAC590DC2A3B100A20D9A /* ApplicationCacheStorage.h in Headers */, 26082 26092 63BD4A5F1F778E9F00438722 /* ApplicationManifest.h in Headers */, 26093 63152D191F9531EE007A5E4B /* ApplicationManifestLoader.h in Headers */, 26083 26094 6354F4C91F7AFC9400D89DF3 /* ApplicationManifestParser.h in Headers */, 26084 26095 9B417064125662B3006B28FC /* ApplyBlockElementCommand.h in Headers */, … … 26221 26232 1A569CFE0D7E2B82007C3983 /* c_utility.h in Headers */, 26222 26233 07C046C41E42508B007201E7 /* CAAudioStreamDescription.h in Headers */, 26234 6353E1E61F91743100A34208 /* CachedApplicationManifest.h in Headers */, 26223 26235 BCB16C1A0979C3BD00467741 /* CachedCSSStyleSheet.h in Headers */, 26224 26236 BC64B4CC0CB4295D005F2B62 /* CachedFont.h in Headers */, -
trunk/Source/WebCore/html/HTMLLinkElement.h
r223802 r225564 74 74 WEBCORE_EXPORT DOMTokenList& relList(); 75 75 76 #if ENABLE(APPLICATION_MANIFEST) 77 bool isApplicationManifest() const { return m_relAttribute.isApplicationManifest; } 78 #endif 79 76 80 private: 77 81 void parseAttribute(const QualifiedName&, const AtomicString&) final; -
trunk/Source/WebCore/html/LinkRelAttribute.cpp
r222613 r225564 66 66 isStyleSheet = true; 67 67 isAlternate = true; 68 #if ENABLE(APPLICATION_MANIFEST) 69 } else if (equalLettersIgnoringASCIICase(rel, "manifest")) { 70 isApplicationManifest = true; 71 #endif 68 72 } else { 69 73 // Tokenize the rel attribute and set bits based on specific keywords that we find. … … 99 103 "prefetch", "subresource", 100 104 #endif 105 #if ENABLE(APPLICATION_MANIFEST) 106 "manifest", 107 #endif 101 108 }; 102 109 -
trunk/Source/WebCore/html/LinkRelAttribute.h
r222613 r225564 52 52 bool isLinkSubresource { false }; 53 53 #endif 54 #if ENABLE(APPLICATION_MANIFEST) 55 bool isApplicationManifest { false }; 56 #endif 54 57 55 58 LinkRelAttribute(); -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
r225546 r225564 71 71 #include <yarr/RegularExpression.h> 72 72 73 #if ENABLE(APPLICATION_MANIFEST) 74 #include "CachedApplicationManifest.h" 75 #endif 76 73 77 #if ENABLE(WEB_ARCHIVE) && USE(CF) 74 78 #include "LegacyWebArchive.h" … … 205 209 case OtherResource: 206 210 return Inspector::Protocol::Page::ResourceType::Other; 211 #if ENABLE(APPLICATION_MANIFEST) 212 case ApplicationManifestResource: 213 break; 214 #endif 207 215 } 208 216 return Inspector::Protocol::Page::ResourceType::Other; … … 230 238 case CachedResource::Beacon: 231 239 return InspectorPageAgent::BeaconResource; 240 #if ENABLE(APPLICATION_MANIFEST) 241 case CachedResource::ApplicationManifest: 242 return InspectorPageAgent::ApplicationManifestResource; 243 #endif 232 244 case CachedResource::MediaResource: 233 245 case CachedResource::Icon: -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h
r225546 r225564 72 72 BeaconResource, 73 73 WebSocketResource, 74 #if ENABLE(APPLICATION_MANIFEST) 75 ApplicationManifestResource, 76 #endif 74 77 OtherResource, 75 78 }; -
trunk/Source/WebCore/loader/ApplicationManifestLoader.h
r225563 r225564 1 1 /* 2 * Copyright (C) 201 6Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if ENABLE(APPLICATION_MANIFEST) 29 30 #include "ApplicationManifest.h" 31 #include "CachedRawResourceClient.h" 32 #include "CachedResourceHandle.h" 33 #include "URL.h" 34 #include <wtf/Noncopyable.h> 35 28 36 namespace WebCore { 29 37 30 namespace ContentSecurityPolicyDirectiveNames { 38 class CachedApplicationManifest; 39 class DocumentLoader; 31 40 32 extern const char* const baseURI; 33 extern const char* const childSrc; 34 extern const char* const connectSrc; 35 extern const char* const defaultSrc; 36 extern const char* const fontSrc; 37 extern const char* const formAction; 38 extern const char* const frameAncestors; 39 extern const char* const frameSrc; 40 extern const char* const imgSrc; 41 extern const char* const mediaSrc; 42 extern const char* const objectSrc; 43 extern const char* const pluginTypes; 44 extern const char* const reportURI; 45 extern const char* const sandbox; 46 extern const char* const scriptSrc; 47 extern const char* const styleSrc; 48 extern const char* const upgradeInsecureRequests; 49 extern const char* const blockAllMixedContent; 41 class ApplicationManifestLoader final : private CachedRawResourceClient { 42 WTF_MAKE_NONCOPYABLE(ApplicationManifestLoader); WTF_MAKE_FAST_ALLOCATED; 43 public: 44 typedef WTF::Function<void (CachedResourceHandle<CachedApplicationManifest>)> CompletionHandlerType; 50 45 51 } // namespace ContentSecurityPolicyDirectiveNames 46 ApplicationManifestLoader(DocumentLoader&, const URL&, bool); 47 virtual ~ApplicationManifestLoader(); 48 49 bool startLoading(); 50 void stopLoading(); 51 52 std::optional<ApplicationManifest>& processManifest(); 53 54 private: 55 void notifyFinished(CachedResource&); 56 57 DocumentLoader& m_documentLoader; 58 std::optional<ApplicationManifest> m_processedManifest; 59 URL m_url; 60 bool m_useCredentials; 61 CachedResourceHandle<CachedApplicationManifest> m_resource; 62 }; 52 63 53 64 } // namespace WebCore 54 65 66 #endif // ENABLE(APPLICATION_MANIFEST) -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r225526 r225564 85 85 #include <wtf/text/WTFString.h> 86 86 87 #if ENABLE(APPLICATION_MANIFEST) 88 #include "ApplicationManifestLoader.h" 89 #include "HTMLHeadElement.h" 90 #include "HTMLLinkElement.h" 91 #endif 92 87 93 #if ENABLE(WEB_ARCHIVE) || ENABLE(MHTML) 88 94 #include "ArchiveFactory.h" … … 282 288 m_iconLoaders.clear(); 283 289 m_iconsPendingLoadDecision.clear(); 290 291 #if ENABLE(APPLICATION_MANIFEST) 292 for (auto callbackIdentifier : m_applicationManifestLoaders.values()) 293 notifyFinishedLoadingApplicationManifest(callbackIdentifier, std::nullopt); 294 m_applicationManifestLoaders.clear(); 295 #endif 284 296 285 297 // Always cancel multipart loaders … … 1045 1057 checkLoadComplete(); 1046 1058 } 1059 1060 #if ENABLE(APPLICATION_MANIFEST) 1061 uint64_t DocumentLoader::loadApplicationManifest() 1062 { 1063 static uint64_t nextCallbackID = 1; 1064 1065 auto* document = this->document(); 1066 if (!document) 1067 return 0; 1068 1069 if (!m_frame->isMainFrame()) 1070 return 0; 1071 1072 if (document->url().isEmpty() || document->url().isBlankURL()) 1073 return 0; 1074 1075 auto head = document->head(); 1076 if (!head) 1077 return 0; 1078 1079 URL manifestURL; 1080 bool useCredentials = false; 1081 for (const auto& link : childrenOfType<HTMLLinkElement>(*head)) { 1082 if (link.isApplicationManifest()) { 1083 manifestURL = link.href(); 1084 useCredentials = equalIgnoringASCIICase(link.attributeWithoutSynchronization(HTMLNames::crossoriginAttr), "use-credentials"); 1085 break; 1086 } 1087 } 1088 1089 if (manifestURL.isEmpty() || !manifestURL.isValid()) 1090 return 0; 1091 1092 auto manifestLoader = std::make_unique<ApplicationManifestLoader>(*this, manifestURL, useCredentials); 1093 auto* rawManifestLoader = manifestLoader.get(); 1094 auto callbackID = nextCallbackID++; 1095 m_applicationManifestLoaders.set(WTFMove(manifestLoader), callbackID); 1096 1097 if (!rawManifestLoader->startLoading()) { 1098 m_applicationManifestLoaders.remove(rawManifestLoader); 1099 return 0; 1100 } 1101 1102 return callbackID; 1103 } 1104 1105 void DocumentLoader::finishedLoadingApplicationManifest(ApplicationManifestLoader& loader) 1106 { 1107 // If the DocumentLoader has detached from its frame, all manifest loads should have already been canceled. 1108 ASSERT(m_frame); 1109 1110 auto callbackIdentifier = m_applicationManifestLoaders.get(&loader); 1111 notifyFinishedLoadingApplicationManifest(callbackIdentifier, loader.processManifest()); 1112 m_applicationManifestLoaders.remove(&loader); 1113 } 1114 1115 void DocumentLoader::notifyFinishedLoadingApplicationManifest(uint64_t callbackIdentifier, std::optional<ApplicationManifest> manifest) 1116 { 1117 RELEASE_ASSERT(callbackIdentifier); 1118 RELEASE_ASSERT(m_frame); 1119 m_frame->loader().client().finishedLoadingApplicationManifest(callbackIdentifier, manifest); 1120 } 1121 #endif 1047 1122 1048 1123 void DocumentLoader::setCustomHeaderFields(Vector<HTTPHeaderField>&& fields) -
trunk/Source/WebCore/loader/DocumentLoader.h
r224852 r225564 51 51 #include <wtf/Vector.h> 52 52 53 #if ENABLE(APPLICATION_MANIFEST) 54 #include "ApplicationManifest.h" 55 #endif 56 53 57 #if HAVE(RUNLOOP_TIMER) 54 58 #include <wtf/RunLoopTimer.h> … … 62 66 63 67 class ApplicationCacheHost; 68 class ApplicationManifestLoader; 64 69 class Archive; 65 70 class ArchiveResource; … … 298 303 const Vector<LinkIcon>& linkIcons() const { return m_linkIcons; } 299 304 305 #if ENABLE(APPLICATION_MANIFEST) 306 WEBCORE_EXPORT uint64_t loadApplicationManifest(); 307 void finishedLoadingApplicationManifest(ApplicationManifestLoader&); 308 #endif 309 300 310 WEBCORE_EXPORT void setCustomHeaderFields(Vector<HTTPHeaderField>&& fields); 301 311 const Vector<HTTPHeaderField>& customHeaderFields() { return m_customHeaderFields; } … … 371 381 void notifyFinishedLoadingIcon(uint64_t callbackIdentifier, SharedBuffer*); 372 382 383 #if ENABLE(APPLICATION_MANIFEST) 384 void notifyFinishedLoadingApplicationManifest(uint64_t callbackIdentifier, std::optional<ApplicationManifest>); 385 #endif 386 373 387 Ref<CachedResourceLoader> m_cachedResourceLoader; 374 388 … … 460 474 Vector<LinkIcon> m_linkIcons; 461 475 476 #if ENABLE(APPLICATION_MANIFEST) 477 HashMap<std::unique_ptr<ApplicationManifestLoader>, uint64_t> m_applicationManifestLoaders; 478 #endif 479 462 480 Vector<HTTPHeaderField> m_customHeaderFields; 463 481 -
trunk/Source/WebCore/loader/FrameLoaderClient.h
r224846 r225564 36 36 #include <wtf/Forward.h> 37 37 #include <wtf/text/WTFString.h> 38 39 #if ENABLE(APPLICATION_MANIFEST) 40 #include "ApplicationManifest.h" 41 #endif 38 42 39 43 #if ENABLE(CONTENT_FILTERING) … … 357 361 virtual void getLoadDecisionForIcons(const Vector<std::pair<WebCore::LinkIcon&, uint64_t>>&) { } 358 362 virtual void finishedLoadingIcon(uint64_t, SharedBuffer*) { } 363 364 #if ENABLE(APPLICATION_MANIFEST) 365 virtual void finishedLoadingApplicationManifest(uint64_t, const std::optional<ApplicationManifest>&) { } 366 #endif 359 367 }; 360 368 -
trunk/Source/WebCore/loader/LinkLoader.cpp
r225499 r225564 172 172 // None of these values is currently supported as an `as` value. 173 173 ASSERT_NOT_REACHED(); 174 #if ENABLE(APPLICATION_MANIFEST) 175 case CachedResource::ApplicationManifest: 176 // FIXME: Support preloading the manifest. 177 ASSERT_NOT_REACHED(); 178 #endif 174 179 } 175 180 return nullptr; … … 199 204 #endif 200 205 case CachedResource::RawResource: 206 #if ENABLE(APPLICATION_MANIFEST) 207 case CachedResource::ApplicationManifest: 208 #endif 201 209 return true; 202 210 default: -
trunk/Source/WebCore/loader/ResourceLoadInfo.cpp
r220303 r225564 71 71 ASSERT_NOT_REACHED(); 72 72 #endif 73 #if ENABLE(APPLICATION_MANIFEST) 74 case CachedResource::ApplicationManifest: 75 return ResourceType::Raw; 76 #endif 73 77 }; 74 78 return ResourceType::Raw; -
trunk/Source/WebCore/loader/SubresourceLoader.cpp
r224699 r225564 472 472 resourceType = DiagnosticLoggingKeys::svgDocumentKey(); 473 473 break; 474 #if ENABLE(APPLICATION_MANIFEST) 475 case CachedResource::ApplicationManifest: 476 resourceType = DiagnosticLoggingKeys::applicationManifestKey(); 477 break; 478 #endif 474 479 #if ENABLE(LINK_PREFETCH) 475 480 case CachedResource::LinkPrefetch: -
trunk/Source/WebCore/loader/cache/CachedApplicationManifest.h
r225563 r225564 1 1 /* 2 * Copyright (C) 201 6Apple Inc. All rights reserved.2 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if ENABLE(APPLICATION_MANIFEST) 29 30 #include "ApplicationManifest.h" 31 #include "CachedResource.h" 32 #include <wtf/Optional.h> 33 28 34 namespace WebCore { 29 35 30 namespace ContentSecurityPolicyDirectiveNames { 36 class ScriptExecutionContext; 37 class TextResourceDecoder; 31 38 32 extern const char* const baseURI; 33 extern const char* const childSrc; 34 extern const char* const connectSrc; 35 extern const char* const defaultSrc; 36 extern const char* const fontSrc; 37 extern const char* const formAction; 38 extern const char* const frameAncestors; 39 extern const char* const frameSrc; 40 extern const char* const imgSrc; 41 extern const char* const mediaSrc; 42 extern const char* const objectSrc; 43 extern const char* const pluginTypes; 44 extern const char* const reportURI; 45 extern const char* const sandbox; 46 extern const char* const scriptSrc; 47 extern const char* const styleSrc; 48 extern const char* const upgradeInsecureRequests; 49 extern const char* const blockAllMixedContent; 39 class CachedApplicationManifest final : public CachedResource { 40 public: 41 CachedApplicationManifest(CachedResourceRequest&&, PAL::SessionID); 50 42 51 } // namespace ContentSecurityPolicyDirectiveNames 43 std::optional<struct ApplicationManifest> process(const URL& manifestURL, const URL& documentURL, RefPtr<ScriptExecutionContext> = nullptr); 44 45 private: 46 void finishLoading(SharedBuffer*) override; 47 const TextResourceDecoder* textResourceDecoder() const override { return m_decoder.ptr(); } 48 void setEncoding(const String&) override; 49 String encoding() const override; 50 51 Ref<TextResourceDecoder> m_decoder; 52 std::optional<String> m_text; 53 }; 52 54 53 55 } // namespace WebCore 54 56 57 SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedApplicationManifest, CachedResource::ApplicationManifest) 58 59 #endif // ENABLE(APPLICATION_MANIFEST) -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r224699 r225564 103 103 return ResourceLoadPriority::Low; 104 104 #endif 105 #if ENABLE(APPLICATION_MANIFEST) 106 case CachedResource::ApplicationManifest: 107 return ResourceLoadPriority::Low; 108 #endif 105 109 } 106 110 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/loader/cache/CachedResource.h
r224699 r225564 85 85 , TextTrackResource 86 86 #endif 87 #if ENABLE(APPLICATION_MANIFEST) 88 , ApplicationManifest 89 #endif 87 90 }; 88 91 -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp
r225294 r225564 78 78 #include <wtf/text/WTFString.h> 79 79 80 #if ENABLE(APPLICATION_MANIFEST) 81 #include "CachedApplicationManifest.h" 82 #endif 83 80 84 #if ENABLE(VIDEO_TRACK) 81 85 #include "CachedTextTrack.h" … … 135 139 return new CachedTextTrack(WTFMove(request), sessionID); 136 140 #endif 141 #if ENABLE(APPLICATION_MANIFEST) 142 case CachedResource::ApplicationManifest: 143 return new CachedApplicationManifest(WTFMove(request), sessionID); 144 #endif 137 145 } 138 146 ASSERT_NOT_REACHED(); … … 323 331 } 324 332 333 #if ENABLE(APPLICATION_MANIFEST) 334 ResourceErrorOr<CachedResourceHandle<CachedApplicationManifest>> CachedResourceLoader::requestApplicationManifest(CachedResourceRequest&& request) 335 { 336 return castCachedResourceTo<CachedApplicationManifest>(requestResource(CachedResource::ApplicationManifest, WTFMove(request))); 337 } 338 #endif // ENABLE(APPLICATION_MANIFEST) 339 325 340 static MixedContentChecker::ContentType contentTypeFromResourceType(CachedResource::Type type) 326 341 { … … 361 376 #if ENABLE(VIDEO_TRACK) 362 377 case CachedResource::TextTrackResource: 378 return MixedContentChecker::ContentType::Active; 379 #endif 380 #if ENABLE(APPLICATION_MANIFEST) 381 case CachedResource::ApplicationManifest: 363 382 return MixedContentChecker::ContentType::Active; 364 383 #endif … … 419 438 // Prefetch cannot affect the current document. 420 439 #endif 440 #if ENABLE(APPLICATION_MANIFEST) 441 case CachedResource::ApplicationManifest: 442 #endif 421 443 break; 422 444 } … … 467 489 case CachedResource::RawResource: 468 490 return true; 491 #if ENABLE(APPLICATION_MANIFEST) 492 case CachedResource::ApplicationManifest: 493 if (!m_document->contentSecurityPolicy()->allowManifestFromSource(url, redirectResponseReceived)) 494 return false; 495 break; 496 #endif 469 497 default: 470 498 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/loader/cache/CachedResourceLoader.h
r220946 r225564 42 42 namespace WebCore { 43 43 44 #if ENABLE(APPLICATION_MANIFEST) 45 class CachedApplicationManifest; 46 #endif 44 47 class CachedCSSStyleSheet; 45 48 class CachedSVGDocument; … … 96 99 #if ENABLE(VIDEO_TRACK) 97 100 ResourceErrorOr<CachedResourceHandle<CachedTextTrack>> requestTextTrack(CachedResourceRequest&&); 101 #endif 102 #if ENABLE(APPLICATION_MANIFEST) 103 ResourceErrorOr<CachedResourceHandle<CachedApplicationManifest>> requestApplicationManifest(CachedResourceRequest&&); 98 104 #endif 99 105 -
trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp
r223785 r225564 414 414 } 415 415 416 #if ENABLE(APPLICATION_MANIFEST) 417 String DiagnosticLoggingKeys::applicationManifestKey() 418 { 419 return ASCIILiteral("applicationManifest"); 420 } 421 #endif 422 416 423 String DiagnosticLoggingKeys::audioKey() 417 424 { -
trunk/Source/WebCore/page/DiagnosticLoggingKeys.h
r223785 r225564 35 35 WEBCORE_EXPORT static String activeInBackgroundTabOnlyKey(); 36 36 static String applicationCacheKey(); 37 #if ENABLE(APPLICATION_MANIFEST) 38 static String applicationManifestKey(); 39 #endif 37 40 static String audioKey(); 38 41 WEBCORE_EXPORT static String backNavigationDeltaKey(); -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
r225231 r225564 550 550 } 551 551 552 #if ENABLE(APPLICATION_MANIFEST) 553 bool ContentSecurityPolicy::allowManifestFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived) const 554 { 555 return allowResourceFromSource(url, redirectResponseReceived, ContentSecurityPolicyDirectiveNames::manifestSrc, &ContentSecurityPolicyDirectiveList::violatedDirectiveForManifest); 556 } 557 #endif // ENABLE(APPLICATION_MANIFEST) 558 552 559 bool ContentSecurityPolicy::allowMediaFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived) const 553 560 { -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.h
r220549 r225564 104 104 bool allowStyleFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 105 105 bool allowFontFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 106 #if ENABLE(APPLICATION_MANIFEST) 107 bool allowManifestFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 108 #endif 106 109 bool allowMediaFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const; 107 110 -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp
r223476 r225564 244 244 } 245 245 246 #if ENABLE(APPLICATION_MANIFEST) 247 const ContentSecurityPolicyDirective* ContentSecurityPolicyDirectiveList::violatedDirectiveForManifest(const URL& url, bool didReceiveRedirectResponse) const 248 { 249 ContentSecurityPolicySourceListDirective* operativeDirective = this->operativeDirective(m_manifestSrc.get()); 250 if (checkSource(operativeDirective, url, didReceiveRedirectResponse)) 251 return nullptr; 252 return operativeDirective; 253 } 254 #endif // ENABLE(APPLICATION_MANIFEST) 255 246 256 const ContentSecurityPolicyDirective* ContentSecurityPolicyDirectiveList::violatedDirectiveForMedia(const URL& url, bool didReceiveRedirectResponse) const 247 257 { … … 476 486 else if (equalIgnoringASCIICase(name, ContentSecurityPolicyDirectiveNames::fontSrc)) 477 487 setCSPDirective<ContentSecurityPolicySourceListDirective>(name, value, m_fontSrc); 488 #if ENABLE(APPLICATION_MANIFEST) 489 else if (equalIgnoringASCIICase(name, ContentSecurityPolicyDirectiveNames::manifestSrc)) 490 setCSPDirective<ContentSecurityPolicySourceListDirective>(name, value, m_manifestSrc); 491 #endif 478 492 else if (equalIgnoringASCIICase(name, ContentSecurityPolicyDirectiveNames::mediaSrc)) 479 493 setCSPDirective<ContentSecurityPolicySourceListDirective>(name, value, m_mediaSrc); -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.h
r218951 r225564 64 64 const ContentSecurityPolicyDirective* violatedDirectiveForFrameAncestor(const Frame&) const; 65 65 const ContentSecurityPolicyDirective* violatedDirectiveForImage(const URL&, bool didReceiveRedirectResponse) const; 66 #if ENABLE(APPLICATION_MANIFEST) 67 const ContentSecurityPolicyDirective* violatedDirectiveForManifest(const URL&, bool didReceiveRedirectResponse) const; 68 #endif 66 69 const ContentSecurityPolicyDirective* violatedDirectiveForMedia(const URL&, bool didReceiveRedirectResponse) const; 67 70 const ContentSecurityPolicyDirective* violatedDirectiveForObjectSource(const URL&, bool didReceiveRedirectResponse, ContentSecurityPolicySourceListDirective::ShouldAllowEmptyURLIfSourceListIsNotNone) const; … … 122 125 std::unique_ptr<ContentSecurityPolicySourceListDirective> m_frameSrc; 123 126 std::unique_ptr<ContentSecurityPolicySourceListDirective> m_imgSrc; 127 #if ENABLE(APPLICATION_MANIFEST) 128 std::unique_ptr<ContentSecurityPolicySourceListDirective> m_manifestSrc; 129 #endif 124 130 std::unique_ptr<ContentSecurityPolicySourceListDirective> m_mediaSrc; 125 131 std::unique_ptr<ContentSecurityPolicySourceListDirective> m_objectSrc; -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveNames.cpp
r209577 r225564 39 39 const char* const frameAncestors = "frame-ancestors"; 40 40 const char* const frameSrc = "frame-src"; 41 #if ENABLE(APPLICATION_MANIFEST) 42 const char* const manifestSrc = "manifest-src"; 43 #endif 41 44 const char* const imgSrc = "img-src"; 42 45 const char* const mediaSrc = "media-src"; -
trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveNames.h
r209577 r225564 39 39 extern const char* const frameSrc; 40 40 extern const char* const imgSrc; 41 #if ENABLE(APPLICATION_MANIFEST) 42 extern const char* const manifestSrc; 43 #endif 41 44 extern const char* const mediaSrc; 42 45 extern const char* const objectSrc; -
trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
r225297 r225564 122 122 #endif 123 123 case CachedResource::FontResource: 124 #if ENABLE(APPLICATION_MANIFEST) 125 case CachedResource::ApplicationManifest: 126 #endif 124 127 return Seconds::infinity(); 125 128 case CachedResource::ImageResource:
Note: See TracChangeset
for help on using the changeset viewer.