Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 015450fc9083884904de9d26c87319b6b123f27f
      
https://github.com/WebKit/WebKit/commit/015450fc9083884904de9d26c87319b6b123f27f
  Author: Ada Chan <adac...@apple.com>
  Date:   2024-07-26 (Fri, 26 Jul 2024)

  Changed paths:
    M Source/WebCore/Modules/gamepad/GamepadManager.cpp
    M Source/WebCore/Modules/gamepad/GamepadManager.h
    M Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp
    M Source/WebCore/Modules/gamepad/NavigatorGamepad.h
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/page/Page.cpp
    M Source/WebCore/page/Page.h
    M Source/WebCore/page/PageConfiguration.h
    A 
Source/WebCore/platform/gamepad/ShouldRequireExplicitConsentForGamepadAccess.h
    M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
    M Source/WebKit/Shared/WebPageCreationParameters.h
    M Source/WebKit/Shared/WebPageCreationParameters.serialization.in
    M Source/WebKit/UIProcess/API/APIPageConfiguration.h
    M Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    M Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h
    M Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
    M Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp
    M Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h
    M Source/WebKit/UIProcess/PageClient.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in

  Log Message:
  -----------
  [visionOS] Add a mechanism to check user authorization for gamepads
https://bugs.webkit.org/show_bug.cgi?id=276842
rdar://132103378

Reviewed by Brady Eidson.

Add a new gamepadAccessRequiresExplicitConsent member in page configuration
to control whether gamepad access is blocked from webpage until
-[WKWebView _setAllowGamepadsAccess:YES] is called. By default,
gamepadAccessRequiresExplicitConsent is false.

Update the logic in GamepadManager that determines when to reveal gamepads
to navigators/windows that are just registered to also consult the
page's m_gamepadAccessGranted boolean. If Page::gamepadAccessGranted() returns
false when the navigator/window is first registered with the manager, they
are first placed in a separate quarantined set, and they don't automatically
get gamepads revealed to them on new gamepad connection or gamepad activity.
They are removed from quarantine only after their pages have been explicitly
granted gamepad access.

Also, add WKUIDelegatePrivate methods to communicate gamepad
access/connection state changes.

* Source/WebCore/Modules/gamepad/GamepadManager.cpp:
(WebCore::GamepadManager::findUnquarantinedNavigatorsAndWindows):
Gather all navigators/windows that are not waiting for explicit
user consent for gamepad access.
(WebCore::GamepadManager::platformGamepadConnected):
Do not notify quarantined navigators/windows of new gamepad connections.
(WebCore::GamepadManager::platformGamepadDisconnected):
Ditto for gamepad disconnections.
(WebCore::GamepadManager::registerNavigator):
Add to the quarantined set if access has not been granted.
(WebCore::GamepadManager::unregisterNavigator):
(WebCore::GamepadManager::registerDOMWindow):
Ditto for window.
(WebCore::GamepadManager::unregisterDOMWindow):
(WebCore::GamepadManager::updateQuarantineStatus):
This is called when a page's gamepad access state has changed.
It goes through the quarantined sets to see which ones are from
pages that have been granted access. Promote them to the blind
sets and remove them from the quarantined sets.
* Source/WebCore/Modules/gamepad/GamepadManager.h:
* Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp:
(WebCore::NavigatorGamepad::protectedPage const):
* Source/WebCore/Modules/gamepad/NavigatorGamepad.h:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/page/Page.cpp:
(WebCore::m_activeNowPlayingSessionUpdateTimer):
(WebCore::Page::didCommitLoad):
Reset gamepad access on new page load.
(WebCore::Page::allowGamepadAccess):
If gamepad access state has changed, tell GamepadManager to update its
quarantined sets of navigators/windows.
(WebCore::Page::initializeGamepadAccessForPageLoad):
* Source/WebCore/page/Page.h:
(WebCore::Page::gamepadAccessGranted const):
* Source/WebCore/page/PageConfiguration.h:
* 
Source/WebCore/platform/gamepad/ShouldRequireExplicitConsentForGamepadAccess.h: 
Added.
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/Shared/WebPageCreationParameters.h:
* Source/WebKit/Shared/WebPageCreationParameters.serialization.in:
* Source/WebKit/UIProcess/API/APIPageConfiguration.h:
(API::PageConfiguration::gamepadAccessRequiresExplicitConsent const):
(API::PageConfiguration::setGamepadAccessRequiresExplicitConsent):
* Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _gamepadsConnected]):
(-[WKWebView _gamepadsConnectedStateChanged]):
(-[WKWebView _setGamepadsRecentlyAccessed:]):
(-[WKWebView _setAllowGamepadsAccess]):
(-[WKWebView _setAllowGamepadsInput:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration encodeWithCoder:]):
(-[WKWebViewConfiguration initWithCoder:]):
(-[WKWebViewConfiguration _gamepadAccessRequiresExplicitConsent]):
(-[WKWebViewConfiguration _setGamepadAccessRequiresExplicitConsent:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h:
* Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm:
(WebKit::PageClientImplCocoa::gamepadsConnectedStateChanged):
* Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.cpp:
(WebKit::UIGamepadProvider::gamepadSyncTimerFired):
Update the new active page's gamepads connection state.
(WebKit::UIGamepadProvider::isAnyGamepadConnected const):
Check if there's any non-null gamepad in m_gamepads.
(WebKit::UIGamepadProvider::viewBecameActive):
Update the new active page's gamepads connection state.
(WebKit::UIGamepadProvider::viewBecameInactive):
* Source/WebKit/UIProcess/Gamepad/UIGamepadProvider.h:
* Source/WebKit/UIProcess/PageClient.h:
(WebKit::PageClient::gamepadsConnectedStateChanged):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCommitLoadForFrame):
Make sure we update the recent gamepad access state to false on page navigation.
(WebKit::WebPageProxy::resetStateAfterProcessExited):
Ditto.
(WebKit::WebPageProxy::creationParameters):
(WebKit::WebPageProxy::resetRecentGamepadAccessState):
Besides cancelling m_recentGamepadAccessHysteresis, we need to make sure
the clients know the recent gamepad access state has been reset to false.
(WebKit::WebPageProxy::setGamepadsConnected):
Notify page client if the gamepad connection state changes.
(WebKit::WebPageProxy::allowGamepadAccess):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::allowGamepadAccess):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:

Canonical link: https://commits.webkit.org/281432@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to