Generate code to set the runtime settings for a service worker process
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jun 2020 07:14:15 +0000 (07:14 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jun 2020 07:14:15 +0000 (07:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=212467

Reviewed by Alex Christensen.

Split the code generated to handle web preference changes to have one method for process wide flags and one for page settings.
Make the process wide flag method static and reuse it in WebSWContextManagerConnection.
Covered by existing tests.

* Scripts/PreferencesTemplates/WebPageUpdatePreferences.cpp.erb:
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::updatePreferencesStore):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
* WebProcess/WebPage/WebPage.h:

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

Source/WebKit/ChangeLog
Source/WebKit/Scripts/PreferencesTemplates/WebPageUpdatePreferences.cpp.erb
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h

index ccfa895..d7c3da8 100644 (file)
@@ -1,3 +1,21 @@
+2020-06-05  Youenn Fablet  <youenn@apple.com>
+
+        Generate code to set the runtime settings for a service worker process
+        https://bugs.webkit.org/show_bug.cgi?id=212467
+
+        Reviewed by Alex Christensen.
+
+        Split the code generated to handle web preference changes to have one method for process wide flags and one for page settings.
+        Make the process wide flag method static and reuse it in WebSWContextManagerConnection.
+        Covered by existing tests.
+
+        * Scripts/PreferencesTemplates/WebPageUpdatePreferences.cpp.erb:
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::updatePreferencesStore):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::updatePreferences):
+        * WebProcess/WebPage/WebPage.h:
+
 2020-06-04  David Kilzer  <ddkilzer@apple.com>
 
         [IPC] Adopt enum class for PluginProcessType and PluginProcessSandboxPolicy
index 201e40b..94dbbd1 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WebKit {
 
-void WebPage::updatePreferencesGenerated(const WebPreferencesStore& store)
+void WebPage::updateSettingsGenerated(const WebPreferencesStore& store)
 {
     WebCore::Settings& settings = m_page->settings();
 
@@ -50,7 +50,10 @@ void WebPage::updatePreferencesGenerated(const WebPreferencesStore& store)
 #endif
 <%- end -%>
 <%- end -%>
+}
 
+void WebPage::updatePreferencesGenerated(const WebPreferencesStore& store)
+{
 <%- for @pref in @preferencesBoundToDeprecatedGlobalSettings do -%>
 <%- if @pref.condition -%>
 #if <%= @pref.condition %>
index 69eb33a..36bc276 100644 (file)
@@ -41,6 +41,7 @@
 #include "WebDatabaseProvider.h"
 #include "WebDocumentLoader.h"
 #include "WebFrameLoaderClient.h"
+#include "WebPage.h"
 #include "WebPreferencesKeys.h"
 #include "WebPreferencesStore.h"
 #include "WebProcess.h"
@@ -119,19 +120,7 @@ void WebSWContextManagerConnection::establishConnection(CompletionHandler<void()
 
 void WebSWContextManagerConnection::updatePreferencesStore(const WebPreferencesStore& store)
 {
-    // FIXME: We should generate that code as done for web pages in WebPage::updatePreferencesGenerated.
-    RuntimeEnabledFeatures::sharedFeatures().setServiceWorkerEnabled(true);
-    RuntimeEnabledFeatures::sharedFeatures().setCacheAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::cacheAPIEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setUserTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::userTimingEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setPaintTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::paintTimingEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setResourceTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::resourceTimingEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setFetchAPIKeepAliveEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIKeepAliveEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setRestrictedHTTPResponseAccess(store.getBoolValueForKey(WebPreferencesKey::restrictedHTTPResponseAccessKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled(store.getBoolValueForKey(WebPreferencesKey::serverTimingEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setIsSecureContextAttributeEnabled(store.getBoolValueForKey(WebPreferencesKey::isSecureContextAttributeEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setSecureContextChecksEnabled(store.getBoolValueForKey(WebPreferencesKey::secureContextChecksEnabledKey()));
-    RuntimeEnabledFeatures::sharedFeatures().setReadableByteStreamAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::readableByteStreamAPIEnabledKey()));
+    WebPage::updatePreferencesGenerated(store);
 
     m_storageBlockingPolicy = static_cast<SecurityOrigin::StorageBlockingPolicy>(store.getUInt32ValueForKey(WebPreferencesKey::storageBlockingPolicyKey()));
     setShouldUseShortTimeout(store.getBoolValueForKey(WebPreferencesKey::shouldUseServiceWorkerShortTimeoutKey()));
index 4d40f4f..37a5d7d 100644 (file)
@@ -3632,6 +3632,7 @@ void WebPage::preferencesDidChange(const WebPreferencesStore& store)
 void WebPage::updatePreferences(const WebPreferencesStore& store)
 {
     updatePreferencesGenerated(store);
+    updateSettingsGenerated(store);
 
     Settings& settings = m_page->settings();
 
index 790da9d..96368ac 100644 (file)
@@ -1339,6 +1339,8 @@ public:
     uint64_t nativeWindowHandle() { return m_nativeWindowHandle; }
 #endif
 
+    static void updatePreferencesGenerated(const WebPreferencesStore&);
+
 private:
     WebPage(WebCore::PageIdentifier, WebPageCreationParameters&&);
 
@@ -1531,7 +1533,7 @@ private:
 
     void preferencesDidChange(const WebPreferencesStore&);
     void updatePreferences(const WebPreferencesStore&);
-    void updatePreferencesGenerated(const WebPreferencesStore&);
+    void updateSettingsGenerated(const WebPreferencesStore&);
 
 #if PLATFORM(IOS_FAMILY)
     bool parentProcessHasServiceWorkerEntitlement() const;