<!--
{
  "availability" : [
    "iOS: 18.4.0 -",
    "iPadOS: 18.4.0 -",
    "macCatalyst: 18.4.0 -",
    "macOS: 15.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:focusedWindowFor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKWebExtensionControllerDelegate(im)webExtensionController:focusedWindowForExtensionContext:"
  },
  "title" : "webExtensionController(_:focusedWindowFor:)"
}
-->

# webExtensionController(_:focusedWindowFor:)

Called when an extension context requests the currently focused window.

```
optional func webExtensionController(_ controller: WKWebExtensionController, focusedWindowFor extensionContext: WKWebExtensionContext) -> (any WKWebExtensionWindow)?
```

## Parameters

`controller`

The web extension controller that is managing the extension.

`extensionContext`

The context in which the web extension is running.

## Discussion

This method can be optionally implemented by the app to designate the window currently in focus to the extension.

If not implemented, the first window in the result of [`webExtensionController(_:openWindowsFor:)`](/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:openWindowsFor:)) is used.

## See Also

[`webExtensionController(_:openWindowsFor:)`](/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:openWindowsFor:))

Called when an extension context requests the list of ordered open windows.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)