TrianguloY/UrlChecker

opening in browser with private mode

Opened this issue · 24 comments

It would be nice to have a button that enable opening the link in browser with private mode (such as firefox, brave, etc) like the custom tabs.

This is useful if you do not want to keep cookie and history only for some links

Thanks for the app
Luca

I think someone mentioned it somewhere.
The issue is that there is no standard Android feature for it. On Android you send data to apps using intents, basically a 'do this' message. There are standard messages for 'open this url', but there is none for opening it privately.
Apps can implement their own messages, so a browser could have a special message that triggers it. But apparently not Chrome nor Firefox have it. Maybe I'm wrong, or maybe there are other browsers that have one. If someone has any clue about it, it should be easy to implement, otherwise I'm afraid this feature will never be possible without the browsers, or Android, help. :( sorry

Normally this is possible, but I am not affirmative, @TrianguloY when you have time, look at this, and tell me (if you feel like it) what you think:
https://stackoverflow.com/questions/66443545/how-can-i-start-chrome-custom-tabs-in-incognito-mode

But this will only work with browsers derived from chrome (i.e. all Chromium browsers)
Including Chrome, Bromite, Vanadium, Vivaldi, Brave, Yandex etc...

I'm not so sure, it seems to be an internal feature that you must enable and only available for specific apps, will try though.

I'm not so sure, it seems to be an internal feature that you must enable and only available for specific apps, will try though.

Yes indeed, I just edited my message in this sense, you were too fast

Found this by looking through App manager.
Chromium based browsers have a public activity to launch incognito tabs.

The issue is that there is no standard Android feature for it.

Still the same issue, and I couldn't find anything similar for firefox.

I don't expect the activity to be able to recive urls though, it seems to me that it just pops out the incognito tab, but I have not looked into it.

Worst case scenario is to expect the user to copy the url before opening the incognito tab, or force a copy, and then manually pasting the url in the search bar. A cheap solution, but it still saves on clicks.

373f0af0-e343-43a8-8803-7a403e97b568 (2)
dbccdf20-3655-447c-b4b4-7feeca084697 (2)

Hmm, something to consider, although I'm not sure if it's worth it. In any case if someone implements it I can add it as an experimental feature.

Isn't there a third party app that acts as exactly this? (I mean, a browser that is just a redirection to that sub activity or whatever necessary)

I don't know the limits of this, or how complex is to implement this, but if it works it would be almost like sending the URL directly to the app.

Android supports autofill services, it allows to autofill fields in a view from another apps. Autofill services are directed towards passwords managers and only one can be enabled. But there are accesibility services too, which if done properly, it could mimic the same feature, accesibility services allow for more than one service enabled at the same time. However I think the settings need to be tuned on a per app basis.

The idea would be to open the incognito tab from URLChecker and then send the URL to the service (which can be bundled with the app). When the view from the browser loads, then the service would fill the URL field.

Bitwarden mobile implements both of these.

https://developer.android.com/guide/topics/ui/accessibility/service
https://developer.android.com/reference/android/accessibilityservice/AccessibilityService

Accessibility services are forbidden on play store unless you use them for accessibility. Adding such a feature may work, but it will need to be enabled/disabled depending on the variant (disabled for Play Store, enabled for Fdroid). It isn't so bad, but injecting the url on an external app may stop working at any time (the view identifier may change) so it's a bit dangerous to implement something that isn't simple if it can stop working tomorrow (but as I said, if someone wants to provide a working prototype, I'm open to including it).

I know it may seem harder, but maybe a better idea is to ask in the browsers issue trackers for this feature (ability to open an url in incognito from an intent). To be honest if Chrome implements it all the others will eventually...

Accessibility services are forbidden on play store unless you use them for accessibility.

Do you mean this? Unless I'm understanding it wrong that is not the case anymore. Althought I must admit it seems like a hassle...

I know it may seem harder, but maybe a better idea is to ask in the browsers issue trackers for this feature (ability to open an url in incognito from an intent). To be honest if Chrome implements it all the others will eventually...

I myself, don't expect them to implement this at all. They even specify this in the source code

Accessibility services are forbidden on play store unless you use them for accessibility.

Do you mean this? Unless I'm understanding it wrong that is not the case anymore. Althought I must admit it seems like a hassle...

Oh, I wasn't aware of that. The thing is that the accessibility service is almost always the culprit of malicious apps and malware because it allows them basically to see and interact with all apps (see your bank app for example). But it seems that Play Store is aware of it's usefulness and at least it allows fair uses, even if it requires a lot of consents. I may try it...

I know it may seem harder, but maybe a better idea is to ask in the browsers issue trackers for this feature (ability to open an url in incognito from an intent). To be honest if Chrome implements it all the others will eventually...

I myself, don't expect them to implement this at all. They even specify this in the source code

:(
Maybe Firefox? I'll check

Supposedly Firefox allows the use of an extra to do this, but I haven't been able to make it work.

Supposedly Firefox allows the use of an extra to do this, but I haven't been able to make it work.

It does? I wasn't able to find anything. Any source?

Here you can see references in the code about this. Here is an issue about allowing this, the status is resolved, and the attachments link to the PR that solves it (there are 2 PRs because they were migrating the repo). I haven´t been able to make it work, even on Firefox nightly, I don't know what I'm missing.

t=new Intent(Intent.ACTION_VIEW,Uri.parse("http://google.es"))
t.putExtra("private_browsing_mode",true)

cntx.startActivity(t)

It works! I'm using the latest play store Firefox version, and I can confirm that the code above works! (even if UrlChecker is opened and then you choose Firefox, thanks past me for keeping the original intent)

Thank you for the discovery and the links! I remember seeing that class, but probably didn't invest much time searching.

Reopening to implement!
It will only work for Firefox, but it will be really useful for me so...

I wrote the extra all in caps that's why I couldn't make it work 🤦‍♂️
I plan to, at some point in the future, add an option to at least make it easier to open non-supported browsers in incognito.

  1. User wants to open a browser in incognito.
  2. The app stores whatever is on the clipboard
  3. Then it loads the URL to the clipboard
  4. Opens the browser in incognito, if possible. If not it opens it as usual but without sending the URL
    • Now the user should paste the URL into the search bar
  5. After 5-10 seconds URLCheck restores the previous value of the clipboard, a toast is shown to notify the user

That's not a bad idea, although with the clipboard restrictions that Android has now it may be more difficult than expected. In any case we can add custom features for each browser as needed, and toast/messages to notify or guide the user.

I have a working version for Firefox on my computer, let me upload it first and then feel free to adapt as needed.

(done)

I finally have some time to try to implement this, so first a recap to keep things clear, also if someone wants to add something.

A browser can:

  • Have incognito (firefox, chromium)
  • Not have it (tor, duckduckgo)

A browser with incognito mode can support opening it with an intent via:

  • Extra (firefox)
  • Activity (chromium)
  • Not compatible with intents

A browser can:

  • Ignore the URL of the intent (chromium)
  • Respect it (firefox)

If a browser ignores the URL we can:

  • Create an accessibility service that automates the input. Find the view, put the URL in there.
  • Use the clipboard (some caveats in higher android versions)

For the clipboard:

  1. User wants to open a browser in incognito.
  2. The app stores whatever is on the clipboard
  3. Then it loads the URL to the clipboard
  4. Opens the browser in incognito, if possible. If not it opens it as usual but without sending the URL
    • Now the user should paste the URL into the search bar
  5. After 5-10 seconds URLCheck restores the previous value of the clipboard, a toast is shown to notify the user

If the user is in a higher android version we can't restore the clipboard from background, alternatives:

  • Storing the previous clipboard content in a notification like Simple Clipboard Editor

I think there are other alternatives, but too complex, at that point an accesibility service would be better.

Basically that, yes. A couple extra notes:

The accessibility service is almost forbidden on play store (I think you need a special permission and the app must be of a special type, but I don't know for sure). If it can't be published, I don't mind keeping 2 versions, one for fdroid with it and another for play store without.

Using the clipboard doesn't seem very user friendly, but I guess it's better than nothing. For restoring it afterwards another solution may be to create a floating button on screen (like the pip video, or those chat bubbles).

Basically that, yes. A couple extra notes:

The accessibility service is almost forbidden on play store (I think you need a special permission and the app must be of a special type, but I don't know for sure). If it can't be published, I don't mind keeping 2 versions, one for fdroid with it and another for play store without.

Using the clipboard doesn't seem very user friendly, but I guess it's better than nothing. For restoring it afterwards another solution may be to create a floating button on screen (like the pip video, or those chat bubbles).

Glad I searched before making a feature request, since it led me here. Sorry, I'm not a dev, and just wanted to ask if I'm understanding correctly.

So having the app open a link in incognito is possible on Firefox, but not on Chrome?

Amazing app btw!

To be precise: if it is possible, we don't know how yet.

On android you can open apps by sending data to them. In the case of browsers you simply send them a url and they know how to handle it. For private browsing there is no standard "hey open this on private mode pls" message, so apps must implement their own. Firefox does have their own message, that we use, but chrome doesn't (at least not a few months ago).

There are alternatives like trying to automate what the user needs to do (open chrome, open private, paste url, press enter) but they have more problems than not :(

This is currently possible and implemented (and has been for a while) in the closed source and somewhat out of use Sync for Reddit app. It's enabled by activating these two chrome flags along with a setting for this feature in the app itself. Although in its current implementation this only works for webview custom tabs, it might be possible for it to work in standard incognito too.
Screenshot_20231129-180213

Please don't give up on adding this feature to chromium based browsers as well. Firefox doesn't feel that bad to use, but in its current state on Android it's not nearly as polished, and its sandboxing leaves much to be desired from a security perspective.

I think I did check those flags when working on this, I don't remember it working outside of custom tabs, but I'm not sure, will have to check that again.

I myself haven't given up on this, but when I did the code it "worked" (using the clipboard). The problem was that the code was awful and there were a lot more things to consider when using the clipboard from the background. These past weeks I have been trying to make some time for this as I feel kind of guilty for personally using the "bad version" I made some months back without making a PR. Hopefully I can find some time in the near future as the festivities of my country are so close.

@PabloOQ work on this