@@ -88,8 +88,6 @@ public class Browser extends LinearLayout {
8888
8989 ValueCallback <Uri []> filePathCallback ;
9090 final int REQUEST_SELECT_FILE = 1 ;
91-
92- private BrowserActivity permissionHandler ;
9391
9492 public Browser (Context context , Ui .Theme theme , Boolean onlyConsole ) {
9593 super (context );
@@ -422,14 +420,6 @@ public void setConsoleVisible(boolean visible) {
422420 public void setProgressBarVisible (boolean visible ) {
423421 loading .setVisibility (visible ? View .VISIBLE : View .GONE );
424422 }
425-
426- public void setPermissionHandler (BrowserActivity handler ) {
427- this .permissionHandler = handler ;
428- }
429-
430- public BrowserActivity getPermissionHandler () {
431- return this .permissionHandler ;
432- }
433423
434424 private void updateViewportDimension (int width , int height ) {
435425 String script =
@@ -632,9 +622,6 @@ public void exit() {
632622class BrowserChromeClient extends WebChromeClient {
633623
634624 Browser browser ;
635-
636- // Cache granted permissions per origin to avoid re-prompting (e.g., when switching cameras)
637- private java .util .Set <String > grantedPermissions = new java .util .HashSet <>();
638625
639626 public BrowserChromeClient (Browser browser ) {
640627 super ();
@@ -695,77 +682,56 @@ public boolean onShowFileChooser(
695682 public void onPermissionRequest (final PermissionRequest request ) {
696683 final String [] resources = request .getResources ();
697684 final Uri origin = request .getOrigin ();
698- final String originKey = origin != null ? origin .toString () : "" ;
699-
700- // Check if all requested permissions are already granted for this origin
701- boolean allCached = true ;
702- for (String resource : resources ) {
703- String cacheKey = originKey + "|" + resource ;
704- if (!grantedPermissions .contains (cacheKey )) {
705- allCached = false ;
706- break ;
707- }
708- }
709-
710- if (allCached ) {
711- request .grant (resources );
712- return ;
713- }
714685
715- // Build a human-readable list with emojis for better visual appeal
686+ // Build a human-readable list of requested permissions
716687 StringBuilder permissionList = new StringBuilder ();
717688 for (String resource : resources ) {
718689 if (resource .equals (PermissionRequest .RESOURCE_VIDEO_CAPTURE )) {
719- permissionList .append ("📷 Camera\n " );
690+ permissionList .append ("• Camera\n " );
720691 } else if (resource .equals (PermissionRequest .RESOURCE_AUDIO_CAPTURE )) {
721- permissionList .append ("🎤 Microphone\n " );
692+ permissionList .append ("• Microphone\n " );
722693 } else if (resource .equals (PermissionRequest .RESOURCE_PROTECTED_MEDIA_ID )) {
723- permissionList .append ("🔐 Protected Media\n " );
694+ permissionList .append ("• Protected Media\n " );
724695 } else if (resource .equals (PermissionRequest .RESOURCE_MIDI_SYSEX )) {
725- permissionList .append ("🎹 MIDI Device\n " );
696+ permissionList .append ("• MIDI Device\n " );
726697 } else {
727- permissionList .append ("🔧 " ).append (resource ).append ("\n " );
698+ permissionList .append ("• " ).append (resource ).append ("\n " );
728699 }
729700 }
730701
731- // Get the site name from origin
702+ // Get the site URL
703+ final String siteUrl = origin != null ? origin .toString () : "" ;
732704 String siteName = origin != null ? origin .getHost () : "This site" ;
733705 if (siteName == null || siteName .isEmpty ()) {
734706 siteName = "This site" ;
735707 }
736708
737- final String message = siteName + " wants to access:\n \n " + permissionList .toString ();
709+ final String message = siteName + " is requesting access to:\n \n " + permissionList .toString () +
710+ "\n \n These permissions are not available in the in-app browser. " +
711+ "Please open this page in an external browser to use these features." ;
738712
739713 new Handler (Looper .getMainLooper ()).post (() -> {
740- AlertDialog dialog = new AlertDialog .Builder (browser .context )
741- .setTitle ("🔔 Permission Request " )
714+ new AlertDialog .Builder (browser .context )
715+ .setTitle ("⚠️ Permission Not Available " )
742716 .setMessage (message )
743- .setPositiveButton ("Allow" , (dlg , which ) -> {
744- // Cache the granted permissions for this origin
745- for (String resource : resources ) {
746- String cacheKey = originKey + "|" + resource ;
747- grantedPermissions .add (cacheKey );
748- }
749-
750- // Check if we have a permission handler (activity) to handle runtime permissions
751- BrowserActivity handler = browser .getPermissionHandler ();
752- if (handler != null ) {
753- handler .handlePermissionRequest (request , resources );
754- } else {
755- // Fallback: directly grant if no handler
756- request .grant (resources );
717+ .setPositiveButton ("Open in Browser" , (dlg , which ) -> {
718+ request .deny ();
719+ // Open in external browser
720+ try {
721+ Intent browserIntent = new Intent (Intent .ACTION_VIEW , Uri .parse (siteUrl ));
722+ browser .context .startActivity (browserIntent );
723+ } catch (Exception e ) {
724+ Toast .makeText (browser .context , "Could not open browser" , Toast .LENGTH_SHORT ).show ();
757725 }
758726 })
759- .setNegativeButton ("Block " , (dlg , which ) -> {
727+ .setNegativeButton ("Cancel " , (dlg , which ) -> {
760728 request .deny ();
761729 })
762730 .setOnCancelListener (dlg -> {
763731 request .deny ();
764732 })
765733 .setCancelable (true )
766- .create ();
767-
768- dialog .show ();
734+ .show ();
769735 });
770736 }
771737
@@ -779,14 +745,6 @@ public void onPermissionRequestCanceled(PermissionRequest request) {
779745 public void onGeolocationPermissionsShowPrompt (final String origin ,
780746 final android .webkit .GeolocationPermissions .Callback callback ) {
781747
782- String cacheKey = origin + "|geolocation" ;
783-
784- // Check if already granted
785- if (grantedPermissions .contains (cacheKey )) {
786- callback .invoke (origin , true , false );
787- return ;
788- }
789-
790748 // Get site name from origin
791749 String siteName = origin ;
792750 try {
@@ -797,22 +755,25 @@ public void onGeolocationPermissionsShowPrompt(final String origin,
797755 }
798756
799757 final String displayName = siteName ;
758+ final String message = displayName + " is requesting access to your location.\n \n " +
759+ "Location access is not available in the in-app browser. " +
760+ "Please open this page in an external browser to use location features." ;
800761
801762 new Handler (Looper .getMainLooper ()).post (() -> {
802763 new AlertDialog .Builder (browser .context )
803- .setTitle ("📍 Location Request " )
804- .setMessage (displayName + " wants to access your location" )
805- .setPositiveButton ("Allow " , (dialog , which ) -> {
806- grantedPermissions . add ( cacheKey );
807- // Check Android runtime location permission
808- BrowserActivity handler = browser . getPermissionHandler ();
809- if ( handler != null ) {
810- handler . handleGeolocationPermission ( origin , callback );
811- } else {
812- callback . invoke ( origin , true , false );
764+ .setTitle ("📍 Location Not Available " )
765+ .setMessage (message )
766+ .setPositiveButton ("Open in Browser " , (dialog , which ) -> {
767+ callback . invoke ( origin , false , false );
768+ // Open in external browser
769+ try {
770+ Intent browserIntent = new Intent ( Intent . ACTION_VIEW , Uri . parse ( origin ));
771+ browser . context . startActivity ( browserIntent );
772+ } catch ( Exception e ) {
773+ Toast . makeText ( browser . context , "Could not open browser" , Toast . LENGTH_SHORT ). show ( );
813774 }
814775 })
815- .setNegativeButton ("Block " , (dialog , which ) -> {
776+ .setNegativeButton ("Cancel " , (dialog , which ) -> {
816777 callback .invoke (origin , false , false );
817778 })
818779 .setOnCancelListener (dialog -> {
0 commit comments