Changeset 286602 in webkit
- Timestamp:
- Dec 7, 2021, 11:35:52 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/APIPageConfiguration.cpp (modified) (1 diff)
-
UIProcess/API/APIPageConfiguration.h (modified) (1 diff)
-
UIProcess/API/APIWebsitePolicies.h (modified) (1 diff)
-
UIProcess/Cocoa/WebProcessPoolCocoa.mm (modified) (5 diffs)
-
UIProcess/WebPageProxy.cpp (modified) (2 diffs)
-
UIProcess/WebPageProxy.h (modified) (2 diffs)
-
UIProcess/WebProcessPool.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r286601 r286602 1 2021-12-07 Chris Dumez <cdumez@apple.com> 2 3 Reload web views when toggling the captive portal mode at system level 4 https://bugs.webkit.org/show_bug.cgi?id=233900 5 6 Reviewed by Brent Fulgham. 7 8 Reload web views when toggling the captive portal mode at system level, so that the views end up 9 being backed by WebProcesses with the proper captive portal mode. 10 11 * UIProcess/Cocoa/WebProcessPoolCocoa.mm: 12 (WebKit::cachedCaptivePortalModeEnabledGlobally): 13 (WebKit::WebProcessPool::captivePortalModeStateChanged): 14 (WebKit::captivePortalModeEnabledBySystem): 15 (WebKit::WebProcessPool::notifyPreferencesChanged): 16 * UIProcess/WebProcessPool.h: 17 1 18 2021-12-07 Sihui Liu <sihui_liu@apple.com> 2 19 -
trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp
r285594 r286602 205 205 } 206 206 207 bool PageConfiguration::isCaptivePortalModeExplicitlySet() const 208 { 209 return m_defaultWebsitePolicies && m_defaultWebsitePolicies->isCaptivePortalModeExplicitlySet(); 210 } 211 207 212 #if ENABLE(APPLICATION_MANIFEST) 208 213 ApplicationManifest* PageConfiguration::applicationManifest() const -
trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h
r285594 r286602 190 190 #endif 191 191 192 bool isCaptivePortalModeExplicitlySet() const; 192 193 bool captivePortalModeEnabled() const; 193 194 -
trunk/Source/WebKit/UIProcess/API/APIWebsitePolicies.h
r286545 r286602 131 131 bool captivePortalModeEnabled() const; 132 132 void setCaptivePortalModeEnabled(std::optional<bool> captivePortalModeEnabled) { m_captivePortalModeEnabled = captivePortalModeEnabled; } 133 bool isCaptivePortalModeExplicitlySet() const { return !!m_captivePortalModeEnabled; } 133 134 134 135 WebCore::MouseEventPolicy mouseEventPolicy() const { return m_mouseEventPolicy; } -
trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
r286590 r286602 27 27 #import "WebProcessPool.h" 28 28 29 #import "APINavigation.h" 29 30 #import "AccessibilityPreferences.h" 30 31 #import "AccessibilitySupportSPI.h" … … 128 129 static CFStringRef AppleColorPreferencesChangedNotification = CFSTR("AppleColorPreferencesChangedNotification"); 129 130 #endif 131 static const char* const WebKitCaptivePortalModeChangedNotification = "WebKitCaptivePortalModeEnabled"; 130 132 131 133 static NSString * const WebKitSuppressMemoryPressureHandlerDefaultsKey = @"WebKitSuppressMemoryPressureHandler"; … … 181 183 182 184 [[NSUserDefaults standardUserDefaults] registerDefaults:registrationDictionary]; 185 } 186 187 static std::optional<bool>& cachedCaptivePortalModeEnabledGlobally() 188 { 189 static std::optional<bool> cachedCaptivePortalModeEnabledGlobally; 190 return cachedCaptivePortalModeEnabledGlobally; 183 191 } 184 192 … … 938 946 } 939 947 948 void WebProcessPool::captivePortalModeStateChanged() 949 { 950 cachedCaptivePortalModeEnabledGlobally() = std::nullopt; 951 auto isNowEnabled = captivePortalModeEnabledBySystem(); 952 953 WEBPROCESSPOOL_RELEASE_LOG(Loading, "WebProcessPool::captivePortalModeStateChanged() isNowEnabled=%d", isNowEnabled); 954 955 for (auto& process : m_processes) { 956 bool processHasCaptivePortalModeEnabled = process->captivePortalMode() == WebProcessProxy::CaptivePortalMode::Enabled; 957 if (processHasCaptivePortalModeEnabled == isNowEnabled) 958 continue; 959 960 for (auto& page : process->pages()) { 961 // When the captive portal mode changes globally at system level, we reload every page that relied on the system setting (rather 962 // than being explicitly opted in/out by the client app at navigation or PageConfiguration level). 963 if (page->isCaptivePortalModeExplicitlySet()) 964 continue; 965 966 WEBPROCESSPOOL_RELEASE_LOG(Loading, "WebProcessPool::captivePortalModeStateChanged() Reloading page with pageProxyID=%" PRIu64 " due to captive portal mode change", page->identifier().toUInt64()); 967 page->reload({ }); 968 } 969 } 970 } 971 940 972 bool captivePortalModeEnabledBySystem() 941 973 { 942 static std::optional<bool> cachedCaptivePortalModeEnabledGlobally; 943 // FIXME: We should invalidate the cached value when the NSUserDefault changes. 944 if (!cachedCaptivePortalModeEnabledGlobally) { 974 auto& cachedState = cachedCaptivePortalModeEnabledGlobally(); 975 if (!cachedState) { 945 976 // FIXME: Using NSUserDefaults is a temporary workaround. This setting should be stored elsewhere (TCC?). 946 cached CaptivePortalModeEnabledGlobally = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitCaptivePortalModeEnabled"];947 } 948 return *cached CaptivePortalModeEnabledGlobally;977 cachedState = [[NSUserDefaults standardUserDefaults] boolForKey:[NSString stringWithUTF8String:WebKitCaptivePortalModeChangedNotification]]; 978 } 979 return *cachedState; 949 980 } 950 981 … … 1016 1047 webAuthnProcess->send(Messages::WebAuthnProcess::NotifyPreferencesChanged(domain, key, encodedValue), 0); 1017 1048 #endif 1049 1050 if (key == WebKitCaptivePortalModeChangedNotification) 1051 captivePortalModeStateChanged(); 1018 1052 } 1019 1053 #endif // ENABLE(CFPREFS_DIRECT_MODE) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r286590 r286602 863 863 else 864 864 m_process = processPool.processForRegistrableDomain(m_websiteDataStore.get(), registrableDomain, shouldEnableCaptivePortalMode() ? WebProcessProxy::CaptivePortalMode::Enabled : WebProcessProxy::CaptivePortalMode::Disabled); 865 865 866 m_hasRunningProcess = true; 867 m_isCaptivePortalModeExplicitlySet = m_configuration->isCaptivePortalModeExplicitlySet(); 866 868 867 869 m_process->addExistingWebPage(*this, WebProcessProxy::BeginsUsingDataStore::Yes); … … 3451 3453 } 3452 3454 3455 m_isCaptivePortalModeExplicitlySet = policies ? policies->isCaptivePortalModeExplicitlySet() : m_configuration->isCaptivePortalModeExplicitlySet(); 3453 3456 auto captivePortalMode = (policies ? policies->captivePortalModeEnabled() : shouldEnableCaptivePortalMode()) ? WebProcessProxy::CaptivePortalMode::Enabled : WebProcessProxy::CaptivePortalMode::Disabled; 3454 3457 process().processPool().processForNavigation(*this, *navigation, sourceProcess.copyRef(), sourceURL, processSwapRequestedByClient, captivePortalMode, frameInfo, WTFMove(websiteDataStore), [this, protectedThis = Ref { *this }, policyAction, navigation = Ref { *navigation }, navigationAction = WTFMove(navigationAction), sourceProcess = sourceProcess.copyRef(), -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r286505 r286602 497 497 void addPreviouslyVisitedPath(const String&); 498 498 499 bool isCaptivePortalModeExplicitlySet() const { return m_isCaptivePortalModeExplicitlySet; } 499 500 bool shouldEnableCaptivePortalMode() const; 500 501 … … 3140 3141 bool m_isRunningModalJavaScriptDialog { false }; 3141 3142 bool m_isSuspended { false }; 3143 bool m_isCaptivePortalModeExplicitlySet { false }; 3142 3144 3143 3145 std::optional<PrivateClickMeasurementAndMetadata> m_privateClickMeasurement; -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r286012 r286602 549 549 void registerNotificationObservers(); 550 550 void unregisterNotificationObservers(); 551 552 void captivePortalModeStateChanged(); 551 553 #endif 552 554
Note:
See TracChangeset
for help on using the changeset viewer.