00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __WEBCORE_H__
00009 #define __WEBCORE_H__
00010
00011 #include "WebView.h"
00012 #include <queue>
00013 #include <vector>
00014 #include <string>
00015
00016 namespace base { class Thread; class AtExitManager; }
00017 class WebCoreProxy;
00018 class WebViewEvent;
00019 class WindowlessPlugin;
00020 class NamedCallback;
00021 std::string GetDataResource(int id);
00022 class Lock;
00023
00024 namespace Awesomium {
00025
00029 enum LogLevel
00030 {
00031 LOG_NONE,
00032 LOG_NORMAL,
00033 LOG_VERBOSE
00034 };
00035
00039 enum PixelFormat
00040 {
00041 PF_BGRA,
00042 PF_RGBA
00043 };
00044
00049 class _OSMExport WebCore
00050 {
00051 public:
00075 WebCore(const std::wstring& cachePath = L"", const std::wstring& cookiePath = L"", const std::wstring& pluginPath = L"",
00076 const std::wstring& logPath = L"", LogLevel level = LOG_NORMAL, bool enablePlugins = false, PixelFormat pixelFormat = PF_BGRA);
00077
00081 ~WebCore();
00082
00090 static WebCore& Get();
00091
00097 static WebCore* GetPointer();
00098
00106 void setBaseDirectory(const std::string& baseDirectory);
00107
00115 void setBaseDirectory(const std::wstring& baseDirectory);
00116
00134 WebView* createWebView(int width, int height, bool isTransparent = false, bool enableAsyncRendering = false, int maxAsyncRenderPerSec = 70);
00135
00145 void setCustomResponsePage(int statusCode, const std::string& filePath);
00146
00151 void update();
00152
00158 const std::wstring& getBaseDirectory() const;
00159
00163 PixelFormat getPixelFormat() const;
00164
00168 bool arePluginsEnabled() const;
00169
00186 void pause();
00187
00193 void resume();
00194
00195 friend class WebView;
00196 friend class FutureJSValue;
00197 friend class ::WebCoreProxy;
00198 friend class ::WebViewProxy;
00199 friend class ::NamedCallback;
00200 friend class ::WindowlessPlugin;
00201 friend std::string GetDataResource(int id);
00202
00203 protected:
00204 static WebCore* instance;
00205 base::Thread* coreThread;
00206 WebCoreProxy* coreProxy;
00207 base::AtExitManager* atExitMgr;
00208 std::vector<WebView*> views;
00209 std::queue<WebViewEvent*> eventQueue;
00210 std::map<int, std::string> customResponsePageMap;
00211 std::wstring baseDirectory;
00212 bool logOpen;
00213 bool pluginsEnabled;
00214 const PixelFormat pixelFormat;
00215 Lock *eventQueueLock, *baseDirLock, *customResponsePageLock;
00216
00217 void queueEvent(WebViewEvent* event);
00218 void removeWebView(WebView* view);
00219
00220 void purgePluginMessages();
00221
00222 void resolveJSValueFuture(WebView* view, int requestID, JSValue* result);
00223
00224 void getCustomResponsePage(int statusCode, std::string& filePathResult);
00225 };
00226
00227 }
00228
00229 #endif