1 /* Berkelium - Embedded Chromium
4 * Copyright (c) 2009, Daniel Reiter Horn
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Sirikata nor the names of its contributors may
17 * be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
24 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _BERKELIUM_HPP_
34 #define _BERKELIUM_HPP_
35 #include "berkelium/Platform.hpp"
36 #include "berkelium/WeakString.hpp"
46 /** May be implemented to handle global errors gracefully.
48 class BERKELIUM_EXPORT ErrorDelegate {
50 virtual ~ErrorDelegate() {}
53 /* TODO: Allow forkedProcessHook to be called without requiring the
54 library to be initialized/in memory (unless this is a sub-process).
55 i.e. an inline function that first searches for "--type=" in argv,
56 then uses dlopen or GetProcAddress.
59 /** Called by child processes.
60 * Should only ever be called from subprocess.cpp (berkelium.exe).
63 void BERKELIUM_EXPORT forkedProcessHook(
64 sandbox::BrokerServices* (*ptrGetBrokerServices)(),
65 sandbox::TargetServices* (*ptrGetTargetServices)(),
66 bool (*ptrSetCurrentProcessDEP)(enum sandbox::DepEnforcement));
68 void BERKELIUM_EXPORT forkedProcessHook(int argc, char **argv);
71 /** Iniitialize berkelium's global object.
72 * \param homeDirectory Just like Chrome's --user-data-dir command line flag.
73 * If homeDirectory is null or empty, creates a temporary data directory.
74 * \param subprocessDirectory Path to berkelium.exe.
76 bool BERKELIUM_EXPORT init(FileString homeDirectory, FileString subprocessDirectory);
78 /** Iniitialize berkelium's global object.
79 * \param homeDirectory Just like Chrome's --user-data-dir command line flag.
80 * If homeDirectory is null or empty, creates a temporary data directory.
82 bool BERKELIUM_EXPORT init(FileString homeDirectory);
84 /** Destroys Berkelium and attempts to free as much memory as possible.
85 * Note: You must destroy all Window and Context objects before calling
86 * Berkelium::destroy()!
88 void BERKELIUM_EXPORT destroy();
90 void BERKELIUM_EXPORT setErrorHandler(ErrorDelegate * errorHandler);
92 /** Runs the message loop until all pending messages are processed.
93 * Must be called from the same thread as all other Berkelium functions,
94 * usually your program's main (UI) thread.
95 * For now, you have to poll to receive updates without blocking indefinitely.
97 * Your WindowDelegate's should only receive callbacks synchronously with
98 * this call to update.
100 void BERKELIUM_EXPORT update();
101 void BERKELIUM_EXPORT runUntilStopped();
102 void BERKELIUM_EXPORT stopRunning();