Skip to content

Commit ab41857

Browse files
CzarekCzarek
authored andcommitted
Added cython imports for cef_values.h.
Fixes to process message utils.
1 parent f3c1843 commit ab41857

9 files changed

Lines changed: 220 additions & 64 deletions

File tree

cefpython/cef3/client_handler/client_handler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
#include "cefpython_public_api.h"
1212

13-
class ClientHandler : public CefClient
13+
class ClientHandler :
14+
public CefClient
1415
{
1516
public:
1617
ClientHandler(){}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
#pragma once
6+
7+
#include "include/cef_app.h"
8+
9+
// CefPythonApp class is also instantiated in cefpython.pyx for the
10+
// browser process.
11+
12+
///
13+
// Implement this interface to provide handler implementations. Methods will be
14+
// called by the process and/or thread indicated.
15+
///
16+
/*--cef(source=client,no_debugct_check)--*/
17+
class CefPythonApp : public CefApp {
18+
public:
19+
///
20+
// Provides an opportunity to view and/or modify command-line arguments before
21+
// processing by CEF and Chromium. The |process_type| value will be empty for
22+
// the browser process. Do not keep a reference to the CefCommandLine object
23+
// passed to this method. The CefSettings.command_line_args_disabled value
24+
// can be used to start with an empty command-line object. Any values
25+
// specified in CefSettings that equate to command-line arguments will be set
26+
// before this method is called. Be cautious when using this method to modify
27+
// command-line arguments for non-browser processes as this may result in
28+
// undefined behavior including crashes.
29+
///
30+
/*--cef(optional_param=process_type)--*/
31+
virtual void OnBeforeCommandLineProcessing(
32+
const CefString& process_type,
33+
CefRefPtr<CefCommandLine> command_line) {
34+
}
35+
36+
///
37+
// Provides an opportunity to register custom schemes. Do not keep a reference
38+
// to the |registrar| object. This method is called on the main thread for
39+
// each process and the registered schemes should be the same across all
40+
// processes.
41+
///
42+
/*--cef()--*/
43+
virtual void OnRegisterCustomSchemes(
44+
CefRefPtr<CefSchemeRegistrar> registrar) {
45+
}
46+
47+
///
48+
// Return the handler for resource bundle events. If
49+
// CefSettings.pack_loading_disabled is true a handler must be returned. If no
50+
// handler is returned resources will be loaded from pack files. This method
51+
// is called by the browser and render processes on multiple threads.
52+
///
53+
/*--cef()--*/
54+
virtual CefRefPtr<CefResourceBundleHandler> GetResourceBundleHandler() {
55+
return NULL;
56+
}
57+
58+
///
59+
// Return the handler for functionality specific to the browser process. This
60+
// method is called on multiple threads in the browser process.
61+
///
62+
/*--cef()--*/
63+
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
64+
return NULL;
65+
}
66+
67+
///
68+
// Return the handler for functionality specific to the render process. This
69+
// method is called on the render process main thread.
70+
///
71+
/*--cef()--*/
72+
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler() {
73+
return NULL;
74+
}
75+
};
76+
77+
class ClientApp : public CefApp {
78+
public:
79+
private:
80+
IMPLEMENT_REFCOUNTING(ClientApp);
81+
};

cefpython/cef3/subprocess/client_app.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

cefpython/cef3/subprocess/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// License: New BSD License.
33
// Website: http://code.google.com/p/cefpython/
44

5-
#include "client_app.h"
5+
#include "cefpython_app.h"
66

77
#if defined(OS_WIN)
88

@@ -25,7 +25,7 @@ int main(int argc, char **argv)
2525

2626
#endif
2727

28-
CefRefPtr<ClientApp> app(new ClientApp);
28+
CefRefPtr<CefPythonApp> app(new CefPythonApp);
2929
int exitCode = CefExecuteProcess(mainArgs, app.get());
3030
return exitCode;
3131
}

cefpython/cefpython.pyx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
# | CefRefPtr[T]& Assign "operator="(T* p)
4848
# | cefBrowser.Assign(CefBrowser*)
4949
# In the same way you can import function with a different name, this one
50-
# imports a static method Create() while adding a prefix "CefProcessMessage_":
51-
# | cdef extern from ".." namespace "CefProcessMessage":
52-
# | static CefRefPtr[CefProcessMessage] CefProcessMessage_Create(..) "Create()"(..)
50+
# imports a static method Create() while adding a prefix "CefSome_":
51+
# | cdef extern from "..":
52+
# | static CefRefPtr[CefSome] CefSome_Create "CefSome::Create"()
5353
#
5454
# - Declaring C++ classes in Cython. Storing python callbacks
5555
# in a C++ class using Py_INCREF, Py_DECREF. Calling from
@@ -75,6 +75,10 @@
7575
# Lots of these warnings results in ignoring them, but sometimes
7676
# they are shown for a good reason, for example when you forget
7777
# to return a value in a function.
78+
#
79+
# - Always import bool from libcpp as cpp_bool, if you import it as
80+
# "bool" in a pxd file, then Cython will complain about bool casts
81+
# like "bool(1)" being invalid, in pyx files.
7882

7983
# Global variables.
8084

@@ -134,15 +138,16 @@ IF CEF_VERSION == 1:
134138
include "drag_data.pyx"
135139
include "drag_handler.pyx"
136140
include "download_handler.pyx"
137-
138-
IF CEF_VERSION == 1:
139141
include "v8context_handler_cef1.pyx"
140142
include "v8function_handler_cef1.pyx"
141143
include "v8utils_cef1.pyx"
142144
include "javascript_bindings.pyx"
143145
include "javascript_callback.pyx"
144146
include "python_callback.pyx"
145147

148+
IF CEF_VERSION == 3:
149+
include "process_message_utils.pyx"
150+
146151
# Try not to run any of the CEF code until Initialize() is called.
147152
# Do not allocate any memory on the heap until Initialize() is called,
148153
# that's why we're not instantiating the ClientHandler class here in
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
from cef_ptr cimport CefRefPtr
6+
from libcpp cimport bool as cpp_bool
7+
from cef_string cimport CefString
8+
from libcpp.vector cimport vector
9+
from cef_types cimport cef_value_type_t
10+
11+
cdef extern from "include/cef_values.h":
12+
CefRefPtr[CefDictionaryValue] CefDictionaryValue_Create "CefDictionaryValue::Create"()
13+
CefRefPtr[CefListValue] CefListValue_Create "CefListValue::Create"()
14+
15+
cdef extern from "include/cef_values.h":
16+
cdef cppclass CefBinaryValue:
17+
pass
18+
19+
cdef cppclass CefDictionaryValue:
20+
cpp_bool IsValid()
21+
cpp_bool IsOwned()
22+
cpp_bool IsReadOnly()
23+
CefRefPtr[CefDictionaryValue] Copy(cpp_bool exclude_empty_children)
24+
size_t GetSize()
25+
cpp_bool Clear()
26+
cpp_bool HasKey(const CefString& key)
27+
cpp_bool GetKeys(vector[CefString]& keys)
28+
cpp_bool Remove(const CefString& key)
29+
cef_value_type_t GetType(const CefString& key)
30+
cpp_bool GetBool(const CefString& key)
31+
int GetInt(const CefString& key)
32+
double GetDouble(const CefString& key)
33+
CefString GetString(const CefString& key)
34+
CefRefPtr[CefBinaryValue] GetBinary(const CefString& key)
35+
CefRefPtr[CefDictionaryValue] GetDictionary(const CefString& key)
36+
CefRefPtr[CefListValue] GetList(const CefString& key)
37+
cpp_bool SetNull(const CefString& key)
38+
cpp_bool SetBool(const CefString& key, cpp_bool value)
39+
cpp_bool SetInt(const CefString& key, int value)
40+
cpp_bool SetDouble(const CefString& key, double value)
41+
cpp_bool SetString(const CefString& key, const CefString& value)
42+
cpp_bool SetBinary(const CefString& key, CefRefPtr[CefBinaryValue] value)
43+
cpp_bool SetDictionary(const CefString& key, CefRefPtr[CefDictionaryValue] value)
44+
cpp_bool SetList(const CefString& key, CefRefPtr[CefListValue] value)
45+
46+
cdef cppclass CefListValue:
47+
cpp_bool IsValid()
48+
cpp_bool IsOwned()
49+
cpp_bool IsReadOnly()
50+
CefRefPtr[CefListValue] Copy()
51+
cpp_bool SetSize(size_t size)
52+
size_t GetSize()
53+
cpp_bool Clear()
54+
cpp_bool Remove(int index)
55+
cef_value_type_t GetType(int index)
56+
cpp_bool GetBool(int index)
57+
int GetInt(int index)
58+
double GetDouble(int index)
59+
CefString GetString(int index)
60+
CefRefPtr[CefBinaryValue] GetBinary(int index)
61+
CefRefPtr[CefDictionaryValue] GetDictionary(int index)
62+
CefRefPtr[CefListValue] GetList(int index)
63+
cpp_bool SetNull(int index)
64+
cpp_bool SetBool(int index, cpp_bool value)
65+
cpp_bool SetInt(int index, int value)
66+
cpp_bool SetDouble(int index, double value)
67+
cpp_bool SetString(int index, const CefString& value)
68+
cpp_bool SetBinary(int index, CefRefPtr[CefBinaryValue] value)
69+
cpp_bool SetDictionary(int index, CefRefPtr[CefDictionaryValue] value)
70+
cpp_bool SetList(int index, CefRefPtr[CefListValue] value)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
from cef_app cimport CefApp
6+
7+
cdef extern from "subprocess/cefpython_app.h":
8+
cdef cppclass CefPythonApp(CefApp):
9+
pass

cefpython/imports.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,6 @@ IF CEF_VERSION == 1:
139139
IF UNAME_SYSNAME == "Windows":
140140
IF CEF_VERSION == 1:
141141
from http_authentication cimport *
142+
143+
IF CEF_VERSION == 3:
144+
from cef_values cimport *

0 commit comments

Comments
 (0)