/// <summary>
 /// Called to format print headers and footers.
 /// |printInfo| contains platform- specific information about the printer context.
 /// |url| is the URL if the currently printing page,
 /// |title| is the title of the currently printing page,
 /// |currentPage| is the current page number
 /// and |maxPages| is the total number of pages.
 /// Six default header locations are provided by the implementation: top left, top center, top right, bottom left, bottom center and bottom right.
 /// To use one of these default locations just assign a string to the appropriate variable.
 /// To draw the header and footer yourself return true.
 /// Otherwise, populate the approprate variables and return false.
 /// </summary>
 protected virtual bool GetPrintHeaderFooter(CefBrowser browser, CefFrame frame,
     CefPrintInfo printInfo, string url, string title, int currentPage, int maxPages,
     ref string topLeft, 
     ref string topCenter, 
     ref string topRight, 
     ref string bottomLeft, 
     ref string bottomCenter, 
     ref string bottomRight)
 {
     return false;
 }
 /// <summary>
 /// Called when a new node in the the browser gets focus.
 /// The |node| value may be empty if no specific node has gained focus.
 /// The node object passed to this method represents a snapshot of the DOM at the time this method is executed.
 /// DOM objects are only valid for the scope of this method.
 /// Do not keep references to or attempt to access any DOM objects outside the scope of this method.
 /// </summary>
 protected virtual void OnFocusedNodeChanged(CefBrowser browser, CefFrame frame, CefDomNode node)
 {
 }
Example #3
0
 /// <summary>
 /// Called when the size of the content area has changed.
 /// </summary>
 protected virtual void OnContentsSizeChange(CefBrowser browser, CefFrame frame, int width, int height)
 {
 }
 /// <summary>
 /// Called when a frame's address has changed.
 /// </summary>
 protected virtual void OnAddressChange(CefBrowser browser, CefFrame frame, string url)
 {
 }
 /// <summary>
 /// Called to run a JavaScript prompt request.
 /// Return false to display the default prompt or true if you displayed a custom prompt.
 /// If you handled the prompt set |retval| to true if the user accepted the prompt and request and |result| to the resulting value.
 /// </summary>
 protected virtual bool OnJSPrompt(CefBrowser browser, CefFrame frame, string message, string defaultValue, out bool retval, out string result)
 {
     retval = false;
     result = null;
     return false;
 }
 /// <summary>
 /// Called to run a JavaScript alert message.
 /// Return false to display the default alert or true if you displayed a custom alert.
 /// </summary>
 protected virtual bool OnJSAlert(CefBrowser browser, CefFrame frame, string message)
 {
     return false;
 }
 /// <summary>
 /// Called to run a JavaScript confirm request.
 /// Return false to display the default alert or true if you displayed a custom alert.
 /// If you handled the alert set |retval| to true if the user accepted the confirmation.
 /// </summary>
 protected virtual bool OnJSConfirm(CefBrowser browser, CefFrame frame, string message, out bool retval)
 {
     retval = false;
     return(false);
 }
 /// <summary>
 /// Called to run a JavaScript prompt request.
 /// Return false to display the default prompt or true if you displayed a custom prompt.
 /// If you handled the prompt set |retval| to true if the user accepted the prompt and request and |result| to the resulting value.
 /// </summary>
 protected virtual bool OnJSPrompt(CefBrowser browser, CefFrame frame, string message, string defaultValue, out bool retval, out string result)
 {
     retval = false;
     result = null;
     return(false);
 }
 /// <summary>
 /// Called when the browser fails to load a resource.
 /// |errorCode| is the error code number and |failedUrl| is the URL that failed to load.
 /// To provide custom error text assign the text to |errorText| and return true.
 /// Otherwise, return false for the default error text.
 /// See net\base\net_error_list.h for complete descriptions of the error codes.
 /// </summary>
 protected virtual bool OnLoadError(CefBrowser browser, CefFrame frame, CefHandlerErrorCode errorCode, string failedUrl, ref string errorText)
 {
     // FIXME: change api... instead of return true/false we can return errorText (custom), or null/empty to default error text.
     return(false);
 }
 /// <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)
 {
 }
 /// <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.
 /// </summary>
 protected virtual void OnLoadStart(CefBrowser browser, CefFrame frame)
 {
 }
 /// <summary>
 /// Called on the UI thread before browser navigation.
 /// Return true to cancel the navigation 
 /// or false to allow the navigation to proceed.
 /// </summary>
 protected virtual bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, CefHandlerNavType navType, bool isRedirect)
 {
     return false;
 }
        /// <summary>
        /// Called to format print headers and footers. |printInfo| contains
        /// platform- specific information about the printer context. |url| is
        /// the URL if the currently printing page, |title| is the title of the
        /// currently printing page, |currentPage| is the current page number and
        /// |maxPages| is the total number of pages. Six default header locations
        /// are provided by the implementation: top left, top center, top right,
        /// bottom left, bottom center and bottom right. To use one of these
        /// default locations just assign a string to the appropriate variable.
        /// To draw the header and footer yourself return true. Otherwise,
        /// populate the approprate variables and return false.
        /// </summary>
        private int get_print_header_footer(cef_print_handler_t *self, cef_browser_t *browser, cef_frame_t *frame, /*const*/ cef_print_info_t *printInfo, /*const*/ cef_string_t *url, /*const*/ cef_string_t *title, int currentPage, int maxPages, cef_string_t *topLeft, cef_string_t *topCenter, cef_string_t *topRight, cef_string_t *bottomLeft, cef_string_t *bottomCenter, cef_string_t *bottomRight)
        {
            ThrowIfObjectDisposed();

            var m_browser   = CefBrowser.From(browser);
            var m_frame     = CefFrame.From(frame);
            var m_printInfo = CefPrintInfo.From(printInfo);
            var m_url       = cef_string_t.ToString(url);
            var m_title     = cef_string_t.ToString(title);

            var m_topLeft      = cef_string_t.ToString(topLeft);
            var m_topCenter    = cef_string_t.ToString(topCenter);
            var m_topRight     = cef_string_t.ToString(topRight);
            var m_bottomLeft   = cef_string_t.ToString(bottomLeft);
            var m_bottomCenter = cef_string_t.ToString(bottomCenter);
            var m_bottomRight  = cef_string_t.ToString(bottomRight);

            var o_topLeft      = m_topLeft;
            var o_topCenter    = m_topCenter;
            var o_topRight     = m_topRight;
            var o_bottomLeft   = m_bottomLeft;
            var o_bottomCenter = m_bottomCenter;
            var o_bottomRight  = m_bottomRight;

            var handled = this.GetPrintHeaderFooter(m_browser, m_frame,
                                                    m_printInfo, m_url, m_title, currentPage, maxPages,
                                                    ref m_topLeft, ref m_topCenter, ref m_topRight,
                                                    ref m_bottomLeft, ref m_bottomCenter, ref m_bottomRight);

            m_printInfo.Dispose();

            if (!handled)
            {
                if ((object)m_topLeft != (object)o_topLeft)
                {
                    cef_string_t.Copy(m_topLeft, topLeft);
                }
                if ((object)m_topCenter != (object)o_topCenter)
                {
                    cef_string_t.Copy(m_topCenter, topCenter);
                }
                if ((object)m_topRight != (object)o_topRight)
                {
                    cef_string_t.Copy(m_topRight, topRight);
                }
                if ((object)m_bottomLeft != (object)o_bottomLeft)
                {
                    cef_string_t.Copy(m_bottomLeft, bottomLeft);
                }
                if ((object)m_bottomCenter != (object)o_bottomCenter)
                {
                    cef_string_t.Copy(m_bottomCenter, bottomCenter);
                }
                if ((object)m_bottomRight != (object)o_bottomRight)
                {
                    cef_string_t.Copy(m_bottomRight, bottomRight);
                }
            }

            return(handled ? 1 : 0);
        }
 /// <summary>
 /// Called for global uncaught exceptions. Execution of this callback is
 /// disabled by default. To enable set
 /// CefSettings.uncaught_exception_stack_size &gt; 0.
 /// </summary>
 protected abstract void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace);
 /// <summary>
 /// Called immediately before the V8 context for a frame is released. No
 /// references to the context should be kept after this function is
 /// called.
 /// </summary>
 protected abstract void OnContextReleased(CefBrowser browser, CefFrame frame, CefV8Context context);
 /// <summary>
 /// Called immediately before the V8 context for a frame is released. No
 /// references to the context should be kept after this function is
 /// called.
 /// </summary>
 protected abstract void OnContextReleased(CefBrowser browser, CefFrame frame, CefV8Context context);
 /// <summary>
 /// Called for global uncaught exceptions. Execution of this callback is
 /// disabled by default. To enable set
 /// CefSettings.uncaught_exception_stack_size &gt; 0.
 /// </summary>
 protected abstract void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace);
 /// <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)
 {
 }
 /// <summary>
 /// Called to run a JavaScript alert message.
 /// Return false to display the default alert or true if you displayed a custom alert.
 /// </summary>
 protected virtual bool OnJSAlert(CefBrowser browser, CefFrame frame, string message)
 {
     return(false);
 }
 /// <summary>
 /// Called when the browser fails to load a resource.
 /// |errorCode| is the error code number and |failedUrl| is the URL that failed to load.
 /// To provide custom error text assign the text to |errorText| and return true.
 /// Otherwise, return false for the default error text.
 /// See net\base\net_error_list.h for complete descriptions of the error codes.
 /// </summary>
 protected virtual bool OnLoadError(CefBrowser browser, CefFrame frame, CefHandlerErrorCode errorCode, string failedUrl, ref string errorText)
 {
     // FIXME: change api... instead of return true/false we can return errorText (custom), or null/empty to default error text.
     return false;
 }
 /// <summary>
 /// Called when a new node in the the browser gets focus.
 /// The |node| value may be empty if no specific node has gained focus.
 /// The node object passed to this method represents a snapshot of the DOM at the time this method is executed.
 /// DOM objects are only valid for the scope of this method.
 /// Do not keep references to or attempt to access any DOM objects outside the scope of this method.
 /// </summary>
 protected virtual void OnFocusedNodeChanged(CefBrowser browser, CefFrame frame, CefDomNode node)
 {
 }
 /// <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.
 /// </summary>
 protected virtual void OnLoadStart(CefBrowser browser, CefFrame frame)
 {
 }
 /// <summary>
 /// Called to run a JavaScript confirm request.
 /// Return false to display the default alert or true if you displayed a custom alert.
 /// If you handled the alert set |retval| to true if the user accepted the confirmation.
 /// </summary>
 protected virtual bool OnJSConfirm(CefBrowser browser, CefFrame frame, string message, out bool retval)
 {
     retval = false;
     return false;
 }
Example #24
0
 /// <summary>
 /// Returns the frame for this context.
 /// </summary>
 public CefFrame GetFrame()
 {
     return(CefFrame.From(
                cef_v8context_t.invoke_get_frame(this.ptr)
                ));
 }
 /// <summary>
 /// Called on the UI thread before a script extension is loaded.
 /// Return false to let the extension load normally.
 /// </summary>
 protected virtual bool OnBeforeScriptExtensionLoad(CefBrowser browser, CefFrame frame, string extensionName)
 {
     return false;
 }
Example #26
0
 /// <summary>
 /// Called on the UI thread before browser navigation.
 /// Return true to cancel the navigation
 /// or false to allow the navigation to proceed.
 /// </summary>
 protected virtual bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, CefHandlerNavType navType, bool isRedirect)
 {
     return(false);
 }
 /// <summary>
 /// Called when the size of the content area has changed.
 /// </summary>
 protected virtual void OnContentsSizeChange(CefBrowser browser, CefFrame frame, int width, int height)
 {
 }
Example #28
0
 /// <summary>
 /// Called when a frame's address has changed.
 /// </summary>
 protected virtual void OnAddressChange(CefBrowser browser, CefFrame frame, string url)
 {
 }