1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
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
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.
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.
30 // ---------------------------------------------------------------------------
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
38 #ifndef CEF_INCLUDE_CEF_APP_H_
39 #define CEF_INCLUDE_CEF_APP_H_
42 #include "include/cef_base.h"
43 #include "include/cef_browser_process_handler.h"
44 #include "include/cef_command_line.h"
45 #include "include/cef_render_process_handler.h"
46 #include "include/cef_resource_bundle_handler.h"
47 #include "include/cef_scheme.h"
52 // This function should be called from the application entry point function to
53 // execute a secondary process. It can be used to run secondary processes from
54 // the browser client executable (default behavior) or from a separate
55 // executable specified by the CefSettings.browser_subprocess_path value. If
56 // called for the browser process (identified by no "type" command-line value)
57 // it will return immediately with a value of -1. If called for a recognized
58 // secondary process it will block until the process should exit and then return
59 // the process exit code. The |application| parameter may be empty. The
60 // |windows_sandbox_info| parameter is only used on Windows and may be NULL (see
61 // cef_sandbox_win.h for details).
63 /*--cef(api_hash_check,optional_param=application,
64 optional_param=windows_sandbox_info)--*/
65 int CefExecuteProcess(const CefMainArgs& args,
66 CefRefPtr<CefApp> application,
67 void* windows_sandbox_info);
70 // This function should be called on the main application thread to initialize
71 // the CEF browser process. The |application| parameter may be empty. A return
72 // value of true indicates that it succeeded and false indicates that it failed.
73 // The |windows_sandbox_info| parameter is only used on Windows and may be NULL
74 // (see cef_sandbox_win.h for details).
76 /*--cef(api_hash_check,optional_param=application,
77 optional_param=windows_sandbox_info)--*/
78 bool CefInitialize(const CefMainArgs& args,
79 const CefSettings& settings,
80 CefRefPtr<CefApp> application,
81 void* windows_sandbox_info);
84 // This function should be called on the main application thread to shut down
85 // the CEF browser process before the application exits.
91 // Perform a single iteration of CEF message loop processing. This function is
92 // used to integrate the CEF message loop into an existing application message
93 // loop. Care must be taken to balance performance against excessive CPU usage.
94 // This function should only be called on the main application thread and only
95 // if CefInitialize() is called with a CefSettings.multi_threaded_message_loop
96 // value of false. This function will not block.
99 void CefDoMessageLoopWork();
102 // Run the CEF message loop. Use this function instead of an application-
103 // provided message loop to get the best balance between performance and CPU
104 // usage. This function should only be called on the main application thread and
105 // only if CefInitialize() is called with a
106 // CefSettings.multi_threaded_message_loop value of false. This function will
107 // block until a quit message is received by the system.
110 void CefRunMessageLoop();
113 // Quit the CEF message loop that was started by calling CefRunMessageLoop().
114 // This function should only be called on the main application thread and only
115 // if CefRunMessageLoop() was used.
118 void CefQuitMessageLoop();
121 // Set to true before calling Windows APIs like TrackPopupMenu that enter a
122 // modal message loop. Set to false after exiting the modal message loop.
125 void CefSetOSModalLoop(bool osModalLoop);
128 // Implement this interface to provide handler implementations. Methods will be
129 // called by the process and/or thread indicated.
131 /*--cef(source=client,no_debugct_check)--*/
132 class CefApp : public virtual CefBase {
135 // Provides an opportunity to view and/or modify command-line arguments before
136 // processing by CEF and Chromium. The |process_type| value will be empty for
137 // the browser process. Do not keep a reference to the CefCommandLine object
138 // passed to this method. The CefSettings.command_line_args_disabled value
139 // can be used to start with an empty command-line object. Any values
140 // specified in CefSettings that equate to command-line arguments will be set
141 // before this method is called. Be cautious when using this method to modify
142 // command-line arguments for non-browser processes as this may result in
143 // undefined behavior including crashes.
145 /*--cef(optional_param=process_type)--*/
146 virtual void OnBeforeCommandLineProcessing(
147 const CefString& process_type,
148 CefRefPtr<CefCommandLine> command_line) {
152 // Provides an opportunity to register custom schemes. Do not keep a reference
153 // to the |registrar| object. This method is called on the main thread for
154 // each process and the registered schemes should be the same across all
158 virtual void OnRegisterCustomSchemes(
159 CefRefPtr<CefSchemeRegistrar> registrar) {
163 // Return the handler for resource bundle events. If
164 // CefSettings.pack_loading_disabled is true a handler must be returned. If no
165 // handler is returned resources will be loaded from pack files. This method
166 // is called by the browser and render processes on multiple threads.
169 virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
174 // Return the handler for functionality specific to the browser process. This
175 // method is called on multiple threads in the browser process.
178 virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
183 // Return the handler for functionality specific to the render process. This
184 // method is called on the render process main thread.
187 virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
192 #endif // CEF_INCLUDE_CEF_APP_H_