CEF 3ノート2(常用類の紹介)

12658 ワード

CEF 3はChromiumベースの組み込みブラウザフレームワークとして開発者にいくつかの基本的なインタフェースクラスを提供し、いくつかの基本的な機能を完成させる.

CefAppクラスの紹介


CefApp:プロセス、コマンドラインパラメータ、エージェント、リソース管理に関連するコールバッククラスは、CEF 3の呼び出し者たちに自分のロジックをカスタマイズさせるために使用されます.クラスに関連するいくつかの関数は次のとおりです.
int CefExecuteProcess(const CefMainArgs& args, CefRefPtr application);
bool CefInitialize(const CefMainArgs& args, const CefSettings& settings,
                   CefRefPtr application);
CefExecuteProcess()   CefInitialize()   CefApp  。

,CefApp , OnBeforeCommandLineProcessing CEF Chromium
OnRegisterCustomSchemes schemes, Handler。
  // Provides an opportunity to view and/or modify command-line arguments before
  // processing by CEF and Chromium. The |process_type| value will be empty for
  // the browser process. Do not keep a reference to the CefCommandLine object
  // passed to this method. The CefSettings.command_line_args_disabled value
  // can be used to start with an empty command-line object. Any values
  // specified in CefSettings that equate to command-line arguments will be set
  // before this method is called. Be cautious when using this method to modify
  // command-line arguments for non-browser processes as this may result in
  // undefined behavior including crashes.
  virtual void OnBeforeCommandLineProcessing(
      const CefString& process_type,
      CefRefPtr command_line) {
  }

  // Provides an opportunity to register custom schemes. Do not keep a reference
  // to the |registrar| object. This method is called on the main thread for
  // each process and the registered schemes should be the same across all
  // processes.
  virtual void OnRegisterCustomSchemes(
      CefRefPtr registrar) {
  }

  // Return the handler for resource bundle events. If
  // CefSettings.pack_loading_disabled is true a handler must be returned. If no
  // handler is returned resources will be loaded from pack files. This method
  // is called by the browser and render processes on multiple threads.
  virtual CefRefPtr GetResourceBundleHandler() {
    return NULL;
  }

  // Return the handler for functionality specific to the browser process. This
  // method is called on multiple threads in the browser process.
  virtual CefRefPtr GetBrowserProcessHandler() {
    return NULL;
  }

  // Return the handler for functionality specific to the render process. This
  // method is called on the render process main thread.
  virtual CefRefPtr GetRenderProcessHandler() {
    return NULL;
  }

CefClientクラスの紹介


CefClient:CefCreateBrowser()またはCefCreateBrowserSync()関数にパラメータとして渡すことができるコールバック管理クラス.このクラスの主なインタフェースは次のとおりです.
  // Return the handler for context menus. If no handler is provided the default
  // implementation will be used.
  virtual CefRefPtr GetContextMenuHandler() {
    return NULL;
  }

  // Return the handler for dialogs. If no handler is provided the default
  // implementation will be used.
  virtual CefRefPtr GetDialogHandler() {
    return NULL;
  }

  // Return the handler for browser display state events.
  virtual CefRefPtr GetDisplayHandler() {
    return NULL;
  }

  // Return the handler for download events. If no handler is returned downloads
  // will not be allowed.
  virtual CefRefPtr GetDownloadHandler() {
    return NULL;
  }

  // Return the handler for focus events.
  virtual CefRefPtr GetFocusHandler() {
    return NULL;
  }

  // Return the handler for geolocation permissions requests. If no handler is
  // provided geolocation access will be denied by default.
  virtual CefRefPtr GetGeolocationHandler() {
    return NULL;
  }

  // Return the handler for JavaScript dialogs. If no handler is provided the
  // default implementation will be used.
  virtual CefRefPtr GetJSDialogHandler() {
    return NULL;
  }

  // Return the handler for keyboard events.
  virtual CefRefPtr GetKeyboardHandler() {
    return NULL;
  }

  // Return the handler for browser life span events.
  virtual CefRefPtr GetLifeSpanHandler() {
    return NULL;
  }

  // Return the handler for browser load status events.
  virtual CefRefPtr GetLoadHandler() {
    return NULL;
  }

  // Return the handler for off-screen rendering events.
  virtual CefRefPtr GetRenderHandler() {
    return NULL;
  }

  // Return the handler for browser request events.
  virtual CefRefPtr GetRequestHandler() {
    return NULL;
  }

  // Called when a new message is received from a different process. Return true
  // if the message was handled or false otherwise. Do not keep a reference to
  // or attempt to access the message outside of this callback.
  virtual bool OnProcessMessageReceived(CefRefPtr browser,
                                        CefProcessId source_process,
                                        CefRefPtr message) {
    return false;
  }

CefClientで返されるコールバッククラスは、次のとおりです.
CefContextMenuHandler,コールバッククラス,主にContext Menuイベントの処理に用いられる.
CefDialogHandler,コールバッククラス,主にダイアログイベントの処理に用いられる.
CefDisplayHandler,コールバッククラス,ページロード状況の変化,アドレスバーの変化,タイトルの変化などのページ状態に関するイベントを扱う.
CefDownloadHandler、コールバッククラス、主にファイルのダウンロードを処理するために使用されます.
CefFocusHandler,コールバッククラス,主に焦点イベントの処理に用いられる.
CefGeolocationHandler、コールバッククラス、geolocation権限の申請に使用されます.
CefJSDialogHandler,コールバッククラス,主にJSダイアログイベントの処理に用いられる.
CefKeyboardHandler、コールバッククラス、主にキーボード入力イベントを処理するために使用されます.
CefLifeSpanHandler、コールバッククラスは、主にブラウザのライフサイクルに関連するイベント、ブラウザオブジェクトの作成、破棄、ポップアップボックスの管理に使用されます.
CefLoadHandler、コールバッククラスは、主にブラウザのページロード状態の変化を処理するために使用されます.例えば、ページロードの開始、完了、エラーなどです.
CefRenderHandler、コールバッククラス、主にウィンドウレンダリング機能がオフの場合のイベントに使用されます.
CefRequestHandler、コールバッククラスは、主にブラウザリクエストに関連するイベント、例えばリソースのロード、リダイレクトなどを処理するために使用されます.