public CwbDOMVisitor(CefBrowser browser, CwbBusinStyle businID, string elementID, string elementValue)
 {
     _businID = businID;
     _elementID = elementID;
     _elementValue = elementValue;
     this.browser = browser;
 }
        protected override bool OnProcessMessageReceived(CefBrowser browser, CefProcessId sourceProcess, CefProcessMessage message)
        {
            Console.WriteLine("Client::OnProcessMessageReceived: SourceProcess={0}", sourceProcess);
            Console.WriteLine("Message Name={0} IsValid={1} IsReadOnly={2}", message.Name, message.IsValid, message.IsReadOnly);
            var arguments = message.Arguments;
            for (var i = 0; i < arguments.Count; i++)
            {
                var type = arguments.GetValueType(i);
                object value;
                switch (type)
                {
                    case CefValueType.Null: value = null; break;
                    case CefValueType.String: value = arguments.GetString(i); break;
                    case CefValueType.Int: value = arguments.GetInt(i); break;
                    case CefValueType.Double: value = arguments.GetDouble(i); break;
                    case CefValueType.Bool: value = arguments.GetBool(i); break;
                    default: value = null; break;
                }

                Console.WriteLine("  [{0}] ({1}) = {2}", i, type, value);
            }

            if (message.Name == "myMessage2" || message.Name == "myMessage3") return true;

            return false;
        }
 protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
 {
     bool res = false;
     if (!string.IsNullOrEmpty(targetUrl))
     {
         if (webBrowser.selfRequest != null)
         {
             CefRequest req = CefRequest.Create();
             req.FirstPartyForCookies = webBrowser.selfRequest.FirstPartyForCookies;
             req.Options = webBrowser.selfRequest.Options;
             /*CefPostData postData = CefPostData.Create();
             CefPostDataElement element = CefPostDataElement.Create();
             int index = targetUrl.IndexOf("?");
             string url = targetUrl.Substring(0, index);
             string data = targetUrl.Substring(index + 1);
             byte[] bytes = Encoding.UTF8.GetBytes(data);
             element.SetToBytes(bytes);
             postData.Add(element);
             */
             System.Collections.Specialized.NameValueCollection h = new System.Collections.Specialized.NameValueCollection();
             h.Add("Content-Type", "application/x-www-form-urlencoded");
             req.Set(targetUrl, webBrowser.selfRequest.Method, null, webBrowser.selfRequest.GetHeaderMap());
             webBrowser.selfRequest = req;
         }
         //webBrowser.selfRequest.Set(targetUrl, webBrowser.selfRequest.Method, webBrowser.selfRequest.PostData, webBrowser.selfRequest.GetHeaderMap());
         res = webBrowser.OnNewWindow(targetUrl);
         if (res)
             return res;
     }
     res = base.OnBeforePopup(browser, frame, targetUrl, targetFrameName, popupFeatures, windowInfo, ref client, settings, ref noJavascriptAccess);
     return res;
 }
 protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url)
 {
     if (frame.IsMain)
     {
         webBrowser.OnUrlChange(url);
     }
 }
 protected override bool OnPreKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr os_event, out bool isKeyboardShortcut)
 {
     if (keyEvent.EventType == CefKeyEventType.RawKeyDown)
         webBrowser.OnPreviewKeyDown(keyEvent.Modifiers == CefEventFlags.AltDown,
                                     keyEvent.Modifiers == CefEventFlags.ControlDown,
                                     keyEvent.Modifiers == CefEventFlags.ShiftDown,
                                     keyEvent.FocusOnEditableField, 
                                     keyEvent.WindowsKeyCode, 
                                     keyEvent.Character);
     return base.OnPreKeyEvent(browser, keyEvent, os_event, out isKeyboardShortcut);
 }
        protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
        {
            base.OnLoadEnd(browser, frame, httpStatusCode);
            webBrowser.OnLoadEnd();
            if (frame.IsMain)
            {
                //browser.SendProcessMessage(CefProcessId.Renderer, CefProcessMessage.Create("VisitorDocument"));
                webBrowser.OnDocumentCompleted();
            }

        }
 protected override bool OnContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams state, int commandId, CefEventFlags eventFlags)
 {
     foreach (CommandItem commItem in commandItems)
     {
         if (commItem.id == commandId)
         {
             commItem.item.PerformClick();
             break;
         }
     }
     return base.OnContextMenuCommand(browser, frame, state, commandId, eventFlags);
 }
 protected override void OnDownloadUpdated(CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback)
 {
     base.OnDownloadUpdated(browser, downloadItem, callback);
     webBrowser.OnDownloading(downloadItem.TotalBytes,
                              downloadItem.ReceivedBytes,
                              downloadItem.CurrentSpeed,
                              downloadItem.PercentComplete,
                              downloadItem.Url,
                              downloadItem.SuggestedFileName,
                              downloadItem.MimeType,
                              downloadItem.IsComplete,
                              downloadItem.IsInProgress);
     
 }
 public CwbElement(CefBrowser browser, string id, string tagName,
                   string value,
                   Boolean isElement,Boolean isEditable,
                   Boolean hasChildren,
                   string text, Boolean hasAttributes)
 {
     this.browserIdentifier = browser.Identifier;
     _id = id;
     _tagName = tagName;
     _value = value;
     _isElement = isElement;
     _isEditable = isEditable;
     _hasChildren = hasChildren;
     _text = text;
     _hasAttributes = hasAttributes;
 }
 protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
 {
     if (!webBrowser.menuVisible)
         model.Clear();
     int commandId = 1001;
     if (webBrowser.ContextMenu != null)
     {
         foreach (MenuItem item in webBrowser.ContextMenu.MenuItems)
         {
             if (item.Text == "-")
                 model.AddSeparator();
             else
                 model.AddItem(commandId, item.Text);
             CommandItem commandItem = new CommandItem();
             commandItem.id = commandId;
             commandItem.item = item;
             commandItems.Add(commandItem);
             commandId++;
         }
     }
     
     base.OnBeforeContextMenu(browser, frame, state, model);
     
 }
        protected override void OnStatusMessage(CefBrowser browser, string value)
        {

        }
 /// <summary>
 /// Called when the default implementation dialog is closed.
 /// </summary>
 protected abstract void OnDialogClosed(CefBrowser browser);
 /// <summary>
 /// Called when the browser begins loading a frame. The |frame| value will
 /// never be empty -- call the IsMain() method to check if this frame is the
 /// main frame. Multiple frames may be loading at the same time. Sub-frames may
 /// start or continue loading after the main frame load has ended. This method
 /// may not be called for a particular frame if the load request for that frame
 /// fails. For notification of overall browser load status use
 /// OnLoadingStateChange instead.
 /// </summary>
 protected virtual void OnLoadStart(CefBrowser browser, CefFrame frame)
 {
 }
 protected override bool GetScreenInfo(CefBrowser browser, CefScreenInfo screenInfo)
 {
     return true;
 }
 /// <summary>
 /// Called to run a dialog asking the user if they want to leave a page. Return
 /// false to use the default dialog implementation. Return true if the
 /// application will use a custom dialog or if the callback has been executed
 /// immediately. Custom dialogs may be either modal or modeless. If a custom
 /// dialog is used the application must execute |callback| once the custom
 /// dialog is dismissed.
 /// </summary>
 protected abstract bool OnBeforeUnloadDialog(CefBrowser browser, string messageText, bool isReload, CefJSDialogCallback callback);
 /// <summary>
 /// Called when the resource load for a navigation fails or is canceled.
 /// |errorCode| is the error code number, |errorText| is the error text and
 /// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
 /// for complete descriptions of the error codes.
 /// </summary>
 protected virtual void OnLoadError(CefBrowser browser, CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl)
 {
 }
 protected override void OnBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, string suggestedName, CefBeforeDownloadCallback callback)
 {
     callback.Continue(suggestedName, true);
     base.OnBeforeDownload(browser, downloadItem, suggestedName, callback);
     webBrowser.OnBeforeDownload();
 }
 /// <summary>
 /// Called when the browser begins loading a frame. The |frame| value will
 /// never be empty -- call the IsMain() method to check if this frame is the
 /// main frame. Multiple frames may be loading at the same time. Sub-frames may
 /// start or continue loading after the main frame load has ended. This method
 /// may not be called for a particular frame if the load request for that frame
 /// fails. For notification of overall browser load status use
 /// OnLoadingStateChange instead.
 /// </summary>
 protected virtual void OnLoadStart(CefBrowser browser, CefFrame frame)
 {
 }
Exemple #19
0
 /// <summary>
 /// Called when the context menu is dismissed irregardless of whether the menu
 /// was empty or a command was selected.
 /// </summary>
 protected virtual void OnContextMenuDismissed(CefBrowser browser, CefFrame frame)
 {
 }
Exemple #20
0
 /// <summary>
 /// Called to execute a command selected from the context menu. Return true if
 /// the command was handled or false for the default implementation. See
 /// cef_menu_id_t for the command ids that have default implementations. All
 /// user-defined command ids should be between MENU_ID_USER_FIRST and
 /// MENU_ID_USER_LAST. |params| will have the same values as what was passed to
 /// OnBeforeContextMenu(). Do not keep a reference to |params| outside of this
 /// callback.
 /// </summary>
 protected virtual bool OnContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams state, int commandId, CefEventFlags eventFlags)
 {
     return(false);
 }
Exemple #21
0
 /// <summary>
 /// Called before a context menu is displayed. |params| provides information
 /// about the context menu state. |model| initially contains the default
 /// context menu. The |model| can be cleared to show no context menu or
 /// modified to show a custom menu. Do not keep references to |params| or
 /// |model| outside of this callback.
 /// </summary>
 protected virtual void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model)
 {
 }
 /// <summary>
 /// Called to run a JavaScript dialog. The |default_prompt_text| value will be
 /// specified for prompt dialogs only. Set |suppress_message| to true and
 /// return false to suppress the message (suppressing messages is preferable
 /// to immediately executing the callback as this is used to detect presumably
 /// malicious behavior like spamming alert messages in onbeforeunload). Set
 /// |suppress_message| to false and return false to use the default
 /// implementation (the default implementation will show one modal dialog at a
 /// time and suppress any additional dialog requests until the displayed dialog
 /// is dismissed). Return true if the application will use a custom dialog or
 /// if the callback has been executed immediately. Custom dialogs may be either
 /// modal or modeless. If a custom dialog is used the application must execute
 /// |callback| once the custom dialog is dismissed.
 /// </summary>
 protected abstract bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message);
 protected override bool OnTooltip(CefBrowser browser, string text)
 {
     Console.WriteLine("OnTooltip: {0}", text);
     return false;
 }
 /// <summary>
 /// Called when an external drag event enters the browser window. |dragData|
 /// contains the drag event data and |mask| represents the type of drag
 /// operation. Return false for default drag handling behavior or true to
 /// cancel the drag event.
 /// </summary>
 protected abstract bool OnDragEnter(CefBrowser browser, CefDragData dragData, CefDragOperationsMask mask);
 /// <summary>
 /// Called before a keyboard event is sent to the renderer. |event| contains
 /// information about the keyboard event. |os_event| is the operating system
 /// event message, if any. Return true if the event was handled or false
 /// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
 /// shortcut set |is_keyboard_shortcut| to true and return false.
 /// </summary>
 protected virtual bool OnPreKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr os_event, out bool isKeyboardShortcut)
 {
     isKeyboardShortcut = false;
     return false;
 }
 /// <summary>
 /// Called to run a file chooser dialog. |mode| represents the type of dialog
 /// to display. |title| to the title to be used for the dialog and may be empty
 /// to show the default title ("Open" or "Save" depending on the mode).
 /// |default_file_name| is the default file name to select in the dialog.
 /// |accept_types| is a list of valid lower-cased MIME types or file extensions
 /// specified in an input element and is used to restrict selectable files to
 /// such types. To display a custom dialog return true and execute |callback|
 /// either inline or at a later time. To display the default dialog return
 /// false.
 /// </summary>
 protected virtual bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFileName, string[] acceptTypes, CefFileDialogCallback callback)
 {
     return false;
 }
 /// <summary>
 /// Called when the resource load for a navigation fails or is canceled.
 /// |errorCode| is the error code number, |errorText| is the error text and
 /// |failedUrl| is the URL that failed to load. See net\base\net_error_list.h
 /// for complete descriptions of the error codes.
 /// </summary>
 protected virtual void OnLoadError(CefBrowser browser, CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl)
 {
 }
 /// <summary>
 /// Called when the loading state has changed. This callback will be executed
 /// twice -- once when loading is initiated either programmatically or by user
 /// action, and once when loading is terminated due to completion, cancellation
 /// of failure.
 /// </summary>
 protected virtual void OnLoadingStateChange(CefBrowser browser, bool isLoading, bool canGoBack, bool canGoForward)
 {
 }
 /// <summary>
 /// Called to cancel any pending dialogs and reset any saved dialog state. Will
 /// be called due to events like page navigation irregardless of whether any
 /// dialogs are currently pending.
 /// </summary>
 protected abstract void OnResetDialogState(CefBrowser browser);
 /// <summary>
 /// Called when the browser is done loading a frame. The |frame| value will
 /// never be empty -- call the IsMain() method to check if this frame is the
 /// main frame. Multiple frames may be loading at the same time. Sub-frames may
 /// start or continue loading after the main frame load has ended. This method
 /// will always be called for all frames irrespective of whether the request
 /// completes successfully.
 /// </summary>
 protected virtual void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
 {
 }
 protected override void OnScrollOffsetChanged(CefBrowser browser)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Called after the renderer and JavaScript in the page has had a chance to
 /// handle the event. |event| contains information about the keyboard event.
 /// |os_event| is the operating system event message, if any. Return true if
 /// the keyboard event was handled or false otherwise.
 /// </summary>
 protected virtual bool OnKeyEvent(CefBrowser browser, CefKeyEvent keyEvent, IntPtr osEvent)
 {
     return false;
 }
 protected override void OnPaint(CefBrowser browser, CefPaintElementType type, CefRectangle[] dirtyRects, IntPtr buffer, int width, int height)
 {
     throw new NotImplementedException();
 }
 protected override bool GetRootScreenRect(CefBrowser browser, ref CefRectangle rect)
 {
     return base.GetRootScreenRect(browser, ref rect);
 }
 /// <summary>
 /// Called when the browser is done loading a frame. The |frame| value will
 /// never be empty -- call the IsMain() method to check if this frame is the
 /// main frame. Multiple frames may be loading at the same time. Sub-frames may
 /// start or continue loading after the main frame load has ended. This method
 /// will always be called for all frames irrespective of whether the request
 /// completes successfully.
 /// </summary>
 protected virtual void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
 {
 }
 protected override void OnCursorChange(CefBrowser browser, IntPtr cursorHandle)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Called when a download's status or progress information has been updated.
 /// This may be called multiple times before and after OnBeforeDownload().
 /// Execute |callback| either asynchronously or in this method to cancel the
 /// download if desired. Do not keep a reference to |download_item| outside of
 /// this method.
 /// </summary>
 protected virtual void OnDownloadUpdated(CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback)
 {
 }
 protected override void OnPopupSize(CefBrowser browser, CefRectangle rect)
 {
     throw new NotImplementedException();
 }
 protected override void OnTitleChange(CefBrowser browser, string title)
 {
     webBrowser.OnTitleChange(title);
 }
 public CwbDocument(CefBrowser browser)
 {
     this.browser = browser;
 }
 /// <summary>
 /// Called when the loading state has changed. This callback will be executed
 /// twice -- once when loading is initiated either programmatically or by user
 /// action, and once when loading is terminated due to completion, cancellation
 /// of failure.
 /// </summary>
 protected virtual void OnLoadingStateChange(CefBrowser browser, bool isLoading, bool canGoBack, bool canGoForward)
 {
 }