5959
6060import com .vaadin .flow .component .PushConfiguration ;
6161import com .vaadin .flow .component .UI ;
62+ import com .vaadin .flow .component .page .ExtendedClientDetails ;
6263import com .vaadin .flow .component .page .Inline ;
6364import com .vaadin .flow .component .page .Push ;
6465import com .vaadin .flow .component .page .Viewport ;
@@ -1354,6 +1355,9 @@ protected BootstrapContext createAndInitUI(Class<? extends UI> uiClass,
13541355
13551356 push .map (Push ::transport ).ifPresent (pushConfiguration ::setTransport );
13561357
1358+ // Parse browser details from request parameters and store in UI
1359+ extractAndStoreBrowserDetails (request , ui );
1360+
13571361 // Set thread local here so it is available in init
13581362 UI .setCurrent (ui );
13591363 ui .doInit (request , session .getNextUIid (), context .getAppId ());
@@ -1367,6 +1371,34 @@ protected BootstrapContext createAndInitUI(Class<? extends UI> uiClass,
13671371 return context ;
13681372 }
13691373
1374+ /**
1375+ * Extracts browser details from the request JSON parameter and stores them
1376+ * in the UI's internals as ExtendedClientDetails.
1377+ *
1378+ * @param request
1379+ * the request containing browser details as JSON parameter
1380+ * @param ui
1381+ * the UI instance to store the details in
1382+ */
1383+ private void extractAndStoreBrowserDetails (VaadinRequest request , UI ui ) {
1384+ // Extract browser details JSON parameter from request
1385+ // This is sent by the client in the v-r=init request
1386+ String browserDetailsJson = request .getParameter ("v-browserDetails" );
1387+
1388+ if (browserDetailsJson != null && !browserDetailsJson .isEmpty ()) {
1389+ try {
1390+ JsonNode json = JacksonUtils .readTree (browserDetailsJson );
1391+ ExtendedClientDetails details = ExtendedClientDetails
1392+ .fromJson (ui , json );
1393+ ui .getInternals ().setExtendedClientDetails (details );
1394+ } catch (Exception e ) {
1395+ // Log and continue without browser details
1396+ getLogger ().debug (
1397+ "Failed to parse browser details from init request" , e );
1398+ }
1399+ }
1400+ }
1401+
13701402 protected void initializeUIWithRouter (BootstrapContext context , UI ui ) {
13711403 if (ui .getInternals ().getRouter () != null ) {
13721404 ui .getInternals ().getRouter ().initializeUI (ui , context .getRoute ());
0 commit comments