Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to programmatically call a Chrome Custom Tab, but as "incognito mode"?

In some case, a user might not want the chrome custom tab to show up in their browsing history. Is there any way the app could tell the Chrome Custom Tab to display the webpage in incognito mode, and avoid storing that URL in the user normal browsing history?

If that's currently not possible, where could someone submit a feature request for that?

Thanks!

like image 788
m-p-3 Avatar asked Jun 01 '16 19:06

m-p-3


1 Answers

It is possible now. For example in C#:

try
{
    string dataFolder = "C:\userFolder"; // If you need to maintain your browser session, you can configure a user data directory
    string urlToOpen = "https://shalliknow.com"; // replace your url to open
    Process process = new Process();
    process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
    process.StartInfo.Arguments = $"--new-window={urlToOpen} --start-maximized --incognito --user-data-dir=\"{ dataFolder}\""; // SSH new Chrome
    process.Start();
}
catch (Exception ex)
{
    Console.Writeline("Exception while opening link in browser");
}

The source of this code, as well as a list of command line arguments for chrome.exe can be found here: https://shalliknow.com/articles/en-scs-how-to-open-chrome-in-incognito-mode-programmatically-in-csharp

like image 85
SymboLinker Avatar answered Jan 04 '23 00:01

SymboLinker