/// <summary> /// Sets the string value of a pref. This is a replacement of nsIPrefBranch::SetCharPref(), which can't handle unicode values. /// </summary> static void SetUnicodePref(nsIPrefBranch branch, string name, string value) { var iid = typeof(nsISupportsString).GUID; var str = Xpcom.CreateInstance<nsISupportsString>(Contracts.SupportsString); nsString.Set(str.SetDataAttribute, value); branch.SetComplexValue(name, ref iid, Xpcom.QueryInterface<nsISupports>(str)); }
/// <summary> /// Sets the string value of a pref. This is a replacement of nsIPrefBranch::SetCharPref(), which can't handle unicode values. /// </summary> private static void SetUnicodePref(nsIPrefBranch branch, string name, string value) { var iid = typeof(nsISupportsString).GUID; var str = Xpcom.CreateInstance <nsISupportsString>(Contracts.SupportsString); nsString.Set(str.SetDataAttribute, value); branch.SetComplexValue(name, ref iid, Xpcom.QueryInterface <nsISupports>(str)); }
private GeckoPreferences(bool defaultBranch) { IsDefaultBranch = defaultBranch; if (defaultBranch) Branch = PrefService.GetDefaultBranch(""); else Branch = PrefService.GetBranch(""); }
/// <summary> /// Gets the string value of a pref. This is a replacement of nsIPrefBranch::GetCharPref(), which can't handle unicode values. /// See also <a href="http://www-archive.mozilla.org/projects/intl/changefontpref2.html">How to change the font setting in Gecko from the Embedding Application</a> /// </summary> static string GetUnicodePref(nsIPrefBranch branch, string name) { var iid = typeof(nsISupportsString).GUID; IntPtr pStr = branch.GetComplexValue (name, ref iid); if (pStr == IntPtr.Zero) return null; var sStr = (nsISupportsString) Xpcom.GetObjectForIUnknown(pStr); Marshal.Release(pStr); return nsString.Get(sStr.GetDataAttribute); }
/// <summary> /// Gets the string value of a pref. This is a replacement of nsIPrefBranch::GetCharPref(), which can't handle unicode values. /// See also <a href="http://www-archive.mozilla.org/projects/intl/changefontpref2.html">How to change the font setting in Gecko from the Embedding Application</a> /// </summary> private static string GetUnicodePref(nsIPrefBranch branch, string name) { var iid = typeof(nsISupportsString).GUID; IntPtr pStr = branch.GetComplexValue(name, ref iid); if (pStr == IntPtr.Zero) { return(null); } var sStr = (nsISupportsString)Xpcom.GetObjectForIUnknown(pStr); Marshal.Release(pStr); return(nsString.Get(sStr.GetDataAttribute)); }
internal PreferencesBranch(nsIPrefBranch prefBranch) { m_PrefBranch = prefBranch; }
public static nsIPrefBranch GetProxy (Mono.WebBrowser.IWebBrowser control, nsIPrefBranch obj) { object o = Base.GetProxyForObject (control, typeof(nsIPrefBranch).GUID, obj); return o as nsIPrefBranch; }
public static nsIPrefBranch GetProxy(Mono.WebBrowser.IWebBrowser control, nsIPrefBranch obj) { object o = Base.GetProxyForObject(control, typeof(nsIPrefBranch).GUID, obj); return(o as nsIPrefBranch); }
private GeckoPreferences(bool defaultBranch) { IsDefaultBranch = defaultBranch; Branch = defaultBranch ? PrefService.GetDefaultBranch("") : PrefService.GetBranch(""); }
private void InitializeBrowser() { this.Dispose(); switch (this.browserType) { case BrowserType.InternetExplorer: this.SetIsLoading(true); SetBrowserEmulationVersion(); this.internetExplorer = new IE { Dock = DockStyle.Fill, // Never change this to true // There's a bug in IE! ScriptErrorsSuppressed = false }; this.internetExplorer.DocumentCompleted += this.WebBrowser_DocumentCompleted; #if IEWORKAROUND dynamic activeXIE = this.internetExplorer.ActiveXInstance; activeXIE.BeforeNavigate2 += new BeforeNavigate2((object pDisp, ref dynamic url, ref dynamic Flags, ref dynamic TargetFrameName, ref dynamic PostData, ref dynamic Headers, ref bool Cancel) => { UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, null, 0, 0); UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, IE10, IE10.Length, 0); // The following code causes problems with AJAX - please don't resend the headers /* * if (!renavigating) * { * const string agent = IE11; * Headers += string.Format("User-Agent: {0}\r\n", agent); * renavigating = true; * Cancel = true; * this.internetExplorer.Navigate((string)url, (string)TargetFrameName, (byte[])PostData, (string)Headers); * } * else * { * renavigating = false; * } */ }); #endif this.browserContainer.Controls.Add(this.internetExplorer); break; #if GECKO case BrowserType.Firefox: // Workaround this.SyncCerts(); Xpcom.Initialize(); // Set some preferences nsIPrefBranch pref = Xpcom.GetService <nsIPrefBranch>("@mozilla.org/preferences-service;1"); // Show same page as firefox does for unsecure SSL/TLS connections ... pref.SetIntPref("browser.ssl_override_behavior", 1); pref.SetIntPref("security.OCSP.enabled", 0); pref.SetBoolPref("security.OCSP.require", false); pref.SetBoolPref("extensions.hotfix.cert.checkAttributes", true); pref.SetBoolPref("security.remember_cert_checkbox_default_setting", true); pref.SetBoolPref("services.sync.prefs.sync.security.default_personal_cert", true); pref.SetBoolPref("browser.xul.error_pages.enabled", true); pref.SetBoolPref("browser.xul.error_pages.expert_bad_cert", false); // disable caching of http documents pref.SetBoolPref("network.http.use-cache", false); // disalbe memory caching pref.SetBoolPref("browser.cache.memory.enable", false); // Desktop Notification pref.SetBoolPref("notification.feature.enabled", true); // WebSMS pref.SetBoolPref("dom.sms.enabled", true); pref.SetCharPref("dom.sms.whitelist", ""); // WebContacts pref.SetBoolPref("dom.mozContacts.enabled", true); pref.SetCharPref("dom.mozContacts.whitelist", ""); pref.SetBoolPref("social.enabled", false); // WebAlarms pref.SetBoolPref("dom.mozAlarms.enabled", true); // WebSettings pref.SetBoolPref("dom.mozSettings.enabled", true); pref.SetBoolPref("network.jar.open-unsafe-types", true); pref.SetBoolPref("security.warn_entering_secure", false); pref.SetBoolPref("security.warn_entering_weak", false); pref.SetBoolPref("security.warn_leaving_secure", false); pref.SetBoolPref("security.warn_viewing_mixed", false); pref.SetBoolPref("security.warn_submit_insecure", false); pref.SetIntPref("security.ssl.warn_missing_rfc5746", 1); pref.SetBoolPref("security.ssl.enable_false_start", false); pref.SetBoolPref("security.enable_ssl3", true); pref.SetBoolPref("security.enable_tls", true); pref.SetBoolPref("security.enable_tls_session_tickets", true); pref.SetIntPref("privacy.popups.disable_from_plugins", 2); // don't store passwords pref.SetIntPref("security.ask_for_password", 1); pref.SetIntPref("security.password_lifetime", 0); pref.SetBoolPref("signon.prefillForms", false); pref.SetBoolPref("signon.rememberSignons", false); pref.SetBoolPref("browser.fixup.hide_user_pass", false); pref.SetBoolPref("privacy.item.passwords", true); this.firefox = new GeckoWebBrowser { Dock = DockStyle.Fill, AllowDrop = true }; this.SetIsLoading(true); this.firefox.DocumentCompleted += this.FireFox_DocumentCompleted; this.browserContainer.Controls.Add(this.firefox); break; #endif } }