Skip to content

Commit

Permalink
Update to Chrome 51.0.2704.103 / CEF 3.2704.1432.g60b3718...
Browse files Browse the repository at this point in the history
It builds fine, but there is an error when running (Issue #231).

Use prebuilt binaries from Spotify automated builds.

Changes in API that break backward compatibility:
* Remove 'accept_lang' arg in JavascriptDialogHandler.OnJavascriptDialog()
* Remove LifespanHandler.RunModal()

Other changes in API:
* Add Browser.TryCloseBrowser()
  • Loading branch information
cztomczak committed Jun 26, 2016
1 parent eea3d8c commit 631fd54
Show file tree
Hide file tree
Showing 142 changed files with 4,210 additions and 1,407 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
__NOTES__:
* Repository rewritten on 2016-02-15 to reduce its size.
Please clone it again.
* Master branch is a work in progress. When building use the cefpython31
branch.
* Master branch is a work in progress. The last stable release
is in the cefpython31 branch.

Table of contents:
* [Introduction](#introduction)
* [Compatibility](#compatibility)
* [Downloads](#downloads)
* [Support](#support)
* [Changes in API during updates](#changes-in-api-during-updates)
* [Donate](#donate)


Expand Down Expand Up @@ -49,6 +50,7 @@ On Win/Mac you can install from PyPI using this command:
__New releases RSS/Atom feed__
To be notified of new releases subscribe to this [Atom feed](https://github.com/cztomczak/cefpython/releases.atom).


## Support

* API docs are in the [docs/api/](docs/api/) directory
Expand All @@ -58,6 +60,16 @@ To be notified of new releases subscribe to this [Atom feed](https://github.com/
* Please do not ask questions in the Issue Tracker


## Changes in API during updates

CEF Python depends on CEF and API breaks are inevitable when updating
to a newer CEF. When updating cefpython to a new version go to the
[GitHub Releases](https://github.com/cztomczak/cefpython/releases) page
and check release notes for all the releases that appeared between
your old version and the new version. Look for lists named
"Changes in API that break backward compatibility".


## Donate

If you would like to support general CEF Python development efforts by making a donation see the [Donations](../../wiki/Donations) wiki page.
562 changes: 281 additions & 281 deletions docs/api/API-index.md

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions docs/api/Browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Table of contents:
* [StopLoad](#stopload)
* [StopFinding](#stopfinding)
* [ToggleFullscreen](#togglefullscreen)
* [TryCloseBrowser](#tryclosebrowser)
* [WasResized](#wasresized)
* [WasHidden](#washidden)

Expand Down Expand Up @@ -126,8 +127,7 @@ information.
| --- | --- |
| __Return__ | bool |

Explicitly close the developer tools window if one exists for this browser
instance.
Explicitly close the associated DevTools browser, if any.


### ExecuteFunction
Expand Down Expand Up @@ -706,7 +706,13 @@ Change the zoom level to the specified value. Specify 0.0 to reset the zoom leve
| --- | --- |
| __Return__ | void |

Open developer tools in a popup window.
Open developer tools (DevTools) in its own browser. The DevTools browser
will remain associated with this browser. If the DevTools browser is
already open then it will be focused, in which case the |windowInfo|,
|client| and |settings| parameters will be ignored. If |inspect_element_at|
is non-empty then the element at the specified (x,y) location will be
inspected. The |windowInfo| parameter will be ignored if this browser is
wrapped in a CefBrowserView.


### StartDownload
Expand Down Expand Up @@ -749,6 +755,16 @@ Switch between fullscreen mode / windowed mode. To check whether in fullscreen m
This function is Windows-only.


### TryCloseBrowser

Helper for closing a browser. Call this method from the top-level window
close handler. Internally this calls CloseBrowser(false) if the close has
not yet been initiated. This method returns false while the close is
pending and true after the close has completed. See CloseBrowser() and
CefLifeSpanHandler::DoClose() documentation for additional usage
information. This method must be called on the browser process UI thread.


### WasResized

| | |
Expand Down
42 changes: 19 additions & 23 deletions docs/api/JavascriptDialogHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,32 @@ pressed. The |userInput| value should be specified for prompt dialogs.
| --- | --- |
| browser | [Browser](Browser.md) |
| origin_url | str |
| accept_lang | str |
| dialog_type | int |
| message_text | str |
| default_prompt_text | str |
| callback | JavascriptDialogCallback |
| suppress_message[0] | bool& |
| __Return__ | bool |

Called to run a JavaScript dialog. If |origin_url| and |accept_lang| are
non-empty they can be passed to the CefFormatUrlForSecurityDisplay function
to retrieve a secure and user-friendly display string. The
|default_prompt_text| value will be specified for prompt dialogs only. Set
|suppress_message| to true and return false to suppress the message
(suppressing messages is preferable to immediately executing the callback
as this is used to detect presumably malicious behavior like spamming alert
messages in onbeforeunload). Set |suppress_message| to false and return
false to use the default implementation (the default implementation will
show one modal dialog at a time and suppress any additional dialog requests
until the displayed dialog is dismissed). Return true if the application
will use a custom dialog or if the callback has been executed immediately.
Custom dialogs may be either modal or modeless. If a custom dialog is used
the application must execute |callback| once the custom dialog is
dismissed.

The `dialog_type` param may be one of:
```
cefpython.JSDIALOGTYPE_ALERT
cefpython.JSDIALOGTYPE_CONFIRM
cefpython.JSDIALOGTYPE_PROMPT
```
Called to run a JavaScript dialog. If |origin_url| is non-empty it can be
passed to the CefFormatUrlForSecurityDisplay function to retrieve a secure
and user-friendly display string. The |default_prompt_text| value will be
specified for prompt dialogs only. Set |suppress_message| to true and
return false to suppress the message (suppressing messages is preferable to
immediately executing the callback as this is used to detect presumably
malicious behavior like spamming alert messages in onbeforeunload). Set
|suppress_message| to false and return false to use the default
implementation (the default implementation will show one modal dialog at a
time and suppress any additional dialog requests until the displayed dialog
is dismissed). Return true if the application will use a custom dialog or
if the callback has been executed immediately. Custom dialogs may be either
modal or modeless. If a custom dialog is used the application must execute
|callback| once the custom dialog is dismissed.

The `dialog_type` constants available in the cefpython module:
* JSDIALOGTYPE_ALERT
* JSDIALOGTYPE_CONFIRM
* JSDIALOGTYPE_PROMPT


### OnBeforeUnloadJavascriptDialog
Expand Down
25 changes: 7 additions & 18 deletions docs/api/LifespanHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Table of contents:
* [Callbacks](#callbacks)
* [OnBeforePopup](#onbeforepopup)
* [_OnAfterCreated](#_onaftercreated)
* [RunModal](#runmodal)
* [DoClose](#doclose)
* [OnBeforeClose](#onbeforeclose)

Expand Down Expand Up @@ -52,7 +51,9 @@ popup browser optionally modify |windowInfo|, |client|, |browserSettings| and
browser return true. The |client| and |settings| values will default to the
source browser's values. If the |no_javascript_access| value is set to
false the new browser will not be scriptable and may not be hosted in the
same renderer process as the source browser.
same renderer process as the source browser. Any modifications to
|windowInfo| will be ignored if the parent browser is wrapped in a
CefBrowserView.

Note that if you return True and create the popup window yourself, then
the popup window and parent window will not be able to script each other.
Expand All @@ -79,23 +80,12 @@ There will be no "window.opener" property available in the popup window.
| browser | [Browser](Browser.md) |
| __Return__ | void |

Called after a new browser is created.
Called after a new browser is created. This callback will be the first
notification that references |browser|.

This callback will be executed during browser creation, thus you must call [cefpython](cefpython.md).SetGlobalClientCallback() to use it. The callback name was prefixed with "`_`" to distinguish this special behavior.


### RunModal

| Parameter | Type |
| --- | --- |
| browser | [Browser](Browser.md) |
| __Return__ | bool |

Called when a modal window is about to display and the modal loop should
begin running. Return false to use the default modal loop implementation or
true to use a custom implementation.


### DoClose

| Parameter | Type |
Expand Down Expand Up @@ -125,7 +115,6 @@ See complete description of this callback in [cef_life_span_handler.h]

Called just before a browser is destroyed. Release all references to the
browser object and do not attempt to execute any methods on the browser
object after this callback returns. If this is a modal window and a custom
modal loop implementation was provided in RunModal() this callback should
be used to exit the custom modal loop. See DoClose() documentation for
object after this callback returns. This callback will be the last
notification that references |browser|. See DoClose() documentation for
additional usage information.
10 changes: 6 additions & 4 deletions docs/api/LoadHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Table of contents:
Called when the loading state has changed. This callback will be executed
twice. Once when loading is initiated either programmatically or by user
action, and once when loading is terminated due to completion, cancellation
of failure.
of failure. It will be called before any calls to OnLoadStart and after all
calls to OnLoadError and/or OnLoadEnd.


### OnLoadStart
Expand All @@ -48,8 +49,8 @@ Called when the browser begins loading a frame. The |frame| value will
never be empty -- call the IsMain() method to check if this frame is the
main frame. Multiple frames may be loading at the same time. Sub-frames may
start or continue loading after the main frame load has ended. This method
may not be called for a particular frame if the load request for that frame
fails. For notification of overall browser load status use
will always be called for all frames irrespective of whether the request
completes successfully. For notification of overall browser load status use
[DisplayHandler](DisplayHandler.md).`OnLoadingStateChange` instead.


Expand All @@ -76,7 +77,8 @@ never be empty -- call the IsMain() method to check if this frame is the
main frame. Multiple frames may be loading at the same time. Sub-frames may
start or continue loading after the main frame load has ended. This method
will always be called for all frames irrespective of whether the request
completes successfully.
completes successfully. For notification of overall browser load status use
OnLoadingStateChange instead.

This event behaves like window.onload, it waits for all the content to load (e.g. images), there is currently no callback for a DOMContentLoaded event, see [Issue #32](../issues/32).

Expand Down
4 changes: 3 additions & 1 deletion docs/api/ResourceHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ returns false. If the response length is known set `responseLengthOut[0]`
to a positive value and ReadResponse() will be called until it returns
false or the specified number of bytes have been read. Use the |response|
object to set the mime type, http status code and other optional header
values. To redirect the request to a new URL set `redirectUrlOut[0]` to the new url.
values. To redirect the request to a new URL set `redirectUrlOut[0]` to the new
URL. If an error occured while setting up the request you can call
SetError() on |response| to indicate the error condition.


### ReadResponse
Expand Down
11 changes: 10 additions & 1 deletion src/browser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cdef PyBrowser GetPyBrowserById(int browserId):
cdef PyBrowser GetPyBrowser(CefRefPtr[CefBrowser] cefBrowser):
global g_pyBrowsers
if <void*>cefBrowser == NULL or not cefBrowser.get():
# noinspection PyUnresolvedReferences
Debug("GetPyBrowser(): returning None")
return None

Expand All @@ -36,10 +37,12 @@ cdef PyBrowser GetPyBrowser(CefRefPtr[CefBrowser] cefBrowser):

for identifier, pyBrowser in g_pyBrowsers.items():
if not pyBrowser.cefBrowser.get():
# noinspection PyUnresolvedReferences
Debug("GetPyBrowser(): removing an empty CefBrowser reference, "
"browserId=%s" % identifier)
del g_pyBrowsers[identifier]

# noinspection PyUnresolvedReferences
Debug("GetPyBrowser(): creating new PyBrowser, browserId=%s" % browserId)
pyBrowser = PyBrowser()
pyBrowser.cefBrowser = cefBrowser
Expand Down Expand Up @@ -84,11 +87,14 @@ cdef void RemovePyBrowser(int browserId) except *:
# This is the last browser remaining.
if g_sharedRequestContext.get():
# A similar release is done in Shutdown and CloseBrowser.
# noinspection PyUnresolvedReferences
Debug("RemovePyBrowser: releasing shared request context")
g_sharedRequestContext.Assign(NULL)
# noinspection PyUnresolvedReferences
Debug("del g_pyBrowsers[%s]" % browserId)
del g_pyBrowsers[browserId]
else:
# noinspection PyUnresolvedReferences
Debug("RemovePyBrowser() FAILED: browser not found, id = %s" \
% browserId)

Expand Down Expand Up @@ -183,7 +189,7 @@ cdef class PyBrowser:
# NOTE: OnAfterCreated not included as it must be set using
# cefpython.SetGlobalClientCallback().
self.allowedClientCallbacks += ["OnBeforePopup",
"RunModal", "DoClose", "OnBeforeClose"]
"DoClose", "OnBeforeClose"]
# RenderHandler
self.allowedClientCallbacks += ["GetRootScreenRect",
"GetViewRect", "GetScreenPoint", "GetScreenInfo",
Expand Down Expand Up @@ -561,6 +567,9 @@ cdef class PyBrowser:
cpdef py_bool IsMouseCursorChangeDisabled(self):
return self.GetCefBrowserHost().get().IsMouseCursorChangeDisabled()

cpdef py_bool TryCloseBrowser(self):
return self.GetCefBrowserHost().get().TryCloseBrowser()

cpdef py_void WasResized(self):
self.GetCefBrowserHost().get().WasResized()

Expand Down
Loading

0 comments on commit 631fd54

Please sign in to comment.