Change header for PostData and Accept-Language

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

Change header for PostData and Accept-Language

Postby Gerrit » Wed Nov 12, 2014 10:22 am

Hi,
I've managed the cefGlue to work as it should for us, but now I've to send postdata and would change the accept-language in the http-header to another language.
I've found a solution in using CefBrowser, but not with CefWebBrowser as I use (Maybe I don't know how to get a CefBrowser instance or inherit from it, instead of CefWebbrowser)
Can someone explain to me, how to do this in general or were I can get the needed information?

Here're some background infos on how i implemented it into my assembly:
1. I'm using CEF 3.2171.1875 (x86) with the latest source from CEFGlue
2. Using an tabControl for the different webbrowser-objects
3. Using the browser instances as singleProcess and with MultiThreadedMessageLoop
4. I created an extra class, which inherits from CefWebBrowser (for my events and so on)

Code: Select all
       
private bool initializeCefBrowser()
        {
            try
            {
                string localization = System.Globalization.CultureInfo.CurrentCulture.Name;

                CefRuntime.Load(GlobalVars.CefRuntimePath);
                var cefArgs = new CefMainArgs(new string[0]);

                CefSettings settings = new CefSettings();
                settings.SingleProcess = true;
                settings.MultiThreadedMessageLoop = true;
                settings.LogSeverity = CefLogSeverity.Disable;
#if Debug
                settings.LogFile = GlobalVars.CefRuntimePath + "\\log.txt";
                settings.LogSeverity = CefLogSeverity.Debug;
#endif
                settings.Locale = "de-DE";                         
                settings.CommandLineArgsDisabled = false;           
                settings.IgnoreCertificateErrors = true;           
                settings.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.2171.19 Safari/537.36"; // didn't work atm as there seems to be a bug in CEF
               
                CefRuntime.Initialize(cefArgs, settings, null);
            }
            catch
            {
                return false;
            }
            return true;
        }

        private void addNewCefBrowserTab(string url,
                                         string websiteID = null,
                                         string parameter = null)
        {
            TabPage tp = new TabPage();
            tp.BackColor = Color.White;
            tp.Tag = websiteID;

            WebBrowserCef wb = new WebBrowserCef(dWebfilter);
           
            wb.StartUrl = url;
            wb.Dock = DockStyle.Fill;           

            wb.showNavigationButtons();

            wb.PnlNav.Location = new Point(tp.Width - 57, 0);
            tp.Controls.Add(wb.PnlNav);

            tp.Controls.Add(wb);
            tabBrowser.TabPages.Add(tp);

        }
Gerrit
Newbie
 
Posts: 1
Joined: Wed Nov 12, 2014 9:59 am

Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 11 guests