[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/2php/cefpython/cefpython51/src/client_handler/client_handler.h [Back]  [Original]

// Copyright (c) 2012-2014 The CEF Python authors. All rights reserved.
// License: New BSD License.
// Website: http://code.google.com/p/cefpython/

// ClientHandler code is running in the Browser process only.

#pragma once

#if defined(_WIN32)
#include "../windows/stdint.h"
#endif

#include "cefpython_public_api.h"

// needs to be forward declared otherwise compile error
typedef cef_return_value_t ReturnValue;

class ClientHandler : 
		public CefClient,
        public CefLifeSpanHandler,
        public CefDisplayHandler,
        public CefKeyboardHandler,
        public CefRequestHandler,
        public CefLoadHandler,
        public CefRenderHandler,
        public CefJSDialogHandler,
        public CefDownloadHandler,
        public CefContextMenuHandler
{
public:
  typedef cef_jsdialog_type_t JSDialogType;
  typedef cef_event_flags_t EventFlags;
  typedef cef_window_open_disposition_t WindowOpenDisposition;

  ClientHandler(){}
  virtual ~ClientHandler(){}

  virtual CefRefPtr GetContextMenuHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetDialogHandler() OVERRIDE {
    return NULL;
  }

  virtual CefRefPtr GetDisplayHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetDownloadHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetDragHandler() OVERRIDE {
    return NULL;
  }

  virtual CefRefPtr GetFindHandler() OVERRIDE {
    return NULL;
  }

  virtual CefRefPtr GetFocusHandler() OVERRIDE {
    return NULL;
  }

  virtual CefRefPtr GetGeolocationHandler() OVERRIDE {
    return NULL;
  }

  virtual CefRefPtr GetJSDialogHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetKeyboardHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetLifeSpanHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetLoadHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetRenderHandler() OVERRIDE {
    return this;
  }

  virtual CefRefPtr GetRequestHandler() OVERRIDE {
    return this;
  }

  virtual bool OnProcessMessageReceived(CefRefPtr browser,
                                        CefProcessId source_process,
                                        CefRefPtr message)
                                        OVERRIDE;

  // --------------------------------------------------------------------------
  // CefLifeSpanHandler
  // --------------------------------------------------------------------------

  virtual bool OnBeforePopup(CefRefPtr browser,
                             CefRefPtr frame,
                             const CefString& target_url,
                             const CefString& target_frame_name,
                             WindowOpenDisposition target_disposition,
                             bool user_gesture,
                             const CefPopupFeatures& popupFeatures,
                             CefWindowInfo& windowInfo,
                             CefRefPtr& client,
                             CefBrowserSettings& settings,
                             bool* no_javascript_access) OVERRIDE;

  virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE;
  virtual bool DoClose(CefRefPtr browser) OVERRIDE;
  virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefDisplayHandler
  // --------------------------------------------------------------------------

  virtual void OnAddressChange(CefRefPtr browser,
                               CefRefPtr frame,
                               const CefString& url) OVERRIDE;

  virtual void OnTitleChange(CefRefPtr browser,
                             const CefString& title) OVERRIDE;

  virtual bool OnTooltip(CefRefPtr browser,
                         CefString& text) OVERRIDE;

  virtual void OnStatusMessage(CefRefPtr browser,
                               const CefString& value) OVERRIDE;

  virtual bool OnConsoleMessage(CefRefPtr browser,
                                const CefString& message,
                                const CefString& source,
                                int line) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefKeyboardHandler
  // --------------------------------------------------------------------------

  virtual bool OnPreKeyEvent(CefRefPtr browser,
                             const CefKeyEvent& event,
                             CefEventHandle os_event,
                             bool* is_keyboard_shortcut) OVERRIDE;

  virtual bool OnKeyEvent(CefRefPtr browser,
                          const CefKeyEvent& event,
                          CefEventHandle os_event) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefRequestHandler
  // --------------------------------------------------------------------------

  virtual bool OnBeforeBrowse(CefRefPtr browser,
                              CefRefPtr frame,
                              CefRefPtr request,
                              bool is_redirect) OVERRIDE;

  virtual ReturnValue OnBeforeResourceLoad(CefRefPtr browser,
                                    CefRefPtr frame,
                                    CefRefPtr request,
                                    CefRefPtr callback
                                    ) OVERRIDE;

  virtual CefRefPtr GetResourceHandler(
      CefRefPtr browser,
      CefRefPtr frame,
      CefRefPtr request) OVERRIDE;

  virtual void OnResourceRedirect(CefRefPtr browser,
                                  CefRefPtr frame,
                                  CefRefPtr request,
                                  CefString& new_url) OVERRIDE;

  virtual bool GetAuthCredentials(CefRefPtr browser,
                                  CefRefPtr frame,
                                  bool isProxy,
                                  const CefString& host,
                                  int port,
                                  const CefString& realm,
                                  const CefString& scheme,
                                  CefRefPtr callback) 
                                  OVERRIDE;

  virtual bool OnQuotaRequest(CefRefPtr browser,
                              const CefString& origin_url,
                              int64 new_size,
                              CefRefPtr callback) OVERRIDE;

  virtual void OnProtocolExecution(CefRefPtr browser,
                                   const CefString& url,
                                   bool& allow_os_execution) OVERRIDE;
  virtual bool OnCertificateError(
      CefRefPtr browser, // not used
      cef_errorcode_t cert_error,
      const CefString& request_url,
      CefRefPtr ssl_info, // not used
      CefRefPtr callback) OVERRIDE;

  virtual void OnRenderProcessTerminated(CefRefPtr browser,
                                         cef_termination_status_t status) 
                                         OVERRIDE;

  virtual void OnPluginCrashed(CefRefPtr browser,
                               const CefString& plugin_path) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefLoadHandler
  // --------------------------------------------------------------------------

  virtual void OnLoadingStateChange(CefRefPtr browser,
                                    bool isLoading,
                                    bool canGoBack,
                                    bool canGoForward) OVERRIDE;

  virtual void OnLoadStart(CefRefPtr browser,
                           CefRefPtr frame) OVERRIDE;

  virtual void OnLoadEnd(CefRefPtr browser,
                         CefRefPtr frame,
                         int httpStatusCode) OVERRIDE;

  virtual void OnLoadError(CefRefPtr browser,
                           CefRefPtr frame,
                           cef_errorcode_t errorCode,
                           const CefString& errorText,
                           const CefString& failedUrl) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefRenderHandler
  // --------------------------------------------------------------------------

  virtual bool GetRootScreenRect(CefRefPtr browser,
                                 CefRect& rect) OVERRIDE;

  virtual bool GetViewRect(CefRefPtr browser, CefRect& rect)
      OVERRIDE;

  virtual bool GetScreenPoint(CefRefPtr browser,
                              int viewX,
                              int viewY,
                              int& screenX,
                              int& screenY) OVERRIDE;

  virtual bool GetScreenInfo(CefRefPtr browser,
                             CefScreenInfo& screen_info) OVERRIDE;

  virtual void OnPopupShow(CefRefPtr browser,
                           bool show) OVERRIDE;

  virtual void OnPopupSize(CefRefPtr browser,
                           const CefRect& rect) OVERRIDE;

  virtual void OnPaint(CefRefPtr browser,
                       PaintElementType type,
                       const RectList& dirtyRects,
                       const void* buffer,
                       int width, int height) OVERRIDE;

  virtual void OnCursorChange(CefRefPtr browser,
                              CefCursorHandle cursor,
                              CursorType type,
                              const CefCursorInfo& custom_cursor_info
                              ) OVERRIDE;

  virtual void OnScrollOffsetChanged(CefRefPtr browser,
                                     double x,
                                     double y) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefJSDialogHandler
  // --------------------------------------------------------------------------

  virtual bool OnJSDialog(CefRefPtr browser,
                          const CefString& origin_url,
                          JSDialogType dialog_type,
                          const CefString& message_text,
                          const CefString& default_prompt_text,
                          CefRefPtr callback,
                          bool& suppress_message) OVERRIDE;

  virtual bool OnBeforeUnloadDialog(CefRefPtr browser,
                                    const CefString& message_text,
                                    bool is_reload,
                                    CefRefPtr callback)
                                    OVERRIDE;

  virtual void OnResetDialogState(CefRefPtr browser) OVERRIDE;

  virtual void OnDialogClosed(CefRefPtr browser) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefDownloadHandler
  // --------------------------------------------------------------------------

  virtual void OnBeforeDownload(
      CefRefPtr browser,
      CefRefPtr download_item,
      const CefString& suggested_name,
      CefRefPtr callback) OVERRIDE;

  virtual void OnDownloadUpdated(
      CefRefPtr browser,
      CefRefPtr download_item,
      CefRefPtr callback) OVERRIDE;

  // --------------------------------------------------------------------------
  // CefDownloadHandler
  // --------------------------------------------------------------------------

  virtual void OnBeforeContextMenu(CefRefPtr browser,
                                   CefRefPtr frame,
                                   CefRefPtr params,
                                   CefRefPtr model) OVERRIDE;

  virtual bool OnContextMenuCommand(CefRefPtr browser,
                                    CefRefPtr frame,
                                    CefRefPtr params,
                                    int command_id,
                                    EventFlags event_flags) OVERRIDE;

  virtual void OnContextMenuDismissed(CefRefPtr browser,
                                      CefRefPtr frame) OVERRIDE;


private:
  IMPLEMENT_REFCOUNTING(ClientHandler);

};

Web Proxy Viewer  |  New URL  |  Original Page