github.com/ckxng/wakeup@v0.0.0-20190105202853-90356a5f5a15/include/capi/cef_life_span_handler_capi.h (about)

     1  // Copyright (c) 2014 Marshall A. Greenblatt. All rights reserved.
     2  //
     3  // Redistribution and use in source and binary forms, with or without
     4  // modification, are permitted provided that the following conditions are
     5  // met:
     6  //
     7  //    * Redistributions of source code must retain the above copyright
     8  // notice, this list of conditions and the following disclaimer.
     9  //    * Redistributions in binary form must reproduce the above
    10  // copyright notice, this list of conditions and the following disclaimer
    11  // in the documentation and/or other materials provided with the
    12  // distribution.
    13  //    * Neither the name of Google Inc. nor the name Chromium Embedded
    14  // Framework nor the names of its contributors may be used to endorse
    15  // or promote products derived from this software without specific prior
    16  // written permission.
    17  //
    18  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    19  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    20  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    21  // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    22  // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    23  // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    24  // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    25  // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    26  // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    27  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29  //
    30  // ---------------------------------------------------------------------------
    31  //
    32  // This file was generated by the CEF translator tool and should not edited
    33  // by hand. See the translator.README.txt file in the tools directory for
    34  // more information.
    35  //
    36  
    37  #ifndef CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
    38  #define CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_
    39  #pragma once
    40  
    41  #ifdef __cplusplus
    42  extern "C" {
    43  #endif
    44  
    45  #include "include/capi/cef_base_capi.h"
    46  #include "include/capi/cef_browser_capi.h"
    47  
    48  struct _cef_client_t;
    49  
    50  ///
    51  // Implement this structure to handle events related to browser life span. The
    52  // functions of this structure will be called on the UI thread unless otherwise
    53  // indicated.
    54  ///
    55  typedef struct _cef_life_span_handler_t {
    56    ///
    57    // Base structure.
    58    ///
    59    cef_base_t base;
    60  
    61    ///
    62    // Called on the IO thread before a new popup window is created. The |browser|
    63    // and |frame| parameters represent the source of the popup request. The
    64    // |target_url| and |target_frame_name| values may be NULL if none were
    65    // specified with the request. The |popupFeatures| structure contains
    66    // information about the requested popup window. To allow creation of the
    67    // popup window optionally modify |windowInfo|, |client|, |settings| and
    68    // |no_javascript_access| and return false (0). To cancel creation of the
    69    // popup window return true (1). The |client| and |settings| values will
    70    // default to the source browser's values. The |no_javascript_access| value
    71    // indicates whether the new browser window should be scriptable and in the
    72    // same process as the source browser.
    73    int (CEF_CALLBACK *on_before_popup)(struct _cef_life_span_handler_t* self,
    74        struct _cef_browser_t* browser, struct _cef_frame_t* frame,
    75        const cef_string_t* target_url, const cef_string_t* target_frame_name,
    76        const struct _cef_popup_features_t* popupFeatures,
    77        struct _cef_window_info_t* windowInfo, struct _cef_client_t** client,
    78        struct _cef_browser_settings_t* settings, int* no_javascript_access);
    79  
    80    ///
    81    // Called after a new browser is created.
    82    ///
    83    void (CEF_CALLBACK *on_after_created)(struct _cef_life_span_handler_t* self,
    84        struct _cef_browser_t* browser);
    85  
    86    ///
    87    // Called when a modal window is about to display and the modal loop should
    88    // begin running. Return false (0) to use the default modal loop
    89    // implementation or true (1) to use a custom implementation.
    90    ///
    91    int (CEF_CALLBACK *run_modal)(struct _cef_life_span_handler_t* self,
    92        struct _cef_browser_t* browser);
    93  
    94    ///
    95    // Called when a browser has recieved a request to close. This may result
    96    // directly from a call to cef_browser_host_t::close_browser() or indirectly
    97    // if the browser is a top-level OS window created by CEF and the user
    98    // attempts to close the window. This function will be called after the
    99    // JavaScript 'onunload' event has been fired. It will not be called for
   100    // browsers after the associated OS window has been destroyed (for those
   101    // browsers it is no longer possible to cancel the close).
   102    //
   103    // If CEF created an OS window for the browser returning false (0) will send
   104    // an OS close notification to the browser window's top-level owner (e.g.
   105    // WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If
   106    // no OS window exists (window rendering disabled) returning false (0) will
   107    // cause the browser object to be destroyed immediately. Return true (1) if
   108    // the browser is parented to another window and that other window needs to
   109    // receive close notification via some non-standard technique.
   110    //
   111    // If an application provides its own top-level window it should handle OS
   112    // close notifications by calling cef_browser_host_t::CloseBrowser(false (0))
   113    // instead of immediately closing (see the example below). This gives CEF an
   114    // opportunity to process the 'onbeforeunload' event and optionally cancel the
   115    // close before do_close() is called.
   116    //
   117    // The cef_life_span_handler_t::OnBeforeclose() function will be called
   118    // immediately before the browser object is destroyed. The application should
   119    // only exit after OnBeforeclose() has been called for all existing browsers.
   120    //
   121    // If the browser represents a modal window and a custom modal loop
   122    // implementation was provided in cef_life_span_handler_t::run_modal() this
   123    // callback should be used to restore the opener window to a usable state.
   124    //
   125    // By way of example consider what should happen during window close when the
   126    // browser is parented to an application-provided top-level OS window. 1.
   127    // User clicks the window close button which sends an OS close
   128    //     notification (e.g. WM_CLOSE on Windows, performClose: on OS-X and
   129    //     "delete_event" on Linux).
   130    // 2.  Application's top-level window receives the close notification and:
   131    //     A. Calls CefBrowserHost::CloseBrowser(false).
   132    //     B. Cancels the window close.
   133    // 3.  JavaScript 'onbeforeunload' handler executes and shows the close
   134    //     confirmation dialog (which can be overridden via
   135    //     CefJSDialogHandler::OnBeforeUnloadDialog()).
   136    // 4.  User approves the close. 5.  JavaScript 'onunload' handler executes. 6.
   137    // Application's do_close() handler is called. Application will:
   138    //     A. Call CefBrowserHost::ParentWindowWillClose() to notify CEF that the
   139    //        parent window will be closing.
   140    //     B. Set a flag to indicate that the next close attempt will be allowed.
   141    //     C. Return false.
   142    // 7.  CEF sends an OS close notification. 8.  Application's top-level window
   143    // receives the OS close notification and
   144    //     allows the window to close based on the flag from #6B.
   145    // 9.  Browser OS window is destroyed. 10. Application's
   146    // cef_life_span_handler_t::OnBeforeclose() handler is called and
   147    //     the browser object is destroyed.
   148    // 11. Application exits by calling cef_quit_message_loop() if no other
   149    // browsers
   150    //     exist.
   151    ///
   152    int (CEF_CALLBACK *do_close)(struct _cef_life_span_handler_t* self,
   153        struct _cef_browser_t* browser);
   154  
   155    ///
   156    // Called just before a browser is destroyed. Release all references to the
   157    // browser object and do not attempt to execute any functions on the browser
   158    // object after this callback returns. If this is a modal window and a custom
   159    // modal loop implementation was provided in run_modal() this callback should
   160    // be used to exit the custom modal loop. See do_close() documentation for
   161    // additional usage information.
   162    ///
   163    void (CEF_CALLBACK *on_before_close)(struct _cef_life_span_handler_t* self,
   164        struct _cef_browser_t* browser);
   165  } cef_life_span_handler_t;
   166  
   167  
   168  #ifdef __cplusplus
   169  }
   170  #endif
   171  
   172  #endif  // CEF_INCLUDE_CAPI_CEF_LIFE_SPAN_HANDLER_CAPI_H_