Project

General

Profile

SO3Engine
SO3EmbeddedWebNavigatorClient.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_CLIENT_
25#define _SCOL_EMBEDDED_WEB_NAVIGATOR_CLIENT_
26
33
34#if SO3_WEB_NAVIGATOR_BUILD == 1
35#include "include/cef_client.h"
36#include "include/cef_browser.h"
37#include "include/cef_frame.h"
38#include "include/cef_print_handler.h"
39#include "include/cef_render_process_handler.h"
40#include "include/cef_context_menu_handler.h"
41#include "include/base/cef_lock.h"
42
43#include "OgreTexture.h"
44
45namespace SO3
46{
47 namespace EmbeddedWebNavigator
48 {
49
50 class WebNavigatorClient : public CefClient,
51 public CefContextMenuHandler,
52 public CefLifeSpanHandler,
53 public CefDragHandler,
54 public CefRequestHandler
55 {
56 public:
57 protected:
58 //Include the default reference counting implementation.
60 // Include the default locking implementation.
62 private:
63 const ScolWindowHandle scolMainWindowHandle;
64 WebNavigator* parentWebNavigator;
65 CefRefPtr<CefBrowser> cefBrowser;
66
67 CefRefPtr<WebNavigatorDisplayHandler> displayHandler;
68 CefRefPtr<WebNavigatorKeyboardHandler> keyboardHandler;
69 CefRefPtr<WebNavigatorLoadHandler> loadHandler;
70 CefRefPtr<WebNavigatorRenderHandler> renderHandler;
71 public:
75 WebNavigatorClient(WebNavigator* parentWebNavigatorInstance, const ScolWindowHandle& scolMainWindow, bool offscreen);
76
80 virtual ~WebNavigatorClient();
81
85 bool BlitOffscreenBitmap(unsigned char* dest, int destWidth, int destHeight, int destBytesPerPixel, int destBitsPerLine);
86
90 bool BlitOffscreenAlphaBitmap(unsigned char* destColor, unsigned char* destAlpha, int destWidth, int destHeight, int destColorBytesPerPixel, int destColorBitsPerLine);
91
94 bool BlitOffscreenTexture(Ogre::TexturePtr& ogreTexture, bool forceUpdate);
95
98 bool CheckPixelAlpha(int posX, int posY, float transparentTresholdColor);
99
103 virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE
104 {
105 return this;
106 }
107 virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE
108 {
109 return this;
110 }
111 virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE
112 {
113 return this;
114 }
115 virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE
116 {
117 return this;
118 }
119 virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE
120 {
121 return displayHandler;
122 }
123 virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE
124 {
125 return keyboardHandler;
126 }
127 virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE
128 {
129 return loadHandler;
130 }
131 virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE
132 {
133 return renderHandler;
134 }
135
136 virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, CefProcessId source_process, CefRefPtr<CefProcessMessage> message) OVERRIDE;
137
141 virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
142 virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
143 virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, bool* no_javascript_access) OVERRIDE;
144 virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
145
150 virtual void OnBeforeContextMenu(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefContextMenuParams> params, CefRefPtr<CefMenuModel> model) OVERRIDE;
151 virtual bool OnContextMenuCommand(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefContextMenuParams> params, int command_id, CefContextMenuHandler::EventFlags event_flags) OVERRIDE;
152
155 CefRefPtr<CefBrowser> GetBrowser();
156
160
165 void _Cleanup();
166 protected:
167 private:
172 };
173
174 }
175}
176
177#endif
178#endif
bool BlitOffscreenAlphaBitmap(unsigned char *destColor, unsigned char *destAlpha, int destWidth, int destHeight, int destColorBytesPerPixel, int destColorBitsPerLine)
virtual CefRefPtr< CefKeyboardHandler > GetKeyboardHandler() OVERRIDE
virtual bool OnContextMenuCommand(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefContextMenuParams > params, int command_id, CefContextMenuHandler::EventFlags event_flags) OVERRIDE
virtual CefRefPtr< CefRequestHandler > GetRequestHandler() OVERRIDE
virtual void OnBeforeContextMenu(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefContextMenuParams > params, CefRefPtr< CefMenuModel > model) OVERRIDE
virtual bool OnProcessMessageReceived(CefRefPtr< CefBrowser > browser, CefProcessId source_process, CefRefPtr< CefProcessMessage > message) OVERRIDE
virtual CefRefPtr< CefDragHandler > GetDragHandler() OVERRIDE
virtual CefRefPtr< CefDisplayHandler > GetDisplayHandler() OVERRIDE
virtual bool DoClose(CefRefPtr< CefBrowser > browser) OVERRIDE
virtual CefRefPtr< CefContextMenuHandler > GetContextMenuHandler() OVERRIDE
virtual CefRefPtr< CefRenderHandler > GetRenderHandler() OVERRIDE
bool CheckPixelAlpha(int posX, int posY, float transparentTresholdColor)
virtual CefRefPtr< CefLoadHandler > GetLoadHandler() OVERRIDE
virtual bool OnBeforePopup(CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, const CefString &target_url, const CefString &target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures &popupFeatures, CefWindowInfo &windowInfo, CefRefPtr< CefClient > &client, CefBrowserSettings &settings, bool *no_javascript_access) OVERRIDE
bool BlitOffscreenTexture(Ogre::TexturePtr &ogreTexture, bool forceUpdate)
virtual void OnBeforeClose(CefRefPtr< CefBrowser > browser) OVERRIDE
bool BlitOffscreenBitmap(unsigned char *dest, int destWidth, int destHeight, int destBytesPerPixel, int destBitsPerLine)
virtual void OnAfterCreated(CefRefPtr< CefBrowser > browser) OVERRIDE
virtual CefRefPtr< CefLifeSpanHandler > GetLifeSpanHandler() OVERRIDE