public static nsIXULWindow CreateTopLevelWindow(nsIXULWindow aParent, nsIURI aUrl, uint aChromeMask, int aInitialWidth, int aInitialHeight) { // TODO: add a nsITabParent return(_appShellService.Instance.CreateTopLevelWindow(aParent, aUrl, aChromeMask, aInitialWidth, aInitialHeight, null)); }
bool nsIWebProgressListener2.OnRefreshAttempted(nsIWebProgress aWebProgress, nsIURI aRefreshURI, int aMillis, bool aSameURI) { if (!_isListening) { return(true); } var evnt = _onNavigatingCallback; if (evnt == null) { return(true); } Uri destUri = new Uri(nsString.Get(aRefreshURI.GetSpecAttribute)); bool cancel = false; using (var domWindow = aWebProgress.GetDOMWindowAttribute().Wrap(x => new GeckoWindow(x))) { GeckoNavigatingEventArgs ea = new GeckoNavigatingEventArgs(destUri, domWindow); evnt(ea); cancel = ea.Cancel; } return(!cancel); }
public void OnHistoryNewEntry(nsIURI aNewURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; //if (b != null) // b.OnHistoryNewEntry(aNewURI); throw new NotImplementedException(); }
public bool OnHistoryGotoIndex(int aIndex, nsIURI aGotoURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) return b.OnHistoryGotoIndex(aIndex, aGotoURI); else return false; }
public bool OnHistoryReload(nsIURI aReloadURI, uint aReloadFlags) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) return b.OnHistoryReload(aReloadURI, aReloadFlags); else return false; }
public bool OnHistoryGoForward(nsIURI aForwardURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) return b.OnHistoryGoForward(aForwardURI); else return false; }
public bool OnHistoryGoBack(nsIURI aBackURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) return b.OnHistoryGoBack(aBackURI); else return false; }
public static nsIChannel NewChannelFromUriWithProxyFlags(nsIURI uri, nsIURI proxyUri, uint proxyFlags) { #if PORTFF60 //return _service.Instance.NewChannelFromURIWithProxyFlags(uri, proxyUri, proxyFlags); #else throw new NotImplementedException(); #endif }
public void OnHistoryNewEntry(nsIURI aNewURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) { b.OnHistoryNewEntry(aNewURI); } }
void nsIWebProgressListener.OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation) { Trace.TraceInformation("nsIWebProgressListener.OnLocationChange"); var e = new LocationChangeEventArgs(aLocation.ToUri()); Events.Raise(EventKey.LocationChange, e); if (e.Cancel && (aRequest != null)) { aRequest.Cancel(nsResult.NS_BINDING_ABORTED); } }
public static Uri ToUri(this nsIURI value) { if (value == null) { return(null); } var spec = nsString.Get(value.GetSpecAttribute); Uri result; return(Uri.TryCreate(spec, UriKind.Absolute, out result) ? result : null); }
public void UnregisterStyleSheet(string sheetURI, uint type) { nsIIOService ios = Xpcom.GetService <nsIIOService>("@mozilla.org/network/io-service;1"); ios = Xpcom.QueryInterface <nsIIOService>(ios); nsIURI ssURI = ios.NewURI(new nsAUTF8String(sheetURI), null, null); if (StyleSheetService.sheetRegistered(ssURI, type)) { StyleSheetService.unregisterSheet(ssURI, type); } }
bool nsIURIContentListener.onStartURIOpen (nsIURI aURI) { NavigationRequestedEventHandler eh = (NavigationRequestedEventHandler) (Events[WebBrowser.NavigationRequestedEvent]); if (eh != null) { AsciiString uri = new Mono.Mozilla.AsciiString (""); aURI.getSpec (uri.Handle); NavigationRequestedEventArgs args = new NavigationRequestedEventArgs (uri.ToString ()); eh (this, args); return args.Cancel; } return true; }
public bool IsStyleSheetRegistered(string sheetURI, uint type) { nsIIOService ios = Xpcom.GetService <nsIIOService>("@mozilla.org/network/io-service;1"); ios = Xpcom.QueryInterface <nsIIOService>(ios); nsIURI ssURI = ios.NewURI(new nsAUTF8String(sheetURI), null, null); if (!StyleSheetService.sheetRegistered(ssURI, type)) { return(false); } return(true); }
public bool OnHistoryGotoIndex(int aIndex, nsIURI aGotoURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) { return(b.OnHistoryGotoIndex(aIndex, aGotoURI)); } else { return(false); } }
public bool OnHistoryReload(nsIURI aReloadURI, uint aReloadFlags) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) { return(b.OnHistoryReload(aReloadURI, aReloadFlags)); } else { return(false); } }
public bool OnHistoryGoForward(nsIURI aForwardURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) { return(b.OnHistoryGoForward(aForwardURI)); } else { return(false); } }
public bool OnHistoryGoBack(nsIURI aBackURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) { return(b.OnHistoryGoBack(aBackURI)); } else { return(false); } }
bool nsIURIContentListener.onStartURIOpen(nsIURI aURI) { NavigationRequestedEventHandler eh = (NavigationRequestedEventHandler)(Events[WebBrowser.NavigationRequestedEvent]); if (eh != null) { AsciiString uri = new Mono.Mozilla.AsciiString(""); aURI.getSpec(uri.Handle); NavigationRequestedEventArgs args = new NavigationRequestedEventArgs(uri.ToString()); eh(this, args); return(args.Cancel); } return(true); }
Boolean nsIURIContentListener.OnStartURIOpen(nsIURI aURI) { String uriSpec = XpcomStringHelper.Get(aURI.GetSpec); Trace.TraceInformation("nsIURIContentListener.OnStartURIOpen: \"{0}\"", uriSpec); Uri uri; if (!Uri.TryCreate(uriSpec, UriKind.Absolute, out uri)) { Trace.TraceWarning("nsIURIContentListener.OnStartURIOpen: Can't create URI"); return false; } var e = new StartUriOpenEventArgs(uri); Events.Raise(EventKey.StartUriOpen, e); Trace.TraceInformation("nsIURIContentListener.OnStartURIOpen: {0}", e.Cancel ? "canceled" : "allowed"); return e.Cancel; }
nsIWebBrowserChrome nsIWindowCreator2.CreateChromeWindow2(nsIWebBrowserChrome parent, UInt32 chromeFlags, UInt32 contextFlags, nsIURI uri, out Boolean cancel) { Trace.TraceInformation("nsIWindowCreator2.CreateChromeWindow2"); var browser = parent as WebBrowser; if (browser == null) { Trace.TraceWarning("Can't get Browser object"); cancel = true; return null; } var e = new CreateWindowEventArgs((ChromeFlags)chromeFlags, uri.ToUri()); browser.Events.Raise(EventKey.CreateWindow, e); cancel = e.Cancel; return !e.Cancel ? e.Window : null; }
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(); } } } }
/// <summary> /// Navigates to the specified URL using the given load flags, referrer and post data /// In order to find out when Navigate has finished attach a handler to NavigateFinishedNotifier.NavigateFinished. /// </summary> /// <param name="url">The url to navigate to. If the url is empty or null, the browser does not navigate and the method returns false.</param> /// <param name="loadFlags">Flags which specify how the page is loaded.</param> /// <param name="referrer">The referring URL, or null.</param> /// <param name="postData">post data and headers, or null</param> /// <param name="headers">headers, or null</param> /// <returns>true if Navigate started. false otherwise.</returns> public bool Navigate(string url, GeckoLoadFlags loadFlags, string referrer, MimeInputStream postData, MimeInputStream headers) { if (string.IsNullOrEmpty(url)) { return(false); } // added these from http://code.google.com/p/geckofx/issues/detail?id=5 so that it will work even if browser isn't currently shown //if (!IsHandleCreated) CreateHandle(); //if (IsBusy) this.Stop(); // if (!IsHandleCreated) // throw new InvalidOperationException("Cannot call Navigate() before the window handle is created."); // WebNav.LoadURI throws an exception if we try to open a file that doesn't exist... Uri created; if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out created) && created.IsAbsoluteUri && created.IsFile) { if (!File.Exists(created.LocalPath) && !Directory.Exists(created.LocalPath)) { return(false); } } nsIURI referrerUri = null; if (!string.IsNullOrEmpty(referrer)) { //referrerUri = Xpcom.GetService<nsIIOService>("@mozilla.org/network/io-service;1").NewURI(new nsAUTF8String(referrer), null, null); referrerUri = IOService.CreateNsIUri(referrer); } _webNav.LoadURI(url, (uint)loadFlags, referrerUri, postData != null ? postData._inputStream : null, headers != null ? headers._inputStream : null); return(true); }
// 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) } }
internal static nsIXULWindow CreateTopLevelWindow(nsIXULWindow aParent, nsIURI aUrl, uint aChromeMask, int aInitialWidth, int aInitialHeight) { return(_appShellService.Instance.CreateTopLevelWindow(aParent, aUrl, aChromeMask, aInitialWidth, aInitialHeight)); }
public void OnLocationChanged(nsIWebProgress progress, nsIRequest request, nsIURI uri) { #if debug OnGeneric("OnLocationChanged"); #endif }
internal nsURI(nsIURI instance) { this.Instance = instance; }
private void OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation, uint aFlags) { if (!_isListening) { return; } }
public static nsIChannel NewChannelFromUriWithProxyFlags(nsIURI uri,nsIURI proxyUri,uint proxyFlags) { return _service.Instance.NewChannelFromURIWithProxyFlags( uri, proxyUri, proxyFlags ); }
public void OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation, uint aFlags) { }
public void CheckLoadURIWithPrincipal(nsIPrincipal aPrincipal, nsIURI uri, uint flags) { }
private void OnLocationChange( nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation, uint aFlags ) { if (!_isListening) return; }
bool nsIWebProgressListener2.OnRefreshAttempted(nsIWebProgress aWebProgress, nsIURI aRefreshURI, int aMillis, bool aSameURI) { if ( !_isListening ) return true; var evnt = _onNavigatingCallback; if ( evnt == null ) return true; Uri destUri = Xpcom.ToUri(aRefreshURI); //aRefreshURI.ToUri(); bool cancel = false; using (var domWindow = ExtensionMethods.Wrap(aWebProgress.GetDOMWindowAttribute(), GeckoWindow.Create)) //aWebProgress.GetDOMWindowAttribute().Wrap(GeckoWindow.Create)) { GeckoNavigatingEventArgs ea = new GeckoNavigatingEventArgs(destUri, domWindow); evnt( ea ); cancel = ea.Cancel; } return !cancel; }
public static nsIChannel NewChannelFromUriWithProxyFlags(nsIURI uri, nsIURI proxyUri, uint proxyFlags) { return(_service.Instance.NewChannelFromURIWithProxyFlags(uri, proxyUri, proxyFlags)); }
//public static nsURI Create(string url) //{ // return new nsURI(CreateNsIUri(url)); //} public static nsIChannel NewChannelFromUri(nsIURI uri) { return(_service.Instance.NewChannelFromURI(uri)); }
public void CheckSameOrigin(IntPtr aJSContext, nsIURI aTargetURI) { }
public void SetCookieString(nsIURI aURI, nsIPrompt aPrompt, string aCookie, nsIChannel aChannel) { // Console.WriteLine("SetCookieString {0} {1} {2} {3}", aURI, aPrompt, aCookie, aChannel); }
internal static Uri ToUri(nsIURI value ) { if (value == null) return null; var spec=nsString.Get( value.GetSpecAttribute ); Uri result; return Uri.TryCreate(spec, UriKind.Absolute, out result) ? result : null; }
public void CheckLoadURIFromScript(IntPtr cx, nsIURI uri) { }
public void NewURI_ValidUri_ReturnsValidUriInstance() { string referrer = "http://www.google.co.uk"; nsIURI result = m_instance.NewURI(new nsAUTF8String(referrer), null, null); }
bool nsISHistoryListener.OnHistoryGoForward(nsIURI aForwardURI) { //GeckoHistoryEventArgs e = new GeckoHistoryEventArgs(new Uri(nsString.Get(aForwardURI.GetSpecAttribute))); //OnHistoryGoForward(e); //return !e.Cancel; return false; }
public static nsIChannel NewChannelFromUri(nsIURI uri) { return _service.Instance.NewChannelFromURI(uri); }
bool nsISHistoryListener.OnHistoryGotoIndex(int aIndex, nsIURI aGotoURI) { //GeckoHistoryGotoIndexEventArgs e = new GeckoHistoryGotoIndexEventArgs(new Uri(nsString.Get(aGotoURI.GetSpecAttribute)), aIndex); //OnHistoryGotoIndex(e); //return !e.Cancel; return false; }
public void OnHistoryNewEntry(nsIURI aNewURI) { nsISHistoryListener b = (nsISHistoryListener)_browser; if (b != null) b.OnHistoryNewEntry(aNewURI); }
bool nsISHistoryListener.OnHistoryReload(nsIURI aReloadURI, uint aReloadFlags) { //GeckoHistoryEventArgs e = new GeckoHistoryEventArgs(new Uri(nsString.Get(aReloadURI.GetSpecAttribute))); //OnHistoryReload(e); //return !e.Cancel; return false; }
void nsIWebProgressListener2.OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation, uint aFlags) { OnLocationChange(aWebProgress, aRequest, aLocation, aFlags); }
public void OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation, uint flags) { nsIWebProgressListener b = (nsIWebProgressListener)_browser; if (b != null) { b.OnLocationChange(aWebProgress, aRequest, aLocation, flags); } }
public void OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation, uint aFlags) { throw new NotImplementedException(); }
public void OnHistoryNewEntry(nsIURI aNewURI, int aOldIndex) { throw new NotImplementedException(); }
bool nsISHistoryListener.OnHistoryGoForward(nsIURI aForwardURI) { GeckoHistoryEventArgs e = new GeckoHistoryEventArgs(new Uri(nsString.Get(aForwardURI.GetSpec))); OnHistoryGoForward(e); return !e.Cancel; }
public void SetCookieStringFromHttp(nsIURI aURI, nsIURI aFirstURI, nsIPrompt aPrompt, string aCookie, string aServerTime, nsIChannel aChannel) { // Console.WriteLine("SetCookieStringFromHttp {0} {1} {2} {3} {4} {5}", aURI, aFirstURI, aPrompt, aCookie, aServerTime, aChannel); }
bool nsISHistoryListener.OnHistoryGotoIndex(int aIndex, nsIURI aGotoURI) { GeckoHistoryGotoIndexEventArgs e = new GeckoHistoryGotoIndexEventArgs(new Uri(nsString.Get(aGotoURI.GetSpec)), aIndex); OnHistoryGotoIndex(e); return !e.Cancel; }
void nsISHistoryListener.OnHistoryNewEntry(nsIURI aNewURI) { OnHistoryNewEntry(new GeckoHistoryEventArgs(new Uri(nsString.Get(aNewURI.GetSpec)))); }
bool nsISHistoryListener.OnHistoryReload(nsIURI aReloadURI, uint aReloadFlags) { GeckoHistoryEventArgs e = new GeckoHistoryEventArgs(new Uri(nsString.Get(aReloadURI.GetSpec))); OnHistoryReload(e); return !e.Cancel; }
/// <summary> /// Initializes a new instance of <see cref="nsURI"/> from the given object, which must implement the unmanaged /// nsIURI interface. /// </summary> /// <param name="instance"></param> public nsURI(object instance) { this.Instance = (nsIURI)instance; }
void nsIWebProgressListener.OnLocationChange(nsIWebProgress aWebProgress, nsIRequest aRequest, nsIURI aLocation) { // make sure we're loading the top-level window nsIDOMWindow domWindow = aWebProgress.GetDOMWindow(); if (domWindow != null) { if (domWindow != domWindow.GetTop()) return; } Uri uri = new Uri(nsString.Get(aLocation.GetSpec)); OnNavigated(new GeckoNavigatedEventArgs(uri, new GeckoResponse(aRequest))); UpdateCommandStatus(); }
public void CheckSameOriginURI(nsIURI aSourceURI, nsIURI aTargetURI, bool reportError) { }