Skip to content

Commit 8172d3d

Browse files
CzarekCzarek
authored andcommitted
Porting CEF 3 to Linux - still underway. The GTK patch needs
yet to be applied to make it work.
1 parent 71d7fe3 commit 8172d3d

61 files changed

Lines changed: 3135 additions & 662 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cefpython/browser.pyx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ cdef class PyBrowser:
233233
cpdef object ClearHistory(self):
234234
self.GetCefBrowser().get().ClearHistory()
235235

236-
cpdef py_void CloseBrowser(self):
236+
cpdef py_void CloseBrowser(self, py_bool forceClose=False):
237237
# In cefclient/cefclient_win.cpp there is only
238238
# ParentWindowWillClose() called. CloseBrowser() is called
239239
# only for popups.
@@ -250,7 +250,7 @@ cdef class PyBrowser:
250250
self.GetCefBrowser().get().CloseBrowser()
251251
ELIF CEF_VERSION == 3:
252252
Debug("CefBrowserHost::CloseBrowser()")
253-
self.GetCefBrowserHost().get().CloseBrowser()
253+
self.GetCefBrowserHost().get().CloseBrowser(bool(forceClose))
254254

255255
IF CEF_VERSION == 1:
256256

@@ -362,8 +362,11 @@ cdef class PyBrowser:
362362
"Browser.IsPopupVisible() may only be called on UI thread")
363363
return self.GetCefBrowser().get().IsPopupVisible()
364364

365-
cpdef py_bool IsWindowRenderingDisabled(self):
365+
cpdef py_bool IsWindowRenderingDisabled(self):
366+
IF CEF_VERSION == 1:
366367
return self.GetCefBrowser().get().IsWindowRenderingDisabled()
368+
ELIF CEF_VERSION == 3:
369+
return self.GetCefBrowserHost().get().IsWindowRenderingDisabled()
367370

368371
cpdef py_void Reload(self):
369372
self.GetCefBrowser().get().Reload()
@@ -580,3 +583,28 @@ cdef class PyBrowser:
580583

581584
cpdef py_void SendCaptureLostEvent(self):
582585
self.GetCefBrowser().get().SendCaptureLostEvent()
586+
587+
IF CEF_VERSION == 3:
588+
cpdef py_void StartDownload(self, py_string url):
589+
self.GetCefBrowserHost().get().StartDownload(PyToCefStringValue(
590+
url))
591+
592+
cpdef py_void SetMouseCursorChangeDisabled(self, py_bool disabled):
593+
self.GetCefBrowserHost().get().SetMouseCursorChangeDisabled(
594+
bool(disabled))
595+
596+
cpdef py_bool IsMouseCursorChangeDisabled(self):
597+
return self.GetCefBrowserHost().get().IsMouseCursorChangeDisabled()
598+
599+
cpdef py_void WasResized(self):
600+
self.GetCefBrowserHost().get().WasResized()
601+
602+
cpdef py_void WasHidden(self, py_bool hidden):
603+
self.GetCefBrowserHost().get().WasHidden(bool(hidden))
604+
605+
cpdef py_void NotifyScreenInfoChanged(self):
606+
self.GetCefBrowserHost().get().NotifyScreenInfoChanged()
607+
608+
# virtual CefTextInputContext GetNSTextInputContext() =0;
609+
# virtual void HandleKeyEventBeforeTextInputClient(CefEventHandle keyEvent) =0;
610+
# virtual void HandleKeyEventAfterTextInputClient(CefEventHandle keyEvent) =0;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// d:\cefpython\src\setup/cefpython.h(22) : warning C4190: 'RequestHandler_GetCookieManager'
2+
// has C-linkage specified, but returns UDT 'CefRefPtr<T>' which is incompatible with C
3+
#if defined(OS_WIN)
4+
#pragma warning(disable:4190)
5+
#endif
6+
7+
// All the imports that are required when including "cefpython.h".
8+
#include "include/cef_client.h"
9+
// #include "include/cef_web_urlrequest.h"
10+
// #include "include/cef_cookie.h"
11+
#include "util.h"
12+
13+
// To be able to use 'public' declarations you need to include Python.h and cefpython.h.
14+
#include "Python.h"
15+
16+
// Python 3.2 fix - DL_IMPORT is not defined in Python.h
17+
#ifndef DL_IMPORT /* declarations for DLL import/export */
18+
#define DL_IMPORT(RTYPE) RTYPE
19+
#endif
20+
#ifndef DL_EXPORT /* declarations for DLL import/export */
21+
#define DL_EXPORT(RTYPE) RTYPE
22+
#endif
23+
24+
#if defined(OS_WIN)
25+
#include "windows/setup/cefpython.h"
26+
#endif
27+
28+
#if defined(OS_LINUX)
29+
#include "linux/setup/cefpython.h"
30+
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.o
2+
*.a
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 = client_handler.cpp
5+
OBJ = $(SRC:.cpp=.o)
6+
OUT = libclient_handler.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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
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+
15
#include "client_handler.h"

cefpython/cef3/client_handler/client_handler.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,11 @@
44

55
#pragma once
66

7-
// d:\cefpython\src\setup/cefpython.h(22) : warning C4190: 'RequestHandler_GetCookieManager'
8-
// has C-linkage specified, but returns UDT 'CefRefPtr<T>' which is incompatible with C
9-
#pragma warning(disable:4190)
10-
11-
#include "include/cef_client.h"
12-
#include "util.h"
13-
14-
// To be able to use 'public' declarations you need to include Python.h and cefpython.h.
15-
#include "Python.h"
16-
17-
// Python 3.2 fix - DL_IMPORT is not defined in Python.h
18-
#ifndef DL_IMPORT /* declarations for DLL import/export */
19-
#define DL_IMPORT(RTYPE) RTYPE
20-
#endif
21-
#ifndef DL_EXPORT /* declarations for DLL import/export */
22-
#define DL_EXPORT(RTYPE) RTYPE
7+
#if defined(_WIN32)
8+
#include "../windows/stdint.h"
239
#endif
2410

25-
#if defined(OS_WIN)
26-
#include "windows/setup/cefpython.h"
27-
#endif
11+
#include "cefpython_public_api.h"
2812

2913
class ClientHandler : public CefClient
3014
{

cefpython/cef3/include/cef_app.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ class CefApp;
5858
// secondary process it will block until the process should exit and then return
5959
// the process exit code. The |application| parameter may be empty.
6060
///
61-
/*--cef(revision_check,optional_param=application)--*/
61+
/*--cef(api_hash_check,optional_param=application)--*/
6262
int CefExecuteProcess(const CefMainArgs& args, CefRefPtr<CefApp> application);
6363

6464
///
6565
// This function should be called on the main application thread to initialize
6666
// the CEF browser process. The |application| parameter may be empty. A return
6767
// value of true indicates that it succeeded and false indicates that it failed.
6868
///
69-
/*--cef(revision_check,optional_param=application)--*/
69+
/*--cef(api_hash_check,optional_param=application)--*/
7070
bool CefInitialize(const CefMainArgs& args, const CefSettings& settings,
7171
CefRefPtr<CefApp> application);
7272

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved.
2+
//
3+
// Redistribution and use in source and binary forms, with or without
4+
// modification, are permitted provided that the following conditions are
5+
// met:
6+
//
7+
// * Redistributions of source code must retain the above copyright
8+
// notice, this list of conditions and the following disclaimer.
9+
// * Redistributions in binary form must reproduce the above
10+
// copyright notice, this list of conditions and the following disclaimer
11+
// in the documentation and/or other materials provided with the
12+
// distribution.
13+
// * Neither the name of Google Inc. nor the name Chromium Embedded
14+
// Framework nor the names of its contributors may be used to endorse
15+
// or promote products derived from this software without specific prior
16+
// written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
30+
#ifndef CEF_INCLUDE_CEF_APPLICATION_MAC_H_
31+
#define CEF_INCLUDE_CEF_APPLICATION_MAC_H_
32+
#pragma once
33+
34+
#include "include/cef_base.h"
35+
36+
#if defined(OS_MACOSX) && defined(__OBJC__)
37+
38+
#ifdef BUILDING_CEF_SHARED
39+
40+
// Use the existing CrAppProtocol definition.
41+
#import "base/message_pump_mac.h"
42+
43+
// Use the existing CrAppControlProtocol definition.
44+
#import "base/mac/scoped_sending_event.h"
45+
46+
// Use the existing UnderlayableSurface definition.
47+
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
48+
49+
// Use the existing empty protocol definitions.
50+
#import "base/mac/cocoa_protocols.h"
51+
52+
#else // BUILDING_CEF_SHARED
53+
54+
#import <AppKit/AppKit.h>
55+
#import <Cocoa/Cocoa.h>
56+
57+
// Copy of definition from base/message_pump_mac.h.
58+
@protocol CrAppProtocol
59+
// Must return true if -[NSApplication sendEvent:] is currently on the stack.
60+
- (BOOL)isHandlingSendEvent;
61+
@end
62+
63+
// Copy of definition from base/mac/scoped_sending_event.h.
64+
@protocol CrAppControlProtocol<CrAppProtocol>
65+
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent;
66+
@end
67+
68+
// Copy of definition from ui/base/cocoa/underlay_opengl_hosting_window.h.
69+
// Common base class for windows that host a OpenGL surface that renders under
70+
// the window. Contains methods relating to hole punching so that the OpenGL
71+
// surface is visible through the window.
72+
@interface UnderlayOpenGLHostingWindow : NSWindow
73+
@end
74+
75+
// The Mac OS X 10.6 SDK introduced new protocols used for delegates. These
76+
// protocol defintions were not present in earlier releases of the Mac OS X
77+
// SDK. In order to support building against the new SDK, which requires
78+
// delegates to conform to these protocols, and earlier SDKs, which do not
79+
// define these protocols at all, this file will provide empty protocol
80+
// definitions when used with earlier SDK versions.
81+
82+
#if !defined(MAC_OS_X_VERSION_10_6) || \
83+
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
84+
85+
#define DEFINE_EMPTY_PROTOCOL(p) \
86+
@protocol p \
87+
@end
88+
89+
DEFINE_EMPTY_PROTOCOL(NSAlertDelegate)
90+
DEFINE_EMPTY_PROTOCOL(NSApplicationDelegate)
91+
DEFINE_EMPTY_PROTOCOL(NSControlTextEditingDelegate)
92+
DEFINE_EMPTY_PROTOCOL(NSMatrixDelegate)
93+
DEFINE_EMPTY_PROTOCOL(NSMenuDelegate)
94+
DEFINE_EMPTY_PROTOCOL(NSOpenSavePanelDelegate)
95+
DEFINE_EMPTY_PROTOCOL(NSOutlineViewDataSource)
96+
DEFINE_EMPTY_PROTOCOL(NSOutlineViewDelegate)
97+
DEFINE_EMPTY_PROTOCOL(NSSpeechSynthesizerDelegate)
98+
DEFINE_EMPTY_PROTOCOL(NSSplitViewDelegate)
99+
DEFINE_EMPTY_PROTOCOL(NSTableViewDataSource)
100+
DEFINE_EMPTY_PROTOCOL(NSTableViewDelegate)
101+
DEFINE_EMPTY_PROTOCOL(NSTextFieldDelegate)
102+
DEFINE_EMPTY_PROTOCOL(NSTextViewDelegate)
103+
DEFINE_EMPTY_PROTOCOL(NSWindowDelegate)
104+
105+
#undef DEFINE_EMPTY_PROTOCOL
106+
107+
#endif
108+
109+
#endif // BUILDING_CEF_SHARED
110+
111+
// All CEF client applications must subclass NSApplication and implement this
112+
// protocol.
113+
@protocol CefAppProtocol<CrAppControlProtocol>
114+
@end
115+
116+
// Controls the state of |isHandlingSendEvent| in the event loop so that it is
117+
// reset properly.
118+
class CefScopedSendingEvent {
119+
public:
120+
CefScopedSendingEvent()
121+
: app_(static_cast<NSApplication<CefAppProtocol>*>(
122+
[NSApplication sharedApplication])),
123+
handling_([app_ isHandlingSendEvent]) {
124+
[app_ setHandlingSendEvent:YES];
125+
}
126+
~CefScopedSendingEvent() {
127+
[app_ setHandlingSendEvent:handling_];
128+
}
129+
130+
private:
131+
NSApplication<CefAppProtocol>* app_;
132+
BOOL handling_;
133+
};
134+
135+
#endif // defined(OS_MACOSX) && defined(__OBJC__)
136+
137+
#endif // CEF_INCLUDE_CEF_APPLICATION_MAC_H_

0 commit comments

Comments
 (0)