| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d398a63 commit 4ba421f
25 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 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 | + cdef PyCallback CreatePyCallback( | ||
| 6 | + CefRefPtr[CefCallback] cefCallback): | ||
| 7 | + cdef PyCallback pyCallback = PyCallback() | ||
| 8 | + pyCallback.cefCallback = cefCallback | ||
| 9 | + return pyCallback | ||
| 10 | + | ||
| 11 | + cdef class PyCallback: | ||
| 12 | + cdef CefRefPtr[CefCallback] cefCallback | ||
| 13 | + | ||
| 14 | + cpdef py_void Continue(self): | ||
| 15 | + self.cefCallback.get().Continue() | ||
| 16 | + | ||
| 17 | + cpdef py_void Cancel(self): | ||
| 18 | + self.cefCallback.get().Cancel() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | CC = g++ | |
| 12 | 12 | CCFLAGS = -g -fPIC -Wall -Werror | |
| 13 | 13 | ||
| 14 | - SRC = client_handler.cpp cookie_visitor.cpp | ||
| 14 | + SRC = client_handler.cpp cookie_visitor.cpp resource_handler.cpp | ||
| 15 | 15 | OBJ = $(SRC:.cpp=.o) | |
| 16 | 16 | OUT = libclient_handler.a | |
| 17 | 17 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,6 +92,10 @@ | |||
| 92 | 92 | <File | |
| 93 | 93 | RelativePath=".\cookie_visitor.h" | |
| 94 | 94 | > | |
| 95 | + </File> | ||
| 96 | + <File | ||
| 97 | + RelativePath=".\resource_handler.h" | ||
| 98 | + > | ||
| 95 | 99 | </File> | |
| 96 | 100 | </Filter> | |
| 97 | 101 | <Filter | |
@@ -112,6 +116,10 @@ | |||
| 112 | 116 | <File | |
| 113 | 117 | RelativePath=".\cookie_visitor.cpp" | |
| 114 | 118 | > | |
| 119 | + </File> | ||
| 120 | + <File | ||
| 121 | + RelativePath=".\resource_handler.cpp" | ||
| 122 | + > | ||
| 115 | 123 | </File> | |
| 116 | 124 | </Filter> | |
| 117 | 125 | </Files> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,6 +91,10 @@ | |||
| 91 | 91 | <File | |
| 92 | 92 | RelativePath=".\cookie_visitor.h" | |
| 93 | 93 | > | |
| 94 | + </File> | ||
| 95 | + <File | ||
| 96 | + RelativePath=".\resource_handler.h" | ||
| 97 | + > | ||
| 94 | 98 | </File> | |
| 95 | 99 | </Filter> | |
| 96 | 100 | <Filter | |
@@ -111,6 +115,10 @@ | |||
| 111 | 115 | <File | |
| 112 | 116 | RelativePath=".\cookie_visitor.cpp" | |
| 113 | 117 | > | |
| 118 | + </File> | ||
| 119 | + <File | ||
| 120 | + RelativePath=".\resource_handler.cpp" | ||
| 121 | + > | ||
| 114 | 122 | </File> | |
| 115 | 123 | </Filter> | |
| 116 | 124 | </Files> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,5 +12,6 @@ bool CookieVisitor::Visit( | |||
| 12 | 12 | bool& deleteCookie | |
| 13 | 13 | ) { | |
| 14 | 14 | REQUIRE_IO_THREAD(); | |
| 15 | - return CookieVisitor_Visit(cookieVisitorId_, cookie, count, total, deleteCookie); | ||
| 15 | + return CookieVisitor_Visit(cookieVisitorId_, cookie, count, total, | ||
| 16 | + deleteCookie); | ||
| 16 | 17 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,86 @@ | |||
| 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 "resource_handler.h" | ||
| 6 | + | ||
| 7 | + /// | ||
| 8 | + // Begin processing the request. To handle the request return true and call | ||
| 9 | + // CefCallback::Continue() once the response header information is available | ||
| 10 | + // (CefCallback::Continue() can also be called from inside this method if | ||
| 11 | + // header information is available immediately). To cancel the request return | ||
| 12 | + // false. | ||
| 13 | + /// | ||
| 14 | + /*--cef()--*/ | ||
| 15 | + bool ResourceHandler::ProcessRequest(CefRefPtr<CefRequest> request, | ||
| 16 | + CefRefPtr<CefCallback> callback) { | ||
| 17 | + REQUIRE_IO_THREAD(); | ||
| 18 | + return ResourceHandler_ProcessRequest(resourceHandlerId_, request, | ||
| 19 | + callback); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /// | ||
| 23 | + // Retrieve response header information. If the response length is not known | ||
| 24 | + // set |response_length| to -1 and ReadResponse() will be called until it | ||
| 25 | + // returns false. If the response length is known set |response_length| | ||
| 26 | + // to a positive value and ReadResponse() will be called until it returns | ||
| 27 | + // false or the specified number of bytes have been read. Use the |response| | ||
| 28 | + // object to set the mime type, http status code and other optional header | ||
| 29 | + // values. To redirect the request to a new URL set |redirectUrl| to the new | ||
| 30 | + // URL. | ||
| 31 | + /// | ||
| 32 | + /*--cef()--*/ | ||
| 33 | + void ResourceHandler::GetResponseHeaders(CefRefPtr<CefResponse> response, | ||
| 34 | + int64& response_length, | ||
| 35 | + CefString& redirectUrl) { | ||
| 36 | + REQUIRE_IO_THREAD(); | ||
| 37 | + ResourceHandler_GetResponseHeaders(resourceHandlerId_, response, | ||
| 38 | + response_length, redirectUrl); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /// | ||
| 42 | + // Read response data. If data is available immediately copy up to | ||
| 43 | + // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of | ||
| 44 | + // bytes copied, and return true. To read the data at a later time set | ||
| 45 | + // |bytes_read| to 0, return true and call CefCallback::Continue() when the | ||
| 46 | + // data is available. To indicate response completion return false. | ||
| 47 | + /// | ||
| 48 | + /*--cef()--*/ | ||
| 49 | + bool ResourceHandler::ReadResponse(void* data_out, | ||
| 50 | + int bytes_to_read, | ||
| 51 | + int& bytes_read, | ||
| 52 | + CefRefPtr<CefCallback> callback) { | ||
| 53 | + REQUIRE_IO_THREAD(); | ||
| 54 | + return ResourceHandler_ReadResponse(resourceHandlerId_, data_out, | ||
| 55 | + bytes_to_read, bytes_read, callback); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /// | ||
| 59 | + // Return true if the specified cookie can be sent with the request or false | ||
| 60 | + // otherwise. If false is returned for any cookie then no cookies will be sent | ||
| 61 | + // with the request. | ||
| 62 | + /// | ||
| 63 | + /*--cef()--*/ | ||
| 64 | + bool ResourceHandler::CanGetCookie(const CefCookie& cookie) { | ||
| 65 | + REQUIRE_IO_THREAD(); | ||
| 66 | + return ResourceHandler_CanGetCookie(resourceHandlerId_, cookie); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + /// | ||
| 70 | + // Return true if the specified cookie returned with the response can be set | ||
| 71 | + // or false otherwise. | ||
| 72 | + /// | ||
| 73 | + /*--cef()--*/ | ||
| 74 | + bool ResourceHandler::CanSetCookie(const CefCookie& cookie) { | ||
| 75 | + REQUIRE_IO_THREAD(); | ||
| 76 | + return ResourceHandler_CanSetCookie(resourceHandlerId_, cookie); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + /// | ||
| 80 | + // Request processing has been canceled. | ||
| 81 | + /// | ||
| 82 | + /*--cef()--*/ | ||
| 83 | + void ResourceHandler::Cancel() { | ||
| 84 | + REQUIRE_IO_THREAD(); | ||
| 85 | + return ResourceHandler_Cancel(resourceHandlerId_); | ||
| 86 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,85 @@ | |||
| 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 | + #if defined(_WIN32) | ||
| 8 | + #include "../windows/stdint.h" | ||
| 9 | + #endif | ||
| 10 | + | ||
| 11 | + #include "cefpython_public_api.h" | ||
| 12 | + | ||
| 13 | + class ResourceHandler : public CefResourceHandler | ||
| 14 | + { | ||
| 15 | + public: | ||
| 16 | + int resourceHandlerId_; | ||
| 17 | + public: | ||
| 18 | + ResourceHandler(int resourceHandlerId) | ||
| 19 | + : resourceHandlerId_(resourceHandlerId) { | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + /// | ||
| 23 | + // Begin processing the request. To handle the request return true and call | ||
| 24 | + // CefCallback::Continue() once the response header information is available | ||
| 25 | + // (CefCallback::Continue() can also be called from inside this method if | ||
| 26 | + // header information is available immediately). To cancel the request return | ||
| 27 | + // false. | ||
| 28 | + /// | ||
| 29 | + /*--cef()--*/ | ||
| 30 | + virtual bool ProcessRequest(CefRefPtr<CefRequest> request, | ||
| 31 | + CefRefPtr<CefCallback> callback) OVERRIDE; | ||
| 32 | + | ||
| 33 | + /// | ||
| 34 | + // Retrieve response header information. If the response length is not known | ||
| 35 | + // set |response_length| to -1 and ReadResponse() will be called until it | ||
| 36 | + // returns false. If the response length is known set |response_length| | ||
| 37 | + // to a positive value and ReadResponse() will be called until it returns | ||
| 38 | + // false or the specified number of bytes have been read. Use the |response| | ||
| 39 | + // object to set the mime type, http status code and other optional header | ||
| 40 | + // values. To redirect the request to a new URL set |redirectUrl| to the new | ||
| 41 | + // URL. | ||
| 42 | + /// | ||
| 43 | + /*--cef()--*/ | ||
| 44 | + virtual void GetResponseHeaders(CefRefPtr<CefResponse> response, | ||
| 45 | + int64& response_length, | ||
| 46 | + CefString& redirectUrl) OVERRIDE; | ||
| 47 | + | ||
| 48 | + /// | ||
| 49 | + // Read response data. If data is available immediately copy up to | ||
| 50 | + // |bytes_to_read| bytes into |data_out|, set |bytes_read| to the number of | ||
| 51 | + // bytes copied, and return true. To read the data at a later time set | ||
| 52 | + // |bytes_read| to 0, return true and call CefCallback::Continue() when the | ||
| 53 | + // data is available. To indicate response completion return false. | ||
| 54 | + /// | ||
| 55 | + /*--cef()--*/ | ||
| 56 | + virtual bool ReadResponse(void* data_out, | ||
| 57 | + int bytes_to_read, | ||
| 58 | + int& bytes_read, | ||
| 59 | + CefRefPtr<CefCallback> callback) OVERRIDE; | ||
| 60 | + | ||
| 61 | + /// | ||
| 62 | + // Return true if the specified cookie can be sent with the request or false | ||
| 63 | + // otherwise. If false is returned for any cookie then no cookies will be sent | ||
| 64 | + // with the request. | ||
| 65 | + /// | ||
| 66 | + /*--cef()--*/ | ||
| 67 | + virtual bool CanGetCookie(const CefCookie& cookie) OVERRIDE; | ||
| 68 | + | ||
| 69 | + /// | ||
| 70 | + // Return true if the specified cookie returned with the response can be set | ||
| 71 | + // or false otherwise. | ||
| 72 | + /// | ||
| 73 | + /*--cef()--*/ | ||
| 74 | + virtual bool CanSetCookie(const CefCookie& cookie) OVERRIDE; | ||
| 75 | + | ||
| 76 | + /// | ||
| 77 | + // Request processing has been canceled. | ||
| 78 | + /// | ||
| 79 | + /*--cef()--*/ | ||
| 80 | + virtual void Cancel() OVERRIDE; | ||
| 81 | + | ||
| 82 | + protected: | ||
| 83 | + // Include the default reference counting implementation. | ||
| 84 | + IMPLEMENT_REFCOUNTING(ResourceHandler); | ||
| 85 | + }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ __PYX_EXTERN_C DL_IMPORT(bool) DisplayHandler_OnConsoleMessage(CefRefPtr<CefBrow | |||
| 27 | 27 | __PYX_EXTERN_C DL_IMPORT(bool) KeyboardHandler_OnPreKeyEvent(CefRefPtr<CefBrowser>, CefKeyEvent const &, CefEventHandle, bool *); | |
| 28 | 28 | __PYX_EXTERN_C DL_IMPORT(bool) KeyboardHandler_OnKeyEvent(CefRefPtr<CefBrowser>, CefKeyEvent const &, CefEventHandle); | |
| 29 | 29 | __PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnBeforeResourceLoad(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefRequest>); | |
| 30 | + __PYX_EXTERN_C DL_IMPORT(CefRefPtr<CefResourceHandler>) RequestHandler_GetResourceHandler(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefRequest>); | ||
| 30 | 31 | __PYX_EXTERN_C DL_IMPORT(void) RequestHandler_OnResourceRedirect(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefString const &, CefString &); | |
| 31 | 32 | __PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_GetAuthCredentials(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, bool, CefString const &, int, CefString const &, CefString const &, CefRefPtr<CefAuthCallback>); | |
| 32 | 33 | __PYX_EXTERN_C DL_IMPORT(bool) RequestHandler_OnQuotaRequest(CefRefPtr<CefBrowser>, CefString const &, int64, CefRefPtr<CefQuotaCallback>); | |
@@ -51,6 +52,12 @@ __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPopupSize(CefRefPtr<CefBrowser>, | |||
| 51 | 52 | __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnPaint(CefRefPtr<CefBrowser>, cef_paint_element_type_t, std::vector<CefRect> &, void const *, int, int); | |
| 52 | 53 | __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnCursorChange(CefRefPtr<CefBrowser>, CefCursorHandle); | |
| 53 | 54 | __PYX_EXTERN_C DL_IMPORT(void) RenderHandler_OnScrollOffsetChanged(CefRefPtr<CefBrowser>); | |
| 55 | + __PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_ProcessRequest(int, CefRefPtr<CefRequest>, CefRefPtr<CefCallback>); | ||
| 56 | + __PYX_EXTERN_C DL_IMPORT(void) ResourceHandler_GetResponseHeaders(int, CefRefPtr<CefResponse>, int64 &, CefString &); | ||
| 57 | + __PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_ReadResponse(int, void *, int, int &, CefRefPtr<CefCallback>); | ||
| 58 | + __PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_CanGetCookie(int, CefCookie const &); | ||
| 59 | + __PYX_EXTERN_C DL_IMPORT(bool) ResourceHandler_CanSetCookie(int, CefCookie const &); | ||
| 60 | + __PYX_EXTERN_C DL_IMPORT(void) ResourceHandler_Cancel(int); | ||
| 54 | 61 | ||
| 55 | 62 | #endif /* !__PYX_HAVE_API__cefpython_py27 */ | |
| 56 | 63 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,7 +131,7 @@ IF CEF_VERSION == 1: | |||
| 131 | 131 | include "stream.pyx" | |
| 132 | 132 | include "content_filter.pyx" | |
| 133 | 133 | include "request_handler_cef1.pyx" | |
| 134 | - include "response.pyx" | ||
| 134 | + include "response_cef1.pyx" | ||
| 135 | 135 | include "display_handler_cef1.pyx" | |
| 136 | 136 | include "lifespan_handler_cef1.pyx" | |
| 137 | 137 | IF UNAME_SYSNAME == "Windows": | |
@@ -166,6 +166,9 @@ IF CEF_VERSION == 3: | |||
| 166 | 166 | include "browser_process_handler_cef3.pyx" | |
| 167 | 167 | include "paint_buffer_cef3.pyx" | |
| 168 | 168 | include "render_handler_cef3.pyx" | |
| 169 | + include "callback_cef3.pyx" | ||
| 170 | + include "resource_handler_cef3.pyx" | ||
| 171 | + include "response_cef3.pyx" | ||
| 169 | 172 | ||
| 170 | 173 | # Try not to run any of the CEF code until Initialize() is called. | |
| 171 | 174 | # Do not allocate any memory on the heap until Initialize() is called, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 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_base cimport CefBase | ||
| 6 | + | ||
| 7 | + cdef extern from "include/cef_callback.h": | ||
| 8 | + cdef cppclass CefCallback(CefBase): | ||
| 9 | + void Continue() | ||
| 10 | + void Cancel() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments