Skip to content

Commit ef62106

Browse files
committed
fixed issues
1 parent 891cfc9 commit ef62106

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

common/src/main/java/com/microsoft/identity/common/internal/providers/oauth2/WebViewAuthorizationFragment.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ public void onPageLoaded(final String url) {
273273
if (!mAuthResultSent && !StringExtensions.isNullOrBlank(javascriptToExecute[0])) {
274274
mWebView.evaluateJavascript(javascriptToExecute[0], null);
275275
}
276+
277+
// Dynamically toggle multiple-windows support so that target="_blank"
278+
// interception is active ONLY on the TLR start page. On all other
279+
// pages the WebView behaves exactly as before (target="_blank" links
280+
// navigate inline, triggering the normal WebViewClient callbacks).
281+
if (CommonFlightsManager.INSTANCE.getFlightsProvider()
282+
.isFlightEnabled(CommonFlight.ENABLE_WEBVIEW_MULTIPLE_WINDOWS)) {
283+
final boolean isTlrPage = url != null && url.contains("/tlr/start");
284+
mWebView.getSettings().setSupportMultipleWindows(isTlrPage);
285+
}
276286
}
277287
},
278288
mRedirectUri,
@@ -362,11 +372,13 @@ public boolean onTouch(final View view, final MotionEvent event) {
362372
mWebView.getSettings().setBuiltInZoomControls(webViewZoomControlsEnabled);
363373
mWebView.getSettings().setSupportZoom(webViewZoomEnabled);
364374

365-
// Enable multiple windows so that target="_blank" links trigger onCreateWindow
366-
// instead of being silently dropped by the WebView - controlled by flight.
375+
// Multiple windows support is toggled dynamically in onPageLoaded based on
376+
// the current URL. It is enabled only on /tlr/start pages so that target="_blank"
377+
// links open in an external browser there. On all other pages, the WebView retains
378+
// its original behavior (target="_blank" navigates inline through the normal
379+
// WebViewClient, preserving redirect-URI detection, PKeyAuth, etc.).
367380
final boolean multipleWindowsEnabled = CommonFlightsManager.INSTANCE.getFlightsProvider()
368381
.isFlightEnabled(CommonFlight.ENABLE_WEBVIEW_MULTIPLE_WINDOWS);
369-
mWebView.getSettings().setSupportMultipleWindows(multipleWindowsEnabled);
370382

371383
mWebView.setVisibility(View.INVISIBLE);
372384
mWebView.setWebViewClient(webViewClient);
@@ -400,12 +412,15 @@ public boolean onCreateWindow(final WebView view, boolean isDialog,
400412
// Flight is off; should not reach here, but guard anyway.
401413
return false;
402414
}
415+
403416
if (resultMsg.obj == null) {
404417
Logger.error(methodTag, "onCreateWindow: resultMsg.obj is null, cannot set up transport.", null);
405418
return false;
406419
}
407-
// Handles target="_blank" links by opening them in the device's default browser
408-
// instead of silently dropping the navigation.
420+
421+
// Handles target="_blank" links by opening them in the device's default browser.
422+
// This callback is only reached when setSupportMultipleWindows is true, which
423+
// is dynamically enabled only on /tlr/start pages (see onPageLoaded).
409424
final SpanContext parentSpanContext = requireActivity() instanceof AuthorizationActivity
410425
? ((AuthorizationActivity) requireActivity()).getSpanContext() : null;
411426
final Span span = OTelUtility.createSpanFromParent(

0 commit comments

Comments
 (0)