Project

General

Profile

SO3Engine
SO3EmbeddedWebNavigatorThread.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_THREAD_
25#define _SCOL_EMBEDDED_WEB_NAVIGATOR_THREAD_
26
28
29#if SO3_WEB_NAVIGATOR_BUILD == 1
30#include "include/cef_cookie.h"
31#include "include/cef_scheme.h"
32
33namespace SO3
34{
35 namespace EmbeddedWebNavigator
36 {
37 class StringVisitor : public CefStringVisitor
38 {
39 public:
40 explicit StringVisitor() {}
41 virtual void Visit(const CefString& string)
42 {
43 content.append(string);
44 }
45
46 std::string GetContent()
47 {
48 return content;
49 }
50 private:
51 std::string content;
52 IMPLEMENT_REFCOUNTING(StringVisitor);
53 };
54
55 class CompletionCallback : public CefCompletionCallback
56 {
57 public:
58 explicit CompletionCallback(CefRefPtr<CefWaitableEvent> event) : event_(event) {}
59 void OnComplete() override { event_->Signal(); }
60
61 private:
62 CefRefPtr<CefWaitableEvent> event_;
63
64 IMPLEMENT_REFCOUNTING(CompletionCallback);
65 DISALLOW_COPY_AND_ASSIGN(CompletionCallback);
66 };
67
68 class SetCookieCallback : public CefSetCookieCallback
69 {
70 public:
71 SetCookieCallback(CefRefPtr<CefWaitableEvent> event) : event_(event) {}
72
73 void OnComplete(bool success) override
74 {
75 event_->Signal();
76 }
77
78 private:
79 CefRefPtr<CefWaitableEvent> event_;
80
81 IMPLEMENT_REFCOUNTING(SetCookieCallback);
82 DISALLOW_COPY_AND_ASSIGN(SetCookieCallback);
83 };
84
85 class DeleteCookiesCallback : public CefDeleteCookiesCallback
86 {
87 public:
88 DeleteCookiesCallback(CefRefPtr<CefWaitableEvent> event) : event_(event) {}
89
90 void OnComplete(int num_deleted) override
91 {
92 event_->Signal();
93 }
94
95 private:
96 CefRefPtr<CefWaitableEvent> event_;
97
98 IMPLEMENT_REFCOUNTING(DeleteCookiesCallback);
99 DISALLOW_COPY_AND_ASSIGN(DeleteCookiesCallback);
100 };
101
103 {
104 public:
105 protected:
106 private:
107
108 public:
114 static void LoadURL(unsigned long webNavigatorId, const std::string url, const std::string frameName = "");
115
122 static void LoadFile(unsigned long webNavigatorId, const std::string file, const std::string frameName = "");
123
124 /*
125 Loads a string of HTML.
126 @param url The html text to load
127 @param frameName The target frame, main frame will be used if empty.
128 @note Relative URLs will be resolved using the base directory.
129 */
130 static void LoadHTML(unsigned long webNavigatorId, const std::string html, const std::string frameName = "");
131
136 static void GetURL(unsigned long webNavigatorId, std::string* frameUrl, HANDLE synchro, const std::string frameName = "");
137
142 static void Undo(unsigned long webNavigatorId, const std::string frameName = "");
143
148 static void Redo(unsigned long webNavigatorId, const std::string frameName = "");
149
154 static void Cut(unsigned long webNavigatorId, const std::string frameName = "");
155
160 static void Copy(unsigned long webNavigatorId, const std::string frameName = "");
161
166 static void Paste(unsigned long webNavigatorId, const std::string frameName = "");
167
172 static void Delete(unsigned long webNavigatorId, const std::string frameName = "");
173
178 static void SelectAll(unsigned long webNavigatorId, const std::string frameName = "");
179
184 static void Print(unsigned long webNavigatorId, const std::string frameName = "");
185
190 static void ViewSource(unsigned long webNavigatorId, const std::string frameName = "");
191
196 static void GetSource(unsigned long webNavigatorId, std::string* frameSource, HANDLE synchro, const std::string frameName = "");
197
202 static void GetText(unsigned long webNavigatorId, std::string* frameText, HANDLE synchro, const std::string frameName = "");
203
211 static void ExecuteJavaScript(unsigned long webNavigatorId, const std::string jsCode, const std::string scriptUrl, int startLine, const std::string frameName = "");
212
216 static void CanGoBack(unsigned long webNavigatorId, bool* canGoBack, HANDLE synchro);
217
221 static void GoBack(unsigned long webNavigatorId);
222
226 static void CanGoForward(unsigned long webNavigatorId, bool* canGoForward, HANDLE synchro);
227
231 static void GoForward(unsigned long webNavigatorId);
232
236 static void Reload(unsigned long webNavigatorId);
237
241 static void ReloadIgnoreCache(unsigned long webNavigatorId);
242
246 static void StopLoad(unsigned long webNavigatorId);
247
256 static void Find(unsigned long webNavigatorId, int identifier, const CefString searchText, bool forward, bool matchCase, bool findNext);
257
261 static void StopFinding(unsigned long webNavigatorId, bool clearSelection);
262
266 static void GetZoomLevel(unsigned long webNavigatorId, double* zoomFactor, HANDLE synchro);
267
271 static void SetZoomLevel(unsigned long webNavigatorId, double zoomLevel);
272
276 static void ClearHistory(unsigned long webNavigatorId);
277
281 static void ShowDevTools(unsigned long webNavigatorId);
282
286 static void CloseDevTools(unsigned long webNavigatorId);
287
290 static void SetCookie(std::string url, CefCookie cookie, bool* result, HANDLE synchro);
291
294 static void DeleteCookies(std::string url, std::string cookie_name, bool* result, HANDLE synchro);
295 protected:
296 private:
301 };
302
303 }
304}
305
306#endif
307#endif
SCOL_EXPORT void SCOL_PTR_TYPE event
Definition SO3SCOL.cpp:5128
CompletionCallback(CefRefPtr< CefWaitableEvent > event)
virtual void Visit(const CefString &string)
static void Delete(unsigned long webNavigatorId, const std::string frameName="")
static void ClearHistory(unsigned long webNavigatorId)
static void Find(unsigned long webNavigatorId, int identifier, const CefString searchText, bool forward, bool matchCase, bool findNext)
static void ReloadIgnoreCache(unsigned long webNavigatorId)
static void GetSource(unsigned long webNavigatorId, std::string *frameSource, HANDLE synchro, const std::string frameName="")
static void CanGoBack(unsigned long webNavigatorId, bool *canGoBack, HANDLE synchro)
static void Cut(unsigned long webNavigatorId, const std::string frameName="")
static void CloseDevTools(unsigned long webNavigatorId)
static void GoForward(unsigned long webNavigatorId)
static void LoadHTML(unsigned long webNavigatorId, const std::string html, const std::string frameName="")
static void LoadFile(unsigned long webNavigatorId, const std::string file, const std::string frameName="")
static void LoadURL(unsigned long webNavigatorId, const std::string url, const std::string frameName="")
static void DeleteCookies(std::string url, std::string cookie_name, bool *result, HANDLE synchro)
static void Print(unsigned long webNavigatorId, const std::string frameName="")
static void SelectAll(unsigned long webNavigatorId, const std::string frameName="")
static void StopFinding(unsigned long webNavigatorId, bool clearSelection)
static void CanGoForward(unsigned long webNavigatorId, bool *canGoForward, HANDLE synchro)
static void Copy(unsigned long webNavigatorId, const std::string frameName="")
static void GetZoomLevel(unsigned long webNavigatorId, double *zoomFactor, HANDLE synchro)
static void GetURL(unsigned long webNavigatorId, std::string *frameUrl, HANDLE synchro, const std::string frameName="")
static void Undo(unsigned long webNavigatorId, const std::string frameName="")
static void GetText(unsigned long webNavigatorId, std::string *frameText, HANDLE synchro, const std::string frameName="")
static void ShowDevTools(unsigned long webNavigatorId)
static void SetCookie(std::string url, CefCookie cookie, bool *result, HANDLE synchro)
static void Redo(unsigned long webNavigatorId, const std::string frameName="")
static void ViewSource(unsigned long webNavigatorId, const std::string frameName="")
static void Paste(unsigned long webNavigatorId, const std::string frameName="")
static void ExecuteJavaScript(unsigned long webNavigatorId, const std::string jsCode, const std::string scriptUrl, int startLine, const std::string frameName="")
static void SetZoomLevel(unsigned long webNavigatorId, double zoomLevel)