Html file is not displayed in HTMLViewer if the application is sandboxed. (If the application is not sandboxed, HTMLViewer displays the html file correctly.) Where might be a problem? Thank you for your help.
The html file is in the user temporary folder, the file is ok, the sandboxed application reads it correctly, the messagebox displays it. However HTMLViewer does not display it. (The HTMLViewer in the sandboxed application does not even display an html string.)
I know that Apple have gotten more “Security” focused over time with the HTML Viewer.
I just wrote my own Help Viewer for App Wrapper (which is not Sandboxed) as help doesn’t work for everyone on Monterey, and dynamically generated content wouldn’t load images or allow the links to work until I was referencing an actual valid web page.
Somewhere on this forum are the declares that should also allow you to grant the HTMLViewer access to a specific folder, which you have to do when you load a page from a Sandboxed application, it MUST be a location that your application has access to, which doesn’t always include the temporary folder, the user cache folder or the application support folder (for your application) should be sufficient.
It’s late here and I’ve had a long day, so I’ll test out the Help Viewer in a Sandboxed application tomorrow and see what needs to be done to make it work (as I’ll need to roll my help viewer into my other applications at some point).
wRender is a reference to a window where HTMLViewer1 resides.
Data_FI is a reference (temporary) where I saved the html created in a TextArea.
Nota to self: I do not saw code to delete that file; I do not saw “this file” (different file name) on my hard disk…
I think I have to thank Sam (once more) for that tip.
Sam, Emile and Rick - thanks a lot for the suggestions. I used the mentioned declares and even after grantAccessToFolder HTMLViewer does not display the html file if the application is sandboxed.
However, it seems that the problem is not in the file access because HTMLViewer does not even display an html string if the application is sandboxed: HTMLViewer.LoadPage(htmlString, nil)
If the application is not sandboxed, HTMLViewer displays the html file or the html string correctly.
If the application is not sandboxed, both of them display the content correctly:
HTMLViewer.LoadPage(htmlString, nil)
HTMLViewer.LoadPage(htmlString, FolderItem.TemporaryFile)
If the application is sandboxed, both of them do not dispaly anything:
HTMLViewer.LoadPage(htmlString, nil)
HTMLViewer.LoadPage(htmlString, FolderItem.TemporaryFile)
How did you get the file access set as Sam said? You shouldn’t be using Nil for that.
I think you should try set a var to SpecialFolder.Temporary and then request access to such folder,
Then create a dummy file there and pass its FolderItem as the second argument of LoadPage()
We have had a similar issue in the Electron repository when sandboxing apps. The issue is CEF related in that case though… Bug has been active since 2017. Wonder if these are related?