Exemple #1
0
 bool ILifeSpanHandler.DoClose(IWebBrowser browserControl, IBrowser browser)
 {
     //The default CEF behaviour (return false) will send a OS close notification (e.g. WM_CLOSE).
     //See the doc for this method for full details.
     //return true here to handle closing yourself (no WM_CLOSE will be sent).
     return true;
 }
Exemple #2
0
        void IDisplayHandler.OnFullscreenModeChange(IWebBrowser browserControl, IBrowser browser, bool fullscreen)
        {
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;

            chromiumWebBrowser.InvokeOnUiThreadIfRequired(() =>
            {
                if (fullscreen)
                {
                    parent = chromiumWebBrowser.Parent;

                    parent.Controls.Remove(chromiumWebBrowser);

                    fullScreenForm = new Form();
                    fullScreenForm.FormBorderStyle = FormBorderStyle.None;
                    fullScreenForm.WindowState = FormWindowState.Maximized;

                    fullScreenForm.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.ShowDialog(parent.FindForm());
                }
                else
                {
                    fullScreenForm.Controls.Remove(chromiumWebBrowser);

                    parent.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.Close();
                    fullScreenForm.Dispose();
                    fullScreenForm = null;
                }
            });
        }
 public bool OnBeforeBrowse(IWebBrowser browser, IRequest request, bool isRedirect)
 {
     if (request.Url.ToLower() != "http://www.google.com/")
     {
         try
         {
             if (PluginSettings.Instance.OpenInInternalBrowser)
             {
                 _parent.BeginInvoke((Action)(() =>
                 {
                     Utils.BasePlugin.Plugin p = Utils.PluginSupport.PluginByName(_core, "GlobalcachingApplication.Plugins.Browser.BrowserPlugin") as Utils.BasePlugin.Plugin;
                     if (p != null)
                     {
                         var m = p.GetType().GetMethod("OpenNewBrowser");
                         m.Invoke(p, new object[] { request.Url.ToString() });
                     }
                 }));
             }
             else
             {
                 System.Diagnostics.Process.Start(request.Url.ToString());
             }
             return true;
         }
         catch
         {
         }
     }
     return false;
 }
 void IRequestHandler.OnResourceResponse(IWebBrowser browser, string url, int status, string statusText, string mimeType, WebHeaderCollection headers)
 {
     if (url.Contains("battlelog-web-plugins"))
     {
         this.InitUpdateWebPlugin(url);
     }
 }
        public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
        {
            if (parameters.IsEditable)
                return true;

            return false;
        }
        public ChatDocument(IInlineUploadViewFactory factory, IWebBrowser browser, IPasteViewFactory pasteViewFactory)
        {
            _factory = factory;
            _browser = browser;
            _pasteViewFactory = pasteViewFactory;
            _handlers = new Dictionary<MessageType, Action<Message, User, Paragraph>>
                {
                    {MessageType.TextMessage, FormatUserMessage},
                    {MessageType.TimestampMessage, FormatTimestampMessage},
                    {MessageType.LeaveMessage, FormatLeaveMessage},
                    {MessageType.KickMessage, FormatKickMessage},
                    {MessageType.PasteMessage, FormatPasteMessage},
                    {MessageType.EnterMessage, FormatEnterMessage},
                    {MessageType.UploadMessage, FormatUploadMessage},
                    {MessageType.TweetMessage, FormatTweetMessage},
                    {MessageType.AdvertisementMessage, FormatAdvertisementMessage},
                    {MessageType.TopicChangeMessage, FormatTopicChangeMessage}

                };

            FontSize = 14;
            FontFamily = new FontFamily("Segoe UI");

            AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(NavigateToLink));
        }
        internal ContinuousConsoleRunner(
            ILogger logger,
            IEventSubscriptionManager eventSubscriptionManager,
            IEventPublisher eventPublisher ,
            string xapPath,
            ClientTestRunConfiguration clientTestRunConfiguration,
            IWebServer webServer,
            IWebBrowser webBrowser)
        {
            _xapPath = xapPath;
            _webServer = webServer;
            _xapFileBuildChangedMonitor = new XapFileBuildChangedMonitor(eventPublisher, _xapPath);

            _continuousRunnerThread = new Thread(() =>
            {
                using (var runner = new ContinuousTestRunner(logger, eventSubscriptionManager, eventPublisher, webBrowser, clientTestRunConfiguration, _xapPath))
                {
                    string line;
                    while (!(line = System.Console.ReadLine()).Equals("exit", StringComparison.OrdinalIgnoreCase))
                    {
                        runner.ForceFilteredTest(line);
                    }
                }
            });
        }
 public bool OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
 {
     Assembly asm = Assembly.GetExecutingAssembly();
     string MIME = "application/octet-stream";
     string requestURL = requestResponse.Request.Url, _lower = requestURL.ToLower();
     if ((_lower == manifestProtocol + "postdata" || _lower.StartsWith(manifestProtocol + "postdata?"))
         && PostContentReceived != null)
         PostContentReceived(browser, new ContentReceivedEventArgs(requestResponse.Request.Body));
     if (requestURL.Contains('?'))
         requestURL = requestURL.Substring(0, requestURL.IndexOf('?'));
     _lower = requestURL.ToLower();
     if (_lower.StartsWith(manifestProtocol)) {
         if (_lower.EndsWith(".html") || _lower.EndsWith(".htm"))
             MIME = "text/html";
         else if (_lower.EndsWith(".css"))
             MIME = "text/css";
         else if (_lower.EndsWith(".js"))
             MIME = "text/javascript";
         else if (_lower.EndsWith(".txt"))
             MIME = "text/plain";
         requestURL = requestURL.Substring(manifestProtocol.Length);
         if (requestURL == "res/lang.js")
             requestURL = strings.script_path;
         requestURL = requestURL.Replace('/', '.').Replace(' ', '_');
         try {
             requestResponse.RespondWith(asm.GetManifestResourceStream(asm.GetName().Name + "." + requestURL), MIME);
         } catch { }
     }
     return false;
 }
 void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
 {
     //Removing existing menu item
     model.Remove(CefMenuCommand.ViewSource); // Remove "View Source" option
     model.Remove(CefMenuCommand.Print);
     //Add new custom menu items
     model.AddItem((CefMenuCommand)ViewSource, "View Page Source");
     if (parameters.TypeFlags.HasFlag(ContextMenuType.Media) && parameters.HasImageContents)
     {
         if(OsirtHelper.HasJpegExtension(parameters.SourceUrl))
         {
             model.AddItem((CefMenuCommand)ViewImageExifData, "View image EXIF data");
         }
         model.AddItem((CefMenuCommand)MenuSaveImage, "Save image");
         model.AddItem((CefMenuCommand)CopyImgLocation, "Copy image location to clipboard");
         model.AddItem((CefMenuCommand)ReverseImageSearch, "Reverse image search using TinEye");
     }
     if(OsirtHelper.IsOnYouTube(browserControl.Address))
     {
         model.AddItem((CefMenuCommand)SaveYouTubeVideo, "Extract YouTube video");
     }
     if (OsirtHelper.IsOnFacebook(browserControl.Address))
     {
         model.AddItem((CefMenuCommand)ViewFacebookId, "Show Facebook profile ID");
     }
     if(!string.IsNullOrEmpty(parameters.UnfilteredLinkUrl))
     {
         model.AddItem((CefMenuCommand)26501, "Open link in new tab");
     }
 }
        public IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request)
        {
            // Every time we request the main GPM page allow another JS injection
            if (Regex.Match(request.Url, @"^http[s]?://play\.google\.com/music/listen", RegexOptions.IgnoreCase).Success)
            {
                firstJSOnly = true;
            }
            if (Regex.Match(request.Url, @"\.js", RegexOptions.IgnoreCase).Success && Regex.Match(request.Url, @"http", RegexOptions.IgnoreCase).Success && firstJSOnly)
            {
                firstJSOnly = false;
                using (WebClient webClient = new WebClient())
                {
                    // These are the JS files to inject into GPM
                    string custom_interface = Properties.Resources.custom_interface;

                    return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes(
                        webClient.DownloadString(request.Url) + ";window.onload=function(){csharpinterface.showApp();};document.addEventListener('DOMContentLoaded', function () {" +
                            "window.OBSERVER = setInterval(function() { if (document.getElementById('material-vslider')) { clearInterval(window.OBSERVER); " +
                            Properties.Resources.gmusic_min + Properties.Resources.gmusic_theme_min + Properties.Resources.gmusic_mini_player_min +
                            this.getInitCode() +
                            custom_interface +
                        "}}, 10);});")), webClient.ResponseHeaders["Content-Type"]);
                }
            }
            return null;
        }
        CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {
            using (callback)
            {
                if (request.Method == "POST")
                {
                    using (var postData = request.PostData)
                    {
                        var elements = postData.Elements;

                        var charSet = request.GetCharSet();

                        foreach (var element in elements)
                        {
                            if (element.Type == PostDataElementType.Bytes)
                            {
                                var body = element.GetBody(charSet);
                            }
                        }
                    }
                }

                //Note to Redirect simply set the request Url
                //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
                //{
                //    request.Url = "https://github.com/";
                //}

                //Callback in async fashion
                //callback.Continue(true);
                //return CefReturnValue.ContinueAsync;
            }
            
            return CefReturnValue.Continue;
        }
 bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request,
     bool isRedirect) {
     if (!frame.IsMain || CommonUrls.IsWithSixUrl(request.Url) || IsAuthUrl(new Uri(request.Url)))
         return false;
     OpenInSystemBrowser(request.Url);
     return true;
 }
        CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame,
            IRequest request, IRequestCallback callback) {
            if (CommonUrls.IsWithSixUrl(request.Url)) {
                var headers = request.Headers;
                headers[Common.ClientHeader] = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString();
                headers[Common.ClientHeaderV] = Common.App.ProductVersion;
                request.Headers = headers;
            }

            return CefReturnValue.Continue;
            //Example of how to set Referer
            // Same should work when setting any header
            // For this example only set Referer when using our custom scheme
            var url = new Uri(request.Url);
            if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName
            {
                var headers = request.Headers;
                headers["Referer"] = "http://google.com";

                request.Headers = headers;
            }

            //NOTE: If you do not wish to implement this method returning false is the default behaviour
            // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
            //callback.Dispose();
            //return false;

            //NOTE: When executing the callback in an async fashion need to check to see if it's disposed
            if (!callback.IsDisposed) {
                using (callback) {
                    if (request.Method == "POST") {
                        using (var postData = request.PostData) {
                            if (postData != null) {
                                var elements = postData.Elements;

                                var charSet = request.GetCharSet();

                                foreach (var element in elements) {
                                    if (element.Type == PostDataElementType.Bytes) {
                                        var body = element.GetBody(charSet);
                                    }
                                }
                            }
                        }
                    }

                    //Note to Redirect simply set the request Url
                    //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    request.Url = "https://github.com/";
                    //}

                    //Callback in async fashion
                    //callback.Continue(true);
                    //return CefReturnValue.ContinueAsync;
                }
            }

            return CefReturnValue.Continue;
        }
Exemple #14
0
 public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, string acceptLang, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
 {
     switch (dialogType)
     {
         case CefJsDialogType.Alert:
             MessageBox.Show(messageText);
             suppressMessage = true;
             return false;
         case CefJsDialogType.Confirm:
             var dr = MessageBox.Show(messageText, "提示", MessageBoxButton.YesNo);
             if (dr == MessageBoxResult.Yes)
                 callback.Continue(true);
             else
                 callback.Continue(false);
             suppressMessage = false;
             return true;
         case CefJsDialogType.Prompt:
             MessageBox.Show("系统不支持prompt形式的提示框", "UTMP系统提示");
             break;
     }
     //如果suppressMessage被设置为true,并且函数返回值为false,将阻止页面打开JS的弹出窗口。
     //如果suppressMessage被设置为false,并且函数返回值也是false,页面将会打开这个JS弹出窗口。
     suppressMessage = true;
     return false;
 }
Exemple #15
0
 /// <inheritdoc/>>
 public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
 {
     bool result = false;
     Debug.WriteLine(String.Format("OnKeyEvent: KeyType: {0} 0x{1:X} Modifiers: {2}", type, windowsKeyCode, modifiers));
     // TODO: Handle MessageNeeded cases here somehow.
     return result;
 }
        public bool OnBeforePopup(IWebBrowser rpBrowserControl, IBlinkBrowser rpBrowser, IFrame rpFrame, string rpTargetUrl, string rpTargetFrameName, WindowOpenDisposition rpTargetDisposition, bool rpUserGesture, IPopupFeatures rpPopupFeatures, IWindowInfo rpWindowInfo, IBrowserSettings rpBrowserSettings, ref bool rrpNoJavascriptAccess, out IWebBrowser ropNewBrowser)
        {
            rpBrowserControl.Load(rpTargetUrl);

            ropNewBrowser = rpBrowserControl;
            return true;
        }
 bool ILifeSpanHandler.OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
 {
     newBrowser = null;
     //browserControl.Load(targetUrl);
     OpenInNewTab?.Invoke(this, new NewTabEventArgs(targetUrl)); //this breaks when there are multiple window.open calls from JS.
     return true;
 }
Exemple #18
0
        public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
        {
            Console.WriteLine("Context menu opened");
            Console.WriteLine(parameters.MisspelledWord);

            return true;
        }
        public IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request)
        {
            // Every time we request the main GPM page allow another JS injection
            if (Regex.Match(request.Url, @"^http[s]?://play\.google\.com/music/listen", RegexOptions.IgnoreCase).Success)
            {
                firstJSOnly = true;
            }
            if (Regex.Match(request.Url, @"\.js", RegexOptions.IgnoreCase).Success && Regex.Match(request.Url, @"http", RegexOptions.IgnoreCase).Success && firstJSOnly)
            {
                firstJSOnly = false;
                using (WebClient webClient = new WebClient())
                {
                    // These are the JS files to inject into GPM
                    string dark_theme = Google_Play_Music.Properties.Resources.dark_theme;
                    string custom_interface = Google_Play_Music.Properties.Resources.custom_interface;
                    string mini_player = Google_Play_Music.Properties.Resources.mini_player;

                    Color c = Properties.Settings.Default.CustomColor;
                    string RGB = "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
                    string custom_color = ";(function() {window.CustomColor = '" + RGB + "';})();";

                    bool controlsOnHover = Properties.Settings.Default.HoverControls;
                    string controlsOnHoverJS = ";(function() {window.hoverControls = " + controlsOnHover.ToString().ToLower() + ";})();";

                    string setInitialZoomJS = ";(function() {csharpinterface.setInitialZoom();})();";

                    return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes(webClient.DownloadString(request.Url) + ";" + custom_color + controlsOnHoverJS + setInitialZoomJS + dark_theme + custom_interface + mini_player)), webClient.ResponseHeaders["Content-Type"]);
                }
            }
            return null;
        }
        bool IGeolocationHandler.OnRequestGeolocationPermission(IWebBrowser browserControl, IBrowser browser, string requestingUrl, int requestId, IGeolocationCallback callback)
        {
            //You can execute the callback inline
            //callback.Continue(true);
            //return true;

            //You can execute the callback in an `async` fashion
            //Open a message box on the `UI` thread and ask for user input.
            //You can open a form, or do whatever you like, just make sure you either
            //execute the callback or call `Dispose` as it's an `unmanaged` wrapper.
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;
            chromiumWebBrowser.Dispatcher.BeginInvoke((Action)(() =>
            {
                //Callback wraps an unmanaged resource, so we'll make sure it's Disposed (calling Continue will also Dipose of the callback, it's safe to dispose multiple times).
                using (callback)
                {
                    var result = MessageBox.Show(String.Format("{0} wants to use your computer's location.  Allow?  ** You must set your Google API key in CefExample.Init() for this to work. **", requestingUrl), "Geolocation", MessageBoxButton.YesNo);

                    //Execute the callback, to allow/deny the request.
                    callback.Continue(result == MessageBoxResult.Yes);
                }
            }));

            //Yes we'd like to hadle this request ourselves.
            return true;
        }
        public bool OnJSPrompt(IWebBrowser browser, string url, string message, string defaultValue, out bool retval, out string result)
        {
            retval = false;
            result = null;

            return false;
        }
            public bool OnBeforePopup(IWebBrowser c_web, string sourceUrl, string targetUrl, ref int x, ref int y, ref int width, ref int height)
            {
                if (targetUrl.Contains("create#instanceId") == false && Properties.Settings.Default.ctrlsetting == 0 && targetUrl.Contains("pages") == true || targetUrl.Contains("create#instanceId") == false && Properties.Settings.Default.ctrlsetting == 0 && targetUrl.Contains("numbers") == true || targetUrl.Contains("create#instanceId") == false && Properties.Settings.Default.ctrlsetting == 0 && targetUrl.Contains("keynote") == true)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        DelayAction(500, new Action(() =>
                        {
                            pressenter();
                        }));

                        DelayAction(600, new Action(() =>
                        {
                            var popupmain = new popupmain(targetUrl);
                            popupmain.Show();
                        }));
                    }));

                    return true;
                }
                else
                {
                    return false;
                }
            }
        public bool OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
        {
            /*
            * Called on the IO thread before a resource is loaded. To allow the resource to load normally return false.
            * To redirect the resource to a new url populate the |redirectUrl| value and return false.
            * To specify data for the resource return a CefStream object in |resourceStream|, use the |response| object to set mime type,
            * HTTP status code and optional header values, and return false. To cancel loading of the resource return true.
            * Any modifications to |request| will be observed. If the URL in |request| is changed and |redirectUrl| is also set,
            * the URL in |request| will be used.
            */
            if (requestResponse.Request.Url.StartsWith(m_InternalDomain))
            {
                var requestUri = requestResponse.Request.Url.Replace(m_InternalDomain, String.Empty);

                HttpResponseMessage response = m_Server(requestUri);

                //TODO: Copy to separate memory stream so we can dispose of parent HttpResponseMessage
                var responseContent = response.Content.ReadAsStreamAsync().Result;

                var responseHeaders = response.Headers.ToDictionary(x => x.Key, x => x.Value.First());

                var responseMime = response.IsSuccessStatusCode
                    ? response.Content.Headers.ContentType.MediaType
                    : "text/html"; //CEFSharp demands a MimeType of some kind...

                requestResponse.RespondWith(responseContent, responseMime, String.Empty, (int) response.StatusCode, responseHeaders);

            }

            return false;
        }
 public bool OnBeforePopup(IWebBrowser browser, string url, ref int x, ref int y, ref int width, ref int height)
 {
     try {
         Process.Start(url);
     } catch { }
     return true;
 }
Exemple #25
0
		private static BindingInfo getBinding (IWebBrowser control)
		{
			if (!boundControls.ContainsKey (control))
				return null;
			BindingInfo info = boundControls[control] as BindingInfo;
			return info;
		}
Exemple #26
0
 bool IContextMenuHandler.OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, int commandId, CefEventFlags eventFlags)
 {
     if (commandId == (int)CefMenuCommand.Reload)
     {
         browser.Reload();
     }
     return false;
 }
Exemple #27
0
        void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
        {
            Console.WriteLine("Context menu opened");
            Console.WriteLine(parameters.MisspelledWord);

            //To disable context mode then clear
            // model.Clear();
        }
Exemple #28
0
        bool IRequestHandler.GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
        {
            //NOTE: If you do not wish to implement this method returning false is the default behaviour
            // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.

            callback.Dispose();
            return false;
        }
        public bool OnJSBeforeUnload(IWebBrowser browser, string message, bool isReload, out bool allowUnload)
        {
            //NOTE: Setting allowUnload to false will cancel the unload request
            allowUnload = false;

            //NOTE: Returning false will trigger the default behaviour, you need to return true to handle yourself.
            return false;
        }
 IResourceHandler IResourceHandlerFactory.GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request)
 {
     if (request.Url.Contains("zeldaADPCM5bit.swf"))
     {
         return new FlashResourceHandler();
     }
     return null;
 }
        /// <summary>
        /// Change the ZoomLevel to the specified value. Can be set to 0.0 to clear the zoom level.
        /// </summary>
        /// <remarks>
        /// If called on the CEF UI thread the change will be applied immediately.
        /// Otherwise, the change will be applied asynchronously on the CEF UI thread.
        /// The CEF UI thread is different to the WPF/WinForms UI Thread
        /// </remarks>
        /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
        /// <param name="zoomLevel">zoom level</param>
        public static void SetZoomLevel(this IWebBrowser browser, double zoomLevel)
        {
            var cefBrowser = browser.GetBrowser();

            cefBrowser.SetZoomLevel(zoomLevel);
        }
Exemple #32
0
 /// <summary>
 /// Called when an external drag event enters the browser window.
 /// </summary>
 /// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
 /// <param name="browser">the browser object</param>
 /// <param name="dragData">contains the drag event data</param>
 /// <param name="mask">represents the type of drag operation</param>
 /// <returns>Return false for default drag handling behavior or true to cancel the drag event. </returns>
 bool IDragHandler.OnDragEnter(IWebBrowser chromiumWebBrowser, IBrowser browser, IDragData dragData, DragOperationsMask mask)
 {
     return(OnDragEnter(chromiumWebBrowser, browser, dragData, mask));
 }
Exemple #33
0
 /// <summary>
 /// Called whenever draggable regions for the browser window change.
 /// These can be specified using the '-webkit-app-region: drag/no-drag' CSS-property.
 /// If draggable regions are never defined in a document this method will also never be called.
 /// If the last draggable region is removed from a document this method will be called with an empty IList.
 /// </summary>
 /// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
 /// <param name="browser">the browser object</param>
 /// <param name="frame">The frame</param>
 /// <param name="regions">List of <see cref="DraggableRegion"/> objects or null if last region was removed.</param>
 void IDragHandler.OnDraggableRegionsChanged(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IList <DraggableRegion> regions)
 {
     OnDraggableRegionsChanged(chromiumWebBrowser, browser, frame, regions);
 }
Exemple #34
0
 /// <summary>
 /// Called whenever draggable regions for the browser window change.
 /// These can be specified using the '-webkit-app-region: drag/no-drag' CSS-property.
 /// If draggable regions are never defined in a document this method will also never be called.
 /// If the last draggable region is removed from a document this method will be called with an empty IList.
 /// </summary>
 /// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
 /// <param name="browser">the browser object</param>
 /// <param name="frame">The frame</param>
 /// <param name="regions">List of <see cref="DraggableRegion"/> objects or null if last region was removed.</param>
 protected virtual void OnDraggableRegionsChanged(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IList <DraggableRegion> regions)
 {
 }
 /// <summary>
 /// Evaluate some Javascript code in the context of this WebBrowser. The script will be executed asynchronously and the
 /// method returns a Task encapsulating the response from the Javascript
 /// This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)
 /// </summary>
 /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
 /// <param name="methodName">The javascript method name to execute</param>
 /// <param name="args">the arguments to be passed as params to the method</param>
 /// <returns><see cref="Task{JavascriptResponse}"/> that can be awaited to perform the script execution</returns>
 public static Task <JavascriptResponse> EvaluateScriptAsync(this IWebBrowser browser, string methodName, params object[] args)
 {
     return(browser.EvaluateScriptAsync(null, methodName, args));
 }
Exemple #36
0
 public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
 {
     return true;
 }
Exemple #37
0
        public bool GetAuthCredentials(IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy,
            string host, int port, string realm, string scheme, IAuthCallback callback)
        {

            return false;
        }
        /// <summary>
        /// Execute some Javascript code in the context of this WebBrowser. As the method name implies, the script will be
        /// executed asynchronously, and the method therefore returns before the script has actually been executed.
        /// This simple helper extension will encapsulate params in single quotes (unless int, uint, etc)
        /// </summary>
        /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
        /// <param name="methodName">The javascript method name to execute</param>
        /// <param name="args">the arguments to be passed as params to the method. Args are encoded using <see cref="EncodeScriptParam"/>,
        /// you can provide a custom implementation if you require a custom implementation</param>
        public static void ExecuteScriptAsync(this IWebBrowser browser, string methodName, params object[] args)
        {
            var script = GetScriptForJavascriptMethodWithArgs(methodName, args);

            browser.ExecuteScriptAsync(script);
        }
 /// <summary>
 /// Registers and loads a <see cref="ResourceHandler"/> that represents the HTML content.
 /// </summary>
 /// <remarks>
 /// `Cef` Native `LoadHtml` is unpredictable and only works sometimes, this method wraps
 /// the provided HTML in a <see cref="ResourceHandler"/> and loads the provided url using
 /// the <see cref="IWebBrowser.Load"/> method.
 /// Defaults to using <see cref="Encoding.UTF8"/> for character encoding
 /// The url must start with a valid schema, other uri's such as about:blank are invalid
 /// A valid example looks like http://test/page
 /// </remarks>
 /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
 /// <param name="html">The HTML content.</param>
 /// <param name="url">The URL that will be treated as the address of the content.</param>
 /// <returns>returns false if the Url was not successfully parsed into a Uri</returns>
 public static bool LoadHtml(this IWebBrowser browser, string html, string url)
 {
     return(browser.LoadHtml(html, url, Encoding.UTF8));
 }
        /// <summary>
        /// Loads html as Data Uri
        /// See https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs for details
        /// If base64Encode is false then html will be Uri encoded
        /// </summary>
        /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
        /// <param name="html">Html to load as data uri.</param>
        /// <param name="base64Encode">if true the html string will be base64 encoded using UTF8 encoding.</param>
        public static void LoadHtml(this IWebBrowser browser, string html, bool base64Encode = false)
        {
            var htmlString = new HtmlString(html, base64Encode);

            browser.Load(htmlString.ToDataUriString());
        }
 public static void RegisterAsyncJsObject(this IWebBrowser webBrowser, string name, object objectToBind, BindingOptions options = null)
 {
     throw new NotImplementedException("This method has been removed, see https://github.com/cefsharp/CefSharp/issues/2990 for details on migrating your code.");
 }
        public static void SetAsPopup(this IWebBrowser browser)
        {
            var internalBrowser = (IWebBrowserInternal)browser;

            internalBrowser.HasParent = true;
        }
 /// <summary>
 /// Reloads the page being displayed. This method will use data from the browser's cache, if available.
 /// </summary>
 public static void Reload(this IWebBrowser browser)
 {
     browser.Reload(false);
 }
Exemple #44
0
 public bool OnProtocolExecution(IWebBrowser browserControl, IBrowser browser, string url)
 {
     return false;
 }
Exemple #45
0
        public void OnPluginCrashed(IWebBrowser browserControl, IBrowser browser, string pluginPath)
        {

        }
Exemple #46
0
 public bool OnSelectClientCertificate(IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback)
 {
     return true;
 }
Exemple #47
0
 public bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture)
 {
     return false;
 }
 void IRenderProcessMessageHandler.OnContextReleased(IWebBrowser browserControl, IBrowser browser, IFrame frame)
 {
     //The V8Context is about to be released, use this notification to cancel any long running tasks your might have
 }
Exemple #49
0
        public bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response)
        {
            return false; ;

        }
        /// <summary>
        /// Shortcut method to get the browser IBrowserHost
        /// </summary>
        /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
        /// <returns>browserHost or null</returns>
        public static IBrowserHost GetBrowserHost(this IWebBrowser browser)
        {
            var cefBrowser = browser.GetBrowser();

            return(cefBrowser == null ? null : cefBrowser.GetHost());
        }
        void IRenderProcessMessageHandler.OnFocusedNodeChanged(IWebBrowser browserControl, IBrowser browser, IFrame frame, IDomNode node)
        {
            var message = node == null ? "lost focus" : node.ToString();

            Console.WriteLine("OnFocusedNodeChanged() - " + message);
        }
Exemple #52
0
        public void OnResourceRedirect(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl)
        {

        }
 public bool OnDragEnter(IWebBrowser browser, IDragData dragData, DragOperationsMask mask)
 {
     return(false);
 }
Exemple #54
0
        public void OnResourceLoadComplete(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
        {

        }
Exemple #55
0
        public void OnRenderViewReady(IWebBrowser browserControl, IBrowser browser)
        {

        }
Exemple #56
0
        public void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status)
        {

        }
Exemple #57
0
 /// <summary>
 /// Called when an external drag event enters the browser window.
 /// </summary>
 /// <param name="chromiumWebBrowser">the ChromiumWebBrowser control</param>
 /// <param name="browser">the browser object</param>
 /// <param name="dragData">contains the drag event data</param>
 /// <param name="mask">represents the type of drag operation</param>
 /// <returns>Return false for default drag handling behavior or true to cancel the drag event. </returns>
 protected virtual bool OnDragEnter(IWebBrowser chromiumWebBrowser, IBrowser browser, IDragData dragData, DragOperationsMask mask)
 {
     return(false);
 }
Exemple #58
0
 public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
 {
     return false;
 }
        /// <summary>
        /// Evaluate some Javascript code in the context of this WebBrowser using the specified timeout. The script will be executed asynchronously and the
        /// method returns a Task encapsulating the response from the Javascript
        /// This simple helper extension will encapsulate params in single quotes (unless int, uint, etc).
        /// </summary>
        /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
        /// <param name="timeout">The timeout after which the Javascript code execution should be aborted.</param>
        /// <param name="methodName">The javascript method name to execute</param>
        /// <param name="args">the arguments to be passed as params to the method. Args are encoded using <see cref="EncodeScriptParam"/>,
        /// you can provide a custom implementation if you require a custom implementation</param>
        /// <returns><see cref="Task{JavascriptResponse}"/> that can be awaited to perform the script execution</returns>
        public static Task <JavascriptResponse> EvaluateScriptAsync(this IWebBrowser browser, TimeSpan?timeout, string methodName, params object[] args)
        {
            var script = GetScriptForJavascriptMethodWithArgs(methodName, args);

            return(browser.EvaluateScriptAsync(script, timeout));
        }
        /// <summary>
        /// Asynchronously gets the current Zoom Level.
        /// </summary>
        public static Task <double> GetZoomLevelAsync(this IWebBrowser browser)
        {
            var cefBrowser = browser.GetBrowser();

            return(cefBrowser.GetZoomLevelAsync());
        }