erisu commented on issue #1776:
URL: 
https://github.com/apache/cordova-android/issues/1776#issuecomment-2982749576

   @AshleyScirra 
   
   I took a quick glance but I'm not sure what changes are required to get this 
working properly.
   
   > I'm happy to sponsor development work.
   
   PRs are always welcome.
   
   ----
   
   Because I'm not very familiar with the new APIs or what's needed on the 
native side, I created a native app without Cordova to see how things behave 
without Cordova's internal logic.
   
   It contains a `WebView` element, and I attached a `WebChromeClient` to 
override `onShowFileChooser`. The override simply logs a message to confirm 
it's being triggered and then defers to the superclass:
   
   ```java
   webView.setWebChromeClient(new WebChromeClient() {
       @Override
       public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> 
filePathCallback, FileChooserParams fileChooserParams) {
           Log.e("MyApp", "onShowFileChooser was called");
           return super.onShowFileChooser(webView, filePathCallback, 
fileChooserParams);
       }
   });
   ```
   
   When clicking the DOM element `<input type="file" />` or using the JS API 
`window.showOpenFilePicker()`, I can see that `onShowFileChooser` is triggered, 
as the log is printed.
   
   However, when using `window.showOpenFilePicker()`, I also see this error:
   
   > `AbortError: Failed to execute 'showOpenFilePicker' on 'Window': The user 
aborted a request.`
   
   I tried using a `WebViewAssetLoader` to serve the content from 
`https://myapp/` instead of using the `file://` scheme, to rule out any 
limitations with the `file` scheme, but the results were the same.
   
   I also added buttons to test the following APIs:
   
   * `window.showDirectoryPicker()`
   * `window.showSaveFilePicker()`
   
   Clicking those buttons does **not** trigger `onShowFileChooser`. I suspect 
this is expected behavior, but I'm not familiar with the expected native-side 
handling of these newer APIs.
   
   In the developer tools, I also see the following errors for those calls:
   
   > `AbortError: Failed to execute 'showDirectoryPicker' on 'Window': The user 
aborted a request.`
   > `AbortError: Failed to execute 'showSaveFilePicker' on 'Window': The user 
aborted a request.`
   
   I was reading through the [Intent to Ship: File System Access on Android and 
WebView](https://groups.google.com/a/chromium.org/g/blink-dev/c/x3IcFv2jY6c/m/HxuEfzBHAAAJ)
 discussion thread to see if there were anything to be aware of.
   
   One response mentioned:
   
   > The FileSystemAccess API is enabled for android and webview in M132 and 
expecting to release to stable in Jan, 2025.
   
   In my test, was running on an SDK 36 (Android 16) emulator, where the 
Android System WebView version is 133.0.
   
   Someone also said earlier:
   
   > Apps that use WebView will need to implement 
`WebChromeClient#onShowFileChooser()` for the JS calls 
`window.showOpenFilePicker()`, `showDirectoryPicker()`, and 
`showSaveFilePicker()`. I'm working on adding more options to 
`WebChromeClient.FileChooserParams` to help clarify which API is being used. 
These additions should be available in the next API release.
   
   Even though I've added a basic `WebChromeClient#onShowFileChooser()` 
override, it doesn't seem to be triggered for anything beyond 
`showOpenFilePicker()`.
   
   That's as far as I've gotten so far.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to