Skip to content

Commit 6643927

Browse files
CzarekCzarek
authored andcommitted
Fixed the compile.py script, sometimes the Makefile didn't
recognize the changes and that it should be recompiled. CEF 3 js bindings preparation: client handler, CefApp, browser process handler, render process handler.
1 parent ab41857 commit 6643927

File tree

11 files changed

+372
-63
lines changed

11 files changed

+372
-63
lines changed

cefpython/cef3/client_handler/client_handler.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,12 @@
33
// Website: http://code.google.com/p/cefpython/
44

55
#include "client_handler.h"
6+
#include <stdio.h>
7+
8+
bool ClientHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
9+
CefProcessId source_process,
10+
CefRefPtr<CefProcessMessage> message) {
11+
std::string name = message.get()->GetName().ToString();
12+
printf("ClientHandler::OnProcessMessageReceived(): %s\n", name.c_str());
13+
return false;
14+
}

cefpython/cef3/client_handler/client_handler.h

Lines changed: 121 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,132 @@ class ClientHandler :
1717
ClientHandler(){}
1818
virtual ~ClientHandler(){}
1919

20+
///
21+
// Return the handler for context menus. If no handler is provided the default
22+
// implementation will be used.
23+
///
24+
/*--cef()--*/
25+
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
26+
return NULL;
27+
}
28+
29+
///
30+
// Return the handler for dialogs. If no handler is provided the default
31+
// implementation will be used.
32+
///
33+
/*--cef()--*/
34+
virtual CefRefPtr<CefDialogHandler> GetDialogHandler() OVERRIDE {
35+
return NULL;
36+
}
37+
38+
///
39+
// Return the handler for browser display state events.
40+
///
41+
/*--cef()--*/
42+
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
43+
return NULL;
44+
}
45+
46+
///
47+
// Return the handler for download events. If no handler is returned downloads
48+
// will not be allowed.
49+
///
50+
/*--cef()--*/
51+
virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE {
52+
return NULL;
53+
}
54+
55+
///
56+
// Return the handler for drag events.
57+
///
58+
/*--cef()--*/
59+
virtual CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE {
60+
return NULL;
61+
}
62+
63+
///
64+
// Return the handler for focus events.
65+
///
66+
/*--cef()--*/
67+
virtual CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE {
68+
return NULL;
69+
}
70+
71+
///
72+
// Return the handler for geolocation permissions requests. If no handler is
73+
// provided geolocation access will be denied by default.
74+
///
75+
/*--cef()--*/
76+
virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
77+
return NULL;
78+
}
79+
80+
///
81+
// Return the handler for JavaScript dialogs. If no handler is provided the
82+
// default implementation will be used.
83+
///
84+
/*--cef()--*/
85+
virtual CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() OVERRIDE {
86+
return NULL;
87+
}
88+
89+
///
90+
// Return the handler for keyboard events.
91+
///
92+
/*--cef()--*/
93+
virtual CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE {
94+
return NULL;
95+
}
96+
97+
///
98+
// Return the handler for browser life span events.
99+
///
100+
/*--cef()--*/
101+
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
102+
return NULL;
103+
}
104+
105+
///
106+
// Return the handler for browser load status events.
107+
///
108+
/*--cef()--*/
109+
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
110+
return NULL;
111+
}
112+
113+
///
114+
// Return the handler for off-screen rendering events.
115+
///
116+
/*--cef()--*/
117+
virtual CefRefPtr<CefRenderHandler> GetRenderHandler() OVERRIDE {
118+
return NULL;
119+
}
120+
121+
///
122+
// Return the handler for browser request events.
123+
///
124+
/*--cef()--*/
125+
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
126+
return NULL;
127+
}
128+
129+
///
130+
// Called when a new message is received from a different process. Return true
131+
// if the message was handled or false otherwise. Do not keep a reference to
132+
// or attempt to access the message outside of this callback.
133+
///
134+
/*--cef()--*/
135+
virtual bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
136+
CefProcessId source_process,
137+
CefRefPtr<CefProcessMessage> message)
138+
OVERRIDE;
139+
20140
protected:
21141

22142
// Include the default reference counting implementation.
23143
IMPLEMENT_REFCOUNTING(ClientHandler);
24144

25145
// Include the default locking implementation.
26-
IMPLEMENT_LOCKING(ClientHandler);
146+
// IMPLEMENT_LOCKING(ClientHandler);
27147

28148
};

cefpython/cef3/linux/compile.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,33 @@
4343
# make should succeed.
4444

4545
os.chdir("./../../cpp_utils/")
46+
subprocess.call("rm -f *.o *.a", shell=True)
47+
4648
ret = subprocess.call("make -f Makefile", shell=True)
4749
if ret != 0:
4850
what = raw_input("make failed, press 'y' to continue, 'n' to stop: ")
4951
if what != "y":
5052
sys.exit(1)
5153

5254
os.chdir("./../cef3/client_handler/")
55+
subprocess.call("rm -f *.o *.a", shell=True)
56+
5357
ret = subprocess.call("make -f Makefile", shell=True)
5458
if ret != 0:
5559
what = raw_input("make failed, press 'y' to continue, 'n' to stop: ")
5660
if what != "y":
5761
sys.exit(1)
5862

5963
os.chdir("./../subprocess/")
64+
subprocess.call("rm -f *.o *.a", shell=True)
65+
subprocess.call("rm -f subprocess", shell=True)
66+
67+
ret = subprocess.call("make -f Makefile-libcefpythonapp", shell=True)
68+
if ret != 0:
69+
what = raw_input("make failed, press 'y' to continue, 'n' to stop: ")
70+
if what != "y":
71+
sys.exit(1)
72+
6073
ret = subprocess.call("make -f Makefile", shell=True)
6174
if ret != 0:
6275
what = raw_input("make failed, press 'y' to continue, 'n' to stop: ")
@@ -67,6 +80,8 @@
6780
st = os.stat(subprocess_exe)
6881
os.chmod(subprocess_exe, st.st_mode | stat.S_IEXEC)
6982

83+
84+
7085
# os.chdir("./../v8function_handler/")
7186
# ret = subprocess.call("make -f Makefile", shell=True)
7287
# if ret != 0:

cefpython/cef3/linux/setup/setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ def CompileTimeConstants():
6565
r'./lib_%s' % BITS,
6666
# r'./../../v8function_handler/',
6767
r'./../../client_handler/',
68+
r'./../../subprocess/', # libcefpythonapp
6869
r'./../../../cpp_utils/'
6970
],
7071

7172
libraries=[
7273
'cef_dll_wrapper',
7374
# 'v8function_handler',
7475
'client_handler',
76+
'cefpythonapp',
7577
'cpp_utils'
7678
],
7779

cefpython/cef3/subprocess/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ LIB = -L./../linux/setup/lib_64bit -L./../linux/setup/lib_32bit -L./../linux/bin
99
subprocess:
1010
# Cython compiler options:
1111
# -fPIC -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro
12-
g++ -fPIC $(INC) $(LIB) main.cpp -lcef_dll_wrapper -lcef -o subprocess -Wl,-rpath,.
12+
g++ -fPIC $(INC) $(LIB) main.cpp cefpython_app.cpp -lcef_dll_wrapper -lcef -o subprocess -Wl,-rpath,.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CC = g++
2+
CCFLAGS = -g
3+
4+
SRC = cefpython_app.cpp
5+
OBJ = $(SRC:.cpp=.o)
6+
OUT = libcefpythonapp.a
7+
8+
INC = -I./../ -I/usr/include/python2.7 -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/atk-1.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include
9+
10+
.cpp.o:
11+
$(CC) -fPIC $(INC) $(CCFLAGS) -c $< -o $@
12+
13+
$(OUT): $(OBJ)
14+
ar rcs $(OUT) $(OBJ)
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// Copyright (c) 2012-2013 The CEF Python authors. All rights reserved.
2+
// License: New BSD License.
3+
// Website: http://code.google.com/p/cefpython/
4+
5+
#include "cefpython_app.h"
6+
#include "util.h"
7+
#include <stdio.h>
8+
9+
void DebugLog(const char* szString)
10+
{
11+
FILE* pFile = fopen("debug.log", "a");
12+
fprintf(pFile, "cefpython_app: %s\n", szString);
13+
fclose(pFile);
14+
}
15+
16+
// -----------------------------------------------------------------------------
17+
// CefApp
18+
// -----------------------------------------------------------------------------
19+
20+
void CefPythonApp::OnBeforeCommandLineProcessing(
21+
const CefString& process_type,
22+
CefRefPtr<CefCommandLine> command_line) {
23+
}
24+
25+
void CefPythonApp::OnRegisterCustomSchemes(
26+
CefRefPtr<CefSchemeRegistrar> registrar) {
27+
}
28+
29+
CefRefPtr<CefResourceBundleHandler> CefPythonApp::GetResourceBundleHandler() {
30+
return NULL;
31+
}
32+
33+
CefRefPtr<CefBrowserProcessHandler> CefPythonApp::GetBrowserProcessHandler() {
34+
return this;
35+
}
36+
37+
CefRefPtr<CefRenderProcessHandler> CefPythonApp::GetRenderProcessHandler() {
38+
DebugLog("GetRenderProcessHandler() called");
39+
return this;
40+
}
41+
42+
// -----------------------------------------------------------------------------
43+
// CefBrowserProcessHandler
44+
// -----------------------------------------------------------------------------
45+
46+
void CefPythonApp::OnContextInitialized() {
47+
REQUIRE_UI_THREAD();
48+
}
49+
50+
void CefPythonApp::OnBeforeChildProcessLaunch(
51+
CefRefPtr<CefCommandLine> command_line) {}
52+
53+
void CefPythonApp::OnRenderProcessThreadCreated(
54+
CefRefPtr<CefListValue> extra_info) {
55+
REQUIRE_IO_THREAD();
56+
}
57+
58+
// -----------------------------------------------------------------------------
59+
// CefRenderProcessHandler
60+
// -----------------------------------------------------------------------------
61+
62+
void CefPythonApp::OnRenderThreadCreated(CefRefPtr<CefListValue> extra_info) {
63+
}
64+
65+
void CefPythonApp::OnWebKitInitialized() {
66+
}
67+
68+
void CefPythonApp::OnBrowserCreated(CefRefPtr<CefBrowser> browser) {
69+
}
70+
71+
void CefPythonApp::OnBrowserDestroyed(CefRefPtr<CefBrowser> browser) {
72+
}
73+
74+
bool CefPythonApp::OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
75+
CefRefPtr<CefFrame> frame,
76+
CefRefPtr<CefRequest> request,
77+
cef_navigation_type_t navigation_type,
78+
bool is_redirect) {
79+
return false;
80+
}
81+
82+
void CefPythonApp::OnContextCreated(CefRefPtr<CefBrowser> browser,
83+
CefRefPtr<CefFrame> frame,
84+
CefRefPtr<CefV8Context> context) {
85+
DebugLog("OnContextCreated() called");
86+
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create(
87+
"OnContextCreated");
88+
browser.get()->SendProcessMessage(PID_BROWSER, msg);
89+
}
90+
91+
void CefPythonApp::OnContextReleased(CefRefPtr<CefBrowser> browser,
92+
CefRefPtr<CefFrame> frame,
93+
CefRefPtr<CefV8Context> context) {
94+
}
95+
96+
void CefPythonApp::OnUncaughtException(CefRefPtr<CefBrowser> browser,
97+
CefRefPtr<CefFrame> frame,
98+
CefRefPtr<CefV8Context> context,
99+
CefRefPtr<CefV8Exception> exception,
100+
CefRefPtr<CefV8StackTrace> stackTrace) {
101+
}
102+
103+
void CefPythonApp::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
104+
CefRefPtr<CefFrame> frame,
105+
CefRefPtr<CefDOMNode> node) {
106+
}
107+
108+
bool CefPythonApp::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
109+
CefProcessId source_process,
110+
CefRefPtr<CefProcessMessage> message) {
111+
return false;
112+
}

0 commit comments

Comments
 (0)