<!--
{
  "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(_:openWindowsFor:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKWebExtensionControllerDelegate(im)webExtensionController:openWindowsForExtensionContext:"
  },
  "title" : "webExtensionController(_:openWindowsFor:)"
}
-->

# webExtensionController(_:openWindowsFor:)

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

```
optional func webExtensionController(_ controller: WKWebExtensionController, openWindowsFor 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 should be implemented by the app to provide the extension with the ordered open windows. Depending on your app’s requirements, you may return different windows for each extension or the same windows for all extensions. The first window in the returned array must correspond to the currently focused window and match the result of [`webExtensionController(_:focusedWindowFor:)`](/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:focusedWindowFor:)).

If [`webExtensionController(_:focusedWindowFor:)`](/documentation/WebKit/WKWebExtensionControllerDelegate/webExtensionController(_:focusedWindowFor:)) returns `nil`, indicating that no window has focus or the focused window is not visible to the extension, the first window in the list returned by this method will be considered the presumed focused window. An empty result indicates no open windows are available for the extension. Defaults to an empty array if not implemented.

## See Also

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

Called when an extension context requests the currently focused window.



---

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)