---
title: "webExtensionController(_:focusedWindowFor:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebextensioncontrollerdelegate/webextensioncontroller(_:focusedwindowfor:)"
---

# webExtensionController(_:focusedWindowFor:)

Called when an extension context requests the currently focused window.

## Declaration

```swift
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

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:) is used.

## See Also

### Related Documentation

- [webExtensionController(_:openWindowsFor:)](webkit/wkwebextensioncontrollerdelegate/webextensioncontroller(_:openwindowsfor:).md)
