Project

General

Profile

SO3Engine
SO3EmbeddedWebNavigatorManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2011 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21-----------------------------------------------------------------------------
22*/
23
24#ifndef _SCOL_EMBEDDED_WEB_NAVIGATOR_MANAGER_
25#define _SCOL_EMBEDDED_WEB_NAVIGATOR_MANAGER_
26
29#if SO3_WEB_NAVIGATOR_BUILD == 1
30#include "include/cef_base.h"
31#include "include/cef_app.h"
32
33#include <boost/asio.hpp>
34#include <thread>
35#include <shared_mutex>
36
37namespace SO3
38{
39 namespace EmbeddedWebNavigator
40 {
41
42 class WebNavigatorManager : public CefApp,
43 public CefBrowserProcessHandler
44 {
45 public:
46 typedef std::map<unsigned long, WebNavigator*> WebNavigatorList;
47
49 boost::asio::io_service mainThreadWebMessageQueue;
50 protected:
51 private:
52 const ScolWindowHandle scolMainWindowHandle;
53 static WebNavigatorManager* thisInstance;
54 WebNavigatorList webNavigatorList;
55 unsigned long nextUniqueId;
56 HANDLE synchroEventSetCookie;
57 HANDLE synchroEventDeleteCookie;
58 bool bInitialized;
59 bool bContextInitialized;
60 std::string sCachePath;
61 public:
65 WebNavigatorManager(const ScolWindowHandle& scolMainWindow, std::string cacheDirectory);
66
71
76
81
85 static void DestroyManager();
86
90 bool IsInitialized();
91
95 virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() OVERRIDE
96 {
97 return this;
98 }
99
103 virtual void OnContextInitialized() OVERRIDE;
104
108 WebNavigator* CreateNavigator(const ScolWindowHandle& parentWindowHandle, int xPosition, int yPosition, int width, int height, std::string url);
109
113 WebNavigator* CreateNavigator(const ScolWindowHandle& parentWindowHandle, int width, int height, std::string url, bool transparency = false);
114
118 void DestroyNavigator(WebNavigator* webNavigator);
119
122 WebNavigator* GetNavigator(unsigned long uniqueId);
123
135 bool SetCookie(const std::string& url, const std::string& name, const std::string& value, const std::string& domain, const std::string& path, const bool& secure, const bool& httponly);
136
144 bool DeleteCookies(const std::string& url, const std::string& cookie_name);
145
149 void Update();
150
154 void InvokeExternalCall(unsigned long uniqueId, SScriptFunction functionCalled);
155
159 void InvokeExternalCallStr(unsigned long uniqueId, SScriptFunction functionCalled);
160
164 void InvokeNavStateChange(unsigned long uniqueId, bool canGoBack, bool canGoForward);
165
169 void InvokeAddressChange(unsigned long uniqueId, const std::string& frameName, const std::string& url);
170
174 void InvokeTitleChange(unsigned long uniqueId, const std::string& title);
175
179 void InvokeTooltip(unsigned long uniqueId, std::string& text);
180
184 void InvokeCursorChange(unsigned long uniqueId, HCURSOR newCursor);
185
189 void InvokeStatusMessage(unsigned long uniqueId, const std::string& value);
190
194 void InvokeConsoleMessage(unsigned long uniqueId, const std::string& message, const std::string& source, int line);
195
199 void InvokeBeforePopup(unsigned long uniqueId, int popupX, int popupY, int popupWidth, int popupHeight, std::string popupUrl);
200
204 void InvokeRunModal(unsigned long uniqueId);
205
209 void InvokeLoadStart(unsigned long uniqueId, const std::string& frameName);
210
214 void InvokeLoadEnd(unsigned long uniqueId, const std::string& frameName, int httpStatusCode);
215
219 void InvokeLoadError(unsigned long uniqueId, const std::string& frameName, int errorCode, const std::string& failedUrl, std::string& errorText);
220
224 void InvokeFindResult(unsigned long uniqueId, int identifier, int count, const CefRect& selectionRect, int activeMatchOrdinal, bool finalUpdate);
225 protected:
226 private:
227 void init();
228 IMPLEMENT_REFCOUNTING(WebNavigatorManager);
233 };
234
235 }
236}
237
238#endif
239#endif
void * HCURSOR
Definition SO3Android.h:60
void InvokeStatusMessage(unsigned long uniqueId, const std::string &value)
bool DeleteCookies(const std::string &url, const std::string &cookie_name)
void InvokeTooltip(unsigned long uniqueId, std::string &text)
std::map< unsigned long, WebNavigator * > WebNavigatorList
void InvokeNavStateChange(unsigned long uniqueId, bool canGoBack, bool canGoForward)
void InvokeConsoleMessage(unsigned long uniqueId, const std::string &message, const std::string &source, int line)
void InvokeExternalCall(unsigned long uniqueId, SScriptFunction functionCalled)
void InvokeLoadEnd(unsigned long uniqueId, const std::string &frameName, int httpStatusCode)
void InvokeLoadError(unsigned long uniqueId, const std::string &frameName, int errorCode, const std::string &failedUrl, std::string &errorText)
virtual CefRefPtr< CefBrowserProcessHandler > GetBrowserProcessHandler() OVERRIDE
WebNavigator * CreateNavigator(const ScolWindowHandle &parentWindowHandle, int xPosition, int yPosition, int width, int height, std::string url)
void InvokeCursorChange(unsigned long uniqueId, HCURSOR newCursor)
void InvokeExternalCallStr(unsigned long uniqueId, SScriptFunction functionCalled)
void InvokeTitleChange(unsigned long uniqueId, const std::string &title)
void InvokeFindResult(unsigned long uniqueId, int identifier, int count, const CefRect &selectionRect, int activeMatchOrdinal, bool finalUpdate)
void InvokeLoadStart(unsigned long uniqueId, const std::string &frameName)
bool SetCookie(const std::string &url, const std::string &name, const std::string &value, const std::string &domain, const std::string &path, const bool &secure, const bool &httponly)
void InvokeBeforePopup(unsigned long uniqueId, int popupX, int popupY, int popupWidth, int popupHeight, std::string popupUrl)
void InvokeAddressChange(unsigned long uniqueId, const std::string &frameName, const std::string &url)