Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 188a002

Browse files
committed
[[ revBrowserCEF ]] Reinstate IE-based browser.
[[ revBrowserCEF ]] Add command to create CEF-based browser
1 parent bd03d30 commit 188a002

File tree

6 files changed

+33
-29
lines changed

6 files changed

+33
-29
lines changed

revbrowser/revbrowser.vcproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@
228228
>
229229
<FileConfiguration
230230
Name="Debug|Win32"
231-
ExcludedFromBuild="true"
232231
>
233232
<Tool
234233
Name="VCCLCompilerTool"

revbrowser/src/cefbrowser_w32.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,3 @@ bool MCCefWin32Browser::PlatformGetWindowID(int32_t &r_id)
176176
return true;
177177
}
178178

179-
180-
static HINSTANCE s_instance = nil;
181-
182-
// DLL Entry Point
183-
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
184-
{
185-
switch (dwReason)
186-
{
187-
case DLL_PROCESS_ATTACH:
188-
s_instance = hInstance;
189-
break;
190-
191-
case DLL_PROCESS_DETACH:
192-
break;
193-
194-
}
195-
196-
return TRUE;
197-
}

revbrowser/src/revbrowser.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,15 +806,19 @@ void CB_NewWindow(int p_instance_id, const char *p_url)
806806
// Result:
807807
// The instance ID of the new browser.
808808
//
809-
void commonBrowserOpen(bool p_is_xbrowser, char *args[], int nargs, char **retstring, Bool *pass, Bool *error)
809+
void commonBrowserOpen(bool p_is_xbrowser, bool p_is_cef_browser, char *args[], int nargs, char **retstring, Bool *pass, Bool *error)
810810
{
811811
char *result = NULL;
812812
char inID[255];
813813

814814
if( nargs > 0 )
815815
{
816816
CWebBrowserBase *t_browser;
817-
t_browser = InstantiateBrowser(atoi(args[0]));
817+
if (p_is_cef_browser)
818+
t_browser = MCCefBrowserInstantiate(atoi(args[0]));
819+
else
820+
t_browser = InstantiateBrowser(atoi(args[0]));
821+
818822

819823
if (t_browser != NULL)
820824
{
@@ -846,12 +850,18 @@ void commonBrowserOpen(bool p_is_xbrowser, char *args[], int nargs, char **retst
846850

847851
void revBrowserOpen(char *args[], int nargs, char **retstring, Bool *pass, Bool *error)
848852
{
849-
commonBrowserOpen(false, args, nargs, retstring, pass, error);
853+
commonBrowserOpen(false, false, args, nargs, retstring, pass, error);
854+
}
855+
856+
// IM-2014-03-18: [[ revBrowserCEF ]] create new browser instance using CEF
857+
void revBrowserOpenCef(char *args[], int nargs, char **retstring, Bool *pass, Bool *error)
858+
{
859+
commonBrowserOpen(false, true, args, nargs, retstring, pass, error);
850860
}
851861

852862
void XBrowserOpen(char *args[], int nargs, char **retstring, Bool *pass, Bool *error)
853863
{
854-
commonBrowserOpen(true, args, nargs, retstring, pass, error);
864+
commonBrowserOpen(true, false, args, nargs, retstring, pass, error);
855865
}
856866

857867
// Command:
@@ -1877,6 +1887,7 @@ template<BrowserHandler u_handler> void revBrowserWrapper(char *p_arguments[], i
18771887

18781888
EXTERNAL_BEGIN_DECLARATIONS("revBrowser")
18791889
EXTERNAL_DECLARE_FUNCTION_OBJC("revBrowserOpen", revBrowserOpen)
1890+
EXTERNAL_DECLARE_FUNCTION_OBJC("revBrowserOpenCef", revBrowserOpenCef)
18801891
EXTERNAL_DECLARE_COMMAND_OBJC("revBrowserClose", revBrowserWrapper<revBrowserClose>)
18811892
EXTERNAL_DECLARE_COMMAND_OBJC("revBrowserStop", revBrowserWrapper<revBrowserStop>)
18821893
EXTERNAL_DECLARE_COMMAND_OBJC("revBrowserRefresh", revBrowserWrapper<revBrowserRefresh>)

revbrowser/src/revbrowser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class CWebBrowserBase
8787
};
8888

8989
CWebBrowserBase *InstantiateBrowser(int p_window_id);
90+
// IM-2014-03-18: [[ revBrowserCEF ]] Create new cef-based browser instance
91+
CWebBrowserBase *MCCefBrowserInstantiate(int p_window_id);
9092

9193
// IM-2014-03-06: [[ revBrowserCEF ]] Send the handler message with the given args
9294
void CB_Custom(int p_instance_id, const char *p_message, char **p_args, uint32_t p_arg_count, bool *r_cancel);

revbrowser/src/w32browser.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ for more details.
1414
You should have received a copy of the GNU General Public License
1515
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1616

17+
#include "core.h"
18+
1719
#include "w32browser.h"
1820
#include <activscp.h>
1921
#include <revolution/support.h>
@@ -187,10 +189,6 @@ CWebBrowser::CWebBrowser(HWND hparent, BOOL isvisible)
187189
s_browsers = this;
188190
}
189191

190-
CWebBrowserBase::~CWebBrowserBase(void)
191-
{
192-
}
193-
194192
CWebBrowser::~CWebBrowser()
195193
{
196194

@@ -1376,6 +1374,16 @@ void CWebBrowser::SetUserAgent(const char *p_user_agent)
13761374
{
13771375
}
13781376

1377+
//////////
1378+
1379+
void CWebBrowser::AddJavaScriptHandler(const char *p_handler)
1380+
{
1381+
}
1382+
1383+
void CWebBrowser::RemoveJavaScriptHandler(const char *p_handler)
1384+
{
1385+
}
1386+
13791387
///////////////////////////////////////////////////////////////////////////////
13801388
//
13811389
// EVENT HANDLING

revbrowser/src/w32browser.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CWebBrowser: public CWebBrowserBase
7272
public:
7373
CWebBrowser(HWND hparent, BOOL isvisible);
7474
CWebBrowser(HWND hparent, BOOL isvisible, BrowserType browser);
75-
~CWebBrowser(void);
75+
virtual ~CWebBrowser(void);
7676

7777
BOOL IsInited() {return inited;}
7878

@@ -146,6 +146,9 @@ class CWebBrowser: public CWebBrowserBase
146146
void SetWindowId(int id);
147147
void SetUserAgent(const char *p_user_agent);
148148

149+
virtual void AddJavaScriptHandler(const char *p_handler);
150+
virtual void RemoveJavaScriptHandler(const char *p_handler);
151+
149152
HWND GetHWND();
150153
HWND GetHostWindow()
151154
{return inited == TRUE? hostwindow: 0;}

0 commit comments

Comments
 (0)