public static object FindEntryProperties(string url) { // TODO - Add nsIProperties wrapper var xpComUri = IOService.CreateNsIUri(url); return(_imgCache.Instance.FindEntryProperties(xpComUri)); }
// Remove entry method does not exist in gecko 45 #if false public static void RemoveEntry(string url) { var xpComUri = IOService.CreateNsIUri(url); _imgCache.Instance.RemoveEntry(xpComUri); Xpcom.FreeComObject(ref xpComUri); }
public UriChecker(string uri) : this(Xpcom.CreateInstance <nsIURIChecker>(Contracts.UriChecker)) { var nsUri = IOService.CreateNsIUri(uri); _checker.Init(nsUri); Marshal.ReleaseComObject(nsUri); }
public static Properties FindEntryProperties(string url) { var xpComUri = IOService.CreateNsIUri(url); var ret = _imgCache.Instance.FindEntryProperties(xpComUri).Wrap((x) => new Properties(x)); Xpcom.FreeComObject(ref xpComUri); return(ret); }
public static Properties FindEntryProperties(string url, GeckoDocument document) { var xpComUri = IOService.CreateNsIUri(url); var ret = Gecko.Interop.ExtensionMethods.Wrap(_imgCache.Instance.FindEntryProperties(xpComUri, document._domDocument), (x) => new Properties(x)); Xpcom.FreeComObject(ref xpComUri); return(ret); }
protected void InternalLoadContent(string content, string url, string contentType) { if (!IsHandleCreated) { WpfExtensions.DoEvents(); } using (var sContentType = new nsACString(contentType)) using (var sUtf8 = new nsACString("UTF8")) { ByteArrayInputStream inputStream = null; try { inputStream = ByteArrayInputStream.Create(System.Text.Encoding.UTF8.GetBytes(content != null ? content : string.Empty)); var docShell = Xpcom.QueryInterface <nsIDocShell> (this.WebBrowser); nsIURI uri = null; if (!string.IsNullOrEmpty(url)) { uri = IOService.CreateNsIUri(url); } nsIDocShellLoadInfo l = null; if (true) { l = Xpcom.QueryInterface <nsIDocShellLoadInfo> (this.WebBrowser); docShell.CreateLoadInfo(ref l); l.SetLoadTypeAttribute(new IntPtr(16)); } docShell.LoadStream(inputStream, uri, sContentType, sUtf8, l); Marshal.ReleaseComObject(docShell); if (l != null) { Marshal.ReleaseComObject(l); } } finally { if (inputStream != null) { inputStream.Close(); } } } }
// From Timothy N in https://bitbucket.org/geckofx/geckofx-29.0/issue/34/how-to-download-files-using-this-engine static void LauncherDialog_Download(IWin32Window owner, object sender, LauncherDialogEvent e) { uint flags = (uint)nsIWebBrowserPersistConsts.PERSIST_FLAGS_NO_CONVERSION | (uint)nsIWebBrowserPersistConsts.PERSIST_FLAGS_REPLACE_EXISTING_FILES | (uint)nsIWebBrowserPersistConsts.PERSIST_FLAGS_BYPASS_CACHE; SaveFileDialog sfd = new SaveFileDialog(); sfd.FileName = e.Filename; if (sfd.ShowDialog(owner) == DialogResult.OK) { // the part that do the download, may be used for automation, or when the source URI is known, or after a parse of the dom : string url = e.Url; //url to download string fullpath = sfd.FileName; //destination file absolute path nsIWebBrowserPersist persist = Xpcom.GetService <nsIWebBrowserPersist>("@mozilla.org/embedding/browser/nsWebBrowserPersist;1"); nsIURI source = IOService.CreateNsIUri(url); nsIURI dest = IOService.CreateNsIUri(new Uri(fullpath).AbsoluteUri); persist.SetPersistFlagsAttribute(flags); persist.SaveURI(source, null, null, null, null, (nsISupports)dest, null); // file is saved - asynchronous call // need to try to have a temp name while the file is downloaded eg filename.ext.geckodownload (one of the SaveURI option) } }
public static Properties FindEntryProperties(string url) { var xpComUri = IOService.CreateNsIUri(url); return(_imgCache.Instance.FindEntryProperties(xpComUri).Wrap((x) => new Properties(x))); }