[Web App Manifest] Add SPI for applying a manifest to a top-level browsing context
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2017 03:30:08 +0000 (03:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Dec 2017 03:30:08 +0000 (03:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180368
rdar://problem/34748067

Patch by David Quesada <david_quesada@apple.com> on 2017-12-06
Reviewed by Geoffrey Garen.

Source/WebCore:

Support applying a manifest to a top-level browsing context by adding a manifest
property on PageConfiguration to be stored on MainFrame instances created from the
configuration.

No new tests, no change in behavior.

* page/MainFrame.cpp:
(WebCore::MainFrame::MainFrame):
* page/MainFrame.h:
* page/PageConfiguration.h:

Source/WebKit:

Add a new property WKWebViewConfiguration._applicationManifest to specify manifest
to apply to application contexts (aka. top-level browsing contexts, i.e. web views).
The manifest is ultimately stored on the MainFrame of the Pages created from the
web view configuration.

No new tests, no change in behavior.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/API/APIPageConfiguration.cpp:
(API::PageConfiguration::copy const):
(API::PageConfiguration::applicationManifest const):
(API::PageConfiguration::setApplicationManifest):
* UIProcess/API/APIPageConfiguration.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration copyWithZone:]):
(-[WKWebViewConfiguration _applicationManifest]):
(-[WKWebViewConfiguration _setApplicationManifest:]):
* UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* UIProcess/API/Cocoa/_WKApplicationManifestInternal.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_cpuLimit):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225615 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/MainFrame.h
Source/WebCore/page/PageConfiguration.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/API/APIApplicationManifest.h
Source/WebKit/UIProcess/API/APIPageConfiguration.cpp
Source/WebKit/UIProcess/API/APIPageConfiguration.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h
Source/WebKit/UIProcess/API/Cocoa/_WKApplicationManifestInternal.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp

index 16720b9..0f822b3 100644 (file)
@@ -1,3 +1,22 @@
+2017-12-06  David Quesada  <david_quesada@apple.com>
+
+        [Web App Manifest] Add SPI for applying a manifest to a top-level browsing context
+        https://bugs.webkit.org/show_bug.cgi?id=180368
+        rdar://problem/34748067
+
+        Reviewed by Geoffrey Garen.
+
+        Support applying a manifest to a top-level browsing context by adding a manifest
+        property on PageConfiguration to be stored on MainFrame instances created from the
+        configuration.
+
+        No new tests, no change in behavior.
+
+        * page/MainFrame.cpp:
+        (WebCore::MainFrame::MainFrame):
+        * page/MainFrame.h:
+        * page/PageConfiguration.h:
+
 2017-12-06  Zalan Bujtas  <zalan@apple.com>
 
         Remove nodes from AXObjectCache when the associated subframe document is getting destroyed.
index 7209926..56f99de 100644 (file)
@@ -51,6 +51,9 @@ inline MainFrame::MainFrame(Page& page, PageConfiguration& configuration)
 #if ENABLE(APPLE_PAY)
     , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient))
 #endif
+#if ENABLE(APPLICATION_MANIFEST)
+    , m_applicationManifest(configuration.applicationManifest)
+#endif
     , m_performanceLogging(std::make_unique<PerformanceLogging>(*this))
 {
 }
index 42cc739..2e45405 100644 (file)
 #pragma once
 
 #include "Frame.h"
+#include <wtf/Optional.h>
 #include <wtf/Vector.h>
 
+#if ENABLE(APPLICATION_MANIFEST)
+#include "ApplicationManifest.h"
+#endif
+
 namespace WebCore {
 
 class PageConfiguration;
@@ -67,6 +72,10 @@ public:
     WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&);
 #endif
 
+#if ENABLE(APPLICATION_MANIFEST)
+    const std::optional<ApplicationManifest>& applicationManifest() const { return m_applicationManifest; }
+#endif
+
     PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
 
     void didCompleteLoad();
@@ -92,6 +101,10 @@ private:
     std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
 #endif
 
+#if ENABLE(APPLICATION_MANIFEST)
+    std::optional<ApplicationManifest> m_applicationManifest;
+#endif
+
     std::unique_ptr<PerformanceLogging> m_performanceLogging;
 
     unsigned m_navigationDisableCount { 0 };
index a862d43..bd071b3 100644 (file)
 #pragma once
 
 #include <wtf/Noncopyable.h>
+#include <wtf/Optional.h>
 #include <wtf/RefPtr.h>
 #include <wtf/UniqueRef.h>
 
+#if ENABLE(APPLICATION_MANIFEST)
+#include "ApplicationManifest.h"
+#endif
+
 namespace WebCore {
 
 class AlternativeTextClient;
@@ -75,6 +80,10 @@ public:
     PaymentCoordinatorClient* paymentCoordinatorClient { nullptr };
 #endif
 
+#if ENABLE(APPLICATION_MANIFEST)
+    std::optional<ApplicationManifest> applicationManifest;
+#endif
+
     UniqueRef<LibWebRTCProvider> libWebRTCProvider;
 
     PlugInClient* plugInClient { nullptr };
index 48df393..9f68657 100644 (file)
@@ -1,3 +1,40 @@
+2017-12-06  David Quesada  <david_quesada@apple.com>
+
+        [Web App Manifest] Add SPI for applying a manifest to a top-level browsing context
+        https://bugs.webkit.org/show_bug.cgi?id=180368
+        rdar://problem/34748067
+
+        Reviewed by Geoffrey Garen.
+
+        Add a new property WKWebViewConfiguration._applicationManifest to specify manifest
+        to apply to application contexts (aka. top-level browsing contexts, i.e. web views).
+        The manifest is ultimately stored on the MainFrame of the Pages created from the
+        web view configuration.
+
+        No new tests, no change in behavior.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/API/APIPageConfiguration.cpp:
+        (API::PageConfiguration::copy const):
+        (API::PageConfiguration::applicationManifest const):
+        (API::PageConfiguration::setApplicationManifest):
+        * UIProcess/API/APIPageConfiguration.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _initializeWithConfiguration:]):
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration copyWithZone:]):
+        (-[WKWebViewConfiguration _applicationManifest]):
+        (-[WKWebViewConfiguration _setApplicationManifest:]):
+        * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+        * UIProcess/API/Cocoa/_WKApplicationManifestInternal.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_cpuLimit):
+
 2017-12-06  Jeff Miller  <jeffm@apple.com>
 
         -[WKWebViewConfiguration copyWithZone] doesn't copy _groupIdentifier
index f1bc62d..0e836cc 100644 (file)
@@ -96,6 +96,9 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const
     encoder << overrideContentSecurityPolicy;
     encoder << cpuLimit;
     encoder << urlSchemeHandlers;
+#if ENABLE(APPLICATION_MANIFEST)
+    encoder << applicationManifest;
+#endif
     encoder << iceCandidateFilteringEnabled;
     encoder << enumeratingAllNetworkInterfacesEnabled;
     encoder << userContentWorlds;
@@ -257,6 +260,14 @@ std::optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::
     if (!decoder.decode(parameters.urlSchemeHandlers))
         return std::nullopt;
 
+#if ENABLE(APPLICATION_MANIFEST)
+    std::optional<std::optional<WebCore::ApplicationManifest>> applicationManifest;
+    decoder >> applicationManifest;
+    if (!applicationManifest)
+        return std::nullopt;
+    parameters.applicationManifest = WTFMove(*applicationManifest);
+#endif
+
     if (!decoder.decode(parameters.iceCandidateFilteringEnabled))
         return std::nullopt;
 
index 6266f79..45a34dd 100644 (file)
 #include "ColorSpaceData.h"
 #endif
 
+#if ENABLE(APPLICATION_MANIFEST)
+#include <WebCore/ApplicationManifest.h>
+#endif
+
 namespace IPC {
 class Decoder;
 class Encoder;
@@ -152,6 +156,10 @@ struct WebPageCreationParameters {
 
     HashMap<String, uint64_t> urlSchemeHandlers;
 
+#if ENABLE(APPLICATION_MANIFEST)
+    std::optional<WebCore::ApplicationManifest> applicationManifest;
+#endif
+
     // WebRTC members.
     bool iceCandidateFilteringEnabled { true };
     bool enumeratingAllNetworkInterfacesEnabled { false };
index ed33148..37a4a68 100644 (file)
 
 #pragma once
 
+#if ENABLE(APPLICATION_MANIFEST)
+
 #include "APIObject.h"
 #include <WebCore/ApplicationManifest.h>
 
 namespace API {
 
-#if ENABLE(APPLICATION_MANIFEST)
 class ApplicationManifest final : public ObjectImpl<Object::Type::ApplicationManifest> {
 public:
     static Ref<ApplicationManifest> create(const WebCore::ApplicationManifest& applicationManifest)
@@ -48,7 +49,7 @@ public:
 private:
     WebCore::ApplicationManifest m_applicationManifest;
 };
-#endif
 
 } // namespace API
 
+#endif // ENABLE(APPLICATION_MANIFEST)
index 2fe3fa6..4b7dcbc 100644 (file)
 #include "WebProcessPool.h"
 #include "WebUserContentControllerProxy.h"
 
+#if ENABLE(APPLICATION_MANIFEST)
+#include "APIApplicationManifest.h"
+#endif
+
 using namespace WebCore;
 using namespace WebKit;
 
@@ -72,6 +76,9 @@ Ref<PageConfiguration> PageConfiguration::copy() const
     copy->m_cpuLimit = this->m_cpuLimit;
     copy->m_controlledByAutomation = this->m_controlledByAutomation;
     copy->m_overrideContentSecurityPolicy = this->m_overrideContentSecurityPolicy;
+#if ENABLE(APPLICATION_MANIFEST)
+    copy->m_applicationManifest = this->m_applicationManifest;
+#endif
 
     return copy;
 }
@@ -165,4 +172,16 @@ void PageConfiguration::setSessionID(PAL::SessionID sessionID)
     m_sessionID = sessionID;
 }
 
+#if ENABLE(APPLICATION_MANIFEST)
+const ApplicationManifest* PageConfiguration::applicationManifest() const
+{
+    return m_applicationManifest.get();
+}
+
+void PageConfiguration::setApplicationManifest(ApplicationManifest* applicationManifest)
+{
+    m_applicationManifest = applicationManifest;
+}
+#endif
+
 } // namespace API
index 9455239..d43b91d 100644 (file)
@@ -43,6 +43,7 @@ class WebUserContentControllerProxy;
 
 namespace API {
 
+class ApplicationManifest;
 class WebsiteDataStore;
 
 class PageConfiguration : public ObjectImpl<Object::Type::PageConfiguration> {
@@ -106,6 +107,11 @@ public:
     const WTF::String& overrideContentSecurityPolicy() const { return m_overrideContentSecurityPolicy; }
     void setOverrideContentSecurityPolicy(const WTF::String& overrideContentSecurityPolicy) { m_overrideContentSecurityPolicy = overrideContentSecurityPolicy; }
 
+#if ENABLE(APPLICATION_MANIFEST)
+    const ApplicationManifest* applicationManifest() const;
+    void setApplicationManifest(ApplicationManifest*);
+#endif
+
 private:
 
     RefPtr<WebKit::WebProcessPool> m_processPool;
@@ -131,6 +137,10 @@ private:
     std::optional<double> m_cpuLimit;
 
     WTF::String m_overrideContentSecurityPolicy;
+
+#if ENABLE(APPLICATION_MANIFEST)
+    RefPtr<ApplicationManifest> m_applicationManifest;
+#endif
 };
 
 } // namespace API
index 44db8c9..30afed8 100644 (file)
@@ -537,6 +537,10 @@ static void validate(WKWebViewConfiguration *configuration)
     pageConfiguration->setWaitsForPaintAfterViewDidMoveToWindow([_configuration _waitsForPaintAfterViewDidMoveToWindow]);
     pageConfiguration->setControlledByAutomation([_configuration _isControlledByAutomation]);
 
+#if ENABLE(APPLICATION_MANIFEST)
+    pageConfiguration->setApplicationManifest([_configuration _applicationManifest] ? [configuration _applicationManifest]->_applicationManifest.get() : nullptr);
+#endif
+
 #if PLATFORM(MAC)
     if (auto cpuLimit = [_configuration _cpuLimit])
         pageConfiguration->setCPULimit(cpuLimit);
index cdce4e6..91a3905 100644 (file)
@@ -146,6 +146,10 @@ static _WKDragLiftDelay toDragLiftDelay(NSUInteger value)
     BOOL _waitsForPaintAfterViewDidMoveToWindow;
     BOOL _controlledByAutomation;
 
+#if ENABLE(APPLICATION_MANIFEST)
+    RetainPtr<_WKApplicationManifest> _applicationManifest;
+#endif
+
 #if ENABLE(APPLE_PAY)
     BOOL _applePayEnabled;
 #endif
@@ -353,6 +357,9 @@ static _WKDragLiftDelay toDragLiftDelay(NSUInteger value)
 #if ENABLE(APPLE_PAY)
     configuration->_applePayEnabled = self->_applePayEnabled;
 #endif
+#if ENABLE(APPLICATION_MANIFEST)
+    configuration->_applicationManifest = self->_applicationManifest;
+#endif
     configuration->_needsStorageAccessFromFileURLsQuirk = self->_needsStorageAccessFromFileURLsQuirk;
     configuration->_overrideContentSecurityPolicy = adoptNS([self->_overrideContentSecurityPolicy copyWithZone:zone]);
 
@@ -746,6 +753,22 @@ static NSString *defaultApplicationNameForUserAgent()
     _controlledByAutomation = controlledByAutomation;
 }
 
+- (_WKApplicationManifest *)_applicationManifest
+{
+#if ENABLE(APPLICATION_MANIFEST)
+    return _applicationManifest.get();
+#else
+    return nil;
+#endif
+}
+
+- (void)_setApplicationManifest:(_WKApplicationManifest *)applicationManifest
+{
+#if ENABLE(APPLICATION_MANIFEST)
+    _applicationManifest = applicationManifest;
+#endif
+}
+
 #if PLATFORM(MAC)
 - (BOOL)_showsURLsInToolTips
 {
index 880bcd3..b9f408c 100644 (file)
@@ -36,6 +36,7 @@ typedef NS_ENUM(NSUInteger, _WKDragLiftDelay) {
 #endif
 
 @class WKWebView;
+@class _WKApplicationManifest;
 @class _WKVisitedLinkStore;
 @class _WKWebsiteDataStore;
 
@@ -66,6 +67,7 @@ typedef NS_ENUM(NSUInteger, _WKDragLiftDelay) {
 @property (nonatomic, setter=_setApplePayEnabled:) BOOL _applePayEnabled WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 @property (nonatomic, setter=_setWaitsForPaintAfterViewDidMoveToWindow:) BOOL _waitsForPaintAfterViewDidMoveToWindow WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
 @property (nonatomic, setter=_setControlledByAutomation:, getter=_isControlledByAutomation) BOOL _controlledByAutomation WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
+@property (nonatomic, setter=_setApplicationManifest:) _WKApplicationManifest *_applicationManifest WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 #if TARGET_OS_IPHONE
 @property (nonatomic, setter=_setAlwaysRunsAtForegroundPriority:) BOOL _alwaysRunsAtForegroundPriority WK_API_AVAILABLE(ios(9_0));
index 2b87886..6a7c109 100644 (file)
 #import "_WKApplicationManifest.h"
 #import <WebCore/ApplicationManifest.h>
 
-namespace WebCore {
-struct ApplicationManifest;
-}
-
 #if ENABLE(APPLICATION_MANIFEST)
 namespace API {
 
index 49975ce..3d21be0 100644 (file)
 #include <wtf/SystemTracing.h>
 #include <wtf/text/StringView.h>
 
+#if ENABLE(APPLICATION_MANIFEST)
+#include "APIApplicationManifest.h"
+#endif
+
 #if ENABLE(ASYNC_SCROLLING)
 #include "RemoteScrollingCoordinatorProxy.h"
 #endif
@@ -5812,6 +5816,10 @@ WebPageCreationParameters WebPageProxy::creationParameters()
 #endif
 #endif
 
+#if ENABLE(APPLICATION_MANIFEST)
+    parameters.applicationManifest = m_configuration->applicationManifest() ? std::optional<WebCore::ApplicationManifest>(m_configuration->applicationManifest()->applicationManifest()) : std::nullopt;
+#endif
+
     m_process->addWebUserContentControllerProxy(m_userContentController, parameters);
 
     return parameters;
index a918ec6..7ea4b4a 100644 (file)
@@ -419,6 +419,10 @@ WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
     pageConfiguration.paymentCoordinatorClient = new WebPaymentCoordinator(*this);
 #endif
 
+#if ENABLE(APPLICATION_MANIFEST)
+    pageConfiguration.applicationManifest = parameters.applicationManifest;
+#endif
+
     m_page = std::make_unique<Page>(WTFMove(pageConfiguration));
     updatePreferences(parameters.store);