Title: [290482] trunk/Source/WebKit
Revision
290482
Author
commit-qu...@webkit.org
Date
2022-02-24 17:44:44 -0800 (Thu, 24 Feb 2022)

Log Message

Port CaptivePortalMode preferences to AnyHost in order to support CFPrefs Direct Mode propagation
https://bugs.webkit.org/show_bug.cgi?id=237098

Patch by Gavin Phillips <gavi...@apple.com> on 2022-02-24
Reviewed by Brent Fulgham.

Move our CaptivePortalMode preference to AnyHost in order to correctly support
CFPrefs Direct Mode propagation. We also now dispatch a CFNotification to ensure our preference
observer is always notified of the change.

* UIProcess/Cocoa/PreferenceObserver.mm:
(-[WKUserDefaults findPreferenceChangesAndNotifyForKeys:toValuesForKeys:]):

* Shared/Cocoa/AuxiliaryProcessCocoa.mm:
(WebKit::AuxiliaryProcess::setPreferenceValue):
* UIProcess/API/Cocoa/_WKSystemPreferences.mm:
(+[_WKSystemPreferences isCaptivePortalModeEnabled]):
(+[_WKSystemPreferences setCaptivePortalModeEnabled:]):
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::captivePortalModeConfigUpdateCallback):
(WebKit::WebProcessPool::registerNotificationObservers):
(WebKit::WebProcessPool::unregisterNotificationObservers):
* UIProcess/WebProcessPool.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (290481 => 290482)


--- trunk/Source/WebKit/ChangeLog	2022-02-25 01:43:01 UTC (rev 290481)
+++ trunk/Source/WebKit/ChangeLog	2022-02-25 01:44:44 UTC (rev 290482)
@@ -1,3 +1,28 @@
+2022-02-24  Gavin Phillips  <gavi...@apple.com>
+
+        Port CaptivePortalMode preferences to AnyHost in order to support CFPrefs Direct Mode propagation
+        https://bugs.webkit.org/show_bug.cgi?id=237098
+
+        Reviewed by Brent Fulgham.
+
+        Move our CaptivePortalMode preference to AnyHost in order to correctly support
+        CFPrefs Direct Mode propagation. We also now dispatch a CFNotification to ensure our preference
+        observer is always notified of the change.
+
+        * UIProcess/Cocoa/PreferenceObserver.mm:
+        (-[WKUserDefaults findPreferenceChangesAndNotifyForKeys:toValuesForKeys:]):
+
+        * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
+        (WebKit::AuxiliaryProcess::setPreferenceValue):
+        * UIProcess/API/Cocoa/_WKSystemPreferences.mm:
+        (+[_WKSystemPreferences isCaptivePortalModeEnabled]):
+        (+[_WKSystemPreferences setCaptivePortalModeEnabled:]):
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::captivePortalModeConfigUpdateCallback):
+        (WebKit::WebProcessPool::registerNotificationObservers):
+        (WebKit::WebProcessPool::unregisterNotificationObservers):
+        * UIProcess/WebProcessPool.h:
+
 2022-02-24  Aditya Keerthi  <akeer...@apple.com>
 
         [iOS] Add support for replacing WKFoundTextRanges

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKSystemPreferences.mm (290481 => 290482)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKSystemPreferences.mm	2022-02-25 01:43:01 UTC (rev 290481)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKSystemPreferences.mm	2022-02-25 01:44:44 UTC (rev 290482)
@@ -36,7 +36,7 @@
 + (BOOL)isCaptivePortalModeEnabled
 {
     auto changedNotificationKey = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, WKCaptivePortalModeEnabledKey, kCFStringEncodingUTF8));
-    auto preferenceValue = adoptCF(CFPreferencesCopyValue(changedNotificationKey.get(), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost));
+    auto preferenceValue = adoptCF(CFPreferencesCopyValue(changedNotificationKey.get(), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
     return preferenceValue.get() == kCFBooleanTrue;
 }
 
@@ -43,8 +43,9 @@
 + (void)setCaptivePortalModeEnabled:(BOOL)enabled
 {
     auto changedNotificationKey = adoptCF(CFStringCreateWithCString(kCFAllocatorDefault, WKCaptivePortalModeEnabledKey, kCFStringEncodingUTF8));
-    CFPreferencesSetValue(changedNotificationKey.get(), enabled ? kCFBooleanTrue : kCFBooleanFalse, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
-    CFPreferencesSynchronize(kCFPreferencesAnyApplication, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+    CFPreferencesSetValue(changedNotificationKey.get(), enabled ? kCFBooleanTrue : kCFBooleanFalse, kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    CFPreferencesSynchronize(kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
+    CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(), (__bridge CFStringRef)WKCaptivePortalModeContainerConfigurationChangedNotification, nullptr, nullptr, true);
 }
 
 + (BOOL)isCaptivePortalModeIgnored:(NSString *)containerPath

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (290481 => 290482)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2022-02-25 01:43:01 UTC (rev 290481)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2022-02-25 01:44:44 UTC (rev 290482)
@@ -624,7 +624,7 @@
 }
 #endif
 
-#if PLATFORM(IOS_FAMILY)
+#if PLATFORM(COCOA)
 void WebProcessPool::captivePortalModeConfigUpdateCallback(CFNotificationCenterRef, void* observer, CFStringRef, const void*, CFDictionaryRef)
 {
     if (auto pool = extractWebProcessPool(observer))
@@ -745,7 +745,7 @@
         sendToAllProcesses(Messages::WebProcess::PowerSourceDidChange(hasAC));
     });
 
-#if PLATFORM(IOS_FAMILY)
+#if PLATFORM(COCOA)
     addCFNotificationObserver(captivePortalModeConfigUpdateCallback, (__bridge CFStringRef)WKCaptivePortalModeContainerConfigurationChangedNotification);
 #endif
 
@@ -793,7 +793,7 @@
 
     m_powerSourceNotifier = nullptr;
     
-#if PLATFORM(IOS_FAMILY)
+#if PLATFORM(COCOA)
     removeCFNotificationObserver((__bridge CFStringRef)WKCaptivePortalModeContainerConfigurationChangedNotification);
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (290481 => 290482)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2022-02-25 01:43:01 UTC (rev 290481)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2022-02-25 01:44:44 UTC (rev 290482)
@@ -585,7 +585,7 @@
 #endif
 #endif
 
-#if PLATFORM(IOS_FAMILY)
+#if PLATFORM(COCOA)
     static void captivePortalModeConfigUpdateCallback(CFNotificationCenterRef, void* observer, CFStringRef name, const void* postingObject, CFDictionaryRef userInfo);
 #endif
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to