Skip to content

Commit

Permalink
Pull vm service uri from extension iFrame query parameters (#6335)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Sep 8, 2023
1 parent aa9c48e commit 89c0f9f
Showing 1 changed file with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,28 @@ class ExtensionManager {

// ignore: unused_element, false positive due to part files
void _init({required bool connectToVmService}) {
html.window.addEventListener('message', _handleMessage);

// TODO(kenz): handle the ide theme that may be part of the query params.
final queryParams = loadQueryParams();
final themeValue = queryParams[ExtensionEventParameters.theme];
darkThemeEnabled.value = themeValue == null ||
themeValue == ExtensionEventParameters.themeValueDark;

html.window.addEventListener('message', _handleMessage);
// TODO(kenz) instead of connecting to the VM service through an event, load
// the vm service URI through a query parameter like we already do in
// DevTools app.
final vmServiceUri = queryParams['uri'];
if (connectToVmService) {
// Request the vm service uri for the connected app. DevTools will
// respond with a [DevToolsPluginEventType.connectedVmService] event with
// containing the currently connected app's vm service URI.
postMessageToDevTools(
DevToolsExtensionEvent(DevToolsExtensionEventType.vmServiceConnection),
);
if (vmServiceUri == null) {
// Request the vm service uri for the connected app. DevTools will
// respond with a [DevToolsPluginEventType.connectedVmService] event
// containing the currently connected app's vm service URI.
postMessageToDevTools(
DevToolsExtensionEvent(
DevToolsExtensionEventType.vmServiceConnection,
),
);
} else {
unawaited(_connectToVmService(vmServiceUri));
}
}
}

Expand Down

0 comments on commit 89c0f9f

Please sign in to comment.