Click here to Skip to main content
16,004,678 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hello
I want to run the browser (Google Chrome with all the features and settings) inside the application(Form) .

In part code 1 calling the Google Chrome browser (with all features and settings), Provides our needs .
In Part code 2 of the Application(Form) , cefsharp provides the Internet connection but Does not meet our needs .

Items needed
1 - Run Chrome browser or another browser with all the features and settings of Google Chrome in the application(Form) .
2 - Access to the possibility of microphone .

What I have tried:

code 1 :


C#
chrome("Url") ;

private static void Chrome(string link)
{
    string url = "";
 
    if (!string.IsNullOrEmpty(link)) //if empty just run the browser
    {
        if (link.Contains('.')) //check if it's an url or a google search
        {
            url = link;
        }
        else
        {
            url = "https://www.google.com/search?q=" + link.Replace(" ", "+");
        }
    }
 
    try
    {
        Process.Start("chrome.exe", url + " --incognito");
    }
    catch (System.ComponentModel.Win32Exception e)
    {
        MessageBox.Show("Unable to find Google Chrome...",
            "chrome.exe not found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}


Code 2 :


C#
InitBrowser();


public ChromiumWebBrowser browser;
public void InitBrowser()
{
    CefSettings settings = new CefSettings();
    settings.CefCommandLineArgs.Add("enable-media-stream", "1");
    settings.CefCommandLineArgs.Add("allow-running-insecure-content", "1");
    settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream", "1");
    settings.CefCommandLineArgs.Add("enable-speech-input", "1");
    settings.CefCommandLineArgs.Add("enable-usermedia-screen-capture", "1");

    Cef.Initialize(settings);
    browser = new ChromiumWebBrowser("https://www.google.com");
    this.Controls.Add(browser);
    browser.Dock = DockStyle.Fill;
}
Posted
Updated 27-Jan-18 23:04pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900