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 // provided for cases where the CEF message loop must be integrated into an
93 // existing application message loop. Use of this function is not recommended
94 // for most users; use either the CefRunMessageLoop() function or
95 // CefSettings.multi_threaded_message_loop if possible. When using this function
96 // care must be taken to balance performance against excessive CPU usage. It is
97 // recommended to enable the CefSettings.external_message_pump option when using
98 // this function so that CefBrowserProcessHandler::OnScheduleMessagePumpWork()
99 // callbacks can facilitate the scheduling process. This function should only be
100 // called on the main application thread and only if CefInitialize() is called
101 // with a CefSettings.multi_threaded_message_loop value of false. This function
105 void CefDoMessageLoopWork();
108 // Run the CEF message loop. Use this function instead of an application-
109 // provided message loop to get the best balance between performance and CPU
110 // usage. This function should only be called on the main application thread and
111 // only if CefInitialize() is called with a
112 // CefSettings.multi_threaded_message_loop value of false. This function will
113 // block until a quit message is received by the system.
116 void CefRunMessageLoop();
119 // Quit the CEF message loop that was started by calling CefRunMessageLoop().
120 // This function should only be called on the main application thread and only
121 // if CefRunMessageLoop() was used.
124 void CefQuitMessageLoop();
127 // Set to true before calling Windows APIs like TrackPopupMenu that enter a
128 // modal message loop. Set to false after exiting the modal message loop.
131 void CefSetOSModalLoop(bool osModalLoop);
134 // Call during process startup to enable High-DPI support on Windows 7 or newer.
135 // Older versions of Windows should be left DPI-unaware because they do not
136 // support DirectWrite and GDI fonts are kerned very badly.
138 /*--cef(capi_name=cef_enable_highdpi_support)--*/
139 void CefEnableHighDPISupport();
142 // Implement this interface to provide handler implementations. Methods will be
143 // called by the process and/or thread indicated.
145 /*--cef(source=client,no_debugct_check)--*/
146 class CefApp : public virtual CefBaseRefCounted {
149 // Provides an opportunity to view and/or modify command-line arguments before
150 // processing by CEF and Chromium. The |process_type| value will be empty for
151 // the browser process. Do not keep a reference to the CefCommandLine object
152 // passed to this method. The CefSettings.command_line_args_disabled value
153 // can be used to start with an empty command-line object. Any values
154 // specified in CefSettings that equate to command-line arguments will be set
155 // before this method is called. Be cautious when using this method to modify
156 // command-line arguments for non-browser processes as this may result in
157 // undefined behavior including crashes.
159 /*--cef(optional_param=process_type)--*/
160 virtual void OnBeforeCommandLineProcessing(
161 const CefString& process_type,
162 CefRefPtr<CefCommandLine> command_line) {
166 // Provides an opportunity to register custom schemes. Do not keep a reference
167 // to the |registrar| object. This method is called on the main thread for
168 // each process and the registered schemes should be the same across all
172 virtual void OnRegisterCustomSchemes(
173 CefRawPtr<CefSchemeRegistrar> registrar) {
177 // Return the handler for resource bundle events. If
178 // CefSettings.pack_loading_disabled is true a handler must be returned. If no
179 // handler is returned resources will be loaded from pack files. This method
180 // is called by the browser and render processes on multiple threads.
183 virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
188 // Return the handler for functionality specific to the browser process. This
189 // method is called on multiple threads in the browser process.
192 virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
197 // Return the handler for functionality specific to the render process. This
198 // method is called on the render process main thread.
201 virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
206 #endif // CEF_INCLUDE_CEF_APP_H_