diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 000000000..b10635fd0 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,20 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "C:/Program Files/Python311/include/**", + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.22621.0", + "cStandard": "c17", + "cppStandard": "c++17" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..ec6c8e6a9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,117 @@ +{ + "files.associations": { + "memory": "cpp", + "__config": "cpp", + "cstddef": "cpp", + "algorithm": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "coroutine": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "exception": "cpp", + "filesystem": "cpp", + "format": "cpp", + "forward_list": "cpp", + "fstream": "cpp", + "functional": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "memory_resource": "cpp", + "mutex": "cpp", + "new": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ostream": "cpp", + "queue": "cpp", + "random": "cpp", + "ranges": "cpp", + "ratio": "cpp", + "regex": "cpp", + "scoped_allocator": "cpp", + "set": "cpp", + "span": "cpp", + "sstream": "cpp", + "stack": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "string": "cpp", + "strstream": "cpp", + "system_error": "cpp", + "thread": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "utility": "cpp", + "valarray": "cpp", + "variant": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstddef": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp", + "__bit_reference": "cpp", + "__bits": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__split_buffer": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__verbose_abort": "cpp", + "propagate_const": "cpp", + "string_view": "cpp", + "*.tcc": "cpp", + "cfenv": "cpp" + } +} \ No newline at end of file diff --git a/README.md b/README.md index e91759715..9d6696607 100644 --- a/README.md +++ b/README.md @@ -1,866 +1,766 @@ -# CEF Python +## CEF Python unofficial Table of contents: -* [Introduction](#introduction) -* [Latest releases sponsored by](#latest-releases-sponsored-by) - * [Thanks to all sponsors](#thanks-to-all-sponsors) -* [Install](#install) -* [Tutorial](#tutorial) -* [Examples](#examples) -* [Support](#support) -* [Releases](#releases) - * [Next release](#next-release) - * [Latest release](#latest-release) - * [v49 release (WinXP/Vista)](#v49-release-winxpvista) - * [v31 release (old systems)](#v31-release-old-systems) -* [Support development](#support-development) - * [Thanks to all](#thanks-to-all) -* [Seeking new sponsors](#seeking-new-sponsors) -* [Other READMEs](#other-readmes) -* [Quick links](#quick-links) +* [Introduction](#introduction) +* [Latest releases sponsored by](#latest-releases-sponsored-by) + * [Thanks to all sponsors](#thanks-to-all-sponsors) +* [Install](#install) +* [Tutorial](#tutorial) +* [Examples](#examples) +* [Support](#support) +* [Releases](#releases) + * [Next release](#next-release) + * [Latest release](#latest-release) + * [v49 release (WinXP/Vista)](#v49-release-winxpvista) + * [v31 release (old systems)](#v31-release-old-systems) +* [Support development](#support-development) + * [Thanks to all](#thanks-to-all) +* [Seeking new sponsors](#seeking-new-sponsors) +* [Other READMEs](#other-readmes) +* [Quick links](#quick-links) ## Introduction -CEF Python is an open source project founded by -[Czarek Tomczak](https://www.linkedin.com/in/czarektomczak/) -in 2012 to provide Python bindings for the -[Chromium Embedded Framework](https://bitbucket.org/chromiumembedded/cef) (CEF). -The Chromium project focuses mainly on Google Chrome application -development while CEF focuses on facilitating embedded browser use cases -in third-party applications. Lots of applications use CEF control, there are -more than [100 million CEF instances](http://en.wikipedia.org/wiki/Chromium_Embedded_Framework#Applications_using_CEF) +CEF Python is an open source project founded by +[Czarek Tomczak](https://www.linkedin.com/in/czarektomczak/) +in 2012 to provide Python bindings for the +[Chromium Embedded Framework](https://bitbucket.org/chromiumembedded/cef) (CEF). +The Chromium project focuses mainly on Google Chrome application +development while CEF focuses on facilitating embedded browser use cases +in third-party applications. Lots of applications use CEF control, there are +more than [100 million CEF instances](http://en.wikipedia.org/wiki/Chromium_Embedded_Framework#Applications_using_CEF) installed around the world. There are numerous use cases for CEF: -1. Use it as a modern HTML5 based rendering engine that can act as - a replacement for classic desktop GUI frameworks. Think of it as Electron - for Python. -2. Embed a web browser widget in a classic Qt / GTK / wxPython desktop - application -3. Render web content off-screen in applications that use custom drawing - frameworks -4. Use it for automated testing of web applications with more advanced - capabilities than Selenium web browser automation due to CEF low level - programming APIs -5. Use it for web scraping, as a web crawler or other kind of internet bots - -CEF Python also provides examples of embedding CEF for many Python GUI -frameworks such as PyQt, wxPython, PyGTK, PyGObject, Tkinter, Kivy, Panda3D, +1. Use it as a modern HTML5 based rendering engine that can act as + a replacement for classic desktop GUI frameworks. Think of it as Electron + for Python. +2. Embed a web browser widget in a classic Qt / GTK / wxPython desktop + application +3. Render web content off-screen in applications that use custom drawing + frameworks +4. Use it for automated testing of web applications with more advanced + capabilities than Selenium web browser automation due to CEF low level + programming APIs +5. Use it for web scraping, as a web crawler or other kind of internet bots + +CEF Python also provides examples of embedding CEF for many Python GUI +frameworks such as PyQt, wxPython, PyGTK, PyGObject, Tkinter, Kivy, Panda3D, PyGame, PyOpenGL, PyWin32, PySide and PySDL2. - ## Latest releases sponsored by - -
- -

- - - -

- -Thank you to Fivestars for sponsoring the [v66.1 release](../../releases/tag/v66.1) -with Python 3.8 / 3.9 support. Fivestars helps local communities thrive by empowering -small businesses with cutting edge marketing technology. Please visit their website: -Fivestars.com - -
- -

- - - -

- -Thank you to Lampix for sponsoring the -[v66 release](../../releases/tag/v66.0). Lampix is the first hardware -and software solution that turns any surface into a smart, augmented reality -or interactive surface. Please visit their website: -Lampix.com - -
+

Thank you to Fivestars for sponsoring the v66.1 release
with Python 3.8 / 3.9 support. Fivestars helps local communities thrive by empowering
small businesses with cutting edge marketing technology. Please visit their website:
Fivestars.com

Thank you to Lampix for sponsoring the
v66 release. Lampix is the first hardware
and software solution that turns any surface into a smart, augmented reality
or interactive surface. Please visit their website:
Lampix.com

### Thanks to all sponsors - - - - - - - - - - - -
-
- - -
- www.fivestars.com -
-
-
- - -
- www.lampix.com -
-
-
- - -
- www.blueplanet.com -
-
-
- - -
- www.highside.io -
-
-
- - -
- www.rentouch.ch -
-
-
- - -
- www.jetbrains.com -
-
- +

www.fivestars.com

www.lampix.com

www.blueplanet.com

www.highside.io

www.rentouch.ch

www.jetbrains.com
## Install -You can install [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3) -package using pip tool. On Linux pip 8.1+ is required. You can -also download packages for offline installation available on the +You can install [pypi/cefpython3](https://pypi.python.org/pypi/cefpython3)\-unoffi +package using pip tool. On Linux pip 8.1+ is required. You can +also download packages for offline installation available on the [GitHub Releases](../../releases) pages. Command to install with pip: -``` -pip install cefpython3==66.0 -``` - +pip install cefpython3-unofficial==66.1 ## Tutorial See the [Tutorial.md](docs/Tutorial.md) document. - ## Examples -See the [README-examples.md](examples/README-examples.md) and +See the [README-examples.md](examples/README-examples.md) and [README-snippets.md](examples/snippets/README-snippets.md) documents. - ## Support -- Ask questions and report problems on the - [Forum](https://groups.google.com/group/cefpython) -- Supported examples are listed in the - [README-examples.md](examples/README-examples.md) file -- Documentation is in the [docs/](docs) directory: - - [Build instructions](docs/Build-instructions.md) - - [Contributing code](docs/Contributing-code.md) - - [Knowledge Base](docs/Knowledge-Base.md) - - [Migration guide](docs/Migration-guide.md) - - [Tutorial](docs/Tutorial.md) -- API reference is in the [api/](api) directory: - - [API categories](api/API-categories.md#api-categories) - - [API index](api/API-index.md#api-index) -- Additional documentation is available in - [Issues labelled Knowledge Base](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22Knowledge+Base%22) -- To search documentation use GitHub "This repository" search - at the top. To narrow results to documentation only select - "Markdown" in the right pane. -- You can vote on issues in the tracker to let us know which issues are - important to you. To do that add a +1 thumb up reaction to the first post - in the issue. See - [Most popular issues](../../issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) - sorted by reactions. - +* Ask questions and report problems on the + [Forum](https://groups.google.com/group/cefpython) +* Supported examples are listed in the + [README-examples.md](examples/README-examples.md) file +* Documentation is in the [docs/](docs) directory: + * [Build instructions](docs/Build-instructions.md) + * [Contributing code](docs/Contributing-code.md) + * [Knowledge Base](docs/Knowledge-Base.md) + * [Migration guide](docs/Migration-guide.md) + * [Tutorial](docs/Tutorial.md) +* API reference is in the [api/](api) directory: + * [API categories](api/API-categories.md#api-categories) + * [API index](api/API-index.md#api-index) +* Additional documentation is available in + [Issues labelled Knowledge Base](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22Knowledge+Base%22) +* To search documentation use GitHub "This repository" search + at the top. To narrow results to documentation only select + "Markdown" in the right pane. +* You can vote on issues in the tracker to let us know which issues are + important to you. To do that add a +1 thumb up reaction to the first post + in the issue. See + [Most popular issues](../../issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc) + sorted by reactions. ## Releases -Information on planned new and current releases, supported platforms, -python versions, architectures and requirements. If you want to +Information on planned new and current releases, supported platforms, +python versions, architectures and requirements. If you want to support old operating systems then choose the v31 release. ### Next release -- To see planned new features or bugs to be fixed in the near future in one of - next releases, see the - [next release](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release%22) - label in the tracker -- To see planned new features or bugs to be fixed in further future, see the - [next release 2](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release+2%22) - label in the tracker +* To see planned new features or bugs to be fixed in the near future in one of + next releases, see the + [next release](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release%22) + label in the tracker +* To see planned new features or bugs to be fixed in further future, see the + [next release 2](../../issues?q=is%3Aissue+is%3Aopen+label%3A%22next+release+2%22) + label in the tracker ### Latest release -OS | Py2 | Py3 | 32bit | 64bit | Requirements ---- | --- | --- | --- | --- | --- -Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 | Yes | Yes | Windows 7+ (Note that Python 3.9 supports Windows 8.1+) -Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+,
Fedora 24+, openSUSE 13.3+ -Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | No | Yes | MacOS 10.9+ +| OS | Py2 | Py3 | 32bit | 64bit | Requirements | +| --- | --- | --- | --- | --- | --- | +| Windows | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 | Yes | Yes | Windows 7+ (Note that Python 3.9 supports Windows 8.1+) | +| Linux | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 | Yes | Yes | Debian 8+, Ubuntu 14.04+, +Fedora 24+, openSUSE 13.3+ | +| Mac | 2.7 | 3.4 / 3.5 / 3.6 / 3.7 / 3.8 / 3.9 | No | Yes | MacOS 10.9+ | These platforms are not supported yet: -- ARM - see [Issue #267](../../issues/267) -- Android - see [Issue #307](../../issues/307) +* ARM - see [Issue #267](../../issues/267) +* Android - see [Issue #307](../../issues/307) ### v49 release (WinXP/Vista) -OS | Py2 | Py3 | 32bit | 64bit | Requirements ---- | --- | --- | --- | --- | --- -Windows | 2.7 | 3.4 | Yes | Yes | Windows XP+ - -- Install with command: `pip --no-cache-dir install cefpython3==49.0`. - - Please note that if you were previously installing cefpython3 - package it is required to use the `--no-cache-dir` flag, - otherwise pip will end up with error message - `No matching distribution found for cefpython3==49.0`. - This happens because 49.0 release occured after 57.0 and 66.0 - releases. -- Downloads are available on GitHub Releases tagged +| OS | Py2 | Py3 | 32bit | 64bit | Requirements | +| --- | --- | --- | --- | --- | --- | +| Windows | 2.7 | 3.4 | Yes | Yes | Windows XP+ | + +* Install with command: pip --no-cache-dir install cefpython3==49.0. + * Please note that if you were previously installing cefpython3 + package it is required to use the --no-cache-dir flag, + otherwise pip will end up with error message + No matching distribution found for cefpython3==49.0. + This happens because 49.0 release occured after 57.0 and 66.0 + releases. +* Downloads are available on GitHub Releases tagged [v49.0](../../releases/tag/v49.0). -- See [Migration guide](docs/Migration-guide.md) document for changes - in this release -- Documentation is available in the [docs/](../../tree/cefpython49-winxp/docs) - directory in the `cefpython49-winxp` branch -- API reference is available in the [api/](../../tree/cefpython49-winxp/api) - directory in the `cefpython49-winxp` branch - +* See [Migration guide](docs/Migration-guide.md) document for changes + in this release +* Documentation is available in the [docs/](../../tree/cefpython49-winxp/docs) + directory in the cefpython49-winxp branch +* API reference is available in the [api/](../../tree/cefpython49-winxp/api) + directory in the cefpython49-winxp branch ### v31 release (old systems) -OS | Py2 | Py3 | 32bit | 64bit | Requirements ---- | --- | --- | --- | --- | --- -Windows | 2.7 | No | Yes | Yes | Windows XP+ -Linux | 2.7 | No | Yes | Yes | Debian 7+ / Ubuntu 12.04+ -Mac | 2.7 | No | Yes | Yes | MacOS 10.7+ +| OS | Py2 | Py3 | 32bit | 64bit | Requirements | +| --- | --- | --- | --- | --- | --- | +| Windows | 2.7 | No | Yes | Yes | Windows XP+ | +| Linux | 2.7 | No | Yes | Yes | Debian 7+ / Ubuntu 12.04+ | +| Mac | 2.7 | No | Yes | Yes | MacOS 10.7+ | Additional information for v31.2 release: -- On Windows/Mac you can install with command: `pip install cefpython3==31.2` -- Downloads are available on the GitHub Releases page tagged - [v31.2](../../releases/tag/v31.2). -- API reference is available in revision [169a1b2](../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api) -- Other documentation can be downloaded by cloning the - cefpython.wiki repository: `git clone git@github.com:cztomczak/cefpython.wiki.git` +* On Windows/Mac you can install with command: pip install cefpython3==31.2 +* Downloads are available on the GitHub Releases page tagged + [v31.2](../../releases/tag/v31.2). +* API reference is available in revision [169a1b2](../../tree/169a1b20d3cd09879070d41aab28cfa195d2a7d5/docs/api) +* Other documentation can be downloaded by cloning the + cefpython.wiki repository: git clone git@github.com:cztomczak/cefpython.wiki.git ## Support development -If you would like to support general CEF Python development efforts -by making a donation then please click the Paypal Donate button below. -If you would like to see a specific feature implemented then you can make -a comment about that when making a donation and that will give it a higher +If you would like to support general CEF Python development efforts +by making a donation then please click the Paypal Donate button below. +If you would like to see a specific feature implemented then you can make +a comment about that when making a donation and that will give it a higher priority. - - -

- +![](https://raw.githubusercontent.com/wiki/cztomczak/cefpython/images/donate.gif) + +  ### Thanks to all -* [2021] Thank you to [Fivestars](https://www.fivestars.com/) for sponsoring - the v66.1 release with Python 3.8 / 3.9 support -* [2018] Thanks to [Fivestars](https://www.fivestars.com/) for sponsoring - the v49 release for legacy systems (WinXP/Vista) -* [2018] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 - release for all platforms -* [2017] Many thanks to [HighSide Inc.](https://highside.io/) for sponsoring - the v55/v56 releases for all platforms -* [2016-2018] Thanks to JetBrains for providing an Open Source license for - [PyCharm](https://www.jetbrains.com/pycharm/) -* [2014] Thanks to Adam Duston for donating a Macbook to aid the development - of Mac port -* [2013-2015] Lots of thanks goes to [Cyan Inc.](http://www.blueplanet.com/) - for sponsoring this project for a long time, making CEF Python 3 mature -* [2013] Thanks to [Rentouch GmbH](http://www.rentouch.ch/) for sponsoring the - development of the off-screen rendering support -* [2013] Thanks to Thomas Wusatiuk for sponsoring the development of the web - response reading features -* [2012-2018] Thanks to those who have made a Paypal donation: - [Rentouch GmbH](http://www.rentouch.ch/), Walter Purvis, Rokas Stupuras, - Alex Rattray, Greg Kacy, Paul Korzhyk, Tomasz Tomanek. -* [2012-2017] Thanks to those who have donated their time through code - contributions, they are listed in the [Authors](Authors) file - +* \[2021\] Thank you to [Fivestars](https://www.fivestars.com/) for sponsoring + the v66.1 release with Python 3.8 / 3.9 support +* \[2018\] Thanks to [Fivestars](https://www.fivestars.com/) for sponsoring + the v49 release for legacy systems (WinXP/Vista) +* \[2018\] Many thanks to [Lampix](https://lampix.com/) for sponsoring the v66 + release for all platforms +* \[2017\] Many thanks to [HighSide Inc.](https://highside.io/) for sponsoring + the v55/v56 releases for all platforms +* \[2016-2018\] Thanks to JetBrains for providing an Open Source license for + [PyCharm](https://www.jetbrains.com/pycharm/) +* \[2014\] Thanks to Adam Duston for donating a Macbook to aid the development + of Mac port +* \[2013-2015\] Lots of thanks goes to [Cyan Inc.](http://www.blueplanet.com/) + for sponsoring this project for a long time, making CEF Python 3 mature +* \[2013\] Thanks to [Rentouch GmbH](http://www.rentouch.ch/) for sponsoring the + development of the off-screen rendering support +* \[2013\] Thanks to Thomas Wusatiuk for sponsoring the development of the web + response reading features +* \[2012-2018\] Thanks to those who have made a Paypal donation: + [Rentouch GmbH](http://www.rentouch.ch/), Walter Purvis, Rokas Stupuras, + Alex Rattray, Greg Kacy, Paul Korzhyk, Tomasz Tomanek. +* \[2012-2017\] Thanks to those who have donated their time through code + contributions, they are listed in the [Authors](Authors) file ## Seeking new sponsors -CEF Python is seeking companies to sponsor further development of the project. -There are many proposals for new features submitted in the issue tracker. Most +CEF Python is seeking companies to sponsor further development of the project. +There are many proposals for new features submitted in the issue tracker. Most notable are: -* Monthly releases with latest Chromium -* An automated build system similar to upstream CEF Spotify Automated Builds -* ARM and Android support -* Multi-threaded support for increased performance -* Proprietary codecs support in build tools: H264, H265,AC3, EAC3, MPEG-4 -* More CEF API exposed, only about 50% is exposed so far -* Hundreds of new settings and Chromium preferences not yet exposed -* Easier integration with popular GUI toolkits in just a few lines of code - and support for more third party GUI frameworks -* More examples of implementing various advanced features and more snippets - as well - -If your company would like to sponsor CEF Python development efforts then -please contact -[Czarek](https://www.linkedin.com/in/czarektomczak/). -Long term sponsorships are welcome and Czarek is open to ideas about -the project. He would love to spend more time on developing this project, -but he can't afford doing so in his free time. Currently there is no company +* Monthly releases with latest Chromium +* An automated build system similar to upstream CEF Spotify Automated Builds +* ARM and Android support +* Multi-threaded support for increased performance +* Proprietary codecs support in build tools: H264, H265,AC3, EAC3, MPEG-4 +* More CEF API exposed, only about 50% is exposed so far +* Hundreds of new settings and Chromium preferences not yet exposed +* Easier integration with popular GUI toolkits in just a few lines of code + and support for more third party GUI frameworks +* More examples of implementing various advanced features and more snippets + as well + +If your company would like to sponsor CEF Python development efforts then +please contact +[Czarek](https://www.linkedin.com/in/czarektomczak/). +Long term sponsorships are welcome and Czarek is open to ideas about +the project. He would love to spend more time on developing this project, +but he can't afford doing so in his free time. Currently there is no company supporting this project actively on a daily basis. - ## Other READMEs -- [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md) - - +* [PyInstaller packager](examples/pyinstaller/README-pyinstaller.md) ## Quick links ### Docs -- [Build instructions](docs/Build-instructions.md) -- [Knowledge Base](docs/Knowledge-Base.md) -- [Migration guide](docs/Migration-guide.md) -- [Tutorial](docs/Tutorial.md) - +* [Build instructions](docs/Build-instructions.md) +* [Knowledge Base](docs/Knowledge-Base.md) +* [Migration guide](docs/Migration-guide.md) +* [Tutorial](docs/Tutorial.md) ### API categories #### Modules - * [cefpython](api/cefpython.md#cefpython) module - +* [cefpython](api/cefpython.md#cefpython) module #### Settings - * [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary - * [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary - * [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary - +* [ApplicationSettings](api/ApplicationSettings.md#application-settings) dictionary +* [BrowserSettings](api/BrowserSettings.md#browser-settings) dictionary +* [CommandLineSwitches](api/CommandLineSwitches.md#command-line-switches) dictionary #### Classes and objects - * [Browser](api/Browser.md#browser-object) object - * [Callback](api/Callback.md#callback-object) object - * [Cookie](api/Cookie.md#cookie-class) class - * [CookieManager](api/CookieManager.md#cookiemanager-class) class - * [DpiAware](api/DpiAware.md#dpiaware-class) class (Win) - * [DragData](api/DragData.md#dragdata-object) object - * [Frame](api/Frame.md#frame-object) object - * [Image](api/Image.md#image-object) object - * [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class - * [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object - * [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object - * [Request](api/Request.md#request-class) class - * [Response](api/Response.md#response-object) object - * [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object - * [WebRequest](api/WebRequest.md#webrequest-class) class - * [WindowInfo](api/WindowInfo.md#windowinfo-class) class - * [WindowUtils](api/WindowUtils.md#windowutils-class) class - +* [Browser](api/Browser.md#browser-object) object +* [Callback](api/Callback.md#callback-object) object +* [Cookie](api/Cookie.md#cookie-class) class +* [CookieManager](api/CookieManager.md#cookiemanager-class) class +* [DpiAware](api/DpiAware.md#dpiaware-class) class (Win) +* [DragData](api/DragData.md#dragdata-object) object +* [Frame](api/Frame.md#frame-object) object +* [Image](api/Image.md#image-object) object +* [JavascriptBindings](api/JavascriptBindings.md#javascriptbindings-class) class +* [JavascriptCallback](api/JavascriptCallback.md#javascriptcallback-object) object +* [PaintBuffer](api/PaintBuffer.md#paintbuffer-object) object +* [Request](api/Request.md#request-class) class +* [Response](api/Response.md#response-object) object +* [WebPluginInfo](api/WebPluginInfo.md#webplugininfo-object) object +* [WebRequest](api/WebRequest.md#webrequest-class) class +* [WindowInfo](api/WindowInfo.md#windowinfo-class) class +* [WindowUtils](api/WindowUtils.md#windowutils-class) class #### Client handlers (interfaces) - * [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface) - * [DisplayHandler](api/DisplayHandler.md#displayhandler-interface) - * [DownloadHandler](api/DownloadHandler.md#downloadhandler) - * [FocusHandler](api/FocusHandler.md#focushandler-interface) - * [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) - * [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface) - * [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface) - * [LoadHandler](api/LoadHandler.md#loadhandler-interface) - * [RenderHandler](api/RenderHandler.md#renderhandler-interface) - * [RequestHandler](api/RequestHandler.md#requesthandler-interface) - * [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface) - * [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface) - +* [AccessibilityHandler](api/AccessibilityHandler.md#accessibilityhandler-interface) +* [DisplayHandler](api/DisplayHandler.md#displayhandler-interface) +* [DownloadHandler](api/DownloadHandler.md#downloadhandler) +* [FocusHandler](api/FocusHandler.md#focushandler-interface) +* [JavascriptDialogHandler](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) +* [KeyboardHandler](api/KeyboardHandler.md#keyboardhandler-interface) +* [LifespanHandler](api/LifespanHandler.md#lifespanhandler-interface) +* [LoadHandler](api/LoadHandler.md#loadhandler-interface) +* [RenderHandler](api/RenderHandler.md#renderhandler-interface) +* [RequestHandler](api/RequestHandler.md#requesthandler-interface) +* [ResourceHandler](api/ResourceHandler.md#resourcehandler-interface) +* [V8ContextHandler](api/V8ContextHandler.md#v8contexthandler-interface) #### Other interfaces - * [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface - * [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface - * [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface - +* [CookieVisitor](api/CookieVisitor.md#cookievisitor-interface) interface +* [StringVisitor](api/StringVisitor.md#stringvisitor-interface) interface +* [WebRequestClient](api/WebRequestClient.md#webrequestclient-interface) interface ### API index -* [AccessibilityHandler (interface)](api/AccessibilityHandler.md#accessibilityhandler-interface) - * [_OnAccessibilityTreeChange](api/AccessibilityHandler.md#_onaccessibilitytreechange) - * [_OnAccessibilityLocationChange](api/AccessibilityHandler.md#_onaccessibilitylocationchange) -* [Application settings](api/ApplicationSettings.md#application-settings) - * [accept_language_list](api/ApplicationSettings.md#accept_language_list) - * [app_user_model_id](api/ApplicationSettings.md#app_user_model_id) - * [auto_zooming](api/ApplicationSettings.md#auto_zooming) - * [background_color](api/ApplicationSettings.md#background_color) - * [browser_subprocess_path](api/ApplicationSettings.md#browser_subprocess_path) - * [cache_path](api/ApplicationSettings.md#cache_path) - * [command_line_args_disabled](api/ApplicationSettings.md#command_line_args_disabled) - * [context_menu](api/ApplicationSettings.md#context_menu) - * [downloads_enabled](api/ApplicationSettings.md#downloads_enabled) - * [external_message_pump](api/ApplicationSettings.md#external_message_pump) - * [framework_dir_path](api/ApplicationSettings.md#framework_dir_path) - * [ignore_certificate_errors](api/ApplicationSettings.md#ignore_certificate_errors) - * [javascript_flags](api/ApplicationSettings.md#javascript_flags) - * [locale](api/ApplicationSettings.md#locale) - * [locales_dir_path](api/ApplicationSettings.md#locales_dir_path) - * [debug](api/ApplicationSettings.md#debug) - * [log_file](api/ApplicationSettings.md#log_file) - * [log_severity](api/ApplicationSettings.md#log_severity) - * [multi_threaded_message_loop](api/ApplicationSettings.md#multi_threaded_message_loop) - * [net_security_expiration_enabled](api/ApplicationSettings.md#net_security_expiration_enabled) - * [pack_loading_disabled](api/ApplicationSettings.md#pack_loading_disabled) - * [persist_session_cookies](api/ApplicationSettings.md#persist_session_cookies) - * [persist_user_preferences](api/ApplicationSettings.md#persist_user_preferences) - * [product_version](api/ApplicationSettings.md#product_version) - * [remote_debugging_port](api/ApplicationSettings.md#remote_debugging_port) - * [resources_dir_path](api/ApplicationSettings.md#resources_dir_path) - * [single_process](api/ApplicationSettings.md#single_process) - * [string_encoding](api/ApplicationSettings.md#string_encoding) - * [uncaught_exception_stack_size](api/ApplicationSettings.md#uncaught_exception_stack_size) - * [unique_request_context_per_browser](api/ApplicationSettings.md#unique_request_context_per_browser) - * [user_agent](api/ApplicationSettings.md#user_agent) - * [user_data_path](api/ApplicationSettings.md#user_data_path) - * [windowless_rendering_enabled](api/ApplicationSettings.md#windowless_rendering_enabled) -* [Browser (object)](api/Browser.md#browser-object) - * [AddWordToDictionary](api/Browser.md#addwordtodictionary) - * [CanGoBack](api/Browser.md#cangoback) - * [CanGoForward](api/Browser.md#cangoforward) - * [CloseBrowser](api/Browser.md#closebrowser) - * [CloseDevTools](api/Browser.md#closedevtools) - * [DragTargetDragEnter](api/Browser.md#dragtargetdragenter) - * [DragTargetDragOver](api/Browser.md#dragtargetdragover) - * [DragTargetDragLeave](api/Browser.md#dragtargetdragleave) - * [DragTargetDrop](api/Browser.md#dragtargetdrop) - * [DragSourceEndedAt](api/Browser.md#dragsourceendedat) - * [DragSourceSystemDragEnded](api/Browser.md#dragsourcesystemdragended) - * [ExecuteFunction](api/Browser.md#executefunction) - * [ExecuteJavascript](api/Browser.md#executejavascript) - * [Find](api/Browser.md#find) - * [GetClientCallback](api/Browser.md#getclientcallback) - * [GetClientCallbacksDict](api/Browser.md#getclientcallbacksdict) - * [GetFocusedFrame](api/Browser.md#getfocusedframe) - * [GetFrame](api/Browser.md#getframe) - * [GetFrameByIdentifier](api/Browser.md#getframebyidentifier) - * [GetFrames](api/Browser.md#getframes) - * [GetFrameCount](api/Browser.md#getframecount) - * [GetFrameIdentifiers](api/Browser.md#getframeidentifiers) - * [GetFrameNames](api/Browser.md#getframenames) - * [GetImage](api/Browser.md#getimage) - * [GetJavascriptBindings](api/Browser.md#getjavascriptbindings) - * [GetMainFrame](api/Browser.md#getmainframe) - * [GetNSTextInputContext](api/Browser.md#getnstextinputcontext) - * [GetOpenerWindowHandle](api/Browser.md#getopenerwindowhandle) - * [GetOuterWindowHandle](api/Browser.md#getouterwindowhandle) - * [GetSetting](api/Browser.md#getsetting) - * [GetUrl](api/Browser.md#geturl) - * [GetUserData](api/Browser.md#getuserdata) - * [GetWindowHandle](api/Browser.md#getwindowhandle) - * [GetIdentifier](api/Browser.md#getidentifier) - * [GetZoomLevel](api/Browser.md#getzoomlevel) - * [GoBack](api/Browser.md#goback) - * [GoForward](api/Browser.md#goforward) - * [HandleKeyEventAfterTextInputClient](api/Browser.md#handlekeyeventaftertextinputclient) - * [HandleKeyEventBeforeTextInputClient](api/Browser.md#handlekeyeventbeforetextinputclient) - * [HasDevTools](api/Browser.md#hasdevtools) - * [HasDocument](api/Browser.md#hasdocument) - * [Invalidate](api/Browser.md#invalidate) - * [IsFullscreen](api/Browser.md#isfullscreen) - * [IsLoading](api/Browser.md#isloading) - * [IsMouseCursorChangeDisabled](api/Browser.md#ismousecursorchangedisabled) - * [IsPopup](api/Browser.md#ispopup) - * [IsWindowRenderingDisabled](api/Browser.md#iswindowrenderingdisabled) - * [LoadUrl](api/Browser.md#loadurl) - * [Navigate](api/Browser.md#navigate) - * [NotifyMoveOrResizeStarted](api/Browser.md#notifymoveorresizestarted) - * [NotifyScreenInfoChanged](api/Browser.md#notifyscreeninfochanged) - * [ParentWindowWillClose](api/Browser.md#parentwindowwillclose) - * [Print](api/Browser.md#print) - * [Reload](api/Browser.md#reload) - * [ReloadIgnoreCache](api/Browser.md#reloadignorecache) - * [ReplaceMisspelling](api/Browser.md#replacemisspelling) - * [SetAutoResizeEnabled](api/Browser.md#setautoresizeenabled) - * [SetBounds](api/Browser.md#setbounds) - * [SendKeyEvent](api/Browser.md#sendkeyevent) - * [SendMouseClickEvent](api/Browser.md#sendmouseclickevent) - * [SendMouseMoveEvent](api/Browser.md#sendmousemoveevent) - * [SendMouseWheelEvent](api/Browser.md#sendmousewheelevent) - * [SendFocusEvent](api/Browser.md#sendfocusevent) - * [SendCaptureLostEvent](api/Browser.md#sendcapturelostevent) - * [SetAccessibilityState](api/Browser.md#setaccessibilitystate) - * [SetClientCallback](api/Browser.md#setclientcallback) - * [SetClientHandler](api/Browser.md#setclienthandler) - * [SetFocus](api/Browser.md#setfocus) - * [SetMouseCursorChangeDisabled](api/Browser.md#setmousecursorchangedisabled) - * [SetJavascriptBindings](api/Browser.md#setjavascriptbindings) - * [SetUserData](api/Browser.md#setuserdata) - * [SetZoomLevel](api/Browser.md#setzoomlevel) - * [ShowDevTools](api/Browser.md#showdevtools) - * [StartDownload](api/Browser.md#startdownload) - * [StopLoad](api/Browser.md#stopload) - * [StopFinding](api/Browser.md#stopfinding) - * [ToggleFullscreen](api/Browser.md#togglefullscreen) - * [TryCloseBrowser](api/Browser.md#tryclosebrowser) - * [WasResized](api/Browser.md#wasresized) - * [WasHidden](api/Browser.md#washidden) -* [Browser settings](api/BrowserSettings.md#browser-settings) - * [Font settings](api/BrowserSettings.md#font-settings) - * [accept_language_list](api/BrowserSettings.md#accept_language_list) - * [application_cache_disabled](api/BrowserSettings.md#application_cache_disabled) - * [background_color](api/BrowserSettings.md#background_color) - * [databases_disabled](api/BrowserSettings.md#databases_disabled) - * [default_encoding](api/BrowserSettings.md#default_encoding) - * [dom_paste_disabled](api/BrowserSettings.md#dom_paste_disabled) - * [file_access_from_file_urls_allowed](api/BrowserSettings.md#file_access_from_file_urls_allowed) - * [inherit_client_handlers_for_popups](api/BrowserSettings.md#inherit_client_handlers_for_popups) - * [image_load_disabled](api/BrowserSettings.md#image_load_disabled) - * [javascript_disabled](api/BrowserSettings.md#javascript_disabled) - * [javascript_close_windows_disallowed](api/BrowserSettings.md#javascript_close_windows_disallowed) - * [javascript_access_clipboard_disallowed](api/BrowserSettings.md#javascript_access_clipboard_disallowed) - * [local_storage_disabled](api/BrowserSettings.md#local_storage_disabled) - * [plugins_disabled](api/BrowserSettings.md#plugins_disabled) - * [remote_fonts](api/BrowserSettings.md#remote_fonts) - * [shrink_standalone_images_to_fit](api/BrowserSettings.md#shrink_standalone_images_to_fit) - * [tab_to_links_disabled](api/BrowserSettings.md#tab_to_links_disabled) - * [text_area_resize_disabled](api/BrowserSettings.md#text_area_resize_disabled) - * [universal_access_from_file_urls_allowed](api/BrowserSettings.md#universal_access_from_file_urls_allowed) - * [user_style_sheet_location](api/BrowserSettings.md#user_style_sheet_location) - * [web_security_disabled](api/BrowserSettings.md#web_security_disabled) - * [webgl_disabled](api/BrowserSettings.md#webgl_disabled) - * [windowless_frame_rate](api/BrowserSettings.md#windowless_frame_rate) -* [Callback (object)](api/Callback.md#callback-object) - * [Continue](api/Callback.md#continue) - * [Cancel](api/Callback.md#cancel) -* [cefpython](api/cefpython.md#cefpython) - * [CreateBrowser](api/cefpython.md#createbrowser) - * [CreateBrowserSync](api/cefpython.md#createbrowsersync) - * [ExceptHook](api/cefpython.md#excepthook) - * [GetAppSetting](api/cefpython.md#getappsetting) - * [GetAppPath](api/cefpython.md#getapppath) - * [GetBrowserByIdentifier](api/cefpython.md#getbrowserbyidentifier) - * [GetBrowserByWindowHandle](api/cefpython.md#getbrowserbywindowhandle) - * [GetCommandLineSwitch](api/cefpython.md#getcommandlineswitch) - * [GetDataUrl](api/cefpython.md#getdataurl) - * [GetGlobalClientCallback](api/cefpython.md#getglobalclientcallback) - * [GetModuleDirectory](api/cefpython.md#getmoduledirectory) - * [GetVersion](api/cefpython.md#getversion) - * [Initialize](api/cefpython.md#initialize) - * [IsThread](api/cefpython.md#isthread) - * [LoadCrlSetsFile](api/cefpython.md#loadcrlsetsfile) - * [MessageLoop](api/cefpython.md#messageloop) - * [MessageLoopWork](api/cefpython.md#messageloopwork) - * [PostTask](api/cefpython.md#posttask) - * [PostDelayedTask](api/cefpython.md#postdelayedtask) - * [QuitMessageLoop](api/cefpython.md#quitmessageloop) - * [SetGlobalClientCallback](api/cefpython.md#setglobalclientcallback) - * [SetGlobalClientHandler](api/cefpython.md#setglobalclienthandler) - * [SetOsModalLoop](api/cefpython.md#setosmodalloop) - * [Shutdown](api/cefpython.md#shutdown) -* [Command line switches](api/CommandLineSwitches.md#command-line-switches) - * [enable-media-stream](api/CommandLineSwitches.md#enable-media-stream) - * [proxy-server](api/CommandLineSwitches.md#proxy-server) - * [no-proxy-server](api/CommandLineSwitches.md#no-proxy-server) - * [disable-gpu](api/CommandLineSwitches.md#disable-gpu) -* [Cookie (class)](api/Cookie.md#cookie-class) - * [Set](api/Cookie.md#set) - * [Get](api/Cookie.md#get) - * [SetName](api/Cookie.md#setname) - * [GetName](api/Cookie.md#getname) - * [SetValue](api/Cookie.md#setvalue) - * [GetValue](api/Cookie.md#getvalue) - * [SetDomain](api/Cookie.md#setdomain) - * [GetDomain](api/Cookie.md#getdomain) - * [SetPath](api/Cookie.md#setpath) - * [GetPath](api/Cookie.md#getpath) - * [SetSecure](api/Cookie.md#setsecure) - * [GetSecure](api/Cookie.md#getsecure) - * [SetHttpOnly](api/Cookie.md#sethttponly) - * [GetHttpOnly](api/Cookie.md#gethttponly) - * [SetCreation](api/Cookie.md#setcreation) - * [GetCreation](api/Cookie.md#getcreation) - * [SetLastAccess](api/Cookie.md#setlastaccess) - * [GetLastAccess](api/Cookie.md#getlastaccess) - * [SetHasExpires](api/Cookie.md#sethasexpires) - * [GetHasExpires](api/Cookie.md#gethasexpires) - * [SetExpires](api/Cookie.md#setexpires) - * [GetExpires](api/Cookie.md#getexpires) -* [CookieManager (class)](api/CookieManager.md#cookiemanager-class) - * [GetGlobalManager](api/CookieManager.md#getglobalmanager) - * [GetBlockingManager](api/CookieManager.md#getblockingmanager) - * [CreateManager](api/CookieManager.md#createmanager) - * [SetSupportedSchemes](api/CookieManager.md#setsupportedschemes) - * [VisitAllCookies](api/CookieManager.md#visitallcookies) - * [VisitUrlCookies](api/CookieManager.md#visiturlcookies) - * [SetCookie](api/CookieManager.md#setcookie) - * [DeleteCookies](api/CookieManager.md#deletecookies) - * [SetStoragePath](api/CookieManager.md#setstoragepath) - * [FlushStore](api/CookieManager.md#flushstore) -* [CookieVisitor (interface)](api/CookieVisitor.md#cookievisitor-interface) - * [Visit](api/CookieVisitor.md#visit) -* [DisplayHandler (interface)](api/DisplayHandler.md#displayhandler-interface) - * [OnAddressChange](api/DisplayHandler.md#onaddresschange) - * [OnAutoResize](api/DisplayHandler.md#onautoresize) - * [OnConsoleMessage](api/DisplayHandler.md#onconsolemessage) - * [OnLoadingProgressChange](api/DisplayHandler.md#onloadingprogresschange) - * [OnStatusMessage](api/DisplayHandler.md#onstatusmessage) - * [OnTitleChange](api/DisplayHandler.md#ontitlechange) - * [OnTooltip](api/DisplayHandler.md#ontooltip) -* [DownloadHandler](api/DownloadHandler.md#downloadhandler) -* [DpiAware (class)](api/DpiAware.md#dpiaware-class) - * [CalculateWindowSize](api/DpiAware.md#calculatewindowsize) - * [EnableHighDpiSupport](api/DpiAware.md#enablehighdpisupport) - * [GetSystemDpi](api/DpiAware.md#getsystemdpi) - * [IsProcessDpiAware](api/DpiAware.md#isprocessdpiaware) - * [SetProcessDpiAware](api/DpiAware.md#setprocessdpiaware) - * [Scale](api/DpiAware.md#scale) -* [DragData (object)](api/DragData.md#dragdata-object) - * [IsLink](api/DragData.md#islink) - * [IsFragment](api/DragData.md#isfragment) - * [GetLinkUrl](api/DragData.md#getlinkurl) - * [GetLinkTitle](api/DragData.md#getlinktitle) - * [GetFragmentText](api/DragData.md#getfragmenttext) - * [GetFragmentHtml](api/DragData.md#getfragmenthtml) - * [GetImage](api/DragData.md#getimage) - * [GetImageHotspot](api/DragData.md#getimagehotspot) - * [HasImage](api/DragData.md#hasimage) -* [FocusHandler (interface)](api/FocusHandler.md#focushandler-interface) - * [OnTakeFocus](api/FocusHandler.md#ontakefocus) - * [OnSetFocus](api/FocusHandler.md#onsetfocus) - * [OnGotFocus](api/FocusHandler.md#ongotfocus) -* [Frame (object)](api/Frame.md#frame-object) - * [Copy](api/Frame.md#copy) - * [Cut](api/Frame.md#cut) - * [Delete](api/Frame.md#delete) - * [ExecuteFunction](api/Frame.md#executefunction) - * [ExecuteJavascript](api/Frame.md#executejavascript) - * [GetBrowser](api/Frame.md#getbrowser) - * [GetParent](api/Frame.md#getparent) - * [GetIdentifier](api/Frame.md#getidentifier) - * [GetBrowserIdentifier](api/Frame.md#getbrowseridentifier) - * [GetName](api/Frame.md#getname) - * [GetParent](api/Frame.md#getparent) - * [GetSource](api/Frame.md#getsource) - * [GetText](api/Frame.md#gettext) - * [GetUrl](api/Frame.md#geturl) - * [IsFocused](api/Frame.md#isfocused) - * [IsMain](api/Frame.md#ismain) - * [IsValid](api/Frame.md#isvalid) - * [LoadString](api/Frame.md#loadstring) - * [LoadUrl](api/Frame.md#loadurl) - * [Paste](api/Frame.md#paste) - * [Redo](api/Frame.md#redo) - * [SelectAll](api/Frame.md#selectall) - * [Undo](api/Frame.md#undo) - * [ViewSource](api/Frame.md#viewsource) -* [Image (object)](api/Image.md#image-object) - * [GetAsBitmap](api/Image.md#getasbitmap) - * [GetAsPng](api/Image.md#getaspng) - * [GetHeight](api/Image.md#getheight) - * [GetWidth](api/Image.md#getwidth) -* [JavascriptBindings (class)](api/JavascriptBindings.md#javascriptbindings-class) - * [\_\_init\_\_](api/JavascriptBindings.md#__init__) - * [IsValueAllowed](api/JavascriptBindings.md#isvalueallowed) - * [Rebind](api/JavascriptBindings.md#rebind) - * [SetFunction](api/JavascriptBindings.md#setfunction) - * [SetObject](api/JavascriptBindings.md#setobject) - * [SetProperty](api/JavascriptBindings.md#setproperty) -* [JavascriptCallback (object)](api/JavascriptCallback.md#javascriptcallback-object) - * [Call](api/JavascriptCallback.md#call) - * [GetFrame](api/JavascriptCallback.md#getframe) - * [GetId](api/JavascriptCallback.md#getid) - * [GetFunctionName](api/JavascriptCallback.md#getfunctionname) -* [JavascriptDialogHandler (interface)](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) - * [Continue](api/JavascriptDialogHandler.md#continue) - * [OnJavascriptDialog](api/JavascriptDialogHandler.md#onjavascriptdialog) - * [OnBeforeUnloadJavascriptDialog](api/JavascriptDialogHandler.md#onbeforeunloadjavascriptdialog) - * [OnResetJavascriptDialogState](api/JavascriptDialogHandler.md#onresetjavascriptdialogstate) - * [OnJavascriptDialogClosed](api/JavascriptDialogHandler.md#onjavascriptdialogclosed) -* [KeyboardHandler (interface)](api/KeyboardHandler.md#keyboardhandler-interface) - * [OnPreKeyEvent](api/KeyboardHandler.md#onprekeyevent) - * [OnKeyEvent](api/KeyboardHandler.md#onkeyevent) -* [LifespanHandler (interface)](api/LifespanHandler.md#lifespanhandler-interface) - * [DoClose](api/LifespanHandler.md#doclose) - * [_OnAfterCreated](api/LifespanHandler.md#_onaftercreated) - * [OnBeforeClose](api/LifespanHandler.md#onbeforeclose) - * [OnBeforePopup](api/LifespanHandler.md#onbeforepopup) -* [LoadHandler (interface)](api/LoadHandler.md#loadhandler-interface) - * [OnLoadingStateChange](api/LoadHandler.md#onloadingstatechange) - * [OnLoadStart](api/LoadHandler.md#onloadstart) - * [OnDomReady](api/LoadHandler.md#ondomready) - * [OnLoadEnd](api/LoadHandler.md#onloadend) - * [OnLoadError](api/LoadHandler.md#onloaderror) -* [Network error](api/NetworkError.md#network-error) - * [ERR_NONE](api/NetworkError.md#err_none) - * [ERR_ABORTED](api/NetworkError.md#err_aborted) - * [ERR_ACCESS_DENIED](api/NetworkError.md#err_access_denied) - * [ERR_ADDRESS_INVALID](api/NetworkError.md#err_address_invalid) - * [ERR_ADDRESS_UNREACHABLE](api/NetworkError.md#err_address_unreachable) - * [ERR_CACHE_MISS](api/NetworkError.md#err_cache_miss) - * [ERR_CERT_AUTHORITY_INVALID](api/NetworkError.md#err_cert_authority_invalid) - * [ERR_CERT_COMMON_NAME_INVALID](api/NetworkError.md#err_cert_common_name_invalid) - * [ERR_CERT_CONTAINS_ERRORS](api/NetworkError.md#err_cert_contains_errors) - * [ERR_CERT_DATE_INVALID](api/NetworkError.md#err_cert_date_invalid) - * [ERR_CERT_END](api/NetworkError.md#err_cert_end) - * [ERR_CERT_INVALID](api/NetworkError.md#err_cert_invalid) - * [ERR_CERT_NO_REVOCATION_MECHANISM](api/NetworkError.md#err_cert_no_revocation_mechanism) - * [ERR_CERT_REVOKED](api/NetworkError.md#err_cert_revoked) - * [ERR_CERT_UNABLE_TO_CHECK_REVOCATION](api/NetworkError.md#err_cert_unable_to_check_revocation) - * [ERR_CONNECTION_ABORTED](api/NetworkError.md#err_connection_aborted) - * [ERR_CONNECTION_CLOSED](api/NetworkError.md#err_connection_closed) - * [ERR_CONNECTION_FAILED](api/NetworkError.md#err_connection_failed) - * [ERR_CONNECTION_REFUSED](api/NetworkError.md#err_connection_refused) - * [ERR_CONNECTION_RESET](api/NetworkError.md#err_connection_reset) - * [ERR_DISALLOWED_URL_SCHEME](api/NetworkError.md#err_disallowed_url_scheme) - * [ERR_EMPTY_RESPONSE](api/NetworkError.md#err_empty_response) - * [ERR_FAILED](api/NetworkError.md#err_failed) - * [ERR_FILE_NOT_FOUND](api/NetworkError.md#err_file_not_found) - * [ERR_FILE_TOO_BIG](api/NetworkError.md#err_file_too_big) - * [ERR_INSECURE_RESPONSE](api/NetworkError.md#err_insecure_response) - * [ERR_INTERNET_DISCONNECTED](api/NetworkError.md#err_internet_disconnected) - * [ERR_INVALID_ARGUMENT](api/NetworkError.md#err_invalid_argument) - * [ERR_INVALID_CHUNKED_ENCODING](api/NetworkError.md#err_invalid_chunked_encoding) - * [ERR_INVALID_HANDLE](api/NetworkError.md#err_invalid_handle) - * [ERR_INVALID_RESPONSE](api/NetworkError.md#err_invalid_response) - * [ERR_INVALID_URL](api/NetworkError.md#err_invalid_url) - * [ERR_METHOD_NOT_SUPPORTED](api/NetworkError.md#err_method_not_supported) - * [ERR_NAME_NOT_RESOLVED](api/NetworkError.md#err_name_not_resolved) - * [ERR_NO_SSL_VERSIONS_ENABLED](api/NetworkError.md#err_no_ssl_versions_enabled) - * [ERR_NOT_IMPLEMENTED](api/NetworkError.md#err_not_implemented) - * [ERR_RESPONSE_HEADERS_TOO_BIG](api/NetworkError.md#err_response_headers_too_big) - * [ERR_SSL_CLIENT_AUTH_CERT_NEEDED](api/NetworkError.md#err_ssl_client_auth_cert_needed) - * [ERR_SSL_PROTOCOL_ERROR](api/NetworkError.md#err_ssl_protocol_error) - * [ERR_SSL_RENEGOTIATION_REQUESTED](api/NetworkError.md#err_ssl_renegotiation_requested) - * [ERR_SSL_VERSION_OR_CIPHER_MISMATCH](api/NetworkError.md#err_ssl_version_or_cipher_mismatch) - * [ERR_TIMED_OUT](api/NetworkError.md#err_timed_out) - * [ERR_TOO_MANY_REDIRECTS](api/NetworkError.md#err_too_many_redirects) - * [ERR_TUNNEL_CONNECTION_FAILED](api/NetworkError.md#err_tunnel_connection_failed) - * [ERR_UNEXPECTED](api/NetworkError.md#err_unexpected) - * [ERR_UNEXPECTED_PROXY_AUTH](api/NetworkError.md#err_unexpected_proxy_auth) - * [ERR_UNKNOWN_URL_SCHEME](api/NetworkError.md#err_unknown_url_scheme) - * [ERR_UNSAFE_PORT](api/NetworkError.md#err_unsafe_port) - * [ERR_UNSAFE_REDIRECT](api/NetworkError.md#err_unsafe_redirect) -* [PaintBuffer (object)](api/PaintBuffer.md#paintbuffer-object) - * [GetIntPointer](api/PaintBuffer.md#getintpointer) - * [GetBytes](api/PaintBuffer.md#getbytes) -* [RenderHandler (interface)](api/RenderHandler.md#renderhandler-interface) - * [GetRootScreenRect](api/RenderHandler.md#getrootscreenrect) - * [GetViewRect](api/RenderHandler.md#getviewrect) - * [GetScreenRect](api/RenderHandler.md#getscreenrect) - * [GetScreenPoint](api/RenderHandler.md#getscreenpoint) - * [OnPopupShow](api/RenderHandler.md#onpopupshow) - * [OnPopupSize](api/RenderHandler.md#onpopupsize) - * [OnPaint](api/RenderHandler.md#onpaint) - * [OnCursorChange](api/RenderHandler.md#oncursorchange) - * [OnScrollOffsetChanged](api/RenderHandler.md#onscrolloffsetchanged) - * [OnTextSelectionChanged](api/RenderHandler.md#ontextselectionchanged) - * [StartDragging](api/RenderHandler.md#startdragging) - * [UpdateDragCursor](api/RenderHandler.md#updatedragcursor) -* [Request (class)](api/Request.md#request-class) - * [CreateRequest](api/Request.md#createrequest) - * [IsReadOnly](api/Request.md#isreadonly) - * [GetUrl](api/Request.md#geturl) - * [SetUrl](api/Request.md#seturl) - * [GetMethod](api/Request.md#getmethod) - * [SetMethod](api/Request.md#setmethod) - * [GetPostData](api/Request.md#getpostdata) - * [SetPostData](api/Request.md#setpostdata) - * [GetHeaderMap](api/Request.md#getheadermap) - * [GetHeaderMultimap](api/Request.md#getheadermultimap) - * [SetHeaderMap](api/Request.md#setheadermap) - * [SetHeaderMultimap](api/Request.md#setheadermultimap) - * [GetFlags](api/Request.md#getflags) - * [SetFlags](api/Request.md#setflags) - * [GetFirstPartyForCookies](api/Request.md#getfirstpartyforcookies) - * [SetFirstPartyForCookies](api/Request.md#setfirstpartyforcookies) - * [GetResourceType](api/Request.md#getresourcetype) - * [GetTransitionType](api/Request.md#gettransitiontype) -* [RequestHandler (interface)](api/RequestHandler.md#requesthandler-interface) - * [CanGetCookies](api/RequestHandler.md#cangetcookies) - * [CanSetCookie](api/RequestHandler.md#cansetcookie) - * [GetAuthCredentials](api/RequestHandler.md#getauthcredentials) - * [GetCookieManager](api/RequestHandler.md#getcookiemanager) - * [GetResourceHandler](api/RequestHandler.md#getresourcehandler) - * [OnBeforeBrowse](api/RequestHandler.md#onbeforebrowse) - * [_OnBeforePluginLoad](api/RequestHandler.md#_onbeforepluginload) - * [OnBeforeResourceLoad](api/RequestHandler.md#onbeforeresourceload) - * [_OnCertificateError](api/RequestHandler.md#_oncertificateerror) - * [OnQuotaRequest](api/RequestHandler.md#onquotarequest) - * [OnResourceRedirect](api/RequestHandler.md#onresourceredirect) - * [OnResourceResponse](api/RequestHandler.md#onresourceresponse) - * [OnPluginCrashed](api/RequestHandler.md#onplugincrashed) - * [OnProtocolExecution](api/RequestHandler.md#onprotocolexecution) - * [OnRendererProcessTerminated](api/RequestHandler.md#onrendererprocessterminated) -* [ResourceHandler (interface)](api/ResourceHandler.md#resourcehandler-interface) - * [ProcessRequest](api/ResourceHandler.md#processrequest) - * [GetResponseHeaders](api/ResourceHandler.md#getresponseheaders) - * [ReadResponse](api/ResourceHandler.md#readresponse) - * [CanGetCookie](api/ResourceHandler.md#cangetcookie) - * [CanSetCookie](api/ResourceHandler.md#cansetcookie) - * [Cancel](api/ResourceHandler.md#cancel) -* [Response (object)](api/Response.md#response-object) - * [IsReadOnly](api/Response.md#isreadonly) - * [GetStatus](api/Response.md#getstatus) - * [SetStatus](api/Response.md#setstatus) - * [GetStatusText](api/Response.md#getstatustext) - * [SetStatusText](api/Response.md#setstatustext) - * [GetMimeType](api/Response.md#getmimetype) - * [SetMimeType](api/Response.md#setmimetype) - * [GetHeader](api/Response.md#getheader) - * [GetHeaderMap](api/Response.md#getheadermap) - * [GetHeaderMultimap](api/Response.md#getheadermultimap) - * [SetHeaderMap](api/Response.md#setheadermap) - * [SetHeaderMultimap](api/Response.md#setheadermultimap) -* [StringVisitor (interface)](api/StringVisitor.md#stringvisitor-interface) - * [Visit](api/StringVisitor.md#visit) -* [V8ContextHandler (interface)](api/V8ContextHandler.md#v8contexthandler-interface) - * [OnContextCreated](api/V8ContextHandler.md#oncontextcreated) - * [OnContextReleased](api/V8ContextHandler.md#oncontextreleased) -* [Virtual Key codes](api/VirtualKey.md#virtual-key-codes) -* [WebPluginInfo (object)](api/WebPluginInfo.md#webplugininfo-object) - * [GetName](api/WebPluginInfo.md#getname) - * [GetPath](api/WebPluginInfo.md#getpath) - * [GetVersion](api/WebPluginInfo.md#getversion) - * [GetDescription](api/WebPluginInfo.md#getdescription) -* [WebRequest (class)](api/WebRequest.md#webrequest-class) - * [Create](api/WebRequest.md#create) - * [GetRequest](api/WebRequest.md#getrequest) - * [GetRequestStatus](api/WebRequest.md#getrequeststatus) - * [GetRequestError](api/WebRequest.md#getrequesterror) - * [GetResponse](api/WebRequest.md#getresponse) - * [Cancel](api/WebRequest.md#cancel) -* [WebRequestClient (interface)](api/WebRequestClient.md#webrequestclient-interface) - * [OnUploadProgress](api/WebRequestClient.md#onuploadprogress) - * [OnDownloadProgress](api/WebRequestClient.md#ondownloadprogress) - * [OnDownloadData](api/WebRequestClient.md#ondownloaddata) - * [OnRequestComplete](api/WebRequestClient.md#onrequestcomplete) -* [WindowInfo (class)](api/WindowInfo.md#windowinfo-class) - * [SetAsChild](api/WindowInfo.md#setaschild) - * [SetAsPopup](api/WindowInfo.md#setaspopup) - * [SetAsOffscreen](api/WindowInfo.md#setasoffscreen) -* [WindowUtils (class)](api/WindowUtils.md#windowutils-class) - * [OnSetFocus ](api/WindowUtils.md#onsetfocus-win) - * [OnSize ](api/WindowUtils.md#onsize-win) - * [OnEraseBackground ](api/WindowUtils.md#onerasebackground-win) - * [SetTitle ](api/WindowUtils.md#settitle-win) - * [SetIcon ](api/WindowUtils.md#seticon-win) - * [GetParentHandle](api/WindowUtils.md#getparenthandle) - * [IsWindowHandle](api/WindowUtils.md#iswindowhandle) - * [gtk_plug_new ](api/WindowUtils.md#gtk_plug_new-linux) - * [gtk_widget_show ](api/WindowUtils.md#gtk_widget_show-linux) - * [InstallX11ErrorHandlers ](api/WindowUtils.md#installx11errorhandlers-linux) +* [AccessibilityHandler (interface)](api/AccessibilityHandler.md#accessibilityhandler-interface) + * [\_OnAccessibilityTreeChange](api/AccessibilityHandler.md#_onaccessibilitytreechange) + * [\_OnAccessibilityLocationChange](api/AccessibilityHandler.md#_onaccessibilitylocationchange) +* [Application settings](api/ApplicationSettings.md#application-settings) + * [accept\_language\_list](api/ApplicationSettings.md#accept_language_list) + * [app\_user\_model\_id](api/ApplicationSettings.md#app_user_model_id) + * [auto\_zooming](api/ApplicationSettings.md#auto_zooming) + * [background\_color](api/ApplicationSettings.md#background_color) + * [browser\_subprocess\_path](api/ApplicationSettings.md#browser_subprocess_path) + * [cache\_path](api/ApplicationSettings.md#cache_path) + * [command\_line\_args\_disabled](api/ApplicationSettings.md#command_line_args_disabled) + * [context\_menu](api/ApplicationSettings.md#context_menu) + * [downloads\_enabled](api/ApplicationSettings.md#downloads_enabled) + * [external\_message\_pump](api/ApplicationSettings.md#external_message_pump) + * [framework\_dir\_path](api/ApplicationSettings.md#framework_dir_path) + * [ignore\_certificate\_errors](api/ApplicationSettings.md#ignore_certificate_errors) + * [javascript\_flags](api/ApplicationSettings.md#javascript_flags) + * [locale](api/ApplicationSettings.md#locale) + * [locales\_dir\_path](api/ApplicationSettings.md#locales_dir_path) + * [debug](api/ApplicationSettings.md#debug) + * [log\_file](api/ApplicationSettings.md#log_file) + * [log\_severity](api/ApplicationSettings.md#log_severity) + * [multi\_threaded\_message\_loop](api/ApplicationSettings.md#multi_threaded_message_loop) + * [net\_security\_expiration\_enabled](api/ApplicationSettings.md#net_security_expiration_enabled) + * [pack\_loading\_disabled](api/ApplicationSettings.md#pack_loading_disabled) + * [persist\_session\_cookies](api/ApplicationSettings.md#persist_session_cookies) + * [persist\_user\_preferences](api/ApplicationSettings.md#persist_user_preferences) + * [product\_version](api/ApplicationSettings.md#product_version) + * [remote\_debugging\_port](api/ApplicationSettings.md#remote_debugging_port) + * [resources\_dir\_path](api/ApplicationSettings.md#resources_dir_path) + * [single\_process](api/ApplicationSettings.md#single_process) + * [string\_encoding](api/ApplicationSettings.md#string_encoding) + * [uncaught\_exception\_stack\_size](api/ApplicationSettings.md#uncaught_exception_stack_size) + * [unique\_request\_context\_per\_browser](api/ApplicationSettings.md#unique_request_context_per_browser) + * [user\_agent](api/ApplicationSettings.md#user_agent) + * [user\_data\_path](api/ApplicationSettings.md#user_data_path) + * [windowless\_rendering\_enabled](api/ApplicationSettings.md#windowless_rendering_enabled) +* [Browser (object)](api/Browser.md#browser-object) + * [AddWordToDictionary](api/Browser.md#addwordtodictionary) + * [CanGoBack](api/Browser.md#cangoback) + * [CanGoForward](api/Browser.md#cangoforward) + * [CloseBrowser](api/Browser.md#closebrowser) + * [CloseDevTools](api/Browser.md#closedevtools) + * [DragTargetDragEnter](api/Browser.md#dragtargetdragenter) + * [DragTargetDragOver](api/Browser.md#dragtargetdragover) + * [DragTargetDragLeave](api/Browser.md#dragtargetdragleave) + * [DragTargetDrop](api/Browser.md#dragtargetdrop) + * [DragSourceEndedAt](api/Browser.md#dragsourceendedat) + * [DragSourceSystemDragEnded](api/Browser.md#dragsourcesystemdragended) + * [ExecuteFunction](api/Browser.md#executefunction) + * [ExecuteJavascript](api/Browser.md#executejavascript) + * [Find](api/Browser.md#find) + * [GetClientCallback](api/Browser.md#getclientcallback) + * [GetClientCallbacksDict](api/Browser.md#getclientcallbacksdict) + * [GetFocusedFrame](api/Browser.md#getfocusedframe) + * [GetFrame](api/Browser.md#getframe) + * [GetFrameByIdentifier](api/Browser.md#getframebyidentifier) + * [GetFrames](api/Browser.md#getframes) + * [GetFrameCount](api/Browser.md#getframecount) + * [GetFrameIdentifiers](api/Browser.md#getframeidentifiers) + * [GetFrameNames](api/Browser.md#getframenames) + * [GetImage](api/Browser.md#getimage) + * [GetJavascriptBindings](api/Browser.md#getjavascriptbindings) + * [GetMainFrame](api/Browser.md#getmainframe) + * [GetNSTextInputContext](api/Browser.md#getnstextinputcontext) + * [GetOpenerWindowHandle](api/Browser.md#getopenerwindowhandle) + * [GetOuterWindowHandle](api/Browser.md#getouterwindowhandle) + * [GetSetting](api/Browser.md#getsetting) + * [GetUrl](api/Browser.md#geturl) + * [GetUserData](api/Browser.md#getuserdata) + * [GetWindowHandle](api/Browser.md#getwindowhandle) + * [GetIdentifier](api/Browser.md#getidentifier) + * [GetZoomLevel](api/Browser.md#getzoomlevel) + * [GoBack](api/Browser.md#goback) + * [GoForward](api/Browser.md#goforward) + * [HandleKeyEventAfterTextInputClient](api/Browser.md#handlekeyeventaftertextinputclient) + * [HandleKeyEventBeforeTextInputClient](api/Browser.md#handlekeyeventbeforetextinputclient) + * [HasDevTools](api/Browser.md#hasdevtools) + * [HasDocument](api/Browser.md#hasdocument) + * [Invalidate](api/Browser.md#invalidate) + * [IsFullscreen](api/Browser.md#isfullscreen) + * [IsLoading](api/Browser.md#isloading) + * [IsMouseCursorChangeDisabled](api/Browser.md#ismousecursorchangedisabled) + * [IsPopup](api/Browser.md#ispopup) + * [IsWindowRenderingDisabled](api/Browser.md#iswindowrenderingdisabled) + * [LoadUrl](api/Browser.md#loadurl) + * [Navigate](api/Browser.md#navigate) + * [NotifyMoveOrResizeStarted](api/Browser.md#notifymoveorresizestarted) + * [NotifyScreenInfoChanged](api/Browser.md#notifyscreeninfochanged) + * [ParentWindowWillClose](api/Browser.md#parentwindowwillclose) + * [Print](api/Browser.md#print) + * [Reload](api/Browser.md#reload) + * [ReloadIgnoreCache](api/Browser.md#reloadignorecache) + * [ReplaceMisspelling](api/Browser.md#replacemisspelling) + * [SetAutoResizeEnabled](api/Browser.md#setautoresizeenabled) + * [SetBounds](api/Browser.md#setbounds) + * [SendKeyEvent](api/Browser.md#sendkeyevent) + * [SendMouseClickEvent](api/Browser.md#sendmouseclickevent) + * [SendMouseMoveEvent](api/Browser.md#sendmousemoveevent) + * [SendMouseWheelEvent](api/Browser.md#sendmousewheelevent) + * [SendFocusEvent](api/Browser.md#sendfocusevent) + * [SendCaptureLostEvent](api/Browser.md#sendcapturelostevent) + * [SetAccessibilityState](api/Browser.md#setaccessibilitystate) + * [SetClientCallback](api/Browser.md#setclientcallback) + * [SetClientHandler](api/Browser.md#setclienthandler) + * [SetFocus](api/Browser.md#setfocus) + * [SetMouseCursorChangeDisabled](api/Browser.md#setmousecursorchangedisabled) + * [SetJavascriptBindings](api/Browser.md#setjavascriptbindings) + * [SetUserData](api/Browser.md#setuserdata) + * [SetZoomLevel](api/Browser.md#setzoomlevel) + * [ShowDevTools](api/Browser.md#showdevtools) + * [StartDownload](api/Browser.md#startdownload) + * [StopLoad](api/Browser.md#stopload) + * [StopFinding](api/Browser.md#stopfinding) + * [ToggleFullscreen](api/Browser.md#togglefullscreen) + * [TryCloseBrowser](api/Browser.md#tryclosebrowser) + * [WasResized](api/Browser.md#wasresized) + * [WasHidden](api/Browser.md#washidden) +* [Browser settings](api/BrowserSettings.md#browser-settings) + * [Font settings](api/BrowserSettings.md#font-settings) + * [accept\_language\_list](api/BrowserSettings.md#accept_language_list) + * [application\_cache\_disabled](api/BrowserSettings.md#application_cache_disabled) + * [background\_color](api/BrowserSettings.md#background_color) + * [databases\_disabled](api/BrowserSettings.md#databases_disabled) + * [default\_encoding](api/BrowserSettings.md#default_encoding) + * [dom\_paste\_disabled](api/BrowserSettings.md#dom_paste_disabled) + * [file\_access\_from\_file\_urls\_allowed](api/BrowserSettings.md#file_access_from_file_urls_allowed) + * [inherit\_client\_handlers\_for\_popups](api/BrowserSettings.md#inherit_client_handlers_for_popups) + * [image\_load\_disabled](api/BrowserSettings.md#image_load_disabled) + * [javascript\_disabled](api/BrowserSettings.md#javascript_disabled) + * [javascript\_close\_windows\_disallowed](api/BrowserSettings.md#javascript_close_windows_disallowed) + * [javascript\_access\_clipboard\_disallowed](api/BrowserSettings.md#javascript_access_clipboard_disallowed) + * [local\_storage\_disabled](api/BrowserSettings.md#local_storage_disabled) + * [plugins\_disabled](api/BrowserSettings.md#plugins_disabled) + * [remote\_fonts](api/BrowserSettings.md#remote_fonts) + * [shrink\_standalone\_images\_to\_fit](api/BrowserSettings.md#shrink_standalone_images_to_fit) + * [tab\_to\_links\_disabled](api/BrowserSettings.md#tab_to_links_disabled) + * [text\_area\_resize\_disabled](api/BrowserSettings.md#text_area_resize_disabled) + * [universal\_access\_from\_file\_urls\_allowed](api/BrowserSettings.md#universal_access_from_file_urls_allowed) + * [user\_style\_sheet\_location](api/BrowserSettings.md#user_style_sheet_location) + * [web\_security\_disabled](api/BrowserSettings.md#web_security_disabled) + * [webgl\_disabled](api/BrowserSettings.md#webgl_disabled) + * [windowless\_frame\_rate](api/BrowserSettings.md#windowless_frame_rate) +* [Callback (object)](api/Callback.md#callback-object) + * [Continue](api/Callback.md#continue) + * [Cancel](api/Callback.md#cancel) +* [cefpython](api/cefpython.md#cefpython) + * [CreateBrowser](api/cefpython.md#createbrowser) + * [CreateBrowserSync](api/cefpython.md#createbrowsersync) + * [ExceptHook](api/cefpython.md#excepthook) + * [GetAppSetting](api/cefpython.md#getappsetting) + * [GetAppPath](api/cefpython.md#getapppath) + * [GetBrowserByIdentifier](api/cefpython.md#getbrowserbyidentifier) + * [GetBrowserByWindowHandle](api/cefpython.md#getbrowserbywindowhandle) + * [GetCommandLineSwitch](api/cefpython.md#getcommandlineswitch) + * [GetDataUrl](api/cefpython.md#getdataurl) + * [GetGlobalClientCallback](api/cefpython.md#getglobalclientcallback) + * [GetModuleDirectory](api/cefpython.md#getmoduledirectory) + * [GetVersion](api/cefpython.md#getversion) + * [Initialize](api/cefpython.md#initialize) + * [IsThread](api/cefpython.md#isthread) + * [LoadCrlSetsFile](api/cefpython.md#loadcrlsetsfile) + * [MessageLoop](api/cefpython.md#messageloop) + * [MessageLoopWork](api/cefpython.md#messageloopwork) + * [PostTask](api/cefpython.md#posttask) + * [PostDelayedTask](api/cefpython.md#postdelayedtask) + * [QuitMessageLoop](api/cefpython.md#quitmessageloop) + * [SetGlobalClientCallback](api/cefpython.md#setglobalclientcallback) + * [SetGlobalClientHandler](api/cefpython.md#setglobalclienthandler) + * [SetOsModalLoop](api/cefpython.md#setosmodalloop) + * [Shutdown](api/cefpython.md#shutdown) +* [Command line switches](api/CommandLineSwitches.md#command-line-switches) + * [enable-media-stream](api/CommandLineSwitches.md#enable-media-stream) + * [proxy-server](api/CommandLineSwitches.md#proxy-server) + * [no-proxy-server](api/CommandLineSwitches.md#no-proxy-server) + * [disable-gpu](api/CommandLineSwitches.md#disable-gpu) +* [Cookie (class)](api/Cookie.md#cookie-class) + * [Set](api/Cookie.md#set) + * [Get](api/Cookie.md#get) + * [SetName](api/Cookie.md#setname) + * [GetName](api/Cookie.md#getname) + * [SetValue](api/Cookie.md#setvalue) + * [GetValue](api/Cookie.md#getvalue) + * [SetDomain](api/Cookie.md#setdomain) + * [GetDomain](api/Cookie.md#getdomain) + * [SetPath](api/Cookie.md#setpath) + * [GetPath](api/Cookie.md#getpath) + * [SetSecure](api/Cookie.md#setsecure) + * [GetSecure](api/Cookie.md#getsecure) + * [SetHttpOnly](api/Cookie.md#sethttponly) + * [GetHttpOnly](api/Cookie.md#gethttponly) + * [SetCreation](api/Cookie.md#setcreation) + * [GetCreation](api/Cookie.md#getcreation) + * [SetLastAccess](api/Cookie.md#setlastaccess) + * [GetLastAccess](api/Cookie.md#getlastaccess) + * [SetHasExpires](api/Cookie.md#sethasexpires) + * [GetHasExpires](api/Cookie.md#gethasexpires) + * [SetExpires](api/Cookie.md#setexpires) + * [GetExpires](api/Cookie.md#getexpires) +* [CookieManager (class)](api/CookieManager.md#cookiemanager-class) + * [GetGlobalManager](api/CookieManager.md#getglobalmanager) + * [GetBlockingManager](api/CookieManager.md#getblockingmanager) + * [CreateManager](api/CookieManager.md#createmanager) + * [SetSupportedSchemes](api/CookieManager.md#setsupportedschemes) + * [VisitAllCookies](api/CookieManager.md#visitallcookies) + * [VisitUrlCookies](api/CookieManager.md#visiturlcookies) + * [SetCookie](api/CookieManager.md#setcookie) + * [DeleteCookies](api/CookieManager.md#deletecookies) + * [SetStoragePath](api/CookieManager.md#setstoragepath) + * [FlushStore](api/CookieManager.md#flushstore) +* [CookieVisitor (interface)](api/CookieVisitor.md#cookievisitor-interface) + * [Visit](api/CookieVisitor.md#visit) +* [DisplayHandler (interface)](api/DisplayHandler.md#displayhandler-interface) + * [OnAddressChange](api/DisplayHandler.md#onaddresschange) + * [OnAutoResize](api/DisplayHandler.md#onautoresize) + * [OnConsoleMessage](api/DisplayHandler.md#onconsolemessage) + * [OnLoadingProgressChange](api/DisplayHandler.md#onloadingprogresschange) + * [OnStatusMessage](api/DisplayHandler.md#onstatusmessage) + * [OnTitleChange](api/DisplayHandler.md#ontitlechange) + * [OnTooltip](api/DisplayHandler.md#ontooltip) +* [DownloadHandler](api/DownloadHandler.md#downloadhandler) +* [DpiAware (class)](api/DpiAware.md#dpiaware-class) + * [CalculateWindowSize](api/DpiAware.md#calculatewindowsize) + * [EnableHighDpiSupport](api/DpiAware.md#enablehighdpisupport) + * [GetSystemDpi](api/DpiAware.md#getsystemdpi) + * [IsProcessDpiAware](api/DpiAware.md#isprocessdpiaware) + * [SetProcessDpiAware](api/DpiAware.md#setprocessdpiaware) + * [Scale](api/DpiAware.md#scale) +* [DragData (object)](api/DragData.md#dragdata-object) + * [IsLink](api/DragData.md#islink) + * [IsFragment](api/DragData.md#isfragment) + * [GetLinkUrl](api/DragData.md#getlinkurl) + * [GetLinkTitle](api/DragData.md#getlinktitle) + * [GetFragmentText](api/DragData.md#getfragmenttext) + * [GetFragmentHtml](api/DragData.md#getfragmenthtml) + * [GetImage](api/DragData.md#getimage) + * [GetImageHotspot](api/DragData.md#getimagehotspot) + * [HasImage](api/DragData.md#hasimage) +* [FocusHandler (interface)](api/FocusHandler.md#focushandler-interface) + * [OnTakeFocus](api/FocusHandler.md#ontakefocus) + * [OnSetFocus](api/FocusHandler.md#onsetfocus) + * [OnGotFocus](api/FocusHandler.md#ongotfocus) +* [Frame (object)](api/Frame.md#frame-object) + * [Copy](api/Frame.md#copy) + * [Cut](api/Frame.md#cut) + * [Delete](api/Frame.md#delete) + * [ExecuteFunction](api/Frame.md#executefunction) + * [ExecuteJavascript](api/Frame.md#executejavascript) + * [GetBrowser](api/Frame.md#getbrowser) + * [GetParent](api/Frame.md#getparent) + * [GetIdentifier](api/Frame.md#getidentifier) + * [GetBrowserIdentifier](api/Frame.md#getbrowseridentifier) + * [GetName](api/Frame.md#getname) + * [GetParent](api/Frame.md#getparent) + * [GetSource](api/Frame.md#getsource) + * [GetText](api/Frame.md#gettext) + * [GetUrl](api/Frame.md#geturl) + * [IsFocused](api/Frame.md#isfocused) + * [IsMain](api/Frame.md#ismain) + * [IsValid](api/Frame.md#isvalid) + * [LoadString](api/Frame.md#loadstring) + * [LoadUrl](api/Frame.md#loadurl) + * [Paste](api/Frame.md#paste) + * [Redo](api/Frame.md#redo) + * [SelectAll](api/Frame.md#selectall) + * [Undo](api/Frame.md#undo) + * [ViewSource](api/Frame.md#viewsource) +* [Image (object)](api/Image.md#image-object) + * [GetAsBitmap](api/Image.md#getasbitmap) + * [GetAsPng](api/Image.md#getaspng) + * [GetHeight](api/Image.md#getheight) + * [GetWidth](api/Image.md#getwidth) +* [JavascriptBindings (class)](api/JavascriptBindings.md#javascriptbindings-class) + * [\_\_init\_\_](api/JavascriptBindings.md#__init__) + * [IsValueAllowed](api/JavascriptBindings.md#isvalueallowed) + * [Rebind](api/JavascriptBindings.md#rebind) + * [SetFunction](api/JavascriptBindings.md#setfunction) + * [SetObject](api/JavascriptBindings.md#setobject) + * [SetProperty](api/JavascriptBindings.md#setproperty) +* [JavascriptCallback (object)](api/JavascriptCallback.md#javascriptcallback-object) + * [Call](api/JavascriptCallback.md#call) + * [GetFrame](api/JavascriptCallback.md#getframe) + * [GetId](api/JavascriptCallback.md#getid) + * [GetFunctionName](api/JavascriptCallback.md#getfunctionname) +* [JavascriptDialogHandler (interface)](api/JavascriptDialogHandler.md#javascriptdialoghandler-interface) + * [Continue](api/JavascriptDialogHandler.md#continue) + * [OnJavascriptDialog](api/JavascriptDialogHandler.md#onjavascriptdialog) + * [OnBeforeUnloadJavascriptDialog](api/JavascriptDialogHandler.md#onbeforeunloadjavascriptdialog) + * [OnResetJavascriptDialogState](api/JavascriptDialogHandler.md#onresetjavascriptdialogstate) + * [OnJavascriptDialogClosed](api/JavascriptDialogHandler.md#onjavascriptdialogclosed) +* [KeyboardHandler (interface)](api/KeyboardHandler.md#keyboardhandler-interface) + * [OnPreKeyEvent](api/KeyboardHandler.md#onprekeyevent) + * [OnKeyEvent](api/KeyboardHandler.md#onkeyevent) +* [LifespanHandler (interface)](api/LifespanHandler.md#lifespanhandler-interface) + * [DoClose](api/LifespanHandler.md#doclose) + * [\_OnAfterCreated](api/LifespanHandler.md#_onaftercreated) + * [OnBeforeClose](api/LifespanHandler.md#onbeforeclose) + * [OnBeforePopup](api/LifespanHandler.md#onbeforepopup) +* [LoadHandler (interface)](api/LoadHandler.md#loadhandler-interface) + * [OnLoadingStateChange](api/LoadHandler.md#onloadingstatechange) + * [OnLoadStart](api/LoadHandler.md#onloadstart) + * [OnDomReady](api/LoadHandler.md#ondomready) + * [OnLoadEnd](api/LoadHandler.md#onloadend) + * [OnLoadError](api/LoadHandler.md#onloaderror) +* [Network error](api/NetworkError.md#network-error) + * [ERR\_NONE](api/NetworkError.md#err_none) + * [ERR\_ABORTED](api/NetworkError.md#err_aborted) + * [ERR\_ACCESS\_DENIED](api/NetworkError.md#err_access_denied) + * [ERR\_ADDRESS\_INVALID](api/NetworkError.md#err_address_invalid) + * [ERR\_ADDRESS\_UNREACHABLE](api/NetworkError.md#err_address_unreachable) + * [ERR\_CACHE\_MISS](api/NetworkError.md#err_cache_miss) + * [ERR\_CERT\_AUTHORITY\_INVALID](api/NetworkError.md#err_cert_authority_invalid) + * [ERR\_CERT\_COMMON\_NAME\_INVALID](api/NetworkError.md#err_cert_common_name_invalid) + * [ERR\_CERT\_CONTAINS\_ERRORS](api/NetworkError.md#err_cert_contains_errors) + * [ERR\_CERT\_DATE\_INVALID](api/NetworkError.md#err_cert_date_invalid) + * [ERR\_CERT\_END](api/NetworkError.md#err_cert_end) + * [ERR\_CERT\_INVALID](api/NetworkError.md#err_cert_invalid) + * [ERR\_CERT\_NO\_REVOCATION\_MECHANISM](api/NetworkError.md#err_cert_no_revocation_mechanism) + * [ERR\_CERT\_REVOKED](api/NetworkError.md#err_cert_revoked) + * [ERR\_CERT\_UNABLE\_TO\_CHECK\_REVOCATION](api/NetworkError.md#err_cert_unable_to_check_revocation) + * [ERR\_CONNECTION\_ABORTED](api/NetworkError.md#err_connection_aborted) + * [ERR\_CONNECTION\_CLOSED](api/NetworkError.md#err_connection_closed) + * [ERR\_CONNECTION\_FAILED](api/NetworkError.md#err_connection_failed) + * [ERR\_CONNECTION\_REFUSED](api/NetworkError.md#err_connection_refused) + * [ERR\_CONNECTION\_RESET](api/NetworkError.md#err_connection_reset) + * [ERR\_DISALLOWED\_URL\_SCHEME](api/NetworkError.md#err_disallowed_url_scheme) + * [ERR\_EMPTY\_RESPONSE](api/NetworkError.md#err_empty_response) + * [ERR\_FAILED](api/NetworkError.md#err_failed) + * [ERR\_FILE\_NOT\_FOUND](api/NetworkError.md#err_file_not_found) + * [ERR\_FILE\_TOO\_BIG](api/NetworkError.md#err_file_too_big) + * [ERR\_INSECURE\_RESPONSE](api/NetworkError.md#err_insecure_response) + * [ERR\_INTERNET\_DISCONNECTED](api/NetworkError.md#err_internet_disconnected) + * [ERR\_INVALID\_ARGUMENT](api/NetworkError.md#err_invalid_argument) + * [ERR\_INVALID\_CHUNKED\_ENCODING](api/NetworkError.md#err_invalid_chunked_encoding) + * [ERR\_INVALID\_HANDLE](api/NetworkError.md#err_invalid_handle) + * [ERR\_INVALID\_RESPONSE](api/NetworkError.md#err_invalid_response) + * [ERR\_INVALID\_URL](api/NetworkError.md#err_invalid_url) + * [ERR\_METHOD\_NOT\_SUPPORTED](api/NetworkError.md#err_method_not_supported) + * [ERR\_NAME\_NOT\_RESOLVED](api/NetworkError.md#err_name_not_resolved) + * [ERR\_NO\_SSL\_VERSIONS\_ENABLED](api/NetworkError.md#err_no_ssl_versions_enabled) + * [ERR\_NOT\_IMPLEMENTED](api/NetworkError.md#err_not_implemented) + * [ERR\_RESPONSE\_HEADERS\_TOO\_BIG](api/NetworkError.md#err_response_headers_too_big) + * [ERR\_SSL\_CLIENT\_AUTH\_CERT\_NEEDED](api/NetworkError.md#err_ssl_client_auth_cert_needed) + * [ERR\_SSL\_PROTOCOL\_ERROR](api/NetworkError.md#err_ssl_protocol_error) + * [ERR\_SSL\_RENEGOTIATION\_REQUESTED](api/NetworkError.md#err_ssl_renegotiation_requested) + * [ERR\_SSL\_VERSION\_OR\_CIPHER\_MISMATCH](api/NetworkError.md#err_ssl_version_or_cipher_mismatch) + * [ERR\_TIMED\_OUT](api/NetworkError.md#err_timed_out) + * [ERR\_TOO\_MANY\_REDIRECTS](api/NetworkError.md#err_too_many_redirects) + * [ERR\_TUNNEL\_CONNECTION\_FAILED](api/NetworkError.md#err_tunnel_connection_failed) + * [ERR\_UNEXPECTED](api/NetworkError.md#err_unexpected) + * [ERR\_UNEXPECTED\_PROXY\_AUTH](api/NetworkError.md#err_unexpected_proxy_auth) + * [ERR\_UNKNOWN\_URL\_SCHEME](api/NetworkError.md#err_unknown_url_scheme) + * [ERR\_UNSAFE\_PORT](api/NetworkError.md#err_unsafe_port) + * [ERR\_UNSAFE\_REDIRECT](api/NetworkError.md#err_unsafe_redirect) +* [PaintBuffer (object)](api/PaintBuffer.md#paintbuffer-object) + * [GetIntPointer](api/PaintBuffer.md#getintpointer) + * [GetBytes](api/PaintBuffer.md#getbytes) +* [RenderHandler (interface)](api/RenderHandler.md#renderhandler-interface) + * [GetRootScreenRect](api/RenderHandler.md#getrootscreenrect) + * [GetViewRect](api/RenderHandler.md#getviewrect) + * [GetScreenRect](api/RenderHandler.md#getscreenrect) + * [GetScreenPoint](api/RenderHandler.md#getscreenpoint) + * [OnPopupShow](api/RenderHandler.md#onpopupshow) + * [OnPopupSize](api/RenderHandler.md#onpopupsize) + * [OnPaint](api/RenderHandler.md#onpaint) + * [OnCursorChange](api/RenderHandler.md#oncursorchange) + * [OnScrollOffsetChanged](api/RenderHandler.md#onscrolloffsetchanged) + * [OnTextSelectionChanged](api/RenderHandler.md#ontextselectionchanged) + * [StartDragging](api/RenderHandler.md#startdragging) + * [UpdateDragCursor](api/RenderHandler.md#updatedragcursor) +* [Request (class)](api/Request.md#request-class) + * [CreateRequest](api/Request.md#createrequest) + * [IsReadOnly](api/Request.md#isreadonly) + * [GetUrl](api/Request.md#geturl) + * [SetUrl](api/Request.md#seturl) + * [GetMethod](api/Request.md#getmethod) + * [SetMethod](api/Request.md#setmethod) + * [GetPostData](api/Request.md#getpostdata) + * [SetPostData](api/Request.md#setpostdata) + * [GetHeaderMap](api/Request.md#getheadermap) + * [GetHeaderMultimap](api/Request.md#getheadermultimap) + * [SetHeaderMap](api/Request.md#setheadermap) + * [SetHeaderMultimap](api/Request.md#setheadermultimap) + * [GetFlags](api/Request.md#getflags) + * [SetFlags](api/Request.md#setflags) + * [GetFirstPartyForCookies](api/Request.md#getfirstpartyforcookies) + * [SetFirstPartyForCookies](api/Request.md#setfirstpartyforcookies) + * [GetResourceType](api/Request.md#getresourcetype) + * [GetTransitionType](api/Request.md#gettransitiontype) +* [RequestHandler (interface)](api/RequestHandler.md#requesthandler-interface) + * [CanGetCookies](api/RequestHandler.md#cangetcookies) + * [CanSetCookie](api/RequestHandler.md#cansetcookie) + * [GetAuthCredentials](api/RequestHandler.md#getauthcredentials) + * [GetCookieManager](api/RequestHandler.md#getcookiemanager) + * [GetResourceHandler](api/RequestHandler.md#getresourcehandler) + * [OnBeforeBrowse](api/RequestHandler.md#onbeforebrowse) + * [\_OnBeforePluginLoad](api/RequestHandler.md#_onbeforepluginload) + * [OnBeforeResourceLoad](api/RequestHandler.md#onbeforeresourceload) + * [\_OnCertificateError](api/RequestHandler.md#_oncertificateerror) + * [OnQuotaRequest](api/RequestHandler.md#onquotarequest) + * [OnResourceRedirect](api/RequestHandler.md#onresourceredirect) + * [OnResourceResponse](api/RequestHandler.md#onresourceresponse) + * [OnPluginCrashed](api/RequestHandler.md#onplugincrashed) + * [OnProtocolExecution](api/RequestHandler.md#onprotocolexecution) + * [OnRendererProcessTerminated](api/RequestHandler.md#onrendererprocessterminated) +* [ResourceHandler (interface)](api/ResourceHandler.md#resourcehandler-interface) + * [ProcessRequest](api/ResourceHandler.md#processrequest) + * [GetResponseHeaders](api/ResourceHandler.md#getresponseheaders) + * [ReadResponse](api/ResourceHandler.md#readresponse) + * [CanGetCookie](api/ResourceHandler.md#cangetcookie) + * [CanSetCookie](api/ResourceHandler.md#cansetcookie) + * [Cancel](api/ResourceHandler.md#cancel) +* [Response (object)](api/Response.md#response-object) + * [IsReadOnly](api/Response.md#isreadonly) + * [GetStatus](api/Response.md#getstatus) + * [SetStatus](api/Response.md#setstatus) + * [GetStatusText](api/Response.md#getstatustext) + * [SetStatusText](api/Response.md#setstatustext) + * [GetMimeType](api/Response.md#getmimetype) + * [SetMimeType](api/Response.md#setmimetype) + * [GetHeader](api/Response.md#getheader) + * [GetHeaderMap](api/Response.md#getheadermap) + * [GetHeaderMultimap](api/Response.md#getheadermultimap) + * [SetHeaderMap](api/Response.md#setheadermap) + * [SetHeaderMultimap](api/Response.md#setheadermultimap) +* [StringVisitor (interface)](api/StringVisitor.md#stringvisitor-interface) + * [Visit](api/StringVisitor.md#visit) +* [V8ContextHandler (interface)](api/V8ContextHandler.md#v8contexthandler-interface) + * [OnContextCreated](api/V8ContextHandler.md#oncontextcreated) + * [OnContextReleased](api/V8ContextHandler.md#oncontextreleased) +* [Virtual Key codes](api/VirtualKey.md#virtual-key-codes) +* [WebPluginInfo (object)](api/WebPluginInfo.md#webplugininfo-object) + * [GetName](api/WebPluginInfo.md#getname) + * [GetPath](api/WebPluginInfo.md#getpath) + * [GetVersion](api/WebPluginInfo.md#getversion) + * [GetDescription](api/WebPluginInfo.md#getdescription) +* [WebRequest (class)](api/WebRequest.md#webrequest-class) + * [Create](api/WebRequest.md#create) + * [GetRequest](api/WebRequest.md#getrequest) + * [GetRequestStatus](api/WebRequest.md#getrequeststatus) + * [GetRequestError](api/WebRequest.md#getrequesterror) + * [GetResponse](api/WebRequest.md#getresponse) + * [Cancel](api/WebRequest.md#cancel) +* [WebRequestClient (interface)](api/WebRequestClient.md#webrequestclient-interface) + * [OnUploadProgress](api/WebRequestClient.md#onuploadprogress) + * [OnDownloadProgress](api/WebRequestClient.md#ondownloadprogress) + * [OnDownloadData](api/WebRequestClient.md#ondownloaddata) + * [OnRequestComplete](api/WebRequestClient.md#onrequestcomplete) +* [WindowInfo (class)](api/WindowInfo.md#windowinfo-class) + * [SetAsChild](api/WindowInfo.md#setaschild) + * [SetAsPopup](api/WindowInfo.md#setaspopup) + * [SetAsOffscreen](api/WindowInfo.md#setasoffscreen) +* [WindowUtils (class)](api/WindowUtils.md#windowutils-class) + * [OnSetFocus](api/WindowUtils.md#onsetfocus-win) + * [OnSize](api/WindowUtils.md#onsize-win) + * [OnEraseBackground](api/WindowUtils.md#onerasebackground-win) + * [SetTitle](api/WindowUtils.md#settitle-win) + * [SetIcon](api/WindowUtils.md#seticon-win) + * [GetParentHandle](api/WindowUtils.md#getparenthandle) + * [IsWindowHandle](api/WindowUtils.md#iswindowhandle) + * [gtk\_plug\_new](api/WindowUtils.md#gtk_plug_new-linux) + * [gtk\_widget\_show](api/WindowUtils.md#gtk_widget_show-linux) + * [InstallX11ErrorHandlers](api/WindowUtils.md#installx11errorhandlers-linux) \ No newline at end of file diff --git a/examples/tutorial.py b/examples/tutorial.py index 860bbe12c..bca8059bd 100644 --- a/examples/tutorial.py +++ b/examples/tutorial.py @@ -60,11 +60,11 @@ def main(): check_versions() sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error - # To change user agent use either "product_version" + # To change user agent use either "user_agent_product" # or "user_agent" options. Explained in Tutorial in # "Change user agent string" section. settings = { - # "product_version": "MyProduct/10.00", + # "user_agent_product": "MyProduct/10.00", # "user_agent": "MyAgent/20.00 MyProduct/10.00", } cef.Initialize(settings=settings) diff --git a/src/browser.pyx b/src/browser.pyx index c8cba03ad..6f89e5b65 100644 --- a/src/browser.pyx +++ b/src/browser.pyx @@ -58,8 +58,8 @@ cdef PyBrowser GetPyBrowser(CefRefPtr[CefBrowser] cefBrowser, provided.""" global g_pyBrowsers - - if cefBrowser == NULL or not cefBrowser.get(): +#lc void* + if not cefBrowser.get(): raise Exception("{caller}: CefBrowser reference is NULL" .format(caller=callerIdStr)) @@ -148,7 +148,7 @@ cdef void RemovePyBrowser(int browserId) except *: # noinspection PyUnresolvedReferences Debug("del g_pyBrowsers[%s]" % browserId) pyBrowser = g_pyBrowsers[browserId] - pyBrowser.cefBrowser.Assign(NULL) + pyBrowser.cefBrowser.Assign(nullptr) del pyBrowser del g_pyBrowsers[browserId] g_unreferenced_browsers.append(browserId) @@ -207,7 +207,8 @@ cdef class PyBrowser: cdef void* imageBuffer cdef CefRefPtr[CefBrowser] GetCefBrowser(self) except *: - if self.cefBrowser != NULL and self.cefBrowser.get(): + #lc void* + if self.cefBrowser.get(): return self.cefBrowser raise Exception("PyBrowser.GetCefBrowser() failed: CefBrowser " "was destroyed") @@ -215,7 +216,8 @@ cdef class PyBrowser: cdef CefRefPtr[CefBrowserHost] GetCefBrowserHost(self) except *: cdef CefRefPtr[CefBrowserHost] cefBrowserHost = ( self.GetCefBrowser().get().GetHost()) - if cefBrowserHost != NULL and cefBrowserHost.get(): + #lc void* + if cefBrowserHost.get(): return cefBrowserHost raise Exception("PyBrowser.GetCefBrowserHost() failed: this " "method can only be called in the browser " @@ -278,6 +280,9 @@ cdef class PyBrowser: # FocusHandler self.allowedClientCallbacks += ["OnTakeFocus", "OnSetFocus", "OnGotFocus"] + # DownloadHandler + self.allowedClientCallbacks += ["OnBeforeDownload", + "OnDownloadUpdated"] if name not in self.allowedClientCallbacks: raise Exception("Browser.SetClientCallback() failed: unknown " @@ -394,9 +399,9 @@ cdef class PyBrowser: # If using GetCookieManager to implement custom cookie managers # then flushing of cookies would need to be handled manually. self.GetCefBrowserHost().get().GetRequestContext().get() \ - .GetDefaultCookieManager( - NULL) \ - .get().FlushStore(NULL) + .GetCookieManager( + nullptr) \ + .get().FlushStore(nullptr) cdef int browserId = self.GetCefBrowser().get().GetIdentifier() self.GetCefBrowserHost().get().CloseBrowser(bool(forceClose)) @@ -413,12 +418,12 @@ cdef class PyBrowser: py_string scriptUrl="", int startLine=1): self.GetMainFrame().ExecuteJavascript(jsCode, scriptUrl, startLine) - cpdef py_void Find(self, int searchId, py_string searchText, + cpdef py_void Find(self, py_string searchText, py_bool forward, py_bool matchCase, py_bool findNext): cdef CefString cefSearchText PyToCefString(searchText, cefSearchText) - self.GetCefBrowserHost().get().Find(searchId, cefSearchText, + self.GetCefBrowserHost().get().Find(cefSearchText, bool(forward), bool(matchCase), bool(findNext)) cpdef PyFrame GetFocusedFrame(self): @@ -581,7 +586,7 @@ cdef class PyBrowser: cdef CefBrowserSettings settings cdef CefPoint inspect_element_at self.GetCefBrowserHost().get().ShowDevTools( - window_info, NULL, settings, + window_info, nullptr, settings, inspect_element_at) cpdef py_void StopLoad(self): @@ -728,8 +733,8 @@ cdef class PyBrowser: self.GetCefBrowserHost().get().SendMouseWheelEvent(mouseEvent, deltaX, deltaY) - cpdef py_void SendFocusEvent(self, py_bool setFocus): - self.GetCefBrowserHost().get().SendFocusEvent(bool(setFocus)) + # cpdef py_void SendFocusEvent(self, py_bool setFocus): + # self.GetCefBrowserHost().get().SendFocusEvent(bool(setFocus)) cpdef py_void SendCaptureLostEvent(self): self.GetCefBrowserHost().get().SendCaptureLostEvent() @@ -738,12 +743,12 @@ cdef class PyBrowser: self.GetCefBrowserHost().get().StartDownload(PyToCefStringValue( url)) - cpdef py_void SetMouseCursorChangeDisabled(self, py_bool disabled): - self.GetCefBrowserHost().get().SetMouseCursorChangeDisabled( - bool(disabled)) + # cpdef py_void SetMouseCursorChangeDisabled(self, py_bool disabled): + # self.GetCefBrowserHost().get().SetMouseCursorChangeDisabled( + # bool(disabled)) - cpdef py_bool IsMouseCursorChangeDisabled(self): - return self.GetCefBrowserHost().get().IsMouseCursorChangeDisabled() + # cpdef py_bool IsMouseCursorChangeDisabled(self): + # return self.GetCefBrowserHost().get().IsMouseCursorChangeDisabled() cpdef py_bool TryCloseBrowser(self): return self.GetCefBrowserHost().get().TryCloseBrowser() @@ -757,28 +762,28 @@ cdef class PyBrowser: cpdef py_void NotifyScreenInfoChanged(self): self.GetCefBrowserHost().get().NotifyScreenInfoChanged() - cdef void SendProcessMessage(self, cef_process_id_t targetProcess, - object frameId, py_string messageName, list pyArguments - ) except *: - cdef CefRefPtr[CefProcessMessage] message = \ - CefProcessMessage_Create(PyToCefStringValue(messageName)) - # This does not work, no idea why, the CEF implementation - # seems not to allow it, both Assign() and swap() do not work: - # | message.get().GetArgumentList().Assign(arguments.get()) - # | message.get().GetArgumentList().swap(arguments) - cdef CefRefPtr[CefListValue] messageArguments = \ - message.get().GetArgumentList() - PyListToExistingCefListValue(self.GetIdentifier(), frameId, - pyArguments, messageArguments) - Debug("SendProcessMessage(): message=%s, arguments size=%d" % ( - messageName, - message.get().GetArgumentList().get().GetSize())) - cdef cpp_bool success = \ - self.GetCefBrowser().get().SendProcessMessage( - targetProcess, message) - if not success: - raise Exception("Browser.SendProcessMessage() failed: "\ - "messageName=%s" % messageName) + # cdef void SendProcessMessage(self, cef_process_id_t targetProcess, + # object frameId, py_string messageName, list pyArguments + # ) except *: + # cdef CefRefPtr[CefProcessMessage] message = \ + # CefProcessMessage_Create(PyToCefStringValue(messageName)) + # # This does not work, no idea why, the CEF implementation + # # seems not to allow it, both Assign() and swap() do not work: + # # | message.get().GetArgumentList().Assign(arguments.get()) + # # | message.get().GetArgumentList().swap(arguments) + # cdef CefRefPtr[CefListValue] messageArguments = \ + # message.get().GetArgumentList() + # PyListToExistingCefListValue(self.GetIdentifier(), frameId, + # pyArguments, messageArguments) + # Debug("SendProcessMessage(): message=%s, arguments size=%d" % ( + # messageName, + # message.get().GetArgumentList().get().GetSize())) + # cdef cpp_bool success = \ + # self.GetCefBrowser().get().SendProcessMessage( + # targetProcess, message) + # if not success: + # raise Exception("Browser.SendProcessMessage() failed: "\ + # "messageName=%s" % messageName) # ------------------------------------------------------------------------- # OSR drag & drop diff --git a/src/cefpython.pyx b/src/cefpython.pyx index c3b1e1a13..fa627ca94 100644 --- a/src/cefpython.pyx +++ b/src/cefpython.pyx @@ -201,6 +201,9 @@ from libc.string cimport memcpy from cython.operator cimport preincrement as preinc, dereference as deref # noinspection PyUnresolvedReferences +from libcpp cimport nullptr_t, nullptr +from libcpp.memory cimport unique_ptr + # from cython.operator cimport address as addr # Address of an c++ object? # noinspection PyUnresolvedReferences @@ -258,7 +261,7 @@ from cef_types cimport ( from cef_ptr cimport CefRefPtr # noinspection PyUnresolvedReferences -from cef_scoped_ptr cimport scoped_ptr +from cef_scoped_refptr cimport scoped_refptr from cef_task cimport * from cef_platform cimport * @@ -302,6 +305,9 @@ from cef_views cimport * from cef_log cimport * from cef_file_util cimport * +from cef_download_item cimport * +from cef_download_handler cimport * + # ----------------------------------------------------------------------------- # GLOBAL VARIABLES @@ -321,7 +327,7 @@ g_browser_settings = {} # noinspection PyUnresolvedReferences cdef CefRefPtr[CefRequestContext] g_shared_request_context -cdef scoped_ptr[MainMessageLoopExternalPump] g_external_message_pump +cdef unique_ptr[MainMessageLoopExternalPump] g_external_message_pump cdef py_bool g_MessageLoop_called = False cdef py_bool g_MessageLoopWork_called = False @@ -372,6 +378,7 @@ include "app.pyx" include "drag_data.pyx" include "helpers.pyx" include "image.pyx" +include "download.pyx" # Handlers include "handlers/accessibility_handler.pyx" @@ -387,6 +394,7 @@ include "handlers/resource_handler.pyx" include "handlers/request_handler.pyx" include "handlers/v8context_handler.pyx" include "handlers/v8function_handler.pyx" +include "handlers/download_handler.pyx" # ----------------------------------------------------------------------------- # Utility functions to provide settings to the C++ browser process code. @@ -581,8 +589,8 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs): # ------------------------------------------------------------------------ if not "multi_threaded_message_loop" in application_settings: application_settings["multi_threaded_message_loop"] = False - if not "single_process" in application_settings: - application_settings["single_process"] = False + # if not "single_process" in application_settings: + # application_settings["single_process"] = False # ------------------------------------------------------------------------ # ------------------------------------------------------------------------ @@ -622,13 +630,13 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs): SetApplicationSettings(application_settings, &cefApplicationSettings) # External message pump + global g_external_message_pump if GetAppSetting("external_message_pump")\ and not g_external_message_pump.get(): Debug("Create external message pump") # Using .reset() here to assign new instance was causing # MainMessageLoopExternalPump destructor to be called. Strange. - g_external_message_pump.Assign( - MainMessageLoopExternalPump.Create()) + g_external_message_pump = MainMessageLoopExternalPump.Create() Debug("CefInitialize()") cdef cpp_bool ret @@ -685,7 +693,7 @@ def CreateBrowserSync(windowInfo=None, and "window_title" in browserSettings: # noinspection PyUnresolvedReferences cef_window = CefWindow.CreateTopLevelWindow( - NULL) + nullptr) Debug("CefWindow.GetChildViewCount = " +str(cef_window.get().GetChildViewCount())) @@ -697,7 +705,7 @@ def CreateBrowserSync(windowInfo=None, #cef_box_layout.get().SetFlexForView(cef_window, 1) cef_window.get().SetToFillLayout() # noinspection PyUnresolvedReferences - cef_panel = CefPanel.CreatePanel(NULL) + cef_panel = CefPanel.CreatePanel(nullptr) cef_window.get().AddChildView(cef_panel) cef_window.get().Layout() cef_window.get().SetVisible(True) @@ -762,13 +770,15 @@ def CreateBrowserSync(windowInfo=None, cefRequestContext.Assign(g_shared_request_context.get()) # CEF browser creation. + cdef CefRefPtr[CefDictionaryValue] cefExtraInfo + with nogil: cefBrowser = cef_browser_static.CreateBrowserSync( cefWindowInfo, clientHandler, - cefNavigateUrl, cefBrowserSettings, + cefNavigateUrl, cefBrowserSettings, cefExtraInfo, cefRequestContext) - - if cefBrowser == NULL or not cefBrowser.get(): + #lc void* + if not cefBrowser.get(): Debug("CefBrowser::CreateBrowserSync() failed") return None else: @@ -943,7 +953,7 @@ def Shutdown(): # causing segmentation fault. See Issue #333: # https://github.com/cztomczak/cefpython/issues/333 # Debug("Free g_shared_request_context") - # g_shared_request_context.Assign(NULL) + # g_shared_request_context.Assign(nullptr) # Release external message pump before CefShutdown, so that # message pump timer is killed. diff --git a/src/client_handler/client_handler.cpp b/src/client_handler/client_handler.cpp index daf9a4e59..3b0b5084f 100644 --- a/src/client_handler/client_handler.cpp +++ b/src/client_handler/client_handler.cpp @@ -27,6 +27,7 @@ bool ClientHandler::OnProcessMessageReceived( CefRefPtr browser, + CefRefPtr frame, CefProcessId source_process, CefRefPtr message) { diff --git a/src/client_handler/client_handler.h b/src/client_handler/client_handler.h index 3e9e3917b..6251f8e71 100644 --- a/src/client_handler/client_handler.h +++ b/src/client_handler/client_handler.h @@ -48,6 +48,9 @@ class ClientHandler : public CefClient, CefRefPtr GetDialogHandler() override { return this; } + CefRefPtr GetPrintHandler() override { + return this; + } #endif CefRefPtr GetDisplayHandler() override { @@ -87,6 +90,7 @@ class ClientHandler : public CefClient, } bool OnProcessMessageReceived(CefRefPtr browser, + CefRefPtr frame, CefProcessId source_process, CefRefPtr message ) override; diff --git a/src/client_handler/cookie_visitor.h b/src/client_handler/cookie_visitor.h index 54c2b53fd..0b990baca 100644 --- a/src/client_handler/cookie_visitor.h +++ b/src/client_handler/cookie_visitor.h @@ -24,7 +24,7 @@ class CookieVisitor : public CefCookieVisitor int count, int total, bool& deleteCookie - ) OVERRIDE; + ) override; protected: IMPLEMENT_REFCOUNTING(CookieVisitor); diff --git a/src/client_handler/dialog_handler.cpp b/src/client_handler/dialog_handler.cpp index ab90de9b6..df9184c2c 100644 --- a/src/client_handler/dialog_handler.cpp +++ b/src/client_handler/dialog_handler.cpp @@ -19,7 +19,7 @@ bool DialogHandler::OnFileDialog(CefRefPtr browser, const CefString& title, const CefString& default_file_path, const std::vector& accept_filters, - int selected_accept_filter, + // int selected_accept_filter, CefRefPtr callback) { #if defined(OS_LINUX) diff --git a/src/client_handler/dialog_handler.h b/src/client_handler/dialog_handler.h index 21d79a60d..537e1f41e 100644 --- a/src/client_handler/dialog_handler.h +++ b/src/client_handler/dialog_handler.h @@ -23,9 +23,9 @@ class DialogHandler : public CefDialogHandler const CefString& title, const CefString& default_file_path, const std::vector& accept_filters, - int selected_accept_filter, + // int selected_accept_filter, CefRefPtr callback) - override; + ; public: #if defined(OS_LINUX) diff --git a/src/client_handler/dialog_handler_gtk.cpp b/src/client_handler/dialog_handler_gtk.cpp index ce5a4d4e0..44a865e6a 100644 --- a/src/client_handler/dialog_handler_gtk.cpp +++ b/src/client_handler/dialog_handler_gtk.cpp @@ -141,7 +141,7 @@ bool ClientDialogHandlerGtk::OnFileDialog( const CefString& title, const CefString& default_file_path, const std::vector& accept_filters, - int selected_accept_filter, + // int selected_accept_filter, CefRefPtr callback) { std::vector files; diff --git a/src/client_handler/dialog_handler_gtk.h b/src/client_handler/dialog_handler_gtk.h index 59f65eda1..30911199e 100644 --- a/src/client_handler/dialog_handler_gtk.h +++ b/src/client_handler/dialog_handler_gtk.h @@ -25,8 +25,8 @@ class ClientDialogHandlerGtk : public CefDialogHandler, const CefString& title, const CefString& default_file_path, const std::vector& accept_filters, - int selected_accept_filter, - CefRefPtr callback) OVERRIDE; + // int selected_accept_filter, + CefRefPtr callback) override; // CefJSDialogHandler methods. bool OnJSDialog(CefRefPtr browser, diff --git a/src/client_handler/download_handler.cpp b/src/client_handler/download_handler.cpp index 9e887e467..8b9b41fd8 100644 --- a/src/client_handler/download_handler.cpp +++ b/src/client_handler/download_handler.cpp @@ -13,16 +13,17 @@ void DownloadHandler::OnBeforeDownload( CefRefPtr callback) { REQUIRE_UI_THREAD(); - bool downloads_enabled = ApplicationSettings_GetBool("downloads_enabled"); - if (downloads_enabled) { - std::string msg = "[Browser process] About to download file: "; - msg.append(suggested_name.ToString().c_str()); - LOG(INFO) << msg.c_str(); - callback->Continue(suggested_name, true); - } else { - LOG(INFO) << "[Browser process] Tried to download file," - " but downloads are disabled"; - } + // bool downloads_enabled = ApplicationSettings_GetBool("downloads_enabled"); + // if (downloads_enabled) { + // std::string msg = "[Browser process] About to download file: "; + // msg.append(suggested_name.ToString().c_str()); + // LOG(INFO) << msg.c_str(); + // callback->Continue(suggested_name, true); + // } else { + // LOG(INFO) << "[Browser process] Tried to download file," + // " but downloads are disabled"; + // } + DownloadHandler_OnBeforeDownload(browser, download_item, suggested_name, callback); } @@ -32,11 +33,12 @@ void DownloadHandler::OnDownloadUpdated( CefRefPtr callback) { REQUIRE_UI_THREAD(); - if (download_item->IsComplete()) { - std::string msg = "[Browser process] Download completed, saved to: "; - msg.append(download_item->GetFullPath().ToString().c_str()); - LOG(INFO) << msg.c_str(); - } else if (download_item->IsCanceled()) { - LOG(INFO) << "[Browser process] Download was cancelled"; - } + // if (download_item->IsComplete()) { + // std::string msg = "[Browser process] Download completed, saved to: "; + // msg.append(download_item->GetFullPath().ToString().c_str()); + // LOG(INFO) << msg.c_str(); + // } else if (download_item->IsCanceled()) { + // LOG(INFO) << "[Browser process] Download was cancelled"; + // } + DownloadHandler_OnDownloadUpdated(browser, download_item, callback); } diff --git a/src/client_handler/dpi_aware.cpp b/src/client_handler/dpi_aware.cpp index 48e2a13f7..9ee258d65 100644 --- a/src/client_handler/dpi_aware.cpp +++ b/src/client_handler/dpi_aware.cpp @@ -11,6 +11,7 @@ #include "include/wrapper/cef_closure_task.h" #include "include/base/cef_bind.h" #include "include/base/cef_logging.h" +#include "include/base/cef_callback.h" const int DEFAULT_DPIX = 96; @@ -219,7 +220,7 @@ void SetBrowserDpiSettings(CefRefPtr cefBrowser, CefPostDelayedTask( TID_UI, CefCreateClosureTask( - base::Bind(&SetBrowserDpiSettings, + base::BindOnce(&SetBrowserDpiSettings, cefBrowser, autoZooming) ), 50 diff --git a/src/client_handler/lifespan_handler.cpp b/src/client_handler/lifespan_handler.cpp index b4d7d52f6..d9d6010d6 100644 --- a/src/client_handler/lifespan_handler.cpp +++ b/src/client_handler/lifespan_handler.cpp @@ -19,6 +19,7 @@ bool LifespanHandler::OnBeforePopup(CefRefPtr browser, CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, + CefRefPtr& extra_info, bool* no_javascript_access) { REQUIRE_UI_THREAD(); @@ -27,7 +28,7 @@ bool LifespanHandler::OnBeforePopup(CefRefPtr browser, return LifespanHandler_OnBeforePopup(browser, frame, target_url, target_frame_name, target_disposition, user_gesture, popupFeaturesNotImpl, windowInfo, client, settings, - no_javascript_access); + extra_info, no_javascript_access); } diff --git a/src/client_handler/lifespan_handler.h b/src/client_handler/lifespan_handler.h index 91244eff9..6b38d7dda 100644 --- a/src/client_handler/lifespan_handler.h +++ b/src/client_handler/lifespan_handler.h @@ -24,6 +24,7 @@ class LifespanHandler : public CefLifeSpanHandler CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, + CefRefPtr& extra_info, bool* no_javascript_access) override; void OnAfterCreated(CefRefPtr browser) override; bool DoClose(CefRefPtr browser) override; diff --git a/src/client_handler/render_handler.cpp b/src/client_handler/render_handler.cpp index cf45d15ee..00d9cbbf2 100644 --- a/src/client_handler/render_handler.cpp +++ b/src/client_handler/render_handler.cpp @@ -4,43 +4,39 @@ #include "render_handler.h" - bool RenderHandler::GetRootScreenRect(CefRefPtr browser, - CefRect& rect) + CefRect &rect) { REQUIRE_UI_THREAD(); return RenderHandler_GetRootScreenRect(browser, rect); } - -bool RenderHandler::GetViewRect(CefRefPtr browser, - CefRect& rect) +void RenderHandler::GetViewRect(CefRefPtr browser, + CefRect &rect) { REQUIRE_UI_THREAD(); - return RenderHandler_GetViewRect(browser, rect); + // return RenderHandler_GetViewRect(browser, rect); + RenderHandler_GetViewRect(browser, rect); } - bool RenderHandler::GetScreenPoint(CefRefPtr browser, int viewX, int viewY, - int& screenX, - int& screenY) + int &screenX, + int &screenY) { REQUIRE_UI_THREAD(); return RenderHandler_GetScreenPoint(browser, viewX, viewY, screenX, screenY); } - bool RenderHandler::GetScreenInfo(CefRefPtr browser, - CefScreenInfo& screen_info) + CefScreenInfo &screen_info) { REQUIRE_UI_THREAD(); return RenderHandler_GetScreenInfo(browser, screen_info); } - void RenderHandler::OnPopupShow(CefRefPtr browser, bool show) { @@ -48,37 +44,34 @@ void RenderHandler::OnPopupShow(CefRefPtr browser, RenderHandler_OnPopupShow(browser, show); } - void RenderHandler::OnPopupSize(CefRefPtr browser, - const CefRect& rect) + const CefRect &rect) { REQUIRE_UI_THREAD(); RenderHandler_OnPopupSize(browser, rect); } - void RenderHandler::OnPaint(CefRefPtr browser, PaintElementType type, - const RectList& dirtyRects, - const void* buffer, + const RectList &dirtyRects, + const void *buffer, int width, int height) { REQUIRE_UI_THREAD(); - RenderHandler_OnPaint(browser, type, const_cast(dirtyRects), + RenderHandler_OnPaint(browser, type, const_cast(dirtyRects), buffer, width, height); } - -void RenderHandler::OnCursorChange(CefRefPtr browser, +bool RenderHandler::OnCursorChange(CefRefPtr browser, CefCursorHandle cursor, - CursorType type, - const CefCursorInfo& custom_cursor_info) + cef_cursor_type_t type, + const CefCursorInfo &custom_cursor_info) { REQUIRE_UI_THREAD(); RenderHandler_OnCursorChange(browser, cursor); + return true; } - void RenderHandler::OnScrollOffsetChanged(CefRefPtr browser, double x, double y) @@ -87,7 +80,6 @@ void RenderHandler::OnScrollOffsetChanged(CefRefPtr browser, RenderHandler_OnScrollOffsetChanged(browser); } - bool RenderHandler::StartDragging(CefRefPtr browser, CefRefPtr drag_data, DragOperationsMask allowed_ops, @@ -99,7 +91,6 @@ bool RenderHandler::StartDragging(CefRefPtr browser, allowed_ops, x, y); } - void RenderHandler::UpdateDragCursor(CefRefPtr browser, DragOperation operation) { @@ -108,8 +99,9 @@ void RenderHandler::UpdateDragCursor(CefRefPtr browser, } void RenderHandler::OnTextSelectionChanged(CefRefPtr browser, - const CefString& selected_text, - const CefRange& selected_range) { + const CefString &selected_text, + const CefRange &selected_range) +{ REQUIRE_UI_THREAD(); RenderHandler_OnTextSelectionChanged(browser, selected_text, selected_range); diff --git a/src/client_handler/render_handler.h b/src/client_handler/render_handler.h index 75eee86c5..f86747768 100644 --- a/src/client_handler/render_handler.h +++ b/src/client_handler/render_handler.h @@ -22,7 +22,7 @@ class RenderHandler : public CefRenderHandler, bool GetRootScreenRect(CefRefPtr browser, CefRect& rect) override; - bool GetViewRect(CefRefPtr browser, + void GetViewRect(CefRefPtr browser, CefRect& rect) override; bool GetScreenPoint(CefRefPtr browser, @@ -46,11 +46,10 @@ class RenderHandler : public CefRenderHandler, const void* buffer, int width, int height) override; - void OnCursorChange(CefRefPtr browser, + bool OnCursorChange(CefRefPtr browser, CefCursorHandle cursor, - CursorType type, - const CefCursorInfo& custom_cursor_info - ) override; + cef_cursor_type_t type, + const CefCursorInfo& custom_cursor_info); void OnScrollOffsetChanged(CefRefPtr browser, double x, diff --git a/src/client_handler/request_context_handler.cpp b/src/client_handler/request_context_handler.cpp index bf816cf51..f606249c0 100644 --- a/src/client_handler/request_context_handler.cpp +++ b/src/client_handler/request_context_handler.cpp @@ -9,31 +9,33 @@ // CefRequestContextHandler // -------------------------------------------------------------------------- -CefRefPtr RequestContextHandler::GetCookieManager() { - REQUIRE_IO_THREAD(); - if (browser_.get()) { - return RequestHandler_GetCookieManager(browser_, - browser_->GetMainFrame()->GetURL()); - } else { - CefString mainUrl; - return RequestHandler_GetCookieManager(browser_, mainUrl); - } - // Default: return NULL. -} +// CefRefPtr RequestContextHandler::GetCookieManager() { +// REQUIRE_IO_THREAD(); +// if (browser_.get()) { +// return RequestHandler_GetCookieManager(browser_, +// browser_->GetMainFrame()->GetURL()); +// } else { +// CefString mainUrl; +// return RequestHandler_GetCookieManager(browser_, mainUrl); +// } +// // Default: return NULL. +// } -bool RequestContextHandler::OnBeforePluginLoad( - const CefString& mime_type, - const CefString& plugin_url, - bool is_main_frame, - const CefString& top_origin_url, - CefRefPtr plugin_info, - PluginPolicy* plugin_policy) { - // Called on multiple threads - return RequestHandler_OnBeforePluginLoad(browser_, - mime_type, - plugin_url, - is_main_frame, - top_origin_url, - plugin_info, - plugin_policy); -} +// bool RequestContextHandler::OnBeforePluginLoad( +// const CefString& mime_type, +// const CefString& plugin_url, +// bool is_main_frame, +// const CefString& top_origin_url, +// CefRefPtr plugin_info, +// PluginPolicy* plugin_policy) { +// // Called on multiple threads +// return RequestHandler_OnBeforePluginLoad(browser_, +// mime_type, +// plugin_url, +// is_main_frame, +// top_origin_url, +// plugin_info, +// plugin_policy); +// } + +//LC TODO \ No newline at end of file diff --git a/src/client_handler/request_context_handler.h b/src/client_handler/request_context_handler.h index b8bf25f3a..cdd870dc3 100644 --- a/src/client_handler/request_context_handler.h +++ b/src/client_handler/request_context_handler.h @@ -10,12 +10,15 @@ #include "common/cefpython_public_api.h" +#include "include/cef_request_context_handler.h" +#include "include/base/cef_callback.h" + class RequestContextHandler : public CefRequestContextHandler { private: CefRefPtr browser_; - typedef cef_plugin_policy_t PluginPolicy; + // typedef cef_plugin_policy_t PluginPolicy; public: // Browser may be NULL when instantiated from cefpython.CreateBrowserSync. @@ -29,13 +32,14 @@ class RequestContextHandler : browser_ = browser; } - virtual CefRefPtr GetCookieManager() OVERRIDE; - virtual bool OnBeforePluginLoad(const CefString& mime_type, - const CefString& plugin_url, - bool is_main_frame, - const CefString& top_origin_url, - CefRefPtr plugin_info, - PluginPolicy* plugin_policy) OVERRIDE; + + // virtual CefRefPtr GetCookieManager() OVERRIDE; + // virtual bool OnBeforePluginLoad(const CefString& mime_type, + // const CefString& plugin_url, + // bool is_main_frame, + // const CefString& top_origin_url, + // CefRefPtr plugin_info, + // PluginPolicy* plugin_policy) OVERRIDE; private: IMPLEMENT_REFCOUNTING(RequestContextHandler); diff --git a/src/client_handler/request_handler.cpp b/src/client_handler/request_handler.cpp index 5227b8921..8e87cf442 100644 --- a/src/client_handler/request_handler.cpp +++ b/src/client_handler/request_handler.cpp @@ -4,7 +4,7 @@ #include "request_handler.h" #include "include/base/cef_logging.h" - +#include "include/base/cef_callback.h" bool RequestHandler::OnBeforeBrowse(CefRefPtr browser, CefRefPtr frame, @@ -22,7 +22,7 @@ ReturnValue RequestHandler::OnBeforeResourceLoad( CefRefPtr browser, CefRefPtr frame, CefRefPtr request, - CefRefPtr callback) + CefRefPtr callback) { REQUIRE_IO_THREAD(); bool retval = RequestHandler_OnBeforeResourceLoad(browser, frame, request); @@ -74,7 +74,7 @@ bool RequestHandler::GetAuthCredentials(CefRefPtr browser, bool RequestHandler::OnQuotaRequest(CefRefPtr browser, const CefString& origin_url, int64 new_size, - CefRefPtr callback) { + CefRefPtr callback) { REQUIRE_IO_THREAD(); return RequestHandler_OnQuotaRequest(browser, origin_url, new_size, callback); @@ -94,7 +94,7 @@ bool RequestHandler::OnCertificateError( cef_errorcode_t cert_error, const CefString& request_url, CefRefPtr ssl_info, // not used - CefRefPtr callback) + CefRefPtr callback) { REQUIRE_UI_THREAD(); return RequestHandler_OnCertificateError(cert_error, request_url, @@ -118,17 +118,17 @@ void RequestHandler::OnPluginCrashed(CefRefPtr browser, RequestHandler_OnPluginCrashed(browser, plugin_path); } -bool RequestHandler::CanGetCookies(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request) { - REQUIRE_IO_THREAD(); - return RequestHandler_CanGetCookies(browser, frame, request); -} - -bool RequestHandler::CanSetCookie(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - const CefCookie& cookie) { - REQUIRE_IO_THREAD(); - return RequestHandler_CanSetCookie(browser, frame, request, cookie); -} +// bool RequestHandler::CanGetCookies(CefRefPtr browser, +// CefRefPtr frame, +// CefRefPtr request) { +// REQUIRE_IO_THREAD(); +// return RequestHandler_CanGetCookies(browser, frame, request); +// } + +// bool RequestHandler::CanSetCookie(CefRefPtr browser, +// CefRefPtr frame, +// CefRefPtr request, +// const CefCookie& cookie) { +// REQUIRE_IO_THREAD(); +// return RequestHandler_CanSetCookie(browser, frame, request, cookie); +// } diff --git a/src/client_handler/request_handler.h b/src/client_handler/request_handler.h index 7e5e0e6c3..dd6b3a795 100644 --- a/src/client_handler/request_handler.h +++ b/src/client_handler/request_handler.h @@ -4,6 +4,7 @@ #include "common/cefpython_public_api.h" #include "include/cef_request_handler.h" +#include "include/base/cef_callback.h" typedef cef_return_value_t ReturnValue; @@ -23,19 +24,19 @@ class RequestHandler : public CefRequestHandler ReturnValue OnBeforeResourceLoad(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, - CefRefPtr callback - ) override; + CefRefPtr callback + ); CefRefPtr GetResourceHandler( CefRefPtr browser, CefRefPtr frame, - CefRefPtr request) override; + CefRefPtr request); void OnResourceRedirect(CefRefPtr browser, CefRefPtr frame, CefRefPtr request, CefRefPtr response, - CefString& new_url) override; + CefString& new_url); bool GetAuthCredentials(CefRefPtr browser, CefRefPtr frame, @@ -44,37 +45,37 @@ class RequestHandler : public CefRequestHandler int port, const CefString& realm, const CefString& scheme, - CefRefPtr callback) override; + CefRefPtr callback); bool OnQuotaRequest(CefRefPtr browser, const CefString& origin_url, int64 new_size, - CefRefPtr callback) override; + CefRefPtr callback) override; void OnProtocolExecution(CefRefPtr browser, const CefString& url, - bool& allow_os_execution) override; + bool& allow_os_execution); bool OnCertificateError(CefRefPtr browser, cef_errorcode_t cert_error, const CefString& request_url, CefRefPtr ssl_info, - CefRefPtr callback) override; + CefRefPtr callback) override; void OnRenderProcessTerminated(CefRefPtr browser, cef_termination_status_t status) override; void OnPluginCrashed(CefRefPtr browser, - const CefString& plugin_path) override; + const CefString& plugin_path); - bool CanGetCookies(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request) override; + // bool CanGetCookies(CefRefPtr browser, + // CefRefPtr frame, + // CefRefPtr request); - bool CanSetCookie(CefRefPtr browser, - CefRefPtr frame, - CefRefPtr request, - const CefCookie& cookie) override; + // bool CanSetCookie(CefRefPtr browser, + // CefRefPtr frame, + // CefRefPtr request, + // const CefCookie& cookie); private: IMPLEMENT_REFCOUNTING(RequestHandler); diff --git a/src/client_handler/resource_handler.cpp b/src/client_handler/resource_handler.cpp index 963575928..9970fe48f 100644 --- a/src/client_handler/resource_handler.cpp +++ b/src/client_handler/resource_handler.cpp @@ -28,15 +28,15 @@ bool ResourceHandler::ReadResponse(void* data_out, bytes_to_read, bytes_read, callback); } -bool ResourceHandler::CanGetCookie(const CefCookie& cookie) { - REQUIRE_IO_THREAD(); - return ResourceHandler_CanGetCookie(resourceHandlerId_, cookie); -} +// bool ResourceHandler::CanGetCookie(const CefCookie& cookie) { +// REQUIRE_IO_THREAD(); +// return ResourceHandler_CanGetCookie(resourceHandlerId_, cookie); +// } -bool ResourceHandler::CanSetCookie(const CefCookie& cookie) { - REQUIRE_IO_THREAD(); - return ResourceHandler_CanSetCookie(resourceHandlerId_, cookie); -} +// bool ResourceHandler::CanSetCookie(const CefCookie& cookie) { +// REQUIRE_IO_THREAD(); +// return ResourceHandler_CanSetCookie(resourceHandlerId_, cookie); +// } void ResourceHandler::Cancel() { REQUIRE_IO_THREAD(); diff --git a/src/client_handler/resource_handler.h b/src/client_handler/resource_handler.h index 3bf5e41f6..e4ad14e68 100644 --- a/src/client_handler/resource_handler.h +++ b/src/client_handler/resource_handler.h @@ -31,11 +31,11 @@ class ResourceHandler : public CefResourceHandler int& bytes_read, CefRefPtr callback) override; - virtual bool CanGetCookie(const CefCookie& cookie) override; + // virtual bool CanGetCookie(const CefCookie& cookie) override; - virtual bool CanSetCookie(const CefCookie& cookie) override; + // virtual bool CanSetCookie(const CefCookie& cookie) override; - virtual void Cancel() OVERRIDE; + virtual void Cancel() override; private: IMPLEMENT_REFCOUNTING(ResourceHandler); diff --git a/src/client_handler/string_visitor.h b/src/client_handler/string_visitor.h index 3765442c5..c36cf40f6 100644 --- a/src/client_handler/string_visitor.h +++ b/src/client_handler/string_visitor.h @@ -21,7 +21,7 @@ class StringVisitor : public CefStringVisitor virtual void Visit( const CefString& string - ) OVERRIDE; + ) override; protected: IMPLEMENT_REFCOUNTING(StringVisitor); diff --git a/src/client_handler/task.cpp b/src/client_handler/task.cpp index ec032a2d6..8c38b1140 100644 --- a/src/client_handler/task.cpp +++ b/src/client_handler/task.cpp @@ -5,11 +5,12 @@ #include "task.h" #include "include/wrapper/cef_closure_task.h" #include "include/base/cef_bind.h" +#include "include/base/cef_callback.h" void PostTaskWrapper(int threadId, int taskId) { CefPostTask( static_cast(threadId), - CefCreateClosureTask(base::Bind( + CefCreateClosureTask(base::BindOnce( &PyTaskRunnable, taskId )) @@ -19,7 +20,7 @@ void PostTaskWrapper(int threadId, int taskId) { void PostDelayedTaskWrapper(int threadId, int64 delay_ms, int taskId) { CefPostDelayedTask( static_cast(threadId), - CefCreateClosureTask(base::Bind( + CefCreateClosureTask(base::BindOnce( &PyTaskRunnable, taskId )), @@ -33,7 +34,7 @@ CefRefPtr CreateTask_SetCookie( const CefCookie& cookie, CefRefPtr callback) { - return CefCreateClosureTask(base::Bind( + return CefCreateClosureTask(base::BindOnce( base::IgnoreResult(&CefCookieManager::SetCookie), obj, url, cookie, @@ -47,7 +48,7 @@ CefRefPtr CreateTask_DeleteCookies( const CefString& cookie_name, CefRefPtr callback) { - return CefCreateClosureTask(base::Bind( + return CefCreateClosureTask(base::BindOnce( base::IgnoreResult(&CefCookieManager::DeleteCookies), obj, url, cookie_name, diff --git a/src/client_handler/web_request_client.h b/src/client_handler/web_request_client.h index 8b815a968..1868a1584 100644 --- a/src/client_handler/web_request_client.h +++ b/src/client_handler/web_request_client.h @@ -20,26 +20,26 @@ class WebRequestClient : public CefURLRequestClient } virtual ~WebRequestClient(){} - virtual void OnRequestComplete(CefRefPtr request) OVERRIDE; + virtual void OnRequestComplete(CefRefPtr request) override; virtual void OnUploadProgress(CefRefPtr request, int64 current, - int64 total) OVERRIDE; + int64 total) override; virtual void OnDownloadProgress(CefRefPtr request, int64 current, - int64 total) OVERRIDE; + int64 total) override; virtual void OnDownloadData(CefRefPtr request, const void* data, - size_t data_length) OVERRIDE; + size_t data_length) override; virtual bool GetAuthCredentials(bool isProxy, const CefString& host, int port, const CefString& realm, const CefString& scheme, - CefRefPtr callback) OVERRIDE; + CefRefPtr callback) override; protected: IMPLEMENT_REFCOUNTING(WebRequestClient); diff --git a/src/common/cefpython_public_api.h b/src/common/cefpython_public_api.h index c796388e6..82a1d1065 100644 --- a/src/common/cefpython_public_api.h +++ b/src/common/cefpython_public_api.h @@ -50,6 +50,12 @@ #include "../../build/build_cefpython/cefpython_py38_fixed.h" #elif PY_MINOR_VERSION == 9 #include "../../build/build_cefpython/cefpython_py39_fixed.h" +#elif PY_MINOR_VERSION == 10 +#include "../../build/build_cefpython/cefpython_py310_fixed.h" +#elif PY_MINOR_VERSION == 11 +#include "../../build/build_cefpython/cefpython_py311_fixed.h" +#else +#error "Unsupported Python version, please check cefpython_public_api.h" #endif // PY_MINOR_VERSION #endif // PY_MAJOR_VERSION diff --git a/src/compile_time_constants.pxi b/src/compile_time_constants.pxi index bf130d6ed..023e1b0e9 100644 --- a/src/compile_time_constants.pxi +++ b/src/compile_time_constants.pxi @@ -1,8 +1,4 @@ # This file was generated by setup.py - -# Type this command to ignore changes to this file: -# git update-index --assume-unchanged src/compile_time_constants.pxi - DEF UNAME_SYSNAME = "Windows" DEF PY_MAJOR_VERSION = 3 cdef extern from "limits.h": diff --git a/src/cookie.pyx b/src/cookie.pyx index 6d90144b0..650232a65 100644 --- a/src/cookie.pyx +++ b/src/cookie.pyx @@ -167,16 +167,16 @@ cdef class Cookie: return self.cefCookie.httponly cpdef py_void SetCreation(self, object creation): - DatetimeToCefTimeT(creation, self.cefCookie.creation) + DatetimeToCefBasetimeT(creation, self.cefCookie.creation) cpdef object GetCreation(self): - return CefTimeTToDatetime(self.cefCookie.creation) + return CefBasetimeTToDatetime(self.cefCookie.creation) cpdef py_void SetLastAccess(self, object lastAccess): - DatetimeToCefTimeT(lastAccess, self.cefCookie.last_access) + DatetimeToCefBasetimeT(lastAccess, self.cefCookie.last_access) cpdef object GetLastAccess(self): - return CefTimeTToDatetime(self.cefCookie.last_access) + return CefBasetimeTToDatetime(self.cefCookie.last_access) cpdef py_void SetHasExpires(self, py_bool hasExpires): self.cefCookie.has_expires = bool(hasExpires) @@ -185,10 +185,10 @@ cdef class Cookie: return self.cefCookie.has_expires cpdef py_void SetExpires(self, object expires): - DatetimeToCefTimeT(expires, self.cefCookie.expires) + DatetimeToCefBasetimeT(expires, self.cefCookie.expires) cpdef object GetExpires(self): - return CefTimeTToDatetime(self.cefCookie.expires) + return CefBasetimeTToDatetime(self.cefCookie.expires) # ------------------------------------------------------------------------------ # CookieManager @@ -204,36 +204,37 @@ class CookieManager(object): cdef CefRefPtr[CefCookieManager] cefCookieManager if not g_globalCookieManager: cefCookieManager = CefCookieManager_GetGlobalManager( - NULL) + nullptr) g_globalCookieManager = CreatePyCookieManager(cefCookieManager) return g_globalCookieManager - @classmethod - def GetBlockingManager(cls): - return CreatePyCookieManager(CefCookieManager_GetBlockingManager()) - - @classmethod - def CreateManager(cls, py_string path, - py_bool persist_session_cookies=False): - """ - Create a new cookie manager. - :param path: - :type path: str - :param persist_session_cookies: - :type path: bool - :return: CookieManager object - :rtype: CookieManager - """ - # When PyCharm generates a stub for the cefpython module - # it doesn't use the above docstring for code inspections. - # No idea why. - cdef CefRefPtr[CefCookieManager] cefCookieManager - cefCookieManager = CefCookieManager_CreateManager( - PyToCefStringValue(path), bool(persist_session_cookies), - NULL) - if cefCookieManager != NULL and cefCookieManager.get(): - return CreatePyCookieManager(cefCookieManager) - return None + # @classmethod + # def GetBlockingManager(cls): + # return CreatePyCookieManager(CefCookieManager_GetBlockingManager()) + + # @classmethod + # def CreateManager(cls, py_string path, + # py_bool persist_session_cookies=False): + # """ + # Create a new cookie manager. + # :param path: + # :type path: str + # :param persist_session_cookies: + # :type path: bool + # :return: CookieManager object + # :rtype: CookieManager + # """ + # # When PyCharm generates a stub for the cefpython module + # # it doesn't use the above docstring for code inspections. + # # No idea why. + # cdef CefRefPtr[CefCookieManager] cefCookieManager + # cefCookieManager = CefCookieManager_CreateManager( + # PyToCefStringValue(path), bool(persist_session_cookies), + # nullptr) + # #lc void* + # if cefCookieManager.get(): + # return CreatePyCookieManager(cefCookieManager) + # return None # ------------------------------------------------------------------------------ # PyCookieManager @@ -248,12 +249,12 @@ cdef PyCookieManager CreatePyCookieManager( cdef class PyCookieManager: cdef CefRefPtr[CefCookieManager] cefCookieManager - cpdef py_void SetSupportedSchemes(self, list schemes): - cdef cpp_vector[CefString] schemesVector - for scheme in schemes: - schemesVector.push_back(PyToCefStringValue(scheme)) - self.cefCookieManager.get().SetSupportedSchemes(schemesVector, - NULL) + # cpdef py_void SetSupportedSchemes(self, list schemes): + # cdef cpp_vector[CefString] schemesVector + # for scheme in schemes: + # schemesVector.push_back(PyToCefStringValue(scheme)) + # self.cefCookieManager.get().SetSupportedSchemes(schemesVector, + # nullptr) cdef py_void ValidateUserCookieVisitor(self, object userCookieVisitor): if userCookieVisitor and hasattr(userCookieVisitor, "Visit") and ( @@ -287,23 +288,23 @@ cdef class PyCookieManager: CefPostTask(TID_IO, CreateTask_SetCookie( self.cefCookieManager.get(), PyToCefStringValue(url), cookie.cefCookie, - NULL)) + nullptr)) cpdef py_void DeleteCookies(self, py_string url, py_string cookie_name): CefPostTask(TID_IO, CreateTask_DeleteCookies( self.cefCookieManager.get(), PyToCefStringValue(url), PyToCefStringValue(cookie_name), - NULL)) + nullptr)) - cpdef py_bool SetStoragePath(self, py_string path, - py_bool persistSessionCookies=False): - return self.cefCookieManager.get().SetStoragePath( - PyToCefStringValue(path), bool(persistSessionCookies), - NULL) + # cpdef py_bool SetStoragePath(self, py_string path, + # py_bool persistSessionCookies=False): + # return self.cefCookieManager.get().SetStoragePath( + # PyToCefStringValue(path), bool(persistSessionCookies), + # nullptr) cpdef py_bool FlushStore(self, callback=None): return self.cefCookieManager.get().FlushStore( - NULL) + nullptr) # ------------------------------------------------------------------------------ diff --git a/src/download.pyx b/src/download.pyx new file mode 100644 index 000000000..f1ce01281 --- /dev/null +++ b/src/download.pyx @@ -0,0 +1,73 @@ +include "cefpython.pyx" + +cdef class PyDownloadItem: + cdef CefRefPtr[CefDownloadItem] cefDownloadItem + + cpdef py_bool IsValid(self): + return self.cefDownloadItem.get().IsValid() + + cpdef py_bool IsInProgress(self): + return self.cefDownloadItem.get().IsInProgress() + + cpdef py_bool IsComplete(self): + return self.cefDownloadItem.get().IsComplete() + + cpdef py_bool IsCanceled(self): + return self.cefDownloadItem.get().IsCanceled() + + cpdef object GetCurrentSpeed(self): + return self.cefDownloadItem.get().GetCurrentSpeed() + + cpdef object GetPercentComplete(self): + return self.cefDownloadItem.get().GetPercentComplete() + + cpdef object GetTotalBytes(self): + return self.cefDownloadItem.get().GetTotalBytes() + + cpdef object GetReceivedBytes(self): + return self.cefDownloadItem.get().GetReceivedBytes() + + cpdef object GetStartTime(self): + return self.cefDownloadItem.get().GetStartTime() + + cpdef object GetEndTime(self): + return self.cefDownloadItem.get().GetEndTime() + + cpdef str GetFullPath(self): + return CefToPyString(self.cefDownloadItem.get().GetFullPath()) + + cpdef object GetId(self): + return self.cefDownloadItem.get().GetId() + + cpdef str GetURL(self): + return CefToPyString(self.cefDownloadItem.get().GetURL()) + + cpdef str GetOriginalUrl(self): + return CefToPyString(self.cefDownloadItem.get().GetOriginalUrl()) + + cpdef str GetSuggestedFileName(self): + return CefToPyString(self.cefDownloadItem.get().GetSuggestedFileName()) + + cpdef str GetContentDisposition(self): + return CefToPyString(self.cefDownloadItem.get().GetContentDisposition()) + + cpdef str GetMimeType(self): + return CefToPyString(self.cefDownloadItem.get().GetMimeType()) + +cdef class PyBeforeDownloadCallback: + cdef CefRefPtr[CefBeforeDownloadCallback] cefBeforeDownloadCallback + + cpdef Continue(self, str downloadPath, py_bool showDialog): + self.cefBeforeDownloadCallback.get().Continue(PyToCefStringValue(downloadPath), showDialog) + +cdef class PyDownloadItemCallback: + cdef CefRefPtr[CefDownloadItemCallback] cefDownloadItemCallback + + cpdef Cancel(self): + self.cefDownloadItemCallback.get().Cancel() + + cpdef Pause(self): + self.cefDownloadItemCallback.get().Pause() + + cpdef Resume(self): + self.cefDownloadItemCallback.get().Resume() \ No newline at end of file diff --git a/src/extern/cef/cef_browser.pxd b/src/extern/cef/cef_browser.pxd index da209d5c3..f96492693 100644 --- a/src/extern/cef/cef_browser.pxd +++ b/src/extern/cef/cef_browser.pxd @@ -66,7 +66,7 @@ cdef extern from "include/cef_browser.h": CefRefPtr[CefRequestContext] GetRequestContext() - void Find(int identifier, const CefString& searchText, cpp_bool forward, + void Find(const CefString& searchText, cpp_bool forward, cpp_bool matchCase, cpp_bool findNext) void StopFinding(cpp_bool clearSelection) void Print() @@ -113,5 +113,5 @@ cdef extern from "include/cef_browser.h": void StopLoad() cpp_bool IsLoading() int GetIdentifier() - cpp_bool SendProcessMessage(CefProcessId target_process, - CefRefPtr[CefProcessMessage] message) + # cpp_bool SendProcessMessage(CefProcessId target_process, + # CefRefPtr[CefProcessMessage] message) diff --git a/src/extern/cef/cef_browser_static.pxd b/src/extern/cef/cef_browser_static.pxd index 17b1a283d..a668968be 100644 --- a/src/extern/cef/cef_browser_static.pxd +++ b/src/extern/cef/cef_browser_static.pxd @@ -19,6 +19,7 @@ from cef_request_context cimport CefRequestContext # noinspection PyUnresolvedReferences from cef_browser cimport CefBrowser from cef_string cimport CefString +from cef_values cimport CefDictionaryValue # Specifying namespace allows to import a static method. cdef extern from "include/cef_browser.h" namespace "CefBrowserHost": @@ -28,4 +29,5 @@ cdef extern from "include/cef_browser.h" namespace "CefBrowserHost": CefRefPtr[CefClient], CefString&, CefBrowserSettings&, + CefRefPtr[CefDictionaryValue], CefRefPtr[CefRequestContext]) nogil diff --git a/src/extern/cef/cef_cookie.pxd b/src/extern/cef/cef_cookie.pxd index c113aea9a..ad7eba595 100644 --- a/src/extern/cef/cef_cookie.pxd +++ b/src/extern/cef/cef_cookie.pxd @@ -4,7 +4,7 @@ from cef_string cimport cef_string_t from libcpp cimport bool as cpp_bool -from cef_time cimport cef_time_t +from cef_time cimport cef_time_t, cef_basetime_t from libcpp.vector cimport vector as cpp_vector from cef_string cimport CefString from cef_ptr cimport CefRefPtr @@ -19,10 +19,10 @@ cdef extern from "include/cef_cookie.h": cef_string_t path cpp_bool secure cpp_bool httponly - cef_time_t creation - cef_time_t last_access + cef_basetime_t creation + cef_basetime_t last_access cpp_bool has_expires - cef_time_t expires + cef_basetime_t expires cdef CefRefPtr[CefCookieManager] CefCookieManager_GetGlobalManager \ "CefCookieManager::GetGlobalManager"( diff --git a/src/extern/cef/cef_download_handler.pxd b/src/extern/cef/cef_download_handler.pxd new file mode 100644 index 000000000..835ed7890 --- /dev/null +++ b/src/extern/cef/cef_download_handler.pxd @@ -0,0 +1,13 @@ +include "compile_time_constants.pxi" + +from libcpp cimport bool as cpp_bool +from cef_string cimport CefString + +cdef extern from "include/cef_download_handler.h": + cdef cppclass CefBeforeDownloadCallback: + void Continue(const CefString& download_path, cpp_bool show_dialog) + + cdef cppclass CefDownloadItemCallback: + void Cancel() + void Pause() + void Resume() \ No newline at end of file diff --git a/src/extern/cef/cef_download_item.pxd b/src/extern/cef/cef_download_item.pxd new file mode 100644 index 000000000..360172309 --- /dev/null +++ b/src/extern/cef/cef_download_item.pxd @@ -0,0 +1,44 @@ +include "compile_time_constants.pxi" + +from libcpp cimport bool as cpp_bool +from cef_string cimport CefString +from cef_time cimport cef_time_t, cef_basetime_t +from cef_types cimport ( + int32, uint32, int64, uint64 +) + +cdef extern from "include/cef_download_item.h": + cdef cppclass CefDownloadItem: + cpp_bool IsValid() + + cpp_bool IsInProgress() + + cpp_bool IsComplete() + + cpp_bool IsCanceled() + + int64 GetCurrentSpeed() + + int GetPercentComplete() + + int64 GetTotalBytes() + + int64 GetReceivedBytes() + + cef_basetime_t GetStartTime() + + cef_basetime_t GetEndTime() + + CefString GetFullPath() + + uint32 GetId() + + CefString GetURL() + + CefString GetOriginalUrl() + + CefString GetSuggestedFileName() + + CefString GetContentDisposition() + + CefString GetMimeType() \ No newline at end of file diff --git a/src/extern/cef/cef_frame.pxd b/src/extern/cef/cef_frame.pxd index 28cdceee2..ecd596d2e 100644 --- a/src/extern/cef/cef_frame.pxd +++ b/src/extern/cef/cef_frame.pxd @@ -10,6 +10,7 @@ from libcpp cimport bool as cpp_bool from cef_ptr cimport CefRefPtr from cef_browser cimport CefBrowser from cef_string_visitor cimport CefStringVisitor +from cef_process_message cimport CefProcessMessage, CefProcessId cdef extern from "include/cef_frame.h": @@ -35,3 +36,5 @@ cdef extern from "include/cef_frame.h": CefString GetName() CefRefPtr[CefFrame] GetParent() CefRefPtr[CefBrowser] GetBrowser() + cpp_bool SendProcessMessage(CefProcessId target_process, + CefRefPtr[CefProcessMessage] message) diff --git a/src/extern/cef/cef_ptr.pxd b/src/extern/cef/cef_ptr.pxd index c5d9877cf..c2a860a75 100644 --- a/src/extern/cef/cef_ptr.pxd +++ b/src/extern/cef/cef_ptr.pxd @@ -1,6 +1,8 @@ # Copyright (c) 2012 CEF Python, see the Authors file. # All rights reserved. Licensed under BSD 3-clause license. # Project website: https://github.com/cztomczak/cefpython +from libcpp cimport nullptr_t, nullptr +from libcpp cimport bool as cpp_bool cdef extern from "include/internal/cef_ptr.h": cdef cppclass CefRefPtr[T]: @@ -14,4 +16,15 @@ cdef extern from "include/internal/cef_ptr.h": # noinspection PyUnresolvedReferences void swap(CefRefPtr[T]& r) # noinspection PyUnresolvedReferences + CefRefPtr[T]& Assign "operator="(nullptr_t) + CefRefPtr[T]& Assign "operator="(T* p) + + + +# cdef class PyCefRefPtr[T]: +# cdef CefRefPtr[T]* thisptr +# def __init__(self, T* p): +# self.thisptr = new CefRefPtr[T](p) +# def __eq__(self, other): +# return self.thisptr.operator==(*other.thisptr) \ No newline at end of file diff --git a/src/extern/cef/cef_request_context.pxd b/src/extern/cef/cef_request_context.pxd index 116741749..1107cb6fc 100644 --- a/src/extern/cef/cef_request_context.pxd +++ b/src/extern/cef/cef_request_context.pxd @@ -16,5 +16,5 @@ cdef extern from "include/cef_request_context.h": CefRefPtr[CefRequestContext] CreateContext( CefRefPtr[CefRequestContext] other, CefRefPtr[CefRequestContextHandler] handler) - CefRefPtr[CefCookieManager] GetDefaultCookieManager( + CefRefPtr[CefCookieManager] GetCookieManager( CefRefPtr[CefCompletionCallback] callback) diff --git a/src/extern/cef/cef_request_handler.pxd b/src/extern/cef/cef_request_handler.pxd index 96a7d88c6..8287f886c 100644 --- a/src/extern/cef/cef_request_handler.pxd +++ b/src/extern/cef/cef_request_handler.pxd @@ -12,6 +12,6 @@ cdef extern from "include/cef_auth_callback.h": void Cancel() cdef extern from "include/cef_request_handler.h": - cdef cppclass CefRequestCallback: + cdef cppclass CefCallback: void Continue(cpp_bool allow) void Cancel() diff --git a/src/extern/cef/cef_response.pxd b/src/extern/cef/cef_response.pxd index ef6729f12..9c08a0ec1 100644 --- a/src/extern/cef/cef_response.pxd +++ b/src/extern/cef/cef_response.pxd @@ -21,6 +21,6 @@ cdef extern from "include/cef_response.h": void SetStatusText(CefString& statusText) CefString GetMimeType() void SetMimeType(CefString& mimeType) - CefString GetHeader(CefString& name) + CefString GetHeaderByName(CefString& name) void GetHeaderMap(CefResponseHeaderMap& headerMap) void SetHeaderMap(CefResponseHeaderMap& headerMap) diff --git a/src/extern/cef/cef_scoped_ptr.pxd b/src/extern/cef/cef_scoped_ptr.pxd deleted file mode 100644 index 2e770a5b9..000000000 --- a/src/extern/cef/cef_scoped_ptr.pxd +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2016 CEF Python, see the Authors file. -# All rights reserved. Licensed under BSD 3-clause license. -# Project website: https://github.com/cztomczak/cefpython - -cdef extern from "include/base/cef_scoped_ptr.h": - cdef cppclass scoped_ptr[T]: - scoped_ptr() - # noinspection PyUnresolvedReferences - scoped_ptr(T* p) - # noinspection PyUnresolvedReferences - void reset() - # noinspection PyUnresolvedReferences - void reset(T* p) - # noinspection PyUnresolvedReferences - T* get() - # noinspection PyUnresolvedReferences - scoped_ptr[T]& Assign "operator="(scoped_ptr[T] p) diff --git a/src/extern/cef/cef_scoped_refptr.pxd b/src/extern/cef/cef_scoped_refptr.pxd new file mode 100644 index 000000000..d85e7261e --- /dev/null +++ b/src/extern/cef/cef_scoped_refptr.pxd @@ -0,0 +1,25 @@ +# Copyright (c) 2016 CEF Python, see the Authors file. +# All rights reserved. Licensed under BSD 3-clause license. +# Project website: https://github.com/cztomczak/cefpython +from libcpp cimport nullptr_t, nullptr +from libcpp cimport bool as cpp_bool + +cdef extern from "include/base/cef_scoped_refptr.h": + cdef cppclass scoped_refptr[T]: + scoped_refptr() + # noinspection PyUnresolvedReferences + scoped_refptr(T* p) + # noinspection PyUnresolvedReferences + void reset() + # noinspection PyUnresolvedReferences + void reset(T* p) + # noinspection PyUnresolvedReferences + T* get() + # noinspection PyUnresolvedReferences + scoped_refptr[T]& Assign "operator="(nullptr_t) + + scoped_refptr[T]& Assign "operator="(scoped_refptr[T] p) + + #cpp_bool Assign "operator=="(const scoped_refptr[U]& rhs) const + + #cpp_bool Assign "operator!="(const scoped_refptr[U]& rhs) const diff --git a/src/extern/cef/cef_time.pxd b/src/extern/cef/cef_time.pxd index cdbdc639f..7387df57e 100644 --- a/src/extern/cef/cef_time.pxd +++ b/src/extern/cef/cef_time.pxd @@ -3,6 +3,7 @@ # Project website: https://github.com/cztomczak/cefpython from ctime cimport time_t +from cef_types cimport int64 cdef extern from "include/internal/cef_time.h": ctypedef struct cef_time_t: @@ -15,6 +16,9 @@ cdef extern from "include/internal/cef_time.h": int second int millisecond + ctypedef struct cef_basetime_t: + int64 val + cdef extern from "include/internal/cef_types.h": cdef cppclass CefTime: CefTime() diff --git a/src/extern/cef/cef_types.pxd b/src/extern/cef/cef_types.pxd index 6bd21ba46..a0055c17d 100644 --- a/src/extern/cef/cef_types.pxd +++ b/src/extern/cef/cef_types.pxd @@ -34,7 +34,7 @@ cdef extern from "include/internal/cef_types.h": ctypedef struct CefSettings: cef_string_t accept_language_list - int single_process + # int single_process cef_string_t browser_subprocess_path int command_line_args_disabled cef_string_t cache_path diff --git a/src/extern/cef/cef_web_plugin.pxd b/src/extern/cef/cef_web_plugin.pxd index 25d33fa9d..0db45b27a 100644 --- a/src/extern/cef/cef_web_plugin.pxd +++ b/src/extern/cef/cef_web_plugin.pxd @@ -6,9 +6,9 @@ from cef_string cimport CefString # CEF 3 only. -cdef extern from "include/cef_web_plugin.h": - cdef cppclass CefWebPluginInfo: - CefString GetName() - CefString GetPath() - CefString GetVersion() - CefString GetDescription() +# cdef extern from "include/cef_web_plugin.h": +# cdef cppclass CefWebPluginInfo: +# CefString GetName() +# CefString GetPath() +# CefString GetVersion() +# CefString GetDescription() diff --git a/src/extern/cef/cef_win.pxd b/src/extern/cef/cef_win.pxd index 5e341b75b..7a579bea7 100644 --- a/src/extern/cef/cef_win.pxd +++ b/src/extern/cef/cef_win.pxd @@ -8,6 +8,7 @@ include "compile_time_constants.pxi" from windows cimport HWND, RECT, HINSTANCE, HCURSOR from cef_string cimport CefString from libcpp cimport bool as cpp_bool +from cef_types cimport CefRect cdef extern from "include/internal/cef_win.h": @@ -18,7 +19,7 @@ cdef extern from "include/internal/cef_win.h": cdef cppclass CefWindowInfo: void SetAsChild(CefWindowHandle parent, - RECT windowRect) + const CefRect windowRect) void SetAsPopup(CefWindowHandle parent, const CefString& windowName) void SetAsWindowless(CefWindowHandle parent) diff --git a/src/extern/main_message_loop.pxd b/src/extern/main_message_loop.pxd index 486f309af..3182214e3 100644 --- a/src/extern/main_message_loop.pxd +++ b/src/extern/main_message_loop.pxd @@ -2,11 +2,13 @@ # All rights reserved. Licensed under BSD 3-clause license. # Project website: https://github.com/cztomczak/cefpython -from cef_scoped_ptr cimport scoped_ptr +from libcpp.memory cimport unique_ptr + +from cef_scoped_refptr cimport scoped_refptr cdef extern from \ "subprocess/main_message_loop/main_message_loop_external_pump.h": cdef cppclass MainMessageLoopExternalPump: @staticmethod - scoped_ptr[MainMessageLoopExternalPump] Create() + unique_ptr[MainMessageLoopExternalPump] Create() diff --git a/src/frame.pyx b/src/frame.pyx index 812e4b3c9..15f33ca3e 100644 --- a/src/frame.pyx +++ b/src/frame.pyx @@ -22,8 +22,8 @@ cdef PyFrame GetPyFrameById(int browserId, object frameId): cdef PyFrame GetPyFrame(CefRefPtr[CefFrame] cefFrame): global g_pyFrames - - if cefFrame == NULL or not cefFrame.get(): +#lc void* + if not cefFrame.get(): raise Exception("GetPyFrame(): CefFrame reference is NULL") cdef PyFrame pyFrame @@ -89,7 +89,7 @@ cdef void RemovePyFrame(int browserId, object frameId) except *: if uniqueFrameId in g_pyFrames: Debug("del g_pyFrames[%s]" % uniqueFrameId) pyFrame = g_pyFrames[uniqueFrameId] - pyFrame.cefFrame.Assign(NULL) + pyFrame.cefFrame.Assign(nullptr) del pyFrame del g_pyFrames[uniqueFrameId] g_unreferenced_frames.append(uniqueFrameId) @@ -109,7 +109,7 @@ cdef void RemovePyFramesForBrowser(int browserId) except *: for uniqueFrameId in toRemove: Debug("del g_pyFrames[%s]" % uniqueFrameId) pyFrame = g_pyFrames[uniqueFrameId] - pyFrame.cefFrame.Assign(NULL) + pyFrame.cefFrame.Assign(nullptr) del pyFrame del g_pyFrames[uniqueFrameId] g_unreferenced_frames.append(uniqueFrameId) @@ -125,16 +125,18 @@ cdef class PyFrame: # Do not call IsValid() here, if the frame does not exist # then no big deal, no reason to crash the application. # The CEF calls will fail, but they also won't cause crash. - if self.cefFrame != NULL and self.cefFrame.get(): + #lc void* + if self.cefFrame.get(): return self.cefFrame raise Exception("PyFrame.GetCefFrame() failed: CefFrame was destroyed") - def __init__(self, int browserId, int frameId): + def __init__(self, int browserId, int64 frameId): self.browserId = browserId self.frameId = frameId cpdef py_bool IsValid(self): - if self.cefFrame != NULL and self.cefFrame.get() \ + #lc void* + if self.cefFrame.get() \ and self.cefFrame.get().IsValid(): return True return False @@ -203,12 +205,12 @@ cdef class PyFrame: cpdef py_bool IsMain(self): return self.GetCefFrame().get().IsMain() - cpdef py_void LoadString(self, py_string value, py_string url): - cdef CefString cefValue - cdef CefString cefUrl - PyToCefString(value, cefValue) - PyToCefString(url, cefUrl) - self.GetCefFrame().get().LoadString(cefValue, cefUrl) + # cpdef py_void LoadString(self, py_string value, py_string url): + # cdef CefString cefValue + # cdef CefString cefUrl + # PyToCefString(value, cefValue) + # PyToCefString(url, cefUrl) + # self.GetCefFrame().get().LoadString(cefValue, cefUrl) cpdef py_void LoadUrl(self, py_string url): cdef CefString cefUrl @@ -229,3 +231,31 @@ cdef class PyFrame: cpdef py_void ViewSource(self): self.GetCefFrame().get().ViewSource() + + cdef void SendProcessMessage(self, cef_process_id_t targetProcess, + object frameId, py_string messageName, list pyArguments + ) except *: + cdef CefRefPtr[CefProcessMessage] message = \ + CefProcessMessage_Create(PyToCefStringValue(messageName)) + # This does not work, no idea why, the CEF implementation + # seems not to allow it, both Assign() and swap() do not work: + # | message.get().GetArgumentList().Assign(arguments.get()) + # | message.get().GetArgumentList().swap(arguments) + cdef CefRefPtr[CefListValue] messageArguments = \ + message.get().GetArgumentList() + PyListToExistingCefListValue(self.GetBrowserIdentifier(), + frameId, + pyArguments, messageArguments) + Debug("SendProcessMessage(): message=%s, arguments size=%d" % ( + messageName, + message.get().GetArgumentList().get().GetSize())) + #lc test + # cdef cpp_bool success = \ + # self.GetCefFrame().get().SendProcessMessage( + # targetProcess, + # message) + # if not success: + # raise Exception("Frame.SendProcessMessage() failed: "\ + # "messageName=%s" % messageName) + + self.GetCefFrame().get().SendProcessMessage(targetProcess, message) diff --git a/src/handlers/browser_process_handler.pyx b/src/handlers/browser_process_handler.pyx index 09463b0ef..276d73ce1 100644 --- a/src/handlers/browser_process_handler.pyx +++ b/src/handlers/browser_process_handler.pyx @@ -4,14 +4,14 @@ include "../cefpython.pyx" -cdef public void BrowserProcessHandler_OnRenderProcessThreadCreated( - CefRefPtr[CefListValue] extra_info - ) except * with gil: - try: - pass - except: - (exc_type, exc_value, exc_trace) = sys.exc_info() - sys.excepthook(exc_type, exc_value, exc_trace) +# cdef public void BrowserProcessHandler_OnRenderProcessThreadCreated( +# CefRefPtr[CefListValue] extra_info +# ) except * with gil: +# try: +# pass +# except: +# (exc_type, exc_value, exc_trace) = sys.exc_info() +# sys.excepthook(exc_type, exc_value, exc_trace) cdef public void BrowserProcessHandler_OnBeforeChildProcessLaunch( CefRefPtr[CefCommandLine] cefCommandLine diff --git a/src/handlers/download_handler.pyx b/src/handlers/download_handler.pyx new file mode 100644 index 000000000..8d88ede2e --- /dev/null +++ b/src/handlers/download_handler.pyx @@ -0,0 +1,50 @@ + + +cdef public void DownloadHandler_OnBeforeDownload( + CefRefPtr[CefBrowser] cefBrowser, + CefRefPtr[CefDownloadItem] cefDownloadItem, + const CefString& cefSuggestedName, + CefRefPtr[CefBeforeDownloadCallback] cefCallback + ) except * with gil: + cdef PyBrowser pyBrowser + cdef PyDownloadItem pyDownloadItem + cdef str pySuggestedName + cdef PyBeforeDownloadCallback pyBeforeDownloadCallback + cdef object callback + try: + pyBrowser = GetPyBrowser(cefBrowser, "OnBeforeDownload") + callback = pyBrowser.GetClientCallback("OnBeforeDownload") + pyDownloadItem = PyDownloadItem() + pyDownloadItem.cefDownloadItem = cefDownloadItem + pySuggestedName = CefToPyString(cefSuggestedName) + pyBeforeDownloadCallback = PyBeforeDownloadCallback() + pyBeforeDownloadCallback.cefBeforeDownloadCallback = cefCallback + if callback: + callback(browser=pyBrowser, downloadItem=pyDownloadItem, + suggestedName=pySuggestedName, callback=pyBeforeDownloadCallback) + except: + (exc_type, exc_value, exc_trace) = sys.exc_info() + sys.excepthook(exc_type, exc_value, exc_trace) + +cdef public void DownloadHandler_OnDownloadUpdated( + CefRefPtr[CefBrowser] cefBrowser, + CefRefPtr[CefDownloadItem] cefDownloadItem, + CefRefPtr[CefDownloadItemCallback] cefCallback + ) except * with gil: + cdef PyBrowser pyBrowser + cdef PyDownloadItem pyDownloadItem + cdef PyDownloadItemCallback pyDownloadItemCallback + cdef object callback + try: + pyBrowser = GetPyBrowser(cefBrowser, "OnDownloadUpdated") + callback = pyBrowser.GetClientCallback("OnDownloadUpdated") + pyDownloadItem = PyDownloadItem() + pyDownloadItem.cefDownloadItem = cefDownloadItem + pyDownloadItemCallback = PyDownloadItemCallback() + pyDownloadItemCallback.cefDownloadItemCallback = cefCallback + if callback: + callback(browser=pyBrowser, downloadItem=pyDownloadItem, + callback=pyDownloadItemCallback) + except: + (exc_type, exc_value, exc_trace) = sys.exc_info() + sys.excepthook(exc_type, exc_value, exc_trace) \ No newline at end of file diff --git a/src/handlers/lifespan_handler.pyx b/src/handlers/lifespan_handler.pyx index bfe22bd11..48a39d429 100644 --- a/src/handlers/lifespan_handler.pyx +++ b/src/handlers/lifespan_handler.pyx @@ -34,6 +34,7 @@ cdef public cpp_bool LifespanHandler_OnBeforePopup( CefWindowInfo& windowInfo, CefRefPtr[CefClient]& client, CefBrowserSettings& settings, + CefRefPtr[CefDictionaryValue]& extra_info, cpp_bool* noJavascriptAccess ) except * with gil: # Empty place-holders: popupFeatures, client. @@ -67,6 +68,7 @@ cdef public cpp_bool LifespanHandler_OnBeforePopup( window_info_out=pyWindowInfo, client=None, browser_settings_out=pyBrowserSettings, + extra_info=None, no_javascript_access_out=pyNoJavascriptAccess)) noJavascriptAccess[0] = bool(pyNoJavascriptAccess[0]) if len(pyBrowserSettings): @@ -133,13 +135,13 @@ cdef public void LifespanHandler_OnBeforeClose( # GetCookieManager to implement custom cookie managers then # flushing of cookies would need to be handled manually. cefBrowser.get().GetHost().get().GetRequestContext().get() \ - .GetDefaultCookieManager( - NULL) \ - .get().FlushStore(NULL) + .GetCookieManager( + nullptr) \ + .get().FlushStore(nullptr) browserId = pyBrowser.GetIdentifier() - pyBrowser.cefBrowser.Assign(NULL) - cefBrowser.Assign(NULL) + pyBrowser.cefBrowser.Assign(nullptr) + cefBrowser.Assign(nullptr) del pyBrowser RemovePythonCallbacksForBrowser(browserId) diff --git a/src/handlers/request_handler.pyx b/src/handlers/request_handler.pyx index 866942bfd..be997a347 100644 --- a/src/handlers/request_handler.pyx +++ b/src/handlers/request_handler.pyx @@ -37,16 +37,19 @@ cdef class PyAuthCallback: # ----------------------------------------------------------------------------- cdef PyRequestCallback CreatePyRequestCallback( - CefRefPtr[CefRequestCallback] cefCallback): + CefRefPtr[CefCallback] cefCallback): cdef PyRequestCallback pyCallback = PyRequestCallback() pyCallback.cefCallback = cefCallback return pyCallback cdef class PyRequestCallback: - cdef CefRefPtr[CefRequestCallback] cefCallback + cdef CefRefPtr[CefCallback] cefCallback cpdef py_void Continue(self, py_bool allow): - self.cefCallback.get().Continue(bool(allow)) + if allow: + self.cefCallback.get().Continue() + else: + self.cefCallback.get().Cancel() cpdef py_void Cancel(self): self.cefCallback.get().Cancel() @@ -140,7 +143,7 @@ cdef public CefRefPtr[CefResourceHandler] RequestHandler_GetResourceHandler( # Issue #455: CefRequestHandler callbacks still executed after # browser was closed. if IsBrowserClosed(cefBrowser): - return NULL + return nullptr pyBrowser = GetPyBrowser(cefBrowser, "GetResourceHandler") pyFrame = GetPyFrame(cefFrame) @@ -154,9 +157,9 @@ cdef public CefRefPtr[CefResourceHandler] RequestHandler_GetResourceHandler( if returnValue: return CreateResourceHandler(returnValue) else: - return NULL + return nullptr else: - return NULL + return nullptr except: (exc_type, exc_value, exc_trace) = sys.exc_info() sys.excepthook(exc_type, exc_value, exc_trace) @@ -280,7 +283,7 @@ cdef public cpp_bool RequestHandler_OnQuotaRequest( CefRefPtr[CefBrowser] cefBrowser, const CefString& cefOriginUrl, int64 newSize, - CefRefPtr[CefRequestCallback] cefRequestCallback + CefRefPtr[CefCallback] CefCallback ) except * with gil: cdef PyBrowser pyBrowser cdef py_string pyOriginUrl @@ -300,7 +303,7 @@ cdef public cpp_bool RequestHandler_OnQuotaRequest( browser=pyBrowser, origin_url=pyOriginUrl, new_size=newSize, - callback=CreatePyRequestCallback(cefRequestCallback)) + callback=CreatePyRequestCallback(CefCallback)) return bool(returnValue) else: return False @@ -308,48 +311,48 @@ cdef public cpp_bool RequestHandler_OnQuotaRequest( (exc_type, exc_value, exc_trace) = sys.exc_info() sys.excepthook(exc_type, exc_value, exc_trace) - -cdef public CefRefPtr[CefCookieManager] RequestHandler_GetCookieManager( - CefRefPtr[CefBrowser] cefBrowser, - const CefString& cefMainUrl - ) except * with gil: - # In CEF the GetCookieManager callback belongs to - # CefRequestContextHandler. - # In an exceptional case the browser parameter may be None - # due to limitation in CEF API. No workaround as of now. - cdef PyBrowser pyBrowser - cdef str pyMainUrl - cdef object clientCallback - cdef PyCookieManager returnValue - try: - # Issue #429: in some cases due to a race condition the browser - # may be NULL. - if not cefBrowser.get(): - return NULL - - # Issue #455: CefRequestHandler callbacks still executed after - # browser was closed. - if IsBrowserClosed(cefBrowser): - return NULL - - pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager") - pyMainUrl = CefToPyString(cefMainUrl) - clientCallback = pyBrowser.GetClientCallback("GetCookieManager") - if clientCallback: - returnValue = clientCallback( - browser=pyBrowser, - main_url=pyMainUrl) - if returnValue: - if isinstance(returnValue, PyCookieManager): - return returnValue.cefCookieManager - else: - raise Exception("Expected a CookieManager object") - return NULL - else: - return NULL - except: - (exc_type, exc_value, exc_trace) = sys.exc_info() - sys.excepthook(exc_type, exc_value, exc_trace) +#LC TEST +# cdef public CefRefPtr[CefCookieManager] RequestHandler_GetCookieManager( +# CefRefPtr[CefBrowser] cefBrowser, +# const CefString& cefMainUrl +# ) except * with gil: +# # In CEF the GetCookieManager callback belongs to +# # CefRequestContextHandler. +# # In an exceptional case the browser parameter may be None +# # due to limitation in CEF API. No workaround as of now. +# cdef PyBrowser pyBrowser +# cdef str pyMainUrl +# cdef object clientCallback +# cdef PyCookieManager returnValue +# try: +# # Issue #429: in some cases due to a race condition the browser +# # may be nullptr. +# if not cefBrowser.get(): +# return nullptr + +# # Issue #455: CefRequestHandler callbacks still executed after +# # browser was closed. +# if IsBrowserClosed(cefBrowser): +# return nullptr + +# pyBrowser = GetPyBrowser(cefBrowser, "GetCookieManager") +# pyMainUrl = CefToPyString(cefMainUrl) +# clientCallback = pyBrowser.GetClientCallback("GetCookieManager") +# if clientCallback: +# returnValue = clientCallback( +# browser=pyBrowser, +# main_url=pyMainUrl) +# if returnValue: +# if isinstance(returnValue, PyCookieManager): +# return returnValue.cefCookieManager +# else: +# raise Exception("Expected a CookieManager object") +# return nullptr +# else: +# return nullptr +# except: +# (exc_type, exc_value, exc_trace) = sys.exc_info() +# sys.excepthook(exc_type, exc_value, exc_trace) cdef public void RequestHandler_OnProtocolExecution( @@ -388,60 +391,60 @@ cdef public void RequestHandler_OnProtocolExecution( sys.excepthook(exc_type, exc_value, exc_trace) -cdef public cpp_bool RequestHandler_OnBeforePluginLoad( - CefRefPtr[CefBrowser] browser, - const CefString& mime_type, - const CefString& plugin_url, - cpp_bool is_main_frame, - const CefString& top_origin_url, - CefRefPtr[CefWebPluginInfo] plugin_info, - cef_types.cef_plugin_policy_t* plugin_policy - ) except * with gil: - cdef PyBrowser pyBrowser - cdef PyWebPluginInfo pyInfo - cdef py_bool returnValue - cdef object clientCallback - try: - # OnBeforePluginLoad is called from RequestContexthandler. - # The Browser object might not be available, because it is - # being set synchronously during CreateBrowserSync, after - # Browser is created. From testing it always works, however - # better be safe. - if not browser.get(): - Debug("WARNING: RequestHandler_OnBeforePluginLoad() failed," - " Browser object is not available") - return False - - # Issue #455: CefRequestHandler callbacks still executed after - # browser was closed. - if IsBrowserClosed(browser): - return False - - py_browser = GetPyBrowser(browser, "OnBeforePluginLoad") - py_plugin_info = CreatePyWebPluginInfo(plugin_info) - clientCallback = GetGlobalClientCallback("OnBeforePluginLoad") - if clientCallback: - returnValue = clientCallback( - browser=py_browser, - mime_type=CefToPyString(mime_type), - plugin_url=CefToPyString(plugin_url), - is_main_frame=bool(is_main_frame), - top_origin_url=CefToPyString(top_origin_url), - plugin_info=py_plugin_info) - if returnValue: - plugin_policy[0] = cef_types.PLUGIN_POLICY_DISABLE - return bool(returnValue) - else: - return False - except: - (exc_type, exc_value, exc_trace) = sys.exc_info() - sys.excepthook(exc_type, exc_value, exc_trace) +# cdef public cpp_bool RequestHandler_OnBeforePluginLoad( +# CefRefPtr[CefBrowser] browser, +# const CefString& mime_type, +# const CefString& plugin_url, +# cpp_bool is_main_frame, +# const CefString& top_origin_url, +# CefRefPtr[CefWebPluginInfo] plugin_info, +# cef_types.cef_plugin_policy_t* plugin_policy +# ) except * with gil: +# cdef PyBrowser pyBrowser +# cdef PyWebPluginInfo pyInfo +# cdef py_bool returnValue +# cdef object clientCallback +# try: +# # OnBeforePluginLoad is called from RequestContexthandler. +# # The Browser object might not be available, because it is +# # being set synchronously during CreateBrowserSync, after +# # Browser is created. From testing it always works, however +# # better be safe. +# if not browser.get(): +# Debug("WARNING: RequestHandler_OnBeforePluginLoad() failed," +# " Browser object is not available") +# return False + +# # Issue #455: CefRequestHandler callbacks still executed after +# # browser was closed. +# if IsBrowserClosed(browser): +# return False + +# py_browser = GetPyBrowser(browser, "OnBeforePluginLoad") +# py_plugin_info = CreatePyWebPluginInfo(plugin_info) +# clientCallback = GetGlobalClientCallback("OnBeforePluginLoad") +# if clientCallback: +# returnValue = clientCallback( +# browser=py_browser, +# mime_type=CefToPyString(mime_type), +# plugin_url=CefToPyString(plugin_url), +# is_main_frame=bool(is_main_frame), +# top_origin_url=CefToPyString(top_origin_url), +# plugin_info=py_plugin_info) +# if returnValue: +# plugin_policy[0] = cef_types.PLUGIN_POLICY_DISABLE +# return bool(returnValue) +# else: +# return False +# except: +# (exc_type, exc_value, exc_trace) = sys.exc_info() +# sys.excepthook(exc_type, exc_value, exc_trace) cdef public cpp_bool RequestHandler_OnCertificateError( int certError, const CefString& cefRequestUrl, - CefRefPtr[CefRequestCallback] cefCertCallback + CefRefPtr[CefCallback] cefCertCallback ) except * with gil: cdef py_bool returnValue cdef object clientCallback @@ -515,73 +518,73 @@ cdef public void RequestHandler_OnPluginCrashed( sys.excepthook(exc_type, exc_value, exc_trace) -cdef public cpp_bool RequestHandler_CanGetCookies( - CefRefPtr[CefBrowser] cef_browser, - CefRefPtr[CefFrame] cef_frame, - CefRefPtr[CefRequest] cef_request - ) except * with gil: - cdef PyBrowser browser - cdef PyFrame frame - cdef PyRequest request - cdef object callback - cdef py_bool retval - try: - # Issue #455: CefRequestHandler callbacks still executed after - # browser was closed. - if IsBrowserClosed(cef_browser): - return False - - browser = GetPyBrowser(cef_browser, "CanGetCookies") - frame = GetPyFrame(cef_frame) - request = CreatePyRequest(cef_request) - callback = browser.GetClientCallback("CanGetCookies") - if callback: - retval = callback( - browser=browser, - frame=frame, - request=request) - return bool(retval) - else: - # Return True by default - return True - except: - (exc_type, exc_value, exc_trace) = sys.exc_info() - sys.excepthook(exc_type, exc_value, exc_trace) - - -cdef public cpp_bool RequestHandler_CanSetCookie( - CefRefPtr[CefBrowser] cef_browser, - CefRefPtr[CefFrame] cef_frame, - CefRefPtr[CefRequest] cef_request, - const CefCookie& cef_cookie - ) except * with gil: - cdef PyBrowser browser - cdef PyFrame frame - cdef PyRequest request - cdef PyCookie cookie - cdef object callback - cdef py_bool retval - try: - # Issue #455: CefRequestHandler callbacks still executed after - # browser was closed. - if IsBrowserClosed(cef_browser): - return False - - browser = GetPyBrowser(cef_browser, "CanSetCookie") - frame = GetPyFrame(cef_frame) - request = CreatePyRequest(cef_request) - cookie = CreatePyCookie(cef_cookie) - callback = browser.GetClientCallback("CanSetCookie") - if callback: - retval = callback( - browser=browser, - frame=frame, - request=request, - cookie=cookie) - return bool(retval) - else: - # Return True by default - return True - except: - (exc_type, exc_value, exc_trace) = sys.exc_info() - sys.excepthook(exc_type, exc_value, exc_trace) +# cdef public cpp_bool RequestHandler_CanGetCookies( +# CefRefPtr[CefBrowser] cef_browser, +# CefRefPtr[CefFrame] cef_frame, +# CefRefPtr[CefRequest] cef_request +# ) except * with gil: +# cdef PyBrowser browser +# cdef PyFrame frame +# cdef PyRequest request +# cdef object callback +# cdef py_bool retval +# try: +# # Issue #455: CefRequestHandler callbacks still executed after +# # browser was closed. +# if IsBrowserClosed(cef_browser): +# return False + +# browser = GetPyBrowser(cef_browser, "CanGetCookies") +# frame = GetPyFrame(cef_frame) +# request = CreatePyRequest(cef_request) +# callback = browser.GetClientCallback("CanGetCookies") +# if callback: +# retval = callback( +# browser=browser, +# frame=frame, +# request=request) +# return bool(retval) +# else: +# # Return True by default +# return True +# except: +# (exc_type, exc_value, exc_trace) = sys.exc_info() +# sys.excepthook(exc_type, exc_value, exc_trace) + + +# cdef public cpp_bool RequestHandler_CanSetCookie( +# CefRefPtr[CefBrowser] cef_browser, +# CefRefPtr[CefFrame] cef_frame, +# CefRefPtr[CefRequest] cef_request, +# const CefCookie& cef_cookie +# ) except * with gil: +# cdef PyBrowser browser +# cdef PyFrame frame +# cdef PyRequest request +# cdef PyCookie cookie +# cdef object callback +# cdef py_bool retval +# try: +# # Issue #455: CefRequestHandler callbacks still executed after +# # browser was closed. +# if IsBrowserClosed(cef_browser): +# return False + +# browser = GetPyBrowser(cef_browser, "CanSetCookie") +# frame = GetPyFrame(cef_frame) +# request = CreatePyRequest(cef_request) +# cookie = CreatePyCookie(cef_cookie) +# callback = browser.GetClientCallback("CanSetCookie") +# if callback: +# retval = callback( +# browser=browser, +# frame=frame, +# request=request, +# cookie=cookie) +# return bool(retval) +# else: +# # Return True by default +# return True +# except: +# (exc_type, exc_value, exc_trace) = sys.exc_info() +# sys.excepthook(exc_type, exc_value, exc_trace) diff --git a/src/include.old/base/cef_atomic_ref_count.h b/src/include.old/base/cef_atomic_ref_count.h new file mode 100644 index 000000000..4d6777970 --- /dev/null +++ b/src/include.old/base/cef_atomic_ref_count.h @@ -0,0 +1,165 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This is a low level implementation of atomic semantics for reference +// counting. Please use cef_ref_counted.h directly instead. +// +// The Chromium implementation includes annotations to avoid some false +// positives when using data race detection tools. Annotations are not +// currently supported by the CEF implementation. + +#ifndef CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ +#define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/atomic_ref_count.h" + +// Used when declaring a base::AtomicRefCount value. This is an object type with +// Chromium headers. +#define ATOMIC_DECLARATION (0) + +// Maintaining compatibility with AtompicRefCount* functions that were removed +// from Chromium in http://crrev.com/ee96d561. +namespace base { + +// Increment a reference count by 1. +inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { + const_cast(ptr)->Increment(); +} + +// Decrement a reference count by 1 and return whether the result is non-zero. +// Insert barriers to ensure that state written before the reference count +// became zero will be visible to a thread that has just made the count zero. +inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { + return const_cast(ptr)->Decrement(); +} + +// Return whether the reference count is one. If the reference count is used +// in the conventional way, a refrerence count of 1 implies that the current +// thread owns the reference and no other thread shares it. This call performs +// the test for a reference count of one, and performs the memory barrier +// needed for the owning thread to act on the object, knowing that it has +// exclusive access to the object. +inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { + return const_cast(ptr)->IsOne(); +} + +// Return whether the reference count is zero. With conventional object +// referencing counting, the object will be destroyed, so the reference count +// should never be zero. Hence this is generally used for a debug check. +inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { + return const_cast(ptr)->IsZero(); +} + +} // namespace base + +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_atomicops.h" + +// Annotations are not currently supported. +#define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ +#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */ + +// Used when declaring a base::AtomicRefCount value. This is an integer/ptr type +// with CEF headers. +#define ATOMIC_DECLARATION = 0 + +namespace base { + +typedef subtle::Atomic32 AtomicRefCount; + +// Increment a reference count by "increment", which must exceed 0. +inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr, + AtomicRefCount increment) { + subtle::NoBarrier_AtomicIncrement(ptr, increment); +} + +// Decrement a reference count by "decrement", which must exceed 0, +// and return whether the result is non-zero. +// Insert barriers to ensure that state written before the reference count +// became zero will be visible to a thread that has just made the count zero. +inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr, + AtomicRefCount decrement) { + ANNOTATE_HAPPENS_BEFORE(ptr); + bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0); + if (!res) { + ANNOTATE_HAPPENS_AFTER(ptr); + } + return res; +} + +// Increment a reference count by 1. +inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { + base::AtomicRefCountIncN(ptr, 1); +} + +// Decrement a reference count by 1 and return whether the result is non-zero. +// Insert barriers to ensure that state written before the reference count +// became zero will be visible to a thread that has just made the count zero. +inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { + return base::AtomicRefCountDecN(ptr, 1); +} + +// Return whether the reference count is one. If the reference count is used +// in the conventional way, a refrerence count of 1 implies that the current +// thread owns the reference and no other thread shares it. This call performs +// the test for a reference count of one, and performs the memory barrier +// needed for the owning thread to act on the object, knowing that it has +// exclusive access to the object. +inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { + bool res = (subtle::Acquire_Load(ptr) == 1); + if (res) { + ANNOTATE_HAPPENS_AFTER(ptr); + } + return res; +} + +// Return whether the reference count is zero. With conventional object +// referencing counting, the object will be destroyed, so the reference count +// should never be zero. Hence this is generally used for a debug check. +inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { + bool res = (subtle::Acquire_Load(ptr) == 0); + if (res) { + ANNOTATE_HAPPENS_AFTER(ptr); + } + return res; +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ diff --git a/src/include/base/cef_atomicops.h b/src/include.old/base/cef_atomicops.h similarity index 100% rename from src/include/base/cef_atomicops.h rename to src/include.old/base/cef_atomicops.h diff --git a/src/include.old/base/cef_basictypes.h b/src/include.old/base/cef_basictypes.h new file mode 100644 index 000000000..e38f4f729 --- /dev/null +++ b/src/include.old/base/cef_basictypes.h @@ -0,0 +1,87 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ +#define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ +#pragma once + +#include // For UINT_MAX +#include // For size_t + +#include "include/base/cef_build.h" + +// The NSPR system headers define 64-bit as |long| when possible, except on +// Mac OS X. In order to not have typedef mismatches, we do the same on LP64. +// +// On Mac OS X, |long long| is used for 64-bit types for compatibility with +// format macros even in the LP64 model. +#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) +typedef long int64; +typedef unsigned long uint64; +#else +typedef long long int64; +typedef unsigned long long uint64; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _INT32 +#define _INT32 +typedef int int32; +#endif + +// TODO: Remove these type guards. These are to avoid conflicts with +// obsolete/protypes.h in the Gecko SDK. +#ifndef _UINT32 +#define _UINT32 +typedef unsigned int uint32; +#endif + +#ifndef _INT16 +#define _INT16 +typedef short int16; +#endif + +#ifndef _UINT16 +#define _UINT16 +typedef unsigned short uint16; +#endif + +// UTF-16 character type. +// This should be kept synchronized with base/strings/string16.h +#ifndef char16 +#if defined(WCHAR_T_IS_UTF16) +typedef wchar_t char16; +#elif defined(WCHAR_T_IS_UTF32) +typedef unsigned short char16; +#endif +#endif + +#endif // CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ diff --git a/src/include.old/base/cef_bind.h b/src/include.old/base/cef_bind.h new file mode 100644 index 000000000..77c9c5573 --- /dev/null +++ b/src/include.old/base/cef_bind.h @@ -0,0 +1,575 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_BIND_H_ +#define CEF_INCLUDE_BASE_CEF_BIND_H_ +#pragma once + +#if defined(BASE_BIND_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/bind.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/internal/cef_bind_internal.h" +#include "include/base/internal/cef_callback_internal.h" + +// ----------------------------------------------------------------------------- +// Usage documentation +// ----------------------------------------------------------------------------- +// +// See base/cef_callback.h for documentation. +// +// +// ----------------------------------------------------------------------------- +// Implementation notes +// ----------------------------------------------------------------------------- +// +// If you're reading the implementation, before proceeding further, you should +// read the top comment of base/bind_internal.h for a definition of common +// terms and concepts. +// +// RETURN TYPES +// +// Though Bind()'s result is meant to be stored in a Callback<> type, it +// cannot actually return the exact type without requiring a large amount +// of extra template specializations. The problem is that in order to +// discern the correct specialization of Callback<>, Bind would need to +// unwrap the function signature to determine the signature's arity, and +// whether or not it is a method. +// +// Each unique combination of (arity, function_type, num_prebound) where +// function_type is one of {function, method, const_method} would require +// one specialization. We eventually have to do a similar number of +// specializations anyways in the implementation (see the Invoker<>, +// classes). However, it is avoidable in Bind if we return the result +// via an indirection like we do below. +// +// TODO(ajwong): We might be able to avoid this now, but need to test. +// +// It is possible to move most of the COMPILE_ASSERT asserts into BindState<>, +// but it feels a little nicer to have the asserts here so people do not +// need to crack open bind_internal.h. On the other hand, it makes Bind() +// harder to read. + +namespace base { + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void()>::UnboundRunType> +Bind(Functor functor) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + typedef cef_internal::BindState BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor))); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1, const P2& p2) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p5_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback( + new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p5_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p6_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback(new BindState( + cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6)); +} + +template +base::Callback::RunnableType, + typename cef_internal::FunctorTraits::RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)>:: + UnboundRunType> +Bind(Functor functor, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6, + const P7& p7) { + // Typedefs for how to store and run the functor. + typedef + typename cef_internal::FunctorTraits::RunnableType RunnableType; + typedef typename cef_internal::FunctorTraits::RunType RunType; + + // Use RunnableType::RunType instead of RunType above because our + // checks should below for bound references need to know what the actual + // functor is going to interpret the argument as. + typedef cef_internal::FunctionTraits + BoundFunctorTraits; + + // Do not allow binding a non-const reference parameter. Non-const reference + // parameters are disallowed by the Google style guide. Also, binding a + // non-const reference parameter can make for subtle bugs because the + // invoked function will receive a reference to the stored copy of the + // argument and not the original. + COMPILE_ASSERT( + !(is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value || + is_non_const_reference::value), + do_not_bind_functions_with_nonconst_ref); + + // For methods, we need to be careful for parameter 1. We do not require + // a scoped_refptr because BindState<> itself takes care of AddRef() for + // methods. We also disallow binding of an array as the method's target + // object. + COMPILE_ASSERT(cef_internal::HasIsMethodTag::value || + !cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p1_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::HasIsMethodTag::value || + !is_array::value, + first_bound_argument_to_method_cannot_be_array); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p2_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p3_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p4_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p5_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p6_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr::value, + p7_is_refcounted_type_and_needs_scoped_refptr); + typedef cef_internal::BindState< + RunnableType, RunType, + void(typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType, + typename cef_internal::CallbackParamTraits::StorageType)> + BindState; + + return Callback(new BindState( + cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, p7)); +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_BIND_H_ diff --git a/src/include/base/cef_bind_helpers.h b/src/include.old/base/cef_bind_helpers.h similarity index 100% rename from src/include/base/cef_bind_helpers.h rename to src/include.old/base/cef_bind_helpers.h diff --git a/src/include.old/base/cef_build.h b/src/include.old/base/cef_build.h new file mode 100644 index 000000000..1e2065ce3 --- /dev/null +++ b/src/include.old/base/cef_build.h @@ -0,0 +1,197 @@ +// Copyright (c) 2011 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_ +#define CEF_INCLUDE_BASE_CEF_BUILD_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/compiler_specific.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#if defined(_WIN32) +#ifndef OS_WIN +#define OS_WIN 1 +#endif +#elif defined(__APPLE__) +#ifndef OS_MACOSX +#define OS_MACOSX 1 +#endif +#elif defined(__linux__) +#ifndef OS_LINUX +#define OS_LINUX 1 +#endif +#else +#error Please add support for your platform in cef_build.h +#endif + +// For access to standard POSIXish features, use OS_POSIX instead of a +// more specific macro. +#if defined(OS_MACOSX) || defined(OS_LINUX) +#ifndef OS_POSIX +#define OS_POSIX 1 +#endif +#endif + +// Compiler detection. +#if defined(__GNUC__) +#ifndef COMPILER_GCC +#define COMPILER_GCC 1 +#endif +#elif defined(_MSC_VER) +#ifndef COMPILER_MSVC +#define COMPILER_MSVC 1 +#endif +#else +#error Please add support for your compiler in cef_build.h +#endif + +// Processor architecture detection. For more info on what's defined, see: +// http://msdn.microsoft.com/en-us/library/b0084kay.aspx +// http://www.agner.org/optimize/calling_conventions.pdf +// or with gcc, run: "echo | gcc -E -dM -" +#if defined(_M_X64) || defined(__x86_64__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86_64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(_M_IX86) || defined(__i386__) +#define ARCH_CPU_X86_FAMILY 1 +#define ARCH_CPU_X86 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__ARMEL__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARMEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__aarch64__) +#define ARCH_CPU_ARM_FAMILY 1 +#define ARCH_CPU_ARM64 1 +#define ARCH_CPU_64_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__pnacl__) +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#elif defined(__MIPSEL__) +#define ARCH_CPU_MIPS_FAMILY 1 +#define ARCH_CPU_MIPSEL 1 +#define ARCH_CPU_32_BITS 1 +#define ARCH_CPU_LITTLE_ENDIAN 1 +#else +#error Please add support for your architecture in cef_build.h +#endif + +// Type detection for wchar_t. +#if defined(OS_WIN) +#define WCHAR_T_IS_UTF16 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) +#define WCHAR_T_IS_UTF32 +#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \ + (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) +// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to +// compile in this mode (in particular, Chrome doesn't). This is intended for +// other projects using base who manage their own dependencies and make sure +// short wchar works for them. +#define WCHAR_T_IS_UTF16 +#else +#error Please add support for your compiler in cef_build.h +#endif + +// Annotate a function indicating the caller must examine the return value. +// Use like: +// int foo() WARN_UNUSED_RESULT; +// To explicitly ignore a result, see |ignore_result()| in . +#ifndef WARN_UNUSED_RESULT +#if defined(COMPILER_GCC) +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define WARN_UNUSED_RESULT +#endif +#endif // WARN_UNUSED_RESULT + +// Annotate a typedef or function indicating it's ok if it's not used. +// Use like: +// typedef Foo Bar ALLOW_UNUSED_TYPE; +#ifndef ALLOW_UNUSED_TYPE +#if defined(COMPILER_GCC) +#define ALLOW_UNUSED_TYPE __attribute__((unused)) +#else +#define ALLOW_UNUSED_TYPE +#endif +#endif // ALLOW_UNUSED_TYPE + +// Annotate a variable indicating it's ok if the variable is not used. +// (Typically used to silence a compiler warning when the assignment +// is important for some other reason.) +// Use like: +// int x = ...; +// ALLOW_UNUSED_LOCAL(x); +#ifndef ALLOW_UNUSED_LOCAL +#define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 +#endif + +#endif // !USING_CHROMIUM_INCLUDES + +// Annotate a virtual method indicating it must be overriding a virtual method +// in the parent class. +// Use like: +// void foo() OVERRIDE; +// NOTE: This define should only be used in classes exposed to the client since +// C++11 support may not be enabled in client applications. CEF internal classes +// should use the `override` keyword directly. +#ifndef OVERRIDE +#if defined(__clang__) +#define OVERRIDE override +#elif defined(COMPILER_MSVC) && _MSC_VER >= 1600 +// Visual Studio 2010 and later support override. +#define OVERRIDE override +#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 +// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. +#define OVERRIDE override +#else +#define OVERRIDE +#endif +#endif // OVERRIDE + +// Check for C++11 template alias support which was added in VS2013 and GCC4.7. +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf +#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \ + (defined(__GNUC__) && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700)) +#define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT +#endif + +#endif // CEF_INCLUDE_BASE_CEF_BUILD_H_ diff --git a/src/include.old/base/cef_callback.h b/src/include.old/base/cef_callback.h new file mode 100644 index 000000000..16e238a97 --- /dev/null +++ b/src/include.old/base/cef_callback.h @@ -0,0 +1,801 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_H_ +#pragma once + +#if defined(BASE_CALLBACK_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_callback_forward.h" +#include "include/base/cef_template_util.h" +#include "include/base/internal/cef_callback_internal.h" + +// NOTE: Header files that do not require the full definition of Callback or +// Closure should #include "base/cef_callback_forward.h" instead of this file. + +// ----------------------------------------------------------------------------- +// Introduction +// ----------------------------------------------------------------------------- +// +// The templated Callback class is a generalized function object. Together +// with the Bind() function in bind.h, they provide a type-safe method for +// performing partial application of functions. +// +// Partial application (or "currying") is the process of binding a subset of +// a function's arguments to produce another function that takes fewer +// arguments. This can be used to pass around a unit of delayed execution, +// much like lexical closures are used in other languages. For example, it +// is used in Chromium code to schedule tasks on different MessageLoops. +// +// A callback with no unbound input parameters (base::Callback) +// is called a base::Closure. Note that this is NOT the same as what other +// languages refer to as a closure -- it does not retain a reference to its +// enclosing environment. +// +// MEMORY MANAGEMENT AND PASSING +// +// The Callback objects themselves should be passed by const-reference, and +// stored by copy. They internally store their state via a refcounted class +// and thus do not need to be deleted. +// +// The reason to pass via a const-reference is to avoid unnecessary +// AddRef/Release pairs to the internal state. +// +// +// ----------------------------------------------------------------------------- +// Quick reference for basic stuff +// ----------------------------------------------------------------------------- +// +// BINDING A BARE FUNCTION +// +// int Return5() { return 5; } +// base::Callback func_cb = base::Bind(&Return5); +// LOG(INFO) << func_cb.Run(); // Prints 5. +// +// BINDING A CLASS METHOD +// +// The first argument to bind is the member function to call, the second is +// the object on which to call it. +// +// class Ref : public base::RefCountedThreadSafe { +// public: +// int Foo() { return 3; } +// void PrintBye() { LOG(INFO) << "bye."; } +// }; +// scoped_refptr ref = new Ref(); +// base::Callback ref_cb = base::Bind(&Ref::Foo, ref); +// LOG(INFO) << ref_cb.Run(); // Prints out 3. +// +// By default the object must support RefCounted or you will get a compiler +// error. If you're passing between threads, be sure it's +// RefCountedThreadSafe! See "Advanced binding of member functions" below if +// you don't want to use reference counting. +// +// RUNNING A CALLBACK +// +// Callbacks can be run with their "Run" method, which has the same +// signature as the template argument to the callback. +// +// void DoSomething(const base::Callback& callback) { +// callback.Run(5, "hello"); +// } +// +// Callbacks can be run more than once (they don't get deleted or marked when +// run). However, this precludes using base::Passed (see below). +// +// void DoSomething(const base::Callback& callback) { +// double myresult = callback.Run(3.14159); +// myresult += callback.Run(2.71828); +// } +// +// PASSING UNBOUND INPUT PARAMETERS +// +// Unbound parameters are specified at the time a callback is Run(). They are +// specified in the Callback template type: +// +// void MyFunc(int i, const std::string& str) {} +// base::Callback cb = base::Bind(&MyFunc); +// cb.Run(23, "hello, world"); +// +// PASSING BOUND INPUT PARAMETERS +// +// Bound parameters are specified when you create thee callback as arguments +// to Bind(). They will be passed to the function and the Run()ner of the +// callback doesn't see those values or even know that the function it's +// calling. +// +// void MyFunc(int i, const std::string& str) {} +// base::Callback cb = base::Bind(&MyFunc, 23, "hello world"); +// cb.Run(); +// +// A callback with no unbound input parameters (base::Callback) +// is called a base::Closure. So we could have also written: +// +// base::Closure cb = base::Bind(&MyFunc, 23, "hello world"); +// +// When calling member functions, bound parameters just go after the object +// pointer. +// +// base::Closure cb = base::Bind(&MyClass::MyFunc, this, 23, "hello world"); +// +// PARTIAL BINDING OF PARAMETERS +// +// You can specify some parameters when you create the callback, and specify +// the rest when you execute the callback. +// +// void MyFunc(int i, const std::string& str) {} +// base::Callback cb = base::Bind(&MyFunc, 23); +// cb.Run("hello world"); +// +// When calling a function bound parameters are first, followed by unbound +// parameters. +// +// +// ----------------------------------------------------------------------------- +// Quick reference for advanced binding +// ----------------------------------------------------------------------------- +// +// BINDING A CLASS METHOD WITH WEAK POINTERS +// +// base::Bind(&MyClass::Foo, GetWeakPtr()); +// +// The callback will not be run if the object has already been destroyed. +// DANGER: weak pointers are not threadsafe, so don't use this +// when passing between threads! +// +// BINDING A CLASS METHOD WITH MANUAL LIFETIME MANAGEMENT +// +// base::Bind(&MyClass::Foo, base::Unretained(this)); +// +// This disables all lifetime management on the object. You're responsible +// for making sure the object is alive at the time of the call. You break it, +// you own it! +// +// BINDING A CLASS METHOD AND HAVING THE CALLBACK OWN THE CLASS +// +// MyClass* myclass = new MyClass; +// base::Bind(&MyClass::Foo, base::Owned(myclass)); +// +// The object will be deleted when the callback is destroyed, even if it's +// not run (like if you post a task during shutdown). Potentially useful for +// "fire and forget" cases. +// +// IGNORING RETURN VALUES +// +// Sometimes you want to call a function that returns a value in a callback +// that doesn't expect a return value. +// +// int DoSomething(int arg) { cout << arg << endl; } +// base::Callback) cb = +// base::Bind(base::IgnoreResult(&DoSomething)); +// +// +// ----------------------------------------------------------------------------- +// Quick reference for binding parameters to Bind() +// ----------------------------------------------------------------------------- +// +// Bound parameters are specified as arguments to Bind() and are passed to the +// function. A callback with no parameters or no unbound parameters is called a +// Closure (base::Callback and base::Closure are the same thing). +// +// PASSING PARAMETERS OWNED BY THE CALLBACK +// +// void Foo(int* arg) { cout << *arg << endl; } +// int* pn = new int(1); +// base::Closure foo_callback = base::Bind(&foo, base::Owned(pn)); +// +// The parameter will be deleted when the callback is destroyed, even if it's +// not run (like if you post a task during shutdown). +// +// PASSING PARAMETERS AS A scoped_ptr +// +// void TakesOwnership(scoped_ptr arg) {} +// scoped_ptr f(new Foo); +// // f becomes null during the following call. +// base::Closure cb = base::Bind(&TakesOwnership, base::Passed(&f)); +// +// Ownership of the parameter will be with the callback until the it is run, +// when ownership is passed to the callback function. This means the callback +// can only be run once. If the callback is never run, it will delete the +// object when it's destroyed. +// +// PASSING PARAMETERS AS A scoped_refptr +// +// void TakesOneRef(scoped_refptr arg) {} +// scoped_refptr f(new Foo) +// base::Closure cb = base::Bind(&TakesOneRef, f); +// +// This should "just work." The closure will take a reference as long as it +// is alive, and another reference will be taken for the called function. +// +// PASSING PARAMETERS BY REFERENCE +// +// Const references are *copied* unless ConstRef is used. Example: +// +// void foo(const int& arg) { printf("%d %p\n", arg, &arg); } +// int n = 1; +// base::Closure has_copy = base::Bind(&foo, n); +// base::Closure has_ref = base::Bind(&foo, base::ConstRef(n)); +// n = 2; +// foo(n); // Prints "2 0xaaaaaaaaaaaa" +// has_copy.Run(); // Prints "1 0xbbbbbbbbbbbb" +// has_ref.Run(); // Prints "2 0xaaaaaaaaaaaa" +// +// Normally parameters are copied in the closure. DANGER: ConstRef stores a +// const reference instead, referencing the original parameter. This means +// that you must ensure the object outlives the callback! +// +// +// ----------------------------------------------------------------------------- +// Implementation notes +// ----------------------------------------------------------------------------- +// +// WHERE IS THIS DESIGN FROM: +// +// The design Callback and Bind is heavily influenced by C++'s +// tr1::function/tr1::bind, and by the "Google Callback" system used inside +// Google. +// +// +// HOW THE IMPLEMENTATION WORKS: +// +// There are three main components to the system: +// 1) The Callback classes. +// 2) The Bind() functions. +// 3) The arguments wrappers (e.g., Unretained() and ConstRef()). +// +// The Callback classes represent a generic function pointer. Internally, +// it stores a refcounted piece of state that represents the target function +// and all its bound parameters. Each Callback specialization has a templated +// constructor that takes an BindState<>*. In the context of the constructor, +// the static type of this BindState<> pointer uniquely identifies the +// function it is representing, all its bound parameters, and a Run() method +// that is capable of invoking the target. +// +// Callback's constructor takes the BindState<>* that has the full static type +// and erases the target function type as well as the types of the bound +// parameters. It does this by storing a pointer to the specific Run() +// function, and upcasting the state of BindState<>* to a +// BindStateBase*. This is safe as long as this BindStateBase pointer +// is only used with the stored Run() pointer. +// +// To BindState<> objects are created inside the Bind() functions. +// These functions, along with a set of internal templates, are responsible for +// +// - Unwrapping the function signature into return type, and parameters +// - Determining the number of parameters that are bound +// - Creating the BindState storing the bound parameters +// - Performing compile-time asserts to avoid error-prone behavior +// - Returning an Callback<> with an arity matching the number of unbound +// parameters and that knows the correct refcounting semantics for the +// target object if we are binding a method. +// +// The Bind functions do the above using type-inference, and template +// specializations. +// +// By default Bind() will store copies of all bound parameters, and attempt +// to refcount a target object if the function being bound is a class method. +// These copies are created even if the function takes parameters as const +// references. (Binding to non-const references is forbidden, see bind.h.) +// +// To change this behavior, we introduce a set of argument wrappers +// (e.g., Unretained(), and ConstRef()). These are simple container templates +// that are passed by value, and wrap a pointer to argument. See the +// file-level comment in base/bind_helpers.h for more info. +// +// These types are passed to the Unwrap() functions, and the MaybeRefcount() +// functions respectively to modify the behavior of Bind(). The Unwrap() +// and MaybeRefcount() functions change behavior by doing partial +// specialization based on whether or not a parameter is a wrapper type. +// +// ConstRef() is similar to tr1::cref. Unretained() is specific to Chromium. +// +// +// WHY NOT TR1 FUNCTION/BIND? +// +// Direct use of tr1::function and tr1::bind was considered, but ultimately +// rejected because of the number of copy constructors invocations involved +// in the binding of arguments during construction, and the forwarding of +// arguments during invocation. These copies will no longer be an issue in +// C++0x because C++0x will support rvalue reference allowing for the compiler +// to avoid these copies. However, waiting for C++0x is not an option. +// +// Measured with valgrind on gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5), the +// tr1::bind call itself will invoke a non-trivial copy constructor three times +// for each bound parameter. Also, each when passing a tr1::function, each +// bound argument will be copied again. +// +// In addition to the copies taken at binding and invocation, copying a +// tr1::function causes a copy to be made of all the bound parameters and +// state. +// +// Furthermore, in Chromium, it is desirable for the Callback to take a +// reference on a target object when representing a class method call. This +// is not supported by tr1. +// +// Lastly, tr1::function and tr1::bind has a more general and flexible API. +// This includes things like argument reordering by use of +// tr1::bind::placeholder, support for non-const reference parameters, and some +// limited amount of subtyping of the tr1::function object (e.g., +// tr1::function is convertible to tr1::function). +// +// These are not features that are required in Chromium. Some of them, such as +// allowing for reference parameters, and subtyping of functions, may actually +// become a source of errors. Removing support for these features actually +// allows for a simpler implementation, and a terser Currying API. +// +// +// WHY NOT GOOGLE CALLBACKS? +// +// The Google callback system also does not support refcounting. Furthermore, +// its implementation has a number of strange edge cases with respect to type +// conversion of its arguments. In particular, the argument's constness must +// at times match exactly the function signature, or the type-inference might +// break. Given the above, writing a custom solution was easier. +// +// +// MISSING FUNCTIONALITY +// - Invoking the return of Bind. Bind(&foo).Run() does not work; +// - Binding arrays to functions that take a non-const pointer. +// Example: +// void Foo(const char* ptr); +// void Bar(char* ptr); +// Bind(&Foo, "test"); +// Bind(&Bar, "test"); // This fails because ptr is not const. + +namespace base { + +// First, we forward declare the Callback class template. This informs the +// compiler that the template only has 1 type parameter which is the function +// signature that the Callback is representing. +// +// After this, create template specializations for 0-7 parameters. Note that +// even though the template typelist grows, the specialization still +// only has one type: the function signature. +// +// If you are thinking of forward declaring Callback in your own header file, +// please include "base/callback_forward.h" instead. +template +class Callback; + +namespace cef_internal { +template +struct BindState; +} // namespace cef_internal + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run() const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get()); + } + + private: + typedef R (*PolymorphicInvoke)(cef_internal::BindStateBase*); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), + cef_internal::CallbackForward(a3)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f(bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), + cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4, A5); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5), + cef_internal::CallbackForward(a6)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +template +class Callback + : public cef_internal::CallbackBase { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); + + Callback() : CallbackBase(NULL) {} + + // Note that this constructor CANNOT be explicit, and that Bind() CANNOT + // return the exact Callback<> type. See base/bind.h for details. + template + Callback( + cef_internal::BindState* bind_state) + : CallbackBase(bind_state) { + // Force the assignment to a local variable of PolymorphicInvoke + // so the compiler will typecheck that the passed in Run() method has + // the correct type. + PolymorphicInvoke invoke_func = + &cef_internal::BindState::InvokerType::Run; + polymorphic_invoke_ = reinterpret_cast(invoke_func); + } + + bool Equals(const Callback& other) const { + return CallbackBase::Equals(other); + } + + R Run(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6, + typename cef_internal::CallbackParamTraits::ForwardType a7) const { + PolymorphicInvoke f = + reinterpret_cast(polymorphic_invoke_); + + return f( + bind_state_.get(), cef_internal::CallbackForward(a1), + cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3), + cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5), + cef_internal::CallbackForward(a6), cef_internal::CallbackForward(a7)); + } + + private: + typedef R (*PolymorphicInvoke)( + cef_internal::BindStateBase*, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType, + typename cef_internal::CallbackParamTraits::ForwardType); +}; + +// Syntactic sugar to make Callbacks easier to declare since it +// will be used in a lot of APIs with delayed execution. +typedef Callback Closure; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_H_ diff --git a/src/include.old/base/cef_callback_forward.h b/src/include.old/base/cef_callback_forward.h new file mode 100644 index 000000000..d604d7cfa --- /dev/null +++ b/src/include.old/base/cef_callback_forward.h @@ -0,0 +1,59 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ +#define INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ +#pragma once + +#if defined(BASE_CALLBACK_FORWARD_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_forward.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +namespace base { + +template +class Callback; + +typedef Callback Closure; + +} // namespace base + +#endif // !!USING_CHROMIUM_INCLUDES + +#endif // INCLUDE_BASE_CEF_CALLBACK_FORWARD_H_ diff --git a/src/include.old/base/cef_callback_helpers.h b/src/include.old/base/cef_callback_helpers.h new file mode 100644 index 000000000..ebe074a1f --- /dev/null +++ b/src/include.old/base/cef_callback_helpers.h @@ -0,0 +1,93 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This defines helpful methods for dealing with Callbacks. Because Callbacks +// are implemented using templates, with a class per callback signature, adding +// methods to Callback<> itself is unattractive (lots of extra code gets +// generated). Instead, consider adding methods here. +// +// ResetAndReturn(&cb) is like cb.Reset() but allows executing a callback (via a +// copy) after the original callback is Reset(). This can be handy if Run() +// reads/writes the variable holding the Callback. + +#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ +#pragma once + +#if defined(BASE_CALLBACK_HELPERS_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_helpers.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_macros.h" + +namespace base { + +template +base::Callback ResetAndReturn(base::Callback* cb) { + base::Callback ret(*cb); + cb->Reset(); + return ret; +} + +// ScopedClosureRunner is akin to scoped_ptr for Closures. It ensures that the +// Closure is executed and deleted no matter how the current scope exits. +class ScopedClosureRunner { + public: + ScopedClosureRunner(); + explicit ScopedClosureRunner(const Closure& closure); + ~ScopedClosureRunner(); + + void Reset(); + void Reset(const Closure& closure); + Closure Release() WARN_UNUSED_RESULT; + + private: + Closure closure_; + + DISALLOW_COPY_AND_ASSIGN(ScopedClosureRunner); +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_HELPERS_H_ diff --git a/src/include.old/base/cef_callback_list.h b/src/include.old/base/cef_callback_list.h new file mode 100644 index 000000000..e0ef3665b --- /dev/null +++ b/src/include.old/base/cef_callback_list.h @@ -0,0 +1,449 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2013 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_ +#define CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_ +#pragma once + +#if defined(BASE_CALLBACK_LIST_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/callback_list.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_scoped_ptr.h" +#include "include/base/internal/cef_callback_internal.h" + +// OVERVIEW: +// +// A container for a list of callbacks. Unlike a normal STL vector or list, +// this container can be modified during iteration without invalidating the +// iterator. It safely handles the case of a callback removing itself +// or another callback from the list while callbacks are being run. +// +// TYPICAL USAGE: +// +// class MyWidget { +// public: +// ... +// +// typedef base::Callback OnFooCallback; +// +// scoped_ptr::Subscription> +// RegisterCallback(const OnFooCallback& cb) { +// return callback_list_.Add(cb); +// } +// +// private: +// void NotifyFoo(const Foo& foo) { +// callback_list_.Notify(foo); +// } +// +// base::CallbackList callback_list_; +// +// DISALLOW_COPY_AND_ASSIGN(MyWidget); +// }; +// +// +// class MyWidgetListener { +// public: +// MyWidgetListener::MyWidgetListener() { +// foo_subscription_ = MyWidget::GetCurrent()->RegisterCallback( +// base::Bind(&MyWidgetListener::OnFoo, this))); +// } +// +// MyWidgetListener::~MyWidgetListener() { +// // Subscription gets deleted automatically and will deregister +// // the callback in the process. +// } +// +// private: +// void OnFoo(const Foo& foo) { +// // Do something. +// } +// +// scoped_ptr::Subscription> +// foo_subscription_; +// +// DISALLOW_COPY_AND_ASSIGN(MyWidgetListener); +// }; + +namespace base { + +namespace cef_internal { + +template +class CallbackListBase { + public: + class Subscription { + public: + Subscription(CallbackListBase* list, + typename std::list::iterator iter) + : list_(list), iter_(iter) {} + + ~Subscription() { + if (list_->active_iterator_count_) { + iter_->Reset(); + } else { + list_->callbacks_.erase(iter_); + if (!list_->removal_callback_.is_null()) + list_->removal_callback_.Run(); + } + } + + private: + CallbackListBase* list_; + typename std::list::iterator iter_; + + DISALLOW_COPY_AND_ASSIGN(Subscription); + }; + + // Add a callback to the list. The callback will remain registered until the + // returned Subscription is destroyed, which must occur before the + // CallbackList is destroyed. + scoped_ptr Add(const CallbackType& cb) WARN_UNUSED_RESULT { + DCHECK(!cb.is_null()); + return scoped_ptr( + new Subscription(this, callbacks_.insert(callbacks_.end(), cb))); + } + + // Sets a callback which will be run when a subscription list is changed. + void set_removal_callback(const Closure& callback) { + removal_callback_ = callback; + } + + // Returns true if there are no subscriptions. This is only valid to call when + // not looping through the list. + bool empty() { + DCHECK_EQ(0, active_iterator_count_); + return callbacks_.empty(); + } + + protected: + // An iterator class that can be used to access the list of callbacks. + class Iterator { + public: + explicit Iterator(CallbackListBase* list) + : list_(list), list_iter_(list_->callbacks_.begin()) { + ++list_->active_iterator_count_; + } + + Iterator(const Iterator& iter) + : list_(iter.list_), list_iter_(iter.list_iter_) { + ++list_->active_iterator_count_; + } + + ~Iterator() { + if (list_ && --list_->active_iterator_count_ == 0) { + list_->Compact(); + } + } + + CallbackType* GetNext() { + while ((list_iter_ != list_->callbacks_.end()) && list_iter_->is_null()) + ++list_iter_; + + CallbackType* cb = NULL; + if (list_iter_ != list_->callbacks_.end()) { + cb = &(*list_iter_); + ++list_iter_; + } + return cb; + } + + private: + CallbackListBase* list_; + typename std::list::iterator list_iter_; + }; + + CallbackListBase() : active_iterator_count_(0) {} + + ~CallbackListBase() { + DCHECK_EQ(0, active_iterator_count_); + DCHECK_EQ(0U, callbacks_.size()); + } + + // Returns an instance of a CallbackListBase::Iterator which can be used + // to run callbacks. + Iterator GetIterator() { return Iterator(this); } + + // Compact the list: remove any entries which were NULLed out during + // iteration. + void Compact() { + typename std::list::iterator it = callbacks_.begin(); + bool updated = false; + while (it != callbacks_.end()) { + if ((*it).is_null()) { + updated = true; + it = callbacks_.erase(it); + } else { + ++it; + } + + if (updated && !removal_callback_.is_null()) + removal_callback_.Run(); + } + } + + private: + std::list callbacks_; + int active_iterator_count_; + Closure removal_callback_; + + DISALLOW_COPY_AND_ASSIGN(CallbackListBase); +}; + +} // namespace cef_internal + +template +class CallbackList; + +template <> +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify() { + cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase< + Callback> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4, a5); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase< + Callback> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4, a5, a6); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +template +class CallbackList + : public cef_internal::CallbackListBase< + Callback> { + public: + typedef Callback CallbackType; + + CallbackList() {} + + void Notify(typename cef_internal::CallbackParamTraits::ForwardType a1, + typename cef_internal::CallbackParamTraits::ForwardType a2, + typename cef_internal::CallbackParamTraits::ForwardType a3, + typename cef_internal::CallbackParamTraits::ForwardType a4, + typename cef_internal::CallbackParamTraits::ForwardType a5, + typename cef_internal::CallbackParamTraits::ForwardType a6, + typename cef_internal::CallbackParamTraits::ForwardType a7) { + typename cef_internal::CallbackListBase::Iterator it = + this->GetIterator(); + CallbackType* cb; + while ((cb = it.GetNext()) != NULL) { + cb->Run(a1, a2, a3, a4, a5, a6, a7); + } + } + + private: + DISALLOW_COPY_AND_ASSIGN(CallbackList); +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CALLBACK_LIST_H_ diff --git a/src/include.old/base/cef_cancelable_callback.h b/src/include.old/base/cef_cancelable_callback.h new file mode 100644 index 000000000..febce3a32 --- /dev/null +++ b/src/include.old/base/cef_cancelable_callback.h @@ -0,0 +1,293 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// CancelableCallback is a wrapper around base::Callback that allows +// cancellation of a callback. CancelableCallback takes a reference on the +// wrapped callback until this object is destroyed or Reset()/Cancel() are +// called. +// +// NOTE: +// +// Calling CancelableCallback::Cancel() brings the object back to its natural, +// default-constructed state, i.e., CancelableCallback::callback() will return +// a null callback. +// +// THREAD-SAFETY: +// +// CancelableCallback objects must be created on, posted to, cancelled on, and +// destroyed on the same thread. +// +// +// EXAMPLE USAGE: +// +// In the following example, the test is verifying that RunIntensiveTest() +// Quit()s the message loop within 4 seconds. The cancelable callback is posted +// to the message loop, the intensive test runs, the message loop is run, +// then the callback is cancelled. +// +// void TimeoutCallback(const std::string& timeout_message) { +// FAIL() << timeout_message; +// MessageLoop::current()->QuitWhenIdle(); +// } +// +// CancelableClosure timeout(base::Bind(&TimeoutCallback, "Test timed out.")); +// MessageLoop::current()->PostDelayedTask(FROM_HERE, timeout.callback(), +// 4000) // 4 seconds to run. +// RunIntensiveTest(); +// MessageLoop::current()->Run(); +// timeout.Cancel(); // Hopefully this is hit before the timeout callback runs. +// + +#ifndef CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_ +#define CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_ +#pragma once + +#if defined(BASE_CANCELABLE_CALLBACK_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/cancelable_callback.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_bind.h" +#include "include/base/cef_build.h" +#include "include/base/cef_callback.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_weak_ptr.h" +#include "include/base/internal/cef_callback_internal.h" + +namespace base { + +template +class CancelableCallback; + +template <> +class CancelableCallback { + public: + CancelableCallback() : weak_factory_(this) {} + + // |callback| must not be null. + explicit CancelableCallback(const base::Callback& callback) + : weak_factory_(this), callback_(callback) { + DCHECK(!callback.is_null()); + InitializeForwarder(); + } + + ~CancelableCallback() {} + + // Cancels and drops the reference to the wrapped callback. + void Cancel() { + weak_factory_.InvalidateWeakPtrs(); + forwarder_.Reset(); + callback_.Reset(); + } + + // Returns true if the wrapped callback has been cancelled. + bool IsCancelled() const { return callback_.is_null(); } + + // Sets |callback| as the closure that may be cancelled. |callback| may not + // be null. Outstanding and any previously wrapped callbacks are cancelled. + void Reset(const base::Callback& callback) { + DCHECK(!callback.is_null()); + + // Outstanding tasks (e.g., posted to a message loop) must not be called. + Cancel(); + + // |forwarder_| is no longer valid after Cancel(), so re-bind. + InitializeForwarder(); + + callback_ = callback; + } + + // Returns a callback that can be disabled by calling Cancel(). + const base::Callback& callback() const { return forwarder_; } + + private: + void Forward() { callback_.Run(); } + + // Helper method to bind |forwarder_| using a weak pointer from + // |weak_factory_|. + void InitializeForwarder() { + forwarder_ = base::Bind(&CancelableCallback::Forward, + weak_factory_.GetWeakPtr()); + } + + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory> weak_factory_; + + // The wrapper closure. + base::Callback forwarder_; + + // The stored closure that may be cancelled. + base::Callback callback_; + + DISALLOW_COPY_AND_ASSIGN(CancelableCallback); +}; + +template +class CancelableCallback { + public: + CancelableCallback() : weak_factory_(this) {} + + // |callback| must not be null. + explicit CancelableCallback(const base::Callback& callback) + : weak_factory_(this), callback_(callback) { + DCHECK(!callback.is_null()); + InitializeForwarder(); + } + + ~CancelableCallback() {} + + // Cancels and drops the reference to the wrapped callback. + void Cancel() { + weak_factory_.InvalidateWeakPtrs(); + forwarder_.Reset(); + callback_.Reset(); + } + + // Returns true if the wrapped callback has been cancelled. + bool IsCancelled() const { return callback_.is_null(); } + + // Sets |callback| as the closure that may be cancelled. |callback| may not + // be null. Outstanding and any previously wrapped callbacks are cancelled. + void Reset(const base::Callback& callback) { + DCHECK(!callback.is_null()); + + // Outstanding tasks (e.g., posted to a message loop) must not be called. + Cancel(); + + // |forwarder_| is no longer valid after Cancel(), so re-bind. + InitializeForwarder(); + + callback_ = callback; + } + + // Returns a callback that can be disabled by calling Cancel(). + const base::Callback& callback() const { return forwarder_; } + + private: + void Forward(A1 a1) const { callback_.Run(a1); } + + // Helper method to bind |forwarder_| using a weak pointer from + // |weak_factory_|. + void InitializeForwarder() { + forwarder_ = base::Bind(&CancelableCallback::Forward, + weak_factory_.GetWeakPtr()); + } + + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory> weak_factory_; + + // The wrapper closure. + base::Callback forwarder_; + + // The stored closure that may be cancelled. + base::Callback callback_; + + DISALLOW_COPY_AND_ASSIGN(CancelableCallback); +}; + +template +class CancelableCallback { + public: + CancelableCallback() : weak_factory_(this) {} + + // |callback| must not be null. + explicit CancelableCallback(const base::Callback& callback) + : weak_factory_(this), callback_(callback) { + DCHECK(!callback.is_null()); + InitializeForwarder(); + } + + ~CancelableCallback() {} + + // Cancels and drops the reference to the wrapped callback. + void Cancel() { + weak_factory_.InvalidateWeakPtrs(); + forwarder_.Reset(); + callback_.Reset(); + } + + // Returns true if the wrapped callback has been cancelled. + bool IsCancelled() const { return callback_.is_null(); } + + // Sets |callback| as the closure that may be cancelled. |callback| may not + // be null. Outstanding and any previously wrapped callbacks are cancelled. + void Reset(const base::Callback& callback) { + DCHECK(!callback.is_null()); + + // Outstanding tasks (e.g., posted to a message loop) must not be called. + Cancel(); + + // |forwarder_| is no longer valid after Cancel(), so re-bind. + InitializeForwarder(); + + callback_ = callback; + } + + // Returns a callback that can be disabled by calling Cancel(). + const base::Callback& callback() const { return forwarder_; } + + private: + void Forward(A1 a1, A2 a2) const { callback_.Run(a1, a2); } + + // Helper method to bind |forwarder_| using a weak pointer from + // |weak_factory_|. + void InitializeForwarder() { + forwarder_ = base::Bind(&CancelableCallback::Forward, + weak_factory_.GetWeakPtr()); + } + + // Used to ensure Forward() is not run when this object is destroyed. + base::WeakPtrFactory> weak_factory_; + + // The wrapper closure. + base::Callback forwarder_; + + // The stored closure that may be cancelled. + base::Callback callback_; + + DISALLOW_COPY_AND_ASSIGN(CancelableCallback); +}; + +typedef CancelableCallback CancelableClosure; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_CANCELABLE_CALLBACK_H_ diff --git a/src/include.old/base/cef_lock.h b/src/include.old/base/cef_lock.h new file mode 100644 index 000000000..6909bd6f2 --- /dev/null +++ b/src/include.old/base/cef_lock.h @@ -0,0 +1,174 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_LOCK_H_ +#define CEF_INCLUDE_BASE_CEF_LOCK_H_ +#pragma once + +#if defined(BASE_SYNCHRONIZATION_LOCK_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/synchronization/lock.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_logging.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_platform_thread.h" +#include "include/base/internal/cef_lock_impl.h" + +namespace base { +namespace cef_internal { + +// A convenient wrapper for an OS specific critical section. The only real +// intelligence in this class is in debug mode for the support for the +// AssertAcquired() method. +class Lock { + public: +#if !DCHECK_IS_ON() // Optimized wrapper implementation + Lock() : lock_() {} + ~Lock() {} + void Acquire() { lock_.Lock(); } + void Release() { lock_.Unlock(); } + + // If the lock is not held, take it and return true. If the lock is already + // held by another thread, immediately return false. This must not be called + // by a thread already holding the lock (what happens is undefined and an + // assertion may fail). + bool Try() { return lock_.Try(); } + + // Null implementation if not debug. + void AssertAcquired() const {} +#else + Lock(); + ~Lock(); + + // NOTE: Although windows critical sections support recursive locks, we do not + // allow this, and we will commonly fire a DCHECK() if a thread attempts to + // acquire the lock a second time (while already holding it). + void Acquire() { + lock_.Lock(); + CheckUnheldAndMark(); + } + void Release() { + CheckHeldAndUnmark(); + lock_.Unlock(); + } + + bool Try() { + bool rv = lock_.Try(); + if (rv) { + CheckUnheldAndMark(); + } + return rv; + } + + void AssertAcquired() const; +#endif // !DCHECK_IS_ON() + + private: +#if DCHECK_IS_ON() + // Members and routines taking care of locks assertions. + // Note that this checks for recursive locks and allows them + // if the variable is set. This is allowed by the underlying implementation + // on windows but not on Posix, so we're doing unneeded checks on Posix. + // It's worth it to share the code. + void CheckHeldAndUnmark(); + void CheckUnheldAndMark(); + + // All private data is implicitly protected by lock_. + // Be VERY careful to only access members under that lock. + base::PlatformThreadRef owning_thread_ref_; +#endif // DCHECK_IS_ON() + + // Platform specific underlying lock implementation. + LockImpl lock_; + + DISALLOW_COPY_AND_ASSIGN(Lock); +}; + +// A helper class that acquires the given Lock while the AutoLock is in scope. +class AutoLock { + public: + struct AlreadyAcquired {}; + + explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); } + + AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) { + lock_.AssertAcquired(); + } + + ~AutoLock() { + lock_.AssertAcquired(); + lock_.Release(); + } + + private: + Lock& lock_; + DISALLOW_COPY_AND_ASSIGN(AutoLock); +}; + +// AutoUnlock is a helper that will Release() the |lock| argument in the +// constructor, and re-Acquire() it in the destructor. +class AutoUnlock { + public: + explicit AutoUnlock(Lock& lock) : lock_(lock) { + // We require our caller to have the lock. + lock_.AssertAcquired(); + lock_.Release(); + } + + ~AutoUnlock() { lock_.Acquire(); } + + private: + Lock& lock_; + DISALLOW_COPY_AND_ASSIGN(AutoUnlock); +}; + +} // namespace cef_internal + +// Implement classes in the cef_internal namespace and then expose them to the +// base namespace. This avoids conflicts with the base.lib implementation when +// linking sandbox support on Windows. +using cef_internal::Lock; +using cef_internal::AutoLock; +using cef_internal::AutoUnlock; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_LOCK_H_ diff --git a/src/include.old/base/cef_logging.h b/src/include.old/base/cef_logging.h new file mode 100644 index 000000000..8d8bb889e --- /dev/null +++ b/src/include.old/base/cef_logging.h @@ -0,0 +1,760 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file are only available to applications that link +// against the libcef_dll_wrapper target. +// +// WARNING: Logging macros should not be used in the main/browser process before +// calling CefInitialize or in sub-processes before calling CefExecuteProcess. +// +// Instructions +// ------------ +// +// Make a bunch of macros for logging. The way to log things is to stream +// things to LOG(). E.g., +// +// LOG(INFO) << "Found " << num_cookies << " cookies"; +// +// You can also do conditional logging: +// +// LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// The CHECK(condition) macro is active in both debug and release builds and +// effectively performs a LOG(FATAL) which terminates the process and +// generates a crashdump unless a debugger is attached. +// +// There are also "debug mode" logging macros like the ones above: +// +// DLOG(INFO) << "Found cookies"; +// +// DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies"; +// +// All "debug mode" logging is compiled away to nothing for non-debug mode +// compiles. LOG_IF and development flags also work well together +// because the code can be compiled away sometimes. +// +// We also have +// +// LOG_ASSERT(assertion); +// DLOG_ASSERT(assertion); +// +// which is syntactic sugar for {,D}LOG_IF(FATAL, assert fails) << assertion; +// +// There are "verbose level" logging macros. They look like +// +// VLOG(1) << "I'm printed when you run the program with --v=1 or more"; +// VLOG(2) << "I'm printed when you run the program with --v=2 or more"; +// +// These always log at the INFO log level (when they log at all). +// The verbose logging can also be turned on module-by-module. For instance, +// --vmodule=profile=2,icon_loader=1,browser_*=3,*/chromeos/*=4 --v=0 +// will cause: +// a. VLOG(2) and lower messages to be printed from profile.{h,cc} +// b. VLOG(1) and lower messages to be printed from icon_loader.{h,cc} +// c. VLOG(3) and lower messages to be printed from files prefixed with +// "browser" +// d. VLOG(4) and lower messages to be printed from files under a +// "chromeos" directory. +// e. VLOG(0) and lower messages to be printed from elsewhere +// +// The wildcarding functionality shown by (c) supports both '*' (match +// 0 or more characters) and '?' (match any single character) +// wildcards. Any pattern containing a forward or backward slash will +// be tested against the whole pathname and not just the module. +// E.g., "*/foo/bar/*=2" would change the logging level for all code +// in source files under a "foo/bar" directory. +// +// There's also VLOG_IS_ON(n) "verbose level" condition macro. To be used as +// +// if (VLOG_IS_ON(2)) { +// // do some logging preparation and logging +// // that can't be accomplished with just VLOG(2) << ...; +// } +// +// There is also a VLOG_IF "verbose level" condition macro for sample +// cases, when some extra computation and preparation for logs is not +// needed. +// +// VLOG_IF(1, (size > 1024)) +// << "I'm printed when size is more than 1024 and when you run the " +// "program with --v=1 or more"; +// +// We also override the standard 'assert' to use 'DLOG_ASSERT'. +// +// Lastly, there is: +// +// PLOG(ERROR) << "Couldn't do foo"; +// DPLOG(ERROR) << "Couldn't do foo"; +// PLOG_IF(ERROR, cond) << "Couldn't do foo"; +// DPLOG_IF(ERROR, cond) << "Couldn't do foo"; +// PCHECK(condition) << "Couldn't do foo"; +// DPCHECK(condition) << "Couldn't do foo"; +// +// which append the last system error to the message in string form (taken from +// GetLastError() on Windows and errno on POSIX). +// +// The supported severity levels for macros that allow you to specify one +// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL. +// +// Very important: logging a message at the FATAL severity level causes +// the program to terminate (after the message is logged). +// +// There is the special severity of DFATAL, which logs FATAL in debug mode, +// ERROR in normal mode. +// + +#ifndef CEF_INCLUDE_BASE_CEF_LOGGING_H_ +#define CEF_INCLUDE_BASE_CEF_LOGGING_H_ +#pragma once + +#if defined(DCHECK) +// Do nothing if the macros provided by this header already exist. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. + +// Always define the DCHECK_IS_ON macro which is used from other CEF headers. +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON() 0 +#else +#define DCHECK_IS_ON() 1 +#endif + +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/logging.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include +#include +#include +#include + +#include "include/base/cef_build.h" +#include "include/base/cef_macros.h" +#include "include/internal/cef_logging_internal.h" + +namespace cef { +namespace logging { + +// Gets the current log level. +inline int GetMinLogLevel() { + return cef_get_min_log_level(); +} + +// Gets the current vlog level for the given file (usually taken from +// __FILE__). Note that |N| is the size *with* the null terminator. +template +int GetVlogLevel(const char (&file)[N]) { + return cef_get_vlog_level(file, N); +} + +typedef int LogSeverity; +const LogSeverity LOG_VERBOSE = -1; // This is level 1 verbosity +// Note: the log severities are used to index into the array of names, +// see log_severity_names. +const LogSeverity LOG_INFO = 0; +const LogSeverity LOG_WARNING = 1; +const LogSeverity LOG_ERROR = 2; +const LogSeverity LOG_FATAL = 3; +const LogSeverity LOG_NUM_SEVERITIES = 4; + +// LOG_DFATAL is LOG_FATAL in debug mode, ERROR in normal mode +#ifdef NDEBUG +const LogSeverity LOG_DFATAL = LOG_ERROR; +#else +const LogSeverity LOG_DFATAL = LOG_FATAL; +#endif + +// A few definitions of macros that don't generate much code. These are used +// by LOG() and LOG_IF, etc. Since these are used all over our code, it's +// better to have compact code for these operations. +#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL, \ + ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ + cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL, \ + ##__VA_ARGS__) + +#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage) +#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) +#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage) +#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage) +#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage) + +#if defined(OS_WIN) +// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets +// substituted with 0, and it expands to COMPACT_GOOGLE_LOG_0. To allow us +// to keep using this syntax, we define this macro to do the same thing +// as COMPACT_GOOGLE_LOG_ERROR, and also define ERROR the same way that +// the Windows SDK does for consistency. +#define ERROR 0 +#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR +// Needed for LOG_IS_ON(ERROR). +const LogSeverity LOG_0 = LOG_ERROR; +#endif + +// As special cases, we can assume that LOG_IS_ON(FATAL) always holds. Also, +// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will +// always fire if they fail. +#define LOG_IS_ON(severity) \ + ((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel()) + +// We can't do any caching tricks with VLOG_IS_ON() like the +// google-glog version since it requires GCC extensions. This means +// that using the v-logging functions in conjunction with --vmodule +// may be slow. +#define VLOG_IS_ON(verboselevel) \ + ((verboselevel) <= ::cef::logging::GetVlogLevel(__FILE__)) + +// Helper macro which avoids evaluating the arguments to a stream if +// the condition doesn't hold. +#define LAZY_STREAM(stream, condition) \ + !(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream) + +// We use the preprocessor's merging operator, "##", so that, e.g., +// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny +// subtle difference between ostream member streaming functions (e.g., +// ostream::operator<<(int) and ostream non-member streaming functions +// (e.g., ::operator<<(ostream&, string&): it turns out that it's +// impossible to stream something like a string directly to an unnamed +// ostream. We employ a neat hack by calling the stream() member +// function of LogMessage which seems to avoid the problem. +#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream() + +#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity)) +#define LOG_IF(severity, condition) \ + LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) + +#define SYSLOG(severity) LOG(severity) +#define SYSLOG_IF(severity, condition) LOG_IF(severity, condition) + +// The VLOG macros log with negative verbosities. +#define VLOG_STREAM(verbose_level) \ + cef::logging::LogMessage(__FILE__, __LINE__, -verbose_level).stream() + +#define VLOG(verbose_level) \ + LAZY_STREAM(VLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level)) + +#define VLOG_IF(verbose_level, condition) \ + LAZY_STREAM(VLOG_STREAM(verbose_level), \ + VLOG_IS_ON(verbose_level) && (condition)) + +#if defined(OS_WIN) +#define VPLOG_STREAM(verbose_level) \ + cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#elif defined(OS_POSIX) +#define VPLOG_STREAM(verbose_level) \ + cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#endif + +#define VPLOG(verbose_level) \ + LAZY_STREAM(VPLOG_STREAM(verbose_level), VLOG_IS_ON(verbose_level)) + +#define VPLOG_IF(verbose_level, condition) \ + LAZY_STREAM(VPLOG_STREAM(verbose_level), \ + VLOG_IS_ON(verbose_level) && (condition)) + +// TODO(akalin): Add more VLOG variants, e.g. VPLOG. + +#define LOG_ASSERT(condition) \ + LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " +#define SYSLOG_ASSERT(condition) \ + SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". " + +#if defined(OS_WIN) +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#elif defined(OS_POSIX) +#define PLOG_STREAM(severity) \ + COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \ + ::cef::logging::GetLastSystemErrorCode()) \ + .stream() +#endif + +#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) + +#define PLOG_IF(severity, condition) \ + LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) + +// The actual stream used isn't important. +#define EAT_STREAM_PARAMETERS \ + true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL) + +// CHECK dies with a fatal error if condition is not true. It is *not* +// controlled by NDEBUG, so the check will be executed regardless of +// compilation mode. +// +// We make sure CHECK et al. always evaluates their arguments, as +// doing CHECK(FunctionWithSideEffect()) is a common idiom. + +#define CHECK(condition) \ + LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \ + << "Check failed: " #condition ". " + +#define PCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \ + << "Check failed: " #condition ". " + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use CHECK_EQ et al below. +// +// TODO(akalin): Rewrite this so that constructs like if (...) +// CHECK_EQ(...) else { ... } work properly. +#define CHECK_OP(name, op, val1, val2) \ + if (std::string* _result = cef::logging::Check##name##Impl( \ + (val1), (val2), #val1 " " #op " " #val2)) \ + cef::logging::LogMessage(__FILE__, __LINE__, _result).stream() + +// Build the error message string. This is separate from the "Impl" +// function template because it is not performance critical and so can +// be out of line, while the "Impl" code should be inline. Caller +// takes ownership of the returned string. +template +std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { + std::ostringstream ss; + ss << names << " (" << v1 << " vs. " << v2 << ")"; + std::string* msg = new std::string(ss.str()); + return msg; +} + +// MSVC doesn't like complex extern templates and DLLs. +#if !defined(COMPILER_MSVC) +// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated +// in logging.cc. +extern template std::string* MakeCheckOpString(const int&, + const int&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned long&, + const unsigned long&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned long&, + const unsigned int&, + const char* names); +extern template std::string* MakeCheckOpString( + const unsigned int&, + const unsigned long&, + const char* names); +extern template std::string* MakeCheckOpString( + const std::string&, + const std::string&, + const char* name); +#endif + +// Helper functions for CHECK_OP macro. +// The (int, int) specialization works around the issue that the compiler +// will not instantiate the template version of the function on values of +// unnamed enum type - see comment below. +#define DEFINE_CHECK_OP_IMPL(name, op) \ + template \ + inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ + const char* names) { \ + if (v1 op v2) \ + return NULL; \ + else \ + return MakeCheckOpString(v1, v2, names); \ + } \ + inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ + if (v1 op v2) \ + return NULL; \ + else \ + return MakeCheckOpString(v1, v2, names); \ + } +DEFINE_CHECK_OP_IMPL(EQ, ==) +DEFINE_CHECK_OP_IMPL(NE, !=) +DEFINE_CHECK_OP_IMPL(LE, <=) +DEFINE_CHECK_OP_IMPL(LT, <) +DEFINE_CHECK_OP_IMPL(GE, >=) +DEFINE_CHECK_OP_IMPL(GT, >) +#undef DEFINE_CHECK_OP_IMPL + +#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) +#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) +#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) +#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2) +#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) +#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2) + +#if defined(NDEBUG) +#define ENABLE_DLOG 0 +#else +#define ENABLE_DLOG 1 +#endif + +#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) +#define DCHECK_IS_ON() 0 +#else +#define DCHECK_IS_ON() 1 +#endif + +// Definitions for DLOG et al. + +#if ENABLE_DLOG + +#define DLOG_IS_ON(severity) LOG_IS_ON(severity) +#define DLOG_IF(severity, condition) LOG_IF(severity, condition) +#define DLOG_ASSERT(condition) LOG_ASSERT(condition) +#define DPLOG_IF(severity, condition) PLOG_IF(severity, condition) +#define DVLOG_IF(verboselevel, condition) VLOG_IF(verboselevel, condition) +#define DVPLOG_IF(verboselevel, condition) VPLOG_IF(verboselevel, condition) + +#else // ENABLE_DLOG + +// If ENABLE_DLOG is off, we want to avoid emitting any references to +// |condition| (which may reference a variable defined only if NDEBUG +// is not defined). Contrast this with DCHECK et al., which has +// different behavior. + +#define DLOG_IS_ON(severity) false +#define DLOG_IF(severity, condition) EAT_STREAM_PARAMETERS +#define DLOG_ASSERT(condition) EAT_STREAM_PARAMETERS +#define DPLOG_IF(severity, condition) EAT_STREAM_PARAMETERS +#define DVLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS +#define DVPLOG_IF(verboselevel, condition) EAT_STREAM_PARAMETERS + +#endif // ENABLE_DLOG + +// DEBUG_MODE is for uses like +// if (DEBUG_MODE) foo.CheckThatFoo(); +// instead of +// #ifndef NDEBUG +// foo.CheckThatFoo(); +// #endif +// +// We tie its state to ENABLE_DLOG. +enum { DEBUG_MODE = ENABLE_DLOG }; + +#undef ENABLE_DLOG + +#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity)) + +#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity)) + +#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) + +#define DVPLOG(verboselevel) DVPLOG_IF(verboselevel, VLOG_IS_ON(verboselevel)) + +// Definitions for DCHECK et al. + +#if DCHECK_IS_ON() + +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL +const LogSeverity LOG_DCHECK = LOG_FATAL; + +#else // DCHECK_IS_ON() + +// These are just dummy values. +#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \ + COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__) +#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO +const LogSeverity LOG_DCHECK = LOG_INFO; + +#endif // DCHECK_IS_ON() + +// DCHECK et al. make sure to reference |condition| regardless of +// whether DCHECKs are enabled; this is so that we don't get unused +// variable warnings if the only use of a variable is in a DCHECK. +// This behavior is different from DLOG_IF et al. + +#define DCHECK(condition) \ + LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ + << "Check failed: " #condition ". " + +#define DPCHECK(condition) \ + LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \ + << "Check failed: " #condition ". " + +// Helper macro for binary operators. +// Don't use this macro directly in your code, use DCHECK_EQ et al below. +#define DCHECK_OP(name, op, val1, val2) \ + if (DCHECK_IS_ON()) \ + if (std::string* _result = cef::logging::Check##name##Impl( \ + (val1), (val2), #val1 " " #op " " #val2)) \ + cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \ + _result) \ + .stream() + +// Equality/Inequality checks - compare two values, and log a +// LOG_DCHECK message including the two values when the result is not +// as expected. The values must have operator<<(ostream, ...) +// defined. +// +// You may append to the error message like so: +// DCHECK_NE(1, 2) << ": The world must be ending!"; +// +// We are very careful to ensure that each argument is evaluated exactly +// once, and that anything which is legal to pass as a function argument is +// legal here. In particular, the arguments may be temporary expressions +// which will end up being destroyed at the end of the apparent statement, +// for example: +// DCHECK_EQ(string("abc")[1], 'b'); +// +// WARNING: These may not compile correctly if one of the arguments is a pointer +// and the other is NULL. To work around this, simply static_cast NULL to the +// type of the desired pointer. + +#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) +#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) +#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) +#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2) +#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) +#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2) + +#if defined(NDEBUG) && defined(OS_CHROMEOS) +#define NOTREACHED() \ + LOG(ERROR) << "NOTREACHED() hit in " << __FUNCTION__ << ". " +#else +#define NOTREACHED() DCHECK(false) +#endif + +// Redefine the standard assert to use our nice log files +#undef assert +#define assert(x) DLOG_ASSERT(x) + +// This class more or less represents a particular log message. You +// create an instance of LogMessage and then stream stuff to it. +// When you finish streaming to it, ~LogMessage is called and the +// full message gets streamed to the appropriate destination. +// +// You shouldn't actually use LogMessage's constructor to log things, +// though. You should use the LOG() macro (and variants thereof) +// above. +class LogMessage { + public: + // Used for LOG(severity). + LogMessage(const char* file, int line, LogSeverity severity); + + // Used for CHECK_EQ(), etc. Takes ownership of the given string. + // Implied severity = LOG_FATAL. + LogMessage(const char* file, int line, std::string* result); + + // Used for DCHECK_EQ(), etc. Takes ownership of the given string. + LogMessage(const char* file, + int line, + LogSeverity severity, + std::string* result); + + ~LogMessage(); + + std::ostream& stream() { return stream_; } + + private: + LogSeverity severity_; + std::ostringstream stream_; + + // The file and line information passed in to the constructor. + const char* file_; + const int line_; + +#if defined(OS_WIN) + // Stores the current value of GetLastError in the constructor and restores + // it in the destructor by calling SetLastError. + // This is useful since the LogMessage class uses a lot of Win32 calls + // that will lose the value of GLE and the code that called the log function + // will have lost the thread error value when the log call returns. + class SaveLastError { + public: + SaveLastError(); + ~SaveLastError(); + + unsigned long get_error() const { return last_error_; } + + protected: + unsigned long last_error_; + }; + + SaveLastError last_error_; +#endif + + DISALLOW_COPY_AND_ASSIGN(LogMessage); +}; + +// A non-macro interface to the log facility; (useful +// when the logging level is not a compile-time constant). +inline void LogAtLevel(int const log_level, std::string const& msg) { + LogMessage(__FILE__, __LINE__, log_level).stream() << msg; +} + +// This class is used to explicitly ignore values in the conditional +// logging macros. This avoids compiler warnings like "value computed +// is not used" and "statement has no effect". +class LogMessageVoidify { + public: + LogMessageVoidify() {} + // This has to be an operator with a precedence lower than << but + // higher than ?: + void operator&(std::ostream&) {} +}; + +#if defined(OS_WIN) +typedef unsigned long SystemErrorCode; +#elif defined(OS_POSIX) +typedef int SystemErrorCode; +#endif + +// Alias for ::GetLastError() on Windows and errno on POSIX. Avoids having to +// pull in windows.h just for GetLastError() and DWORD. +SystemErrorCode GetLastSystemErrorCode(); +std::string SystemErrorCodeToString(SystemErrorCode error_code); + +#if defined(OS_WIN) +// Appends a formatted system message of the GetLastError() type. +class Win32ErrorLogMessage { + public: + Win32ErrorLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err); + + // Appends the error message before destructing the encapsulated class. + ~Win32ErrorLogMessage(); + + std::ostream& stream() { return log_message_.stream(); } + + private: + SystemErrorCode err_; + LogMessage log_message_; + + DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage); +}; +#elif defined(OS_POSIX) +// Appends a formatted system message of the errno type +class ErrnoLogMessage { + public: + ErrnoLogMessage(const char* file, + int line, + LogSeverity severity, + SystemErrorCode err); + + // Appends the error message before destructing the encapsulated class. + ~ErrnoLogMessage(); + + std::ostream& stream() { return log_message_.stream(); } + + private: + SystemErrorCode err_; + LogMessage log_message_; + + DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage); +}; +#endif // OS_WIN + +} // namespace logging +} // namespace cef + +// These functions are provided as a convenience for logging, which is where we +// use streams (it is against Google style to use streams in other places). It +// is designed to allow you to emit non-ASCII Unicode strings to the log file, +// which is normally ASCII. It is relatively slow, so try not to use it for +// common cases. Non-ASCII characters will be converted to UTF-8 by these +// operators. +std::ostream& operator<<(std::ostream& out, const wchar_t* wstr); +inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) { + return out << wstr.c_str(); +} + +// The NOTIMPLEMENTED() macro annotates codepaths which have +// not been implemented yet. +// +// The implementation of this macro is controlled by NOTIMPLEMENTED_POLICY: +// 0 -- Do nothing (stripped by compiler) +// 1 -- Warn at compile time +// 2 -- Fail at compile time +// 3 -- Fail at runtime (DCHECK) +// 4 -- [default] LOG(ERROR) at runtime +// 5 -- LOG(ERROR) at runtime, only once per call-site + +#ifndef NOTIMPLEMENTED_POLICY +#if defined(OS_ANDROID) && defined(OFFICIAL_BUILD) +#define NOTIMPLEMENTED_POLICY 0 +#else +// Select default policy: LOG(ERROR) +#define NOTIMPLEMENTED_POLICY 4 +#endif +#endif + +#if defined(COMPILER_GCC) +// On Linux, with GCC, we can use __PRETTY_FUNCTION__ to get the demangled name +// of the current function in the NOTIMPLEMENTED message. +#define NOTIMPLEMENTED_MSG "Not implemented reached in " << __PRETTY_FUNCTION__ +#else +#define NOTIMPLEMENTED_MSG "NOT IMPLEMENTED" +#endif + +#if NOTIMPLEMENTED_POLICY == 0 +#define NOTIMPLEMENTED() EAT_STREAM_PARAMETERS +#elif NOTIMPLEMENTED_POLICY == 1 +// TODO, figure out how to generate a warning +#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) +#elif NOTIMPLEMENTED_POLICY == 2 +#define NOTIMPLEMENTED() COMPILE_ASSERT(false, NOT_IMPLEMENTED) +#elif NOTIMPLEMENTED_POLICY == 3 +#define NOTIMPLEMENTED() NOTREACHED() +#elif NOTIMPLEMENTED_POLICY == 4 +#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG +#elif NOTIMPLEMENTED_POLICY == 5 +#define NOTIMPLEMENTED() \ + do { \ + static bool logged_once = false; \ + LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \ + logged_once = true; \ + } while (0); \ + EAT_STREAM_PARAMETERS +#endif + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_LOGGING_H_ diff --git a/src/include.old/base/cef_macros.h b/src/include.old/base/cef_macros.h new file mode 100644 index 000000000..e714529cd --- /dev/null +++ b/src/include.old/base/cef_macros.h @@ -0,0 +1,220 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_MACROS_H_ +#define CEF_INCLUDE_BASE_CEF_MACROS_H_ +#pragma once + +#if defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/macros.h" + +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include // For size_t. +#include "include/base/cef_build.h" // For COMPILER_MSVC + +#if !defined(arraysize) + +// The arraysize(arr) macro returns the # of elements in an array arr. +// The expression is a compile-time constant, and therefore can be +// used in defining new arrays, for example. If you use arraysize on +// a pointer by mistake, you will get a compile-time error. +// +// One caveat is that arraysize() doesn't accept any array of an +// anonymous type or a type defined inside a function. In these rare +// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is +// due to a limitation in C++'s template system. The limitation might +// eventually be removed, but it hasn't happened yet. + +// This template function declaration is used in defining arraysize. +// Note that the function doesn't need an implementation, as we only +// use its type. +template +char (&ArraySizeHelper(T (&array)[N]))[N]; + +// That gcc wants both of these prototypes seems mysterious. VC, for +// its part, can't decide which to use (another mystery). Matching of +// template overloads: the final frontier. +#ifndef _MSC_VER +template +char (&ArraySizeHelper(const T (&array)[N]))[N]; +#endif + +#define arraysize(array) (sizeof(ArraySizeHelper(array))) + +#endif // !arraysize + +#if !defined(DISALLOW_COPY_AND_ASSIGN) + +// A macro to disallow the copy constructor and operator= functions +// This should be used in the private: declarations for a class +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +#endif // !DISALLOW_COPY_AND_ASSIGN + +#if !defined(DISALLOW_IMPLICIT_CONSTRUCTORS) + +// A macro to disallow all the implicit constructors, namely the +// default constructor, copy constructor and operator= functions. +// +// This should be used in the private: declarations for a class +// that wants to prevent anyone from instantiating it. This is +// especially useful for classes containing only static methods. +#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ + TypeName(); \ + DISALLOW_COPY_AND_ASSIGN(TypeName) + +#endif // !DISALLOW_IMPLICIT_CONSTRUCTORS + +#if !defined(COMPILE_ASSERT) + +// The COMPILE_ASSERT macro can be used to verify that a compile time +// expression is true. For example, you could use it to verify the +// size of a static array: +// +// COMPILE_ASSERT(ARRAYSIZE_UNSAFE(content_type_names) == CONTENT_NUM_TYPES, +// content_type_names_incorrect_size); +// +// or to make sure a struct is smaller than a certain size: +// +// COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); +// +// The second argument to the macro is the name of the variable. If +// the expression is false, most compilers will issue a warning/error +// containing the name of the variable. + +#if __cplusplus >= 201103L + +// Under C++11, just use static_assert. +#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) + +#else + +namespace cef { + +template +struct CompileAssert {}; + +} // namespace cef + +#define COMPILE_ASSERT(expr, msg) \ + typedef cef::CompileAssert<(bool(expr))> \ + msg[bool(expr) ? 1 : -1] ALLOW_UNUSED_TYPE + +// Implementation details of COMPILE_ASSERT: +// +// - COMPILE_ASSERT works by defining an array type that has -1 +// elements (and thus is invalid) when the expression is false. +// +// - The simpler definition +// +// #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1] +// +// does not work, as gcc supports variable-length arrays whose sizes +// are determined at run-time (this is gcc's extension and not part +// of the C++ standard). As a result, gcc fails to reject the +// following code with the simple definition: +// +// int foo; +// COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is +// // not a compile-time constant. +// +// - By using the type CompileAssert<(bool(expr))>, we ensures that +// expr is a compile-time constant. (Template arguments must be +// determined at compile-time.) +// +// - The outer parentheses in CompileAssert<(bool(expr))> are necessary +// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written +// +// CompileAssert +// +// instead, these compilers will refuse to compile +// +// COMPILE_ASSERT(5 > 0, some_message); +// +// (They seem to think the ">" in "5 > 0" marks the end of the +// template argument list.) +// +// - The array size is (bool(expr) ? 1 : -1), instead of simply +// +// ((expr) ? 1 : -1). +// +// This is to avoid running into a bug in MS VC 7.1, which +// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. + +#endif // !(__cplusplus >= 201103L) + +#endif // !defined(COMPILE_ASSERT) + +#endif // !USING_CHROMIUM_INCLUDES + +#if !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC) + +// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled. +// The warning remains disabled until popped by MSVC_POP_WARNING. +#define MSVC_PUSH_DISABLE_WARNING(n) \ + __pragma(warning(push)) __pragma(warning(disable : n)) + +// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level +// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all +// warnings. +#define MSVC_PUSH_WARNING_LEVEL(n) __pragma(warning(push, n)) + +// Pop effects of innermost MSVC_PUSH_* macro. +#define MSVC_POP_WARNING() __pragma(warning(pop)) + +#endif // !defined(MSVC_PUSH_DISABLE_WARNING) && defined(COMPILER_MSVC) + +#if !defined(ALLOW_THIS_IN_INITIALIZER_LIST) +#if defined(COMPILER_MSVC) +// Allows |this| to be passed as an argument in constructor initializer lists. +// This uses push/pop instead of the seemingly simpler suppress feature to avoid +// having the warning be disabled for more than just |code|. +// +// Example usage: +// Foo::Foo() : x(NULL), ALLOW_THIS_IN_INITIALIZER_LIST(y(this)), z(3) {} +// +// Compiler warning C4355: 'this': used in base member initializer list: +// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) \ + MSVC_PUSH_DISABLE_WARNING(4355) \ + code MSVC_POP_WARNING() +#else // !COMPILER_MSVC +#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code +#endif // !COMPILER_MSVC +#endif // !ALLOW_THIS_IN_INITIALIZER_LIST + +#endif // CEF_INCLUDE_BASE_CEF_MACROS_H_ diff --git a/src/include/base/cef_move.h b/src/include.old/base/cef_move.h similarity index 100% rename from src/include/base/cef_move.h rename to src/include.old/base/cef_move.h diff --git a/src/include.old/base/cef_platform_thread.h b/src/include.old/base/cef_platform_thread.h new file mode 100644 index 000000000..d3fdd798e --- /dev/null +++ b/src/include.old/base/cef_platform_thread.h @@ -0,0 +1,106 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// WARNING: You should *NOT* be using this class directly. PlatformThread is +// the low-level platform-specific abstraction to the OS's threading interface. +// You should instead be using a message-loop driven Thread, see thread.h. + +#ifndef CEF_INCLUDE_BASE_PLATFORM_THREAD_H_ +#define CEF_INCLUDE_BASE_PLATFORM_THREAD_H_ + +#if defined(BASE_THREADING_PLATFORM_THREAD_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/threading/platform_thread.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_build.h" +#include "include/internal/cef_thread_internal.h" + +namespace base { + +// Used for logging. Always an integer value. +typedef cef_platform_thread_id_t PlatformThreadId; + +// Used for thread checking and debugging. +// Meant to be as fast as possible. +// These are produced by PlatformThread::CurrentRef(), and used to later +// check if we are on the same thread or not by using ==. These are safe +// to copy between threads, but can't be copied to another process as they +// have no meaning there. Also, the internal identifier can be re-used +// after a thread dies, so a PlatformThreadRef cannot be reliably used +// to distinguish a new thread from an old, dead thread. +class PlatformThreadRef { + public: + typedef cef_platform_thread_handle_t RefType; + + PlatformThreadRef() : id_(0) {} + + explicit PlatformThreadRef(RefType id) : id_(id) {} + + bool operator==(PlatformThreadRef other) const { return id_ == other.id_; } + + bool is_null() const { return id_ == 0; } + + private: + RefType id_; +}; + +// A namespace for low-level thread functions. +// Chromium uses a class with static methods but CEF uses an actual namespace +// to avoid linker problems with the sandbox libaries on Windows. +namespace PlatformThread { + +// Gets the current thread id, which may be useful for logging purposes. +inline PlatformThreadId CurrentId() { + return cef_get_current_platform_thread_id(); +} + +// Gets the current thread reference, which can be used to check if +// we're on the right thread quickly. +inline PlatformThreadRef CurrentRef() { + return PlatformThreadRef(cef_get_current_platform_thread_handle()); +} + +} // namespace PlatformThread + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_PLATFORM_THREAD_H_ diff --git a/src/include.old/base/cef_ref_counted.h b/src/include.old/base/cef_ref_counted.h new file mode 100644 index 000000000..480b1ce9d --- /dev/null +++ b/src/include.old/base/cef_ref_counted.h @@ -0,0 +1,378 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_ +#define CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_ +#pragma once + +#if defined(BASE_MEMORY_REF_COUNTED_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/memory/ref_counted.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include + +#include "include/base/cef_atomic_ref_count.h" +#include "include/base/cef_build.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_thread_collision_warner.h" + +namespace base { + +namespace cef_subtle { + +class RefCountedBase { + public: + bool HasOneRef() const { return ref_count_ == 1; } + + protected: + RefCountedBase() + : ref_count_(0) +#if DCHECK_IS_ON() + , + in_dtor_(false) +#endif + { + } + + ~RefCountedBase() { +#if DCHECK_IS_ON() + DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()"; +#endif + } + + void AddRef() const { +// TODO(maruel): Add back once it doesn't assert 500 times/sec. +// Current thread books the critical section "AddRelease" +// without release it. +// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); +#if DCHECK_IS_ON() + DCHECK(!in_dtor_); +#endif + ++ref_count_; + } + + // Returns true if the object should self-delete. + bool Release() const { +// TODO(maruel): Add back once it doesn't assert 500 times/sec. +// Current thread books the critical section "AddRelease" +// without release it. +// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_); +#if DCHECK_IS_ON() + DCHECK(!in_dtor_); +#endif + if (--ref_count_ == 0) { +#if DCHECK_IS_ON() + in_dtor_ = true; +#endif + return true; + } + return false; + } + + private: + mutable int ref_count_; +#if DCHECK_IS_ON() + mutable bool in_dtor_; +#endif + + DFAKE_MUTEX(add_release_); + + DISALLOW_COPY_AND_ASSIGN(RefCountedBase); +}; + +class RefCountedThreadSafeBase { + public: + bool HasOneRef() const; + + protected: + RefCountedThreadSafeBase(); + ~RefCountedThreadSafeBase(); + + void AddRef() const; + + // Returns true if the object should self-delete. + bool Release() const; + + private: + mutable AtomicRefCount ref_count_; +#if DCHECK_IS_ON() + mutable bool in_dtor_; +#endif + + DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase); +}; + +} // namespace cef_subtle + +// +// A base class for reference counted classes. Otherwise, known as a cheap +// knock-off of WebKit's RefCounted class. To use this guy just extend your +// class from it like so: +// +// class MyFoo : public base::RefCounted { +// ... +// private: +// friend class base::RefCounted; +// ~MyFoo(); +// }; +// +// You should always make your destructor private, to avoid any code deleting +// the object accidently while there are references to it. +template +class RefCounted : public cef_subtle::RefCountedBase { + public: + RefCounted() {} + + void AddRef() const { cef_subtle::RefCountedBase::AddRef(); } + + void Release() const { + if (cef_subtle::RefCountedBase::Release()) { + delete static_cast(this); + } + } + + protected: + ~RefCounted() {} + + private: + DISALLOW_COPY_AND_ASSIGN(RefCounted); +}; + +// Forward declaration. +template +class RefCountedThreadSafe; + +// Default traits for RefCountedThreadSafe. Deletes the object when its ref +// count reaches 0. Overload to delete it on a different thread etc. +template +struct DefaultRefCountedThreadSafeTraits { + static void Destruct(const T* x) { + // Delete through RefCountedThreadSafe to make child classes only need to be + // friend with RefCountedThreadSafe instead of this struct, which is an + // implementation detail. + RefCountedThreadSafe::DeleteInternal( + x); + } +}; + +// +// A thread-safe variant of RefCounted +// +// class MyFoo : public base::RefCountedThreadSafe { +// ... +// }; +// +// If you're using the default trait, then you should add compile time +// asserts that no one else is deleting your object. i.e. +// private: +// friend class base::RefCountedThreadSafe; +// ~MyFoo(); +template > +class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase { + public: + RefCountedThreadSafe() {} + + void AddRef() const { cef_subtle::RefCountedThreadSafeBase::AddRef(); } + + void Release() const { + if (cef_subtle::RefCountedThreadSafeBase::Release()) { + Traits::Destruct(static_cast(this)); + } + } + + protected: + ~RefCountedThreadSafe() {} + + private: + friend struct DefaultRefCountedThreadSafeTraits; + static void DeleteInternal(const T* x) { delete x; } + + DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe); +}; + +// +// A thread-safe wrapper for some piece of data so we can place other +// things in scoped_refptrs<>. +// +template +class RefCountedData + : public base::RefCountedThreadSafe> { + public: + RefCountedData() : data() {} + RefCountedData(const T& in_value) : data(in_value) {} + + T data; + + private: + friend class base::RefCountedThreadSafe>; + ~RefCountedData() {} +}; + +} // namespace base + +// +// A smart pointer class for reference counted objects. Use this class instead +// of calling AddRef and Release manually on a reference counted object to +// avoid common memory leaks caused by forgetting to Release an object +// reference. Sample usage: +// +// class MyFoo : public RefCounted { +// ... +// }; +// +// void some_function() { +// scoped_refptr foo = new MyFoo(); +// foo->Method(param); +// // |foo| is released when this function returns +// } +// +// void some_other_function() { +// scoped_refptr foo = new MyFoo(); +// ... +// foo = NULL; // explicitly releases |foo| +// ... +// if (foo) +// foo->Method(param); +// } +// +// The above examples show how scoped_refptr acts like a pointer to T. +// Given two scoped_refptr classes, it is also possible to exchange +// references between the two objects, like so: +// +// { +// scoped_refptr a = new MyFoo(); +// scoped_refptr b; +// +// b.swap(a); +// // now, |b| references the MyFoo object, and |a| references NULL. +// } +// +// To make both |a| and |b| in the above example reference the same MyFoo +// object, simply use the assignment operator: +// +// { +// scoped_refptr a = new MyFoo(); +// scoped_refptr b; +// +// b = a; +// // now, |a| and |b| each own a reference to the same MyFoo object. +// } +// +template +class scoped_refptr { + public: + typedef T element_type; + + scoped_refptr() : ptr_(NULL) {} + + scoped_refptr(T* p) : ptr_(p) { + if (ptr_) + ptr_->AddRef(); + } + + scoped_refptr(const scoped_refptr& r) : ptr_(r.ptr_) { + if (ptr_) + ptr_->AddRef(); + } + + template + scoped_refptr(const scoped_refptr& r) : ptr_(r.get()) { + if (ptr_) + ptr_->AddRef(); + } + + ~scoped_refptr() { + if (ptr_) + ptr_->Release(); + } + + T* get() const { return ptr_; } + + // Allow scoped_refptr to be used in boolean expression + // and comparison operations. + operator T*() const { return ptr_; } + + T* operator->() const { + assert(ptr_ != NULL); + return ptr_; + } + + scoped_refptr& operator=(T* p) { + // AddRef first so that self assignment should work + if (p) + p->AddRef(); + T* old_ptr = ptr_; + ptr_ = p; + if (old_ptr) + old_ptr->Release(); + return *this; + } + + scoped_refptr& operator=(const scoped_refptr& r) { + return *this = r.ptr_; + } + + template + scoped_refptr& operator=(const scoped_refptr& r) { + return *this = r.get(); + } + + void swap(T** pp) { + T* p = ptr_; + ptr_ = *pp; + *pp = p; + } + + void swap(scoped_refptr& r) { swap(&r.ptr_); } + + protected: + T* ptr_; +}; + +// Handy utility for creating a scoped_refptr out of a T* explicitly without +// having to retype all the template arguments +template +scoped_refptr make_scoped_refptr(T* t) { + return scoped_refptr(t); +} + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_REF_COUNTED_H_ diff --git a/src/include/base/cef_scoped_ptr.h b/src/include.old/base/cef_scoped_ptr.h similarity index 100% rename from src/include/base/cef_scoped_ptr.h rename to src/include.old/base/cef_scoped_ptr.h diff --git a/src/include/base/cef_string16.h b/src/include.old/base/cef_string16.h similarity index 100% rename from src/include/base/cef_string16.h rename to src/include.old/base/cef_string16.h diff --git a/src/include.old/base/cef_template_util.h b/src/include.old/base/cef_template_util.h new file mode 100644 index 000000000..38fa5839c --- /dev/null +++ b/src/include.old/base/cef_template_util.h @@ -0,0 +1,214 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_ +#define CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_ +#pragma once + +#if defined(BASE_TEMPLATE_UTIL_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/template_util.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include // For size_t. + +#include "include/base/cef_build.h" + +namespace base { + +// template definitions from tr1 + +template +struct integral_constant { + static const T value = v; + typedef T value_type; + typedef integral_constant type; +}; + +template +const T integral_constant::value; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +template +struct is_pointer : false_type {}; +template +struct is_pointer : true_type {}; + +// Member function pointer detection up to four params. Add more as needed +// below. This is built-in to C++ 11, and we can remove this when we switch. +template +struct is_member_function_pointer : false_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_member_function_pointer : true_type {}; +template +struct is_member_function_pointer : true_type {}; + +template +struct is_same : public false_type {}; +template +struct is_same : true_type {}; + +template +struct is_array : public false_type {}; +template +struct is_array : public true_type {}; +template +struct is_array : public true_type {}; + +template +struct is_non_const_reference : false_type {}; +template +struct is_non_const_reference : true_type {}; +template +struct is_non_const_reference : false_type {}; + +template +struct is_const : false_type {}; +template +struct is_const : true_type {}; + +template +struct is_void : false_type {}; +template <> +struct is_void : true_type {}; + +namespace cef_internal { + +// Types YesType and NoType are guaranteed such that sizeof(YesType) < +// sizeof(NoType). +typedef char YesType; + +struct NoType { + YesType dummy[2]; +}; + +// This class is an implementation detail for is_convertible, and you +// don't need to know how it works to use is_convertible. For those +// who care: we declare two different functions, one whose argument is +// of type To and one with a variadic argument list. We give them +// return types of different size, so we can use sizeof to trick the +// compiler into telling us which function it would have chosen if we +// had called it with an argument of type From. See Alexandrescu's +// _Modern C++ Design_ for more details on this sort of trick. + +struct ConvertHelper { + template + static YesType Test(To); + + template + static NoType Test(...); + + template + static From& Create(); +}; + +// Used to determine if a type is a struct/union/class. Inspired by Boost's +// is_class type_trait implementation. +struct IsClassHelper { + template + static YesType Test(void (C::*)(void)); + + template + static NoType Test(...); +}; + +} // namespace cef_internal + +// Inherits from true_type if From is convertible to To, false_type otherwise. +// +// Note that if the type is convertible, this will be a true_type REGARDLESS +// of whether or not the conversion would emit a warning. +template +struct is_convertible + : integral_constant( + cef_internal::ConvertHelper::Create())) == + sizeof(cef_internal::YesType)> {}; + +template +struct is_class + : integral_constant(0)) == + sizeof(cef_internal::YesType)> {}; + +template +struct enable_if {}; + +template +struct enable_if { + typedef T type; +}; + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_TEMPLATE_UTIL_H_ diff --git a/src/include.old/base/cef_thread_checker.h b/src/include.old/base/cef_thread_checker.h new file mode 100644 index 000000000..e48c8d033 --- /dev/null +++ b/src/include.old/base/cef_thread_checker.h @@ -0,0 +1,121 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_BASE_THREAD_CHECKER_H_ +#define CEF_INCLUDE_BASE_THREAD_CHECKER_H_ +#pragma once + +#if defined(BASE_THREADING_THREAD_CHECKER_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/threading/thread_checker.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_logging.h" +#include "include/base/internal/cef_thread_checker_impl.h" + +// Apart from debug builds, we also enable the thread checker in +// builds with DCHECK_ALWAYS_ON so that trybots and waterfall bots +// with this define will get the same level of thread checking as +// debug bots. +#if DCHECK_IS_ON() +#define ENABLE_THREAD_CHECKER 1 +#else +#define ENABLE_THREAD_CHECKER 0 +#endif + +namespace base { + +namespace cef_internal { + +// Do nothing implementation, for use in release mode. +// +// Note: You should almost always use the ThreadChecker class to get the +// right version for your build configuration. +class ThreadCheckerDoNothing { + public: + bool CalledOnValidThread() const { return true; } + + void DetachFromThread() {} +}; + +} // namespace cef_internal + +// ThreadChecker is a helper class used to help verify that some methods of a +// class are called from the same thread. It provides identical functionality to +// base::NonThreadSafe, but it is meant to be held as a member variable, rather +// than inherited from base::NonThreadSafe. +// +// While inheriting from base::NonThreadSafe may give a clear indication about +// the thread-safety of a class, it may also lead to violations of the style +// guide with regard to multiple inheritance. The choice between having a +// ThreadChecker member and inheriting from base::NonThreadSafe should be based +// on whether: +// - Derived classes need to know the thread they belong to, as opposed to +// having that functionality fully encapsulated in the base class. +// - Derived classes should be able to reassign the base class to another +// thread, via DetachFromThread. +// +// If neither of these are true, then having a ThreadChecker member and calling +// CalledOnValidThread is the preferable solution. +// +// Example: +// class MyClass { +// public: +// void Foo() { +// DCHECK(thread_checker_.CalledOnValidThread()); +// ... (do stuff) ... +// } +// +// private: +// ThreadChecker thread_checker_; +// } +// +// In Release mode, CalledOnValidThread will always return true. +#if ENABLE_THREAD_CHECKER +class ThreadChecker : public cef_internal::ThreadCheckerImpl {}; +#else +class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {}; +#endif // ENABLE_THREAD_CHECKER + +#undef ENABLE_THREAD_CHECKER + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_THREAD_CHECKER_H_ diff --git a/src/include/base/cef_thread_collision_warner.h b/src/include.old/base/cef_thread_collision_warner.h similarity index 100% rename from src/include/base/cef_thread_collision_warner.h rename to src/include.old/base/cef_thread_collision_warner.h diff --git a/src/include.old/base/cef_trace_event.h b/src/include.old/base/cef_trace_event.h new file mode 100644 index 000000000..1b2cad014 --- /dev/null +++ b/src/include.old/base/cef_trace_event.h @@ -0,0 +1,420 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/// +// Trace events are for tracking application performance and resource usage. +// Macros are provided to track: +// Begin and end of function calls +// Counters +// +// Events are issued against categories. Whereas LOG's categories are statically +// defined, TRACE categories are created implicitly with a string. For example: +// TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") +// +// Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: +// TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") +// doSomethingCostly() +// TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") +// Note: Our tools can't always determine the correct BEGIN/END pairs unless +// these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you +// need them to be in separate scopes. +// +// A common use case is to trace entire function scopes. This issues a trace +// BEGIN and END automatically: +// void doSomethingCostly() { +// TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly"); +// ... +// } +// +// Additional parameters can be associated with an event: +// void doSomethingCostly2(int howMuch) { +// TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", +// "howMuch", howMuch); +// ... +// } +// +// The trace system will automatically add to this information the current +// process id, thread id, and a timestamp in microseconds. +// +// To trace an asynchronous procedure such as an IPC send/receive, use +// ASYNC_BEGIN and ASYNC_END: +// [single threaded sender code] +// static int send_count = 0; +// ++send_count; +// TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count); +// Send(new MyMessage(send_count)); +// [receive code] +// void OnMyMessage(send_count) { +// TRACE_EVENT_ASYNC_END0("ipc", "message", send_count); +// } +// The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs. +// ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process. +// Pointers can be used for the ID parameter, and they will be mangled +// internally so that the same pointer on two different processes will not +// match. For example: +// class MyTracedClass { +// public: +// MyTracedClass() { +// TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this); +// } +// ~MyTracedClass() { +// TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this); +// } +// } +// +// The trace event also supports counters, which is a way to track a quantity +// as it varies over time. Counters are created with the following macro: +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue); +// +// Counters are process-specific. The macro itself can be issued from any +// thread, however. +// +// Sometimes, you want to track two counters at once. You can do this with two +// counter macros: +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]); +// TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]); +// Or you can do it with a combined macro: +// TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter", +// "bytesPinned", g_myCounterValue[0], +// "bytesAllocated", g_myCounterValue[1]); +// This indicates to the tracing UI that these counters should be displayed +// in a single graph, as a summed area chart. +// +// Since counters are in a global namespace, you may want to disembiguate with a +// unique ID, by using the TRACE_COUNTER_ID* variations. +// +// By default, trace collection is compiled in, but turned off at runtime. +// Collecting trace data is the responsibility of the embedding application. In +// CEF's case, calling BeginTracing will turn on tracing on all active +// processes. +// +// +// Memory scoping note: +// Tracing copies the pointers, not the string content, of the strings passed +// in for category, name, and arg_names. Thus, the following code will cause +// problems: +// char* str = strdup("impprtantName"); +// TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! +// free(str); // Trace system now has dangling pointer +// +// To avoid this issue with the |name| and |arg_name| parameters, use the +// TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime +// overhead. +// Notes: The category must always be in a long-lived char* (i.e. static const). +// The |arg_values|, when used, are always deep copied with the _COPY +// macros. +// +// +// Thread Safety: +// All macros are thread safe and can be used from any process. +/// + +#ifndef CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ +#define CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ +#pragma once + +#if defined(TRACE_EVENT0) +// Do nothing if the macros provided by this header already exist. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/trace_event/trace_event.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/internal/cef_trace_event_internal.h" + +// Records a pair of begin and end events called "name" for the current +// scope, with 0, 1 or 2 associated arguments. If the category is not +// enabled, then this does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \ + CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) +#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \ + CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) +#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false); \ + CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) + +// Implementation detail: trace event macros create temporary variable names. +// These macros give each temporary variable a unique name based on the line +// number to prevent name collisions. +#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b +#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) CEF_INTERNAL_TRACE_EVENT_UID3(a, b) +#define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \ + CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) + +// Implementation detail: internal macro to end end event when the scope ends. +#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \ + cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \ + profileScope)(category, name) + +// Records a single event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT_INSTANT0(category, name) \ + cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false) +#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define TRACE_EVENT_COPY_INSTANT0(category, name) \ + cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true) +#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records a single BEGIN event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT_BEGIN0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false) +#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define TRACE_EVENT_COPY_BEGIN0(category, name) \ + cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true) +#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records a single END event for "name" immediately. If the category +// is not enabled, then this does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_EVENT_END0(category, name) \ + cef_trace_event_end(category, name, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false) +#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, false) +#define TRACE_EVENT_COPY_END0(category, name) \ + cef_trace_event_end(category, name, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true) +#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \ + arg2_val, true) + +// Records the value of a counter called "name" immediately. Value +// must be representable as a 32 bit integer. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_COUNTER1(category, name, value) \ + cef_trace_counter(category, name, NULL, value, NULL, 0, false) +#define TRACE_COPY_COUNTER1(category, name, value) \ + cef_trace_counter(category, name, NULL, value, NULL, 0, true) + +// Records the values of a multi-parted counter called "name" immediately. +// The UI will treat value1 and value2 as parts of a whole, displaying their +// values as a stacked-bar chart. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \ + value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, false) +#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter(category, name, value1_name, value1_val, value2_name, \ + value2_val, true) + +// Records the value of a counter called "name" immediately. Value +// must be representable as a 32 bit integer. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to disambiguate counters with the same name. It must either +// be a pointer or an integer value up to 64 bits. If it's a pointer, the +// bits will be xored with a hash of the process ID so that the same pointer +// on two different processes will not collide. +#define TRACE_COUNTER_ID1(category, name, id, value) \ + cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, false) +#define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ + cef_trace_counter_id(category, name, id, NULL, value, NULL, 0, true) + +// Records the values of a multi-parted counter called "name" immediately. +// The UI will treat value1 and value2 as parts of a whole, displaying their +// values as a stacked-bar chart. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to disambiguate counters with the same name. It must either +// be a pointer or an integer value up to 64 bits. If it's a pointer, the +// bits will be xored with a hash of the process ID so that the same pointer +// on two different processes will not collide. +#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, false) +#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ + value2_name, value2_val) \ + cef_trace_counter_id(category, name, id, value1_name, value1_val, \ + value2_name, value2_val, true) + +// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 +// associated arguments. If the category is not enabled, then this +// does nothing. +// - category and name strings must have application lifetime (statics or +// literals). They may not include " chars. +// - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. +// ASYNC events are considered to match if their category, name and id values +// all match. |id| must either be a pointer or an integer value up to 64 +// bits. If it's a pointer, the bits will be xored with a hash of the process +// ID sothat the same pointer on two different processes will not collide. +// An asynchronous operation can consist of multiple phases. The first phase is +// defined by the ASYNC_BEGIN calls. Additional phases can be defined using the +// ASYNC_STEP_BEGIN macros. When the operation completes, call ASYNC_END. +// An async operation can span threads and processes, but all events in that +// operation must use the same |name| and |id|. Each event can have its own +// args. +#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ + cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, false) +#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) +#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \ + cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \ + 0, true) +#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) + +// Records a single ASYNC_STEP_INTO event for |step| immediately. If the +// category is not enabled, then this does nothing. The |name| and |id| must +// match the ASYNC_BEGIN event above. The |step| param identifies this step +// within the async event. This should be called at the beginning of the next +// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any +// ASYNC_STEP_PAST events. +#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \ + cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false) +#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ + arg1_val, false) +#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \ + cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_into(category, name, id, step, arg1_name, \ + arg1_val, true) + +// Records a single ASYNC_STEP_PAST event for |step| immediately. If the +// category is not enabled, then this does nothing. The |name| and |id| must +// match the ASYNC_BEGIN event above. The |step| param identifies this step +// within the async event. This should be called at the beginning of the next +// phase of an asynchronous operation. The ASYNC_BEGIN event must not have any +// ASYNC_STEP_INTO events. +#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \ + cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false) +#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ + arg1_val, false) +#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \ + cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \ + arg1_val) \ + cef_trace_event_async_step_past(category, name, id, step, arg1_name, \ + arg1_val, true) + +// Records a single ASYNC_END event for "name" immediately. If the category +// is not enabled, then this does nothing. +#define TRACE_EVENT_ASYNC_END0(category, name, id) \ + cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false) +#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ + false) +#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, false) +#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \ + cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true) +#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \ + true) +#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val) \ + cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \ + arg2_name, arg2_val, true) + +namespace cef_trace_event { + +// Used by TRACE_EVENTx macro. Do not use directly. +class CefTraceEndOnScopeClose { + public: + CefTraceEndOnScopeClose(const char* category, const char* name) + : category_(category), name_(name) {} + ~CefTraceEndOnScopeClose() { + cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false); + } + + private: + const char* category_; + const char* name_; +}; + +} // cef_trace_event + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_TRACE_EVENT_H_ diff --git a/src/include.old/base/cef_tuple.h b/src/include.old/base/cef_tuple.h new file mode 100644 index 000000000..aeb6e9cea --- /dev/null +++ b/src/include.old/base/cef_tuple.h @@ -0,0 +1,1610 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2011 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// A Tuple is a generic templatized container, similar in concept to std::pair. +// There are classes Tuple0 to Tuple6, cooresponding to the number of elements +// it contains. The convenient MakeTuple() function takes 0 to 6 arguments, +// and will construct and return the appropriate Tuple object. The functions +// DispatchToMethod and DispatchToFunction take a function pointer or instance +// and method pointer, and unpack a tuple into arguments to the call. +// +// Tuple elements are copied by value, and stored in the tuple. See the unit +// tests for more details of how/when the values are copied. +// +// Example usage: +// // These two methods of creating a Tuple are identical. +// Tuple2 tuple_a(1, "wee"); +// Tuple2 tuple_b = MakeTuple(1, "wee"); +// +// void SomeFunc(int a, const char* b) { } +// DispatchToFunction(&SomeFunc, tuple_a); // SomeFunc(1, "wee") +// DispatchToFunction( +// &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") +// +// struct { void SomeMeth(int a, int b, int c) { } } foo; +// DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); +// // foo->SomeMeth(1, 2, 3); + +#ifndef CEF_INCLUDE_BASE_CEF_TUPLE_H_ +#define CEF_INCLUDE_BASE_CEF_TUPLE_H_ +#pragma once + +#if defined(BASE_TUPLE_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/tuple.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_bind_helpers.h" + +namespace base { + +// Traits ---------------------------------------------------------------------- +// +// A simple traits class for tuple arguments. +// +// ValueType: the bare, nonref version of a type (same as the type for nonrefs). +// RefType: the ref version of a type (same as the type for refs). +// ParamType: what type to pass to functions (refs should not be constified). + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef const P& ParamType; +}; + +template +struct TupleTraits { + typedef P ValueType; + typedef P& RefType; + typedef P& ParamType; +}; + +template +struct TupleTypes {}; + +// Tuple ----------------------------------------------------------------------- +// +// This set of classes is useful for bundling 0 or more heterogeneous data types +// into a single variable. The advantage of this is that it greatly simplifies +// function objects that need to take an arbitrary number of parameters; see +// RunnableMethod and IPC::MessageWithTuple. +// +// Tuple0 is supplied to act as a 'void' type. It can be used, for example, +// when dispatching to a function that accepts no arguments (see the +// Dispatchers below). +// Tuple1 is rarely useful. One such use is when A is non-const ref that you +// want filled by the dispatchee, and the tuple is merely a container for that +// output (a "tier"). See MakeRefTuple and its usages. + +struct Tuple0 { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct Tuple1 { + public: + typedef A TypeA; + + Tuple1() {} + explicit Tuple1(typename TupleTraits::ParamType a) : a(a) {} + + A a; +}; + +template +struct Tuple2 { + public: + typedef A TypeA; + typedef B TypeB; + + Tuple2() {} + Tuple2(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b) + : a(a), b(b) {} + + A a; + B b; +}; + +template +struct Tuple3 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + + Tuple3() {} + Tuple3(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c) + : a(a), b(b), c(c) {} + + A a; + B b; + C c; +}; + +template +struct Tuple4 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + + Tuple4() {} + Tuple4(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d) + : a(a), b(b), c(c), d(d) {} + + A a; + B b; + C c; + D d; +}; + +template +struct Tuple5 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + + Tuple5() {} + Tuple5(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e) + : a(a), b(b), c(c), d(d), e(e) {} + + A a; + B b; + C c; + D d; + E e; +}; + +template +struct Tuple6 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + + Tuple6() {} + Tuple6(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f) + : a(a), b(b), c(c), d(d), e(e), f(f) {} + + A a; + B b; + C c; + D d; + E e; + F f; +}; + +template +struct Tuple7 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + + Tuple7() {} + Tuple7(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g) {} + + A a; + B b; + C c; + D d; + E e; + F f; + G g; +}; + +template +struct Tuple8 { + public: + typedef A TypeA; + typedef B TypeB; + typedef C TypeC; + typedef D TypeD; + typedef E TypeE; + typedef F TypeF; + typedef G TypeG; + typedef H TypeH; + + Tuple8() {} + Tuple8(typename TupleTraits::ParamType a, + typename TupleTraits::ParamType b, + typename TupleTraits::ParamType c, + typename TupleTraits::ParamType d, + typename TupleTraits::ParamType e, + typename TupleTraits::ParamType f, + typename TupleTraits::ParamType g, + typename TupleTraits::ParamType h) + : a(a), b(b), c(c), d(d), e(e), f(f), g(g), h(h) {} + + A a; + B b; + C c; + D d; + E e; + F f; + G g; + H h; +}; + +// Tuple types ---------------------------------------------------------------- +// +// Allows for selection of ValueTuple/RefTuple/ParamTuple without needing the +// definitions of class types the tuple takes as parameters. + +template <> +struct TupleTypes { + typedef Tuple0 ValueTuple; + typedef Tuple0 RefTuple; + typedef Tuple0 ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple1::ValueType> ValueTuple; + typedef Tuple1::RefType> RefTuple; + typedef Tuple1::ParamType> ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple2::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple2::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple2::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple3::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple3::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple3::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple4::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple4::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple4::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple5::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple5::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple5::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple6::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple6::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple6::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple7::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple7::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple7::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +template +struct TupleTypes> { + typedef Tuple8::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType, + typename TupleTraits::ValueType> + ValueTuple; + typedef Tuple8::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType, + typename TupleTraits::RefType> + RefTuple; + typedef Tuple8::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType, + typename TupleTraits::ParamType> + ParamTuple; +}; + +// Tuple creators ------------------------------------------------------------- +// +// Helper functions for constructing tuples while inferring the template +// argument types. + +inline Tuple0 MakeTuple() { + return Tuple0(); +} + +template +inline Tuple1 MakeTuple(const A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeTuple(const A& a, const B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeTuple(const A& a, const B& b, const C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f, + const G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 MakeTuple(const A& a, + const B& b, + const C& c, + const D& d, + const E& e, + const F& f, + const G& g, + const H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// The following set of helpers make what Boost refers to as "Tiers" - a tuple +// of references. + +template +inline Tuple1 MakeRefTuple(A& a) { + return Tuple1(a); +} + +template +inline Tuple2 MakeRefTuple(A& a, B& b) { + return Tuple2(a, b); +} + +template +inline Tuple3 MakeRefTuple(A& a, B& b, C& c) { + return Tuple3(a, b, c); +} + +template +inline Tuple4 MakeRefTuple(A& a, B& b, C& c, D& d) { + return Tuple4(a, b, c, d); +} + +template +inline Tuple5 MakeRefTuple(A& a, B& b, C& c, D& d, E& e) { + return Tuple5(a, b, c, d, e); +} + +template +inline Tuple6 MakeRefTuple(A& a, + B& b, + C& c, + D& d, + E& e, + F& f) { + return Tuple6(a, b, c, d, e, f); +} + +template +inline Tuple7 +MakeRefTuple(A& a, B& b, C& c, D& d, E& e, F& f, G& g) { + return Tuple7(a, b, c, d, e, f, g); +} + +template +inline Tuple8 +MakeRefTuple(A& a, B& b, C& c, D& d, E& e, F& f, G& g, H& h) { + return Tuple8(a, b, c, d, e, f, g, h); +} + +// Dispatchers ---------------------------------------------------------------- +// +// Helper functions that call the given method on an object, with the unpacked +// tuple arguments. Notice that they all have the same number of arguments, +// so you need only write: +// DispatchToMethod(object, &Object::method, args); +// This is very useful for templated dispatchers, since they don't need to know +// what type |args| is. + +// Non-Static Dispatchers with no out params. + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple0& arg) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg)); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const Tuple1& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple7& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple8& arg) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g), + base::cef_internal::UnwrapTraits::Unwrap(arg.h)); +} + +// Static Dispatchers with no out params. + +template +inline void DispatchToFunction(Function function, const Tuple0& arg) { + (*function)(); +} + +template +inline void DispatchToFunction(Function function, const A& arg) { + (*function)(arg); +} + +template +inline void DispatchToFunction(Function function, const Tuple1& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); +} + +template +inline void DispatchToFunction(Function function, const Tuple2& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b)); +} + +template +inline void DispatchToFunction(Function function, const Tuple3& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple4& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple5& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple6& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple7& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g)); +} + +template +inline void DispatchToFunction(Function function, + const Tuple8& arg) { + (*function)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f), + base::cef_internal::UnwrapTraits::Unwrap(arg.g), + base::cef_internal::UnwrapTraits::Unwrap(arg.h)); +} + +// Dispatchers with 0 out param (as a Tuple0). + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& arg, + Tuple0*) { + (obj->*method)(); +} + +template +inline void DispatchToMethod(ObjT* obj, Method method, const A& arg, Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e)); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& arg, + Tuple0*) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(arg.a), + base::cef_internal::UnwrapTraits::Unwrap(arg.b), + base::cef_internal::UnwrapTraits::Unwrap(arg.c), + base::cef_internal::UnwrapTraits::Unwrap(arg.d), + base::cef_internal::UnwrapTraits::Unwrap(arg.e), + base::cef_internal::UnwrapTraits::Unwrap(arg.f)); +} + +// Dispatchers with 1 out param. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple1* out) { + (obj->*method)(&out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple1* out) { + (obj->*method)(in, &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple1* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a); +} + +// Dispatchers with 2 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple2* out) { + (obj->*method)(&out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple2* out) { + (obj->*method)(in, &out->a, &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple2* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b); +} + +// Dispatchers with 3 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple3* out) { + (obj->*method)(&out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple3* out) { + (obj->*method)(in, &out->a, &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple3* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c); +} + +// Dispatchers with 4 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple4* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c, &out->d); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple4* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c, &out->d); +} + +// Dispatchers with 5 out params. + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple0& in, + Tuple5* out) { + (obj->*method)(&out->a, &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const InA& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple1& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple2& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple3& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple4& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple5& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +template +inline void DispatchToMethod(ObjT* obj, + Method method, + const Tuple6& in, + Tuple5* out) { + (obj->*method)(base::cef_internal::UnwrapTraits::Unwrap(in.a), + base::cef_internal::UnwrapTraits::Unwrap(in.b), + base::cef_internal::UnwrapTraits::Unwrap(in.c), + base::cef_internal::UnwrapTraits::Unwrap(in.d), + base::cef_internal::UnwrapTraits::Unwrap(in.e), + base::cef_internal::UnwrapTraits::Unwrap(in.f), &out->a, + &out->b, &out->c, &out->d, &out->e); +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_TUPLE_H_ diff --git a/src/include.old/base/cef_weak_ptr.h b/src/include.old/base/cef_weak_ptr.h new file mode 100644 index 000000000..1ba34b9db --- /dev/null +++ b/src/include.old/base/cef_weak_ptr.h @@ -0,0 +1,385 @@ +// Copyright (c) 2014 Marshall A. Greenblatt. Portions copyright (c) 2012 +// Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Weak pointers are pointers to an object that do not affect its lifetime, +// and which may be invalidated (i.e. reset to NULL) by the object, or its +// owner, at any time, most commonly when the object is about to be deleted. + +// Weak pointers are useful when an object needs to be accessed safely by one +// or more objects other than its owner, and those callers can cope with the +// object vanishing and e.g. tasks posted to it being silently dropped. +// Reference-counting such an object would complicate the ownership graph and +// make it harder to reason about the object's lifetime. + +// EXAMPLE: +// +// class Controller { +// public: +// Controller() : weak_factory_(this) {} +// void SpawnWorker() { Worker::StartNew(weak_factory_.GetWeakPtr()); } +// void WorkComplete(const Result& result) { ... } +// private: +// // Member variables should appear before the WeakPtrFactory, to ensure +// // that any WeakPtrs to Controller are invalidated before its members +// // variable's destructors are executed, rendering them invalid. +// WeakPtrFactory weak_factory_; +// }; +// +// class Worker { +// public: +// static void StartNew(const WeakPtr& controller) { +// Worker* worker = new Worker(controller); +// // Kick off asynchronous processing... +// } +// private: +// Worker(const WeakPtr& controller) +// : controller_(controller) {} +// void DidCompleteAsynchronousProcessing(const Result& result) { +// if (controller_) +// controller_->WorkComplete(result); +// } +// WeakPtr controller_; +// }; +// +// With this implementation a caller may use SpawnWorker() to dispatch multiple +// Workers and subsequently delete the Controller, without waiting for all +// Workers to have completed. + +// ------------------------- IMPORTANT: Thread-safety ------------------------- + +// Weak pointers may be passed safely between threads, but must always be +// dereferenced and invalidated on the same thread otherwise checking the +// pointer would be racey. +// +// To ensure correct use, the first time a WeakPtr issued by a WeakPtrFactory +// is dereferenced, the factory and its WeakPtrs become bound to the calling +// thread, and cannot be dereferenced or invalidated on any other thread. Bound +// WeakPtrs can still be handed off to other threads, e.g. to use to post tasks +// back to object on the bound thread. +// +// If all WeakPtr objects are destroyed or invalidated then the factory is +// unbound from the SequencedTaskRunner/Thread. The WeakPtrFactory may then be +// destroyed, or new WeakPtr objects may be used, from a different sequence. +// +// Thus, at least one WeakPtr object must exist and have been dereferenced on +// the correct thread to enforce that other WeakPtr objects will enforce they +// are used on the desired thread. + +#ifndef CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_ +#define CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_ +#pragma once + +#if defined(BASE_MEMORY_WEAK_PTR_H_) +// Do nothing if the Chromium header has already been included. +// This can happen in cases where Chromium code is used directly by the +// client application. When using Chromium code directly always include +// the Chromium header first to avoid type conflicts. +#elif defined(USING_CHROMIUM_INCLUDES) +// When building CEF include the Chromium header directly. +#include "base/memory/weak_ptr.h" +#else // !USING_CHROMIUM_INCLUDES +// The following is substantially similar to the Chromium implementation. +// If the Chromium implementation diverges the below implementation should be +// updated to match. + +#include "include/base/cef_basictypes.h" +#include "include/base/cef_logging.h" +#include "include/base/cef_ref_counted.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_thread_checker.h" + +namespace base { + +template +class SupportsWeakPtr; +template +class WeakPtr; + +namespace cef_internal { +// These classes are part of the WeakPtr implementation. +// DO NOT USE THESE CLASSES DIRECTLY YOURSELF. + +class WeakReference { + public: + // Although Flag is bound to a specific thread, it may be deleted from another + // via base::WeakPtr::~WeakPtr(). + class Flag : public RefCountedThreadSafe { + public: + Flag(); + + void Invalidate(); + bool IsValid() const; + + private: + friend class base::RefCountedThreadSafe; + + ~Flag(); + + // The current Chromium implementation uses SequenceChecker instead of + // ThreadChecker to support SequencedWorkerPools. CEF does not yet expose + // the concept of SequencedWorkerPools. + ThreadChecker thread_checker_; + bool is_valid_; + }; + + WeakReference(); + explicit WeakReference(const Flag* flag); + ~WeakReference(); + + bool is_valid() const; + + private: + scoped_refptr flag_; +}; + +class WeakReferenceOwner { + public: + WeakReferenceOwner(); + ~WeakReferenceOwner(); + + WeakReference GetRef() const; + + bool HasRefs() const { return flag_.get() && !flag_->HasOneRef(); } + + void Invalidate(); + + private: + mutable scoped_refptr flag_; +}; + +// This class simplifies the implementation of WeakPtr's type conversion +// constructor by avoiding the need for a public accessor for ref_. A +// WeakPtr cannot access the private members of WeakPtr, so this +// base class gives us a way to access ref_ in a protected fashion. +class WeakPtrBase { + public: + WeakPtrBase(); + ~WeakPtrBase(); + + protected: + explicit WeakPtrBase(const WeakReference& ref); + + WeakReference ref_; +}; + +// This class provides a common implementation of common functions that would +// otherwise get instantiated separately for each distinct instantiation of +// SupportsWeakPtr<>. +class SupportsWeakPtrBase { + public: + // A safe static downcast of a WeakPtr to WeakPtr. This + // conversion will only compile if there is exists a Base which inherits + // from SupportsWeakPtr. See base::AsWeakPtr() below for a helper + // function that makes calling this easier. + template + static WeakPtr StaticAsWeakPtr(Derived* t) { + typedef is_convertible + convertible; + COMPILE_ASSERT(convertible::value, + AsWeakPtr_argument_inherits_from_SupportsWeakPtr); + return AsWeakPtrImpl(t, *t); + } + + private: + // This template function uses type inference to find a Base of Derived + // which is an instance of SupportsWeakPtr. We can then safely + // static_cast the Base* to a Derived*. + template + static WeakPtr AsWeakPtrImpl(Derived* t, + const SupportsWeakPtr&) { + WeakPtr ptr = t->Base::AsWeakPtr(); + return WeakPtr(ptr.ref_, static_cast(ptr.ptr_)); + } +}; + +} // namespace cef_internal + +template +class WeakPtrFactory; + +// The WeakPtr class holds a weak reference to |T*|. +// +// This class is designed to be used like a normal pointer. You should always +// null-test an object of this class before using it or invoking a method that +// may result in the underlying object being destroyed. +// +// EXAMPLE: +// +// class Foo { ... }; +// WeakPtr foo; +// if (foo) +// foo->method(); +// +template +class WeakPtr : public cef_internal::WeakPtrBase { + public: + WeakPtr() : ptr_(NULL) {} + + // Allow conversion from U to T provided U "is a" T. Note that this + // is separate from the (implicit) copy constructor. + template + WeakPtr(const WeakPtr& other) : WeakPtrBase(other), ptr_(other.ptr_) {} + + T* get() const { return ref_.is_valid() ? ptr_ : NULL; } + + T& operator*() const { + DCHECK(get() != NULL); + return *get(); + } + T* operator->() const { + DCHECK(get() != NULL); + return get(); + } + + // Allow WeakPtr to be used in boolean expressions, but not + // implicitly convertible to a real bool (which is dangerous). + // + // Note that this trick is only safe when the == and != operators + // are declared explicitly, as otherwise "weak_ptr1 == weak_ptr2" + // will compile but do the wrong thing (i.e., convert to Testable + // and then do the comparison). + private: + typedef T* WeakPtr::*Testable; + + public: + operator Testable() const { return get() ? &WeakPtr::ptr_ : NULL; } + + void reset() { + ref_ = cef_internal::WeakReference(); + ptr_ = NULL; + } + + private: + // Explicitly declare comparison operators as required by the bool + // trick, but keep them private. + template + bool operator==(WeakPtr const&) const; + template + bool operator!=(WeakPtr const&) const; + + friend class cef_internal::SupportsWeakPtrBase; + template + friend class WeakPtr; + friend class SupportsWeakPtr; + friend class WeakPtrFactory; + + WeakPtr(const cef_internal::WeakReference& ref, T* ptr) + : WeakPtrBase(ref), ptr_(ptr) {} + + // This pointer is only valid when ref_.is_valid() is true. Otherwise, its + // value is undefined (as opposed to NULL). + T* ptr_; +}; + +// A class may be composed of a WeakPtrFactory and thereby +// control how it exposes weak pointers to itself. This is helpful if you only +// need weak pointers within the implementation of a class. This class is also +// useful when working with primitive types. For example, you could have a +// WeakPtrFactory that is used to pass around a weak reference to a bool. +template +class WeakPtrFactory { + public: + explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {} + + ~WeakPtrFactory() { ptr_ = NULL; } + + WeakPtr GetWeakPtr() { + DCHECK(ptr_); + return WeakPtr(weak_reference_owner_.GetRef(), ptr_); + } + + // Call this method to invalidate all existing weak pointers. + void InvalidateWeakPtrs() { + DCHECK(ptr_); + weak_reference_owner_.Invalidate(); + } + + // Call this method to determine if any weak pointers exist. + bool HasWeakPtrs() const { + DCHECK(ptr_); + return weak_reference_owner_.HasRefs(); + } + + private: + cef_internal::WeakReferenceOwner weak_reference_owner_; + T* ptr_; + DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory); +}; + +// A class may extend from SupportsWeakPtr to let others take weak pointers to +// it. This avoids the class itself implementing boilerplate to dispense weak +// pointers. However, since SupportsWeakPtr's destructor won't invalidate +// weak pointers to the class until after the derived class' members have been +// destroyed, its use can lead to subtle use-after-destroy issues. +template +class SupportsWeakPtr : public cef_internal::SupportsWeakPtrBase { + public: + SupportsWeakPtr() {} + + WeakPtr AsWeakPtr() { + return WeakPtr(weak_reference_owner_.GetRef(), static_cast(this)); + } + + protected: + ~SupportsWeakPtr() {} + + private: + cef_internal::WeakReferenceOwner weak_reference_owner_; + DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr); +}; + +// Helper function that uses type deduction to safely return a WeakPtr +// when Derived doesn't directly extend SupportsWeakPtr, instead it +// extends a Base that extends SupportsWeakPtr. +// +// EXAMPLE: +// class Base : public base::SupportsWeakPtr {}; +// class Derived : public Base {}; +// +// Derived derived; +// base::WeakPtr ptr = base::AsWeakPtr(&derived); +// +// Note that the following doesn't work (invalid type conversion) since +// Derived::AsWeakPtr() is WeakPtr SupportsWeakPtr::AsWeakPtr(), +// and there's no way to safely cast WeakPtr to WeakPtr at +// the caller. +// +// base::WeakPtr ptr = derived.AsWeakPtr(); // Fails. + +template +WeakPtr AsWeakPtr(Derived* t) { + return cef_internal::SupportsWeakPtrBase::StaticAsWeakPtr(t); +} + +} // namespace base + +#endif // !USING_CHROMIUM_INCLUDES + +#endif // CEF_INCLUDE_BASE_CEF_WEAK_PTR_H_ diff --git a/src/include/base/internal/cef_atomicops_arm_gcc.h b/src/include.old/base/internal/cef_atomicops_arm_gcc.h similarity index 100% rename from src/include/base/internal/cef_atomicops_arm_gcc.h rename to src/include.old/base/internal/cef_atomicops_arm_gcc.h diff --git a/src/include/base/internal/cef_atomicops_atomicword_compat.h b/src/include.old/base/internal/cef_atomicops_atomicword_compat.h similarity index 100% rename from src/include/base/internal/cef_atomicops_atomicword_compat.h rename to src/include.old/base/internal/cef_atomicops_atomicword_compat.h diff --git a/src/include/base/internal/cef_atomicops_mac.h b/src/include.old/base/internal/cef_atomicops_mac.h similarity index 100% rename from src/include/base/internal/cef_atomicops_mac.h rename to src/include.old/base/internal/cef_atomicops_mac.h diff --git a/src/include/base/internal/cef_atomicops_x86_gcc.h b/src/include.old/base/internal/cef_atomicops_x86_gcc.h similarity index 100% rename from src/include/base/internal/cef_atomicops_x86_gcc.h rename to src/include.old/base/internal/cef_atomicops_x86_gcc.h diff --git a/src/include/base/internal/cef_atomicops_x86_msvc.h b/src/include.old/base/internal/cef_atomicops_x86_msvc.h similarity index 100% rename from src/include/base/internal/cef_atomicops_x86_msvc.h rename to src/include.old/base/internal/cef_atomicops_x86_msvc.h diff --git a/src/include.old/base/internal/cef_bind_internal.h b/src/include.old/base/internal/cef_bind_internal.h new file mode 100644 index 000000000..64eeb3f3b --- /dev/null +++ b/src/include.old/base/internal/cef_bind_internal.h @@ -0,0 +1,3190 @@ +// Copyright (c) 2011 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Do not include this header file directly. Use base/cef_bind.h instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_ + +#include "include/base/cef_bind_helpers.h" +#include "include/base/cef_build.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_weak_ptr.h" +#include "include/base/internal/cef_callback_internal.h" +#include "include/base/internal/cef_raw_scoped_refptr_mismatch_checker.h" + +#if defined(OS_WIN) +#include "include/base/internal/cef_bind_internal_win.h" +#endif + +namespace base { +namespace cef_internal { + +// See base/callback.h for user documentation. +// +// +// CONCEPTS: +// Runnable -- A type (really a type class) that has a single Run() method +// and a RunType typedef that corresponds to the type of Run(). +// A Runnable can declare that it should treated like a method +// call by including a typedef named IsMethod. The value of +// this typedef is NOT inspected, only the existence. When a +// Runnable declares itself a method, Bind() will enforce special +// refcounting + WeakPtr handling semantics for the first +// parameter which is expected to be an object. +// Functor -- A copyable type representing something that should be called. +// All function pointers, Callback<>, and Runnables are functors +// even if the invocation syntax differs. +// RunType -- A function type (as opposed to function _pointer_ type) for +// a Run() function. Usually just a convenience typedef. +// (Bound)ArgsType -- A function type that is being (ab)used to store the +// types of set of arguments. The "return" type is always +// void here. We use this hack so that we do not need +// a new type name for each arity of type. (eg., +// BindState1, BindState2). This makes forward +// declarations and friending much much easier. +// +// Types: +// RunnableAdapter<> -- Wraps the various "function" pointer types into an +// object that adheres to the Runnable interface. +// There are |3*ARITY| RunnableAdapter types. +// FunctionTraits<> -- Type traits that unwrap a function signature into a +// a set of easier to use typedefs. Used mainly for +// compile time asserts. +// There are |ARITY| FunctionTraits types. +// ForceVoidReturn<> -- Helper class for translating function signatures to +// equivalent forms with a "void" return type. +// There are |ARITY| ForceVoidReturn types. +// FunctorTraits<> -- Type traits used determine the correct RunType and +// RunnableType for a Functor. This is where function +// signature adapters are applied. +// There are |ARITY| ForceVoidReturn types. +// MakeRunnable<> -- Takes a Functor and returns an object in the Runnable +// type class that represents the underlying Functor. +// There are |O(1)| MakeRunnable types. +// InvokeHelper<> -- Take a Runnable + arguments and actully invokes it. +// Handle the differing syntaxes needed for WeakPtr<> support, +// and for ignoring return values. This is separate from +// Invoker to avoid creating multiple version of Invoker<> +// which grows at O(n^2) with the arity. +// There are |k*ARITY| InvokeHelper types. +// Invoker<> -- Unwraps the curried parameters and executes the Runnable. +// There are |(ARITY^2 + ARITY)/2| Invoketypes. +// BindState<> -- Stores the curried parameters, and is the main entry point +// into the Bind() system, doing most of the type resolution. +// There are ARITY BindState types. + +// RunnableAdapter<> +// +// The RunnableAdapter<> templates provide a uniform interface for invoking +// a function pointer, method pointer, or const method pointer. The adapter +// exposes a Run() method with an appropriate signature. Using this wrapper +// allows for writing code that supports all three pointer types without +// undue repetition. Without it, a lot of code would need to be repeated 3 +// times. +// +// For method pointers and const method pointers the first argument to Run() +// is considered to be the received of the method. This is similar to STL's +// mem_fun(). +// +// This class also exposes a RunType typedef that is the function type of the +// Run() function. +// +// If and only if the wrapper contains a method or const method pointer, an +// IsMethod typedef is exposed. The existence of this typedef (NOT the value) +// marks that the wrapper should be considered a method wrapper. + +template +class RunnableAdapter; + +// Function: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(); + + explicit RunnableAdapter(R (*function)()) : function_(function) {} + + R Run() { return function_(); } + + private: + R (*function_)(); +}; + +// Method: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)()) : method_(method) {} + + R Run(T* object) { return (object->*method_)(); } + + private: + R (T::*method_)(); +}; + +// Const Method: Arity 0. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)() const) : method_(method) {} + + R Run(const T* object) { return (object->*method_)(); } + + private: + R (T::*method_)() const; +}; + +// Function: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1); + + explicit RunnableAdapter(R (*function)(A1)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1) { + return function_(CallbackForward(a1)); + } + + private: + R (*function_)(A1); +}; + +// Method: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1)) : method_(method) {} + + R Run(T* object, typename CallbackParamTraits::ForwardType a1) { + return (object->*method_)(CallbackForward(a1)); + } + + private: + R (T::*method_)(A1); +}; + +// Const Method: Arity 1. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1) const) : method_(method) {} + + R Run(const T* object, typename CallbackParamTraits::ForwardType a1) { + return (object->*method_)(CallbackForward(a1)); + } + + private: + R (T::*method_)(A1) const; +}; + +// Function: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2); + + explicit RunnableAdapter(R (*function)(A1, A2)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return function_(CallbackForward(a1), CallbackForward(a2)); + } + + private: + R (*function_)(A1, A2); +}; + +// Method: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2)) : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); + } + + private: + R (T::*method_)(A1, A2); +}; + +// Const Method: Arity 2. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2) const) : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2)); + } + + private: + R (T::*method_)(A1, A2) const; +}; + +// Function: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3); + + explicit RunnableAdapter(R (*function)(A1, A2, A3)) : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } + + private: + R (*function_)(A1, A2, A3); +}; + +// Method: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3)) : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } + + private: + R (T::*method_)(A1, A2, A3); +}; + +// Const Method: Arity 3. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } + + private: + R (T::*method_)(A1, A2, A3) const; +}; + +// Function: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } + + private: + R (*function_)(A1, A2, A3, A4); +}; + +// Method: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4)) : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } + + private: + R (T::*method_)(A1, A2, A3, A4); +}; + +// Const Method: Arity 4. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } + + private: + R (T::*method_)(A1, A2, A3, A4) const; +}; + +// Function: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } + + private: + R (*function_)(A1, A2, A3, A4, A5); +}; + +// Method: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4, A5); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5); +}; + +// Const Method: Arity 5. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4, A5); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5) const; +}; + +// Function: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5, A6)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } + + private: + R (*function_)(A1, A2, A3, A4, A5, A6); +}; + +// Method: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4, A5, A6); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6); +}; + +// Const Method: Arity 6. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4, A5, A6); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6) const; +}; + +// Function: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7); + + explicit RunnableAdapter(R (*function)(A1, A2, A3, A4, A5, A6, A7)) + : function_(function) {} + + R Run(typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return function_(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } + + private: + R (*function_)(A1, A2, A3, A4, A5, A6, A7); +}; + +// Method: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(T*, A1, A2, A3, A4, A5, A6, A7); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6, A7)) + : method_(method) {} + + R Run(T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6, A7); +}; + +// Const Method: Arity 7. +template +class RunnableAdapter { + public: + typedef R(RunType)(const T*, A1, A2, A3, A4, A5, A6, A7); + typedef true_type IsMethod; + + explicit RunnableAdapter(R (T::*method)(A1, A2, A3, A4, A5, A6, A7) const) + : method_(method) {} + + R Run(const T* object, + typename CallbackParamTraits::ForwardType a1, + typename CallbackParamTraits::ForwardType a2, + typename CallbackParamTraits::ForwardType a3, + typename CallbackParamTraits::ForwardType a4, + typename CallbackParamTraits::ForwardType a5, + typename CallbackParamTraits::ForwardType a6, + typename CallbackParamTraits::ForwardType a7) { + return (object->*method_)(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } + + private: + R (T::*method_)(A1, A2, A3, A4, A5, A6, A7) const; +}; + +// FunctionTraits<> +// +// Breaks a function signature apart into typedefs for easier introspection. +template +struct FunctionTraits; + +template +struct FunctionTraits { + typedef R ReturnType; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; + typedef A5 A5Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; + typedef A5 A5Type; + typedef A6 A6Type; +}; + +template +struct FunctionTraits { + typedef R ReturnType; + typedef A1 A1Type; + typedef A2 A2Type; + typedef A3 A3Type; + typedef A4 A4Type; + typedef A5 A5Type; + typedef A6 A6Type; + typedef A7 A7Type; +}; + +// ForceVoidReturn<> +// +// Set of templates that support forcing the function return type to void. +template +struct ForceVoidReturn; + +template +struct ForceVoidReturn { + typedef void(RunType)(); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4, A5); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4, A5, A6); +}; + +template +struct ForceVoidReturn { + typedef void(RunType)(A1, A2, A3, A4, A5, A6, A7); +}; + +// FunctorTraits<> +// +// See description at top of file. +template +struct FunctorTraits { + typedef RunnableAdapter RunnableType; + typedef typename RunnableType::RunType RunType; +}; + +template +struct FunctorTraits> { + typedef typename FunctorTraits::RunnableType RunnableType; + typedef + typename ForceVoidReturn::RunType RunType; +}; + +template +struct FunctorTraits> { + typedef Callback RunnableType; + typedef typename Callback::RunType RunType; +}; + +// MakeRunnable<> +// +// Converts a passed in functor to a RunnableType using type inference. + +template +typename FunctorTraits::RunnableType MakeRunnable(const T& t) { + return RunnableAdapter(t); +} + +template +typename FunctorTraits::RunnableType MakeRunnable( + const IgnoreResultHelper& t) { + return MakeRunnable(t.functor_); +} + +template +const typename FunctorTraits>::RunnableType& MakeRunnable( + const Callback& t) { + DCHECK(!t.is_null()); + return t; +} + +// InvokeHelper<> +// +// There are 3 logical InvokeHelper<> specializations: normal, void-return, +// WeakCalls. +// +// The normal type just calls the underlying runnable. +// +// We need a InvokeHelper to handle void return types in order to support +// IgnoreResult(). Normally, if the Runnable's RunType had a void return, +// the template system would just accept "return functor.Run()" ignoring +// the fact that a void function is being used with return. This piece of +// sugar breaks though when the Runnable's RunType is not void. Thus, we +// need a partial specialization to change the syntax to drop the "return" +// from the invocation call. +// +// WeakCalls similarly need special syntax that is applied to the first +// argument to check if they should no-op themselves. +template +struct InvokeHelper; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable) { return runnable.Run(); } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable) { runnable.Run(); } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1) { + return runnable.Run(CallbackForward(a1)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1) { + runnable.Run(CallbackForward(a1)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get()); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2) { + runnable.Run(CallbackForward(a1), CallbackForward(a2)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, BoundWeakPtr weak_ptr, A2 a2, A3 a3) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4)); + } +}; + +template +struct InvokeHelper { + static ReturnType MakeItSo(Runnable runnable, + A1 a1, + A2 a2, + A3 a3, + A4 a4, + A5 a5) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5)); + } +}; + +template +struct InvokeHelper { + static ReturnType + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static void + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5, + A6 a6) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6)); + } +}; + +template +struct InvokeHelper { + static ReturnType + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { + return runnable.Run(CallbackForward(a1), CallbackForward(a2), + CallbackForward(a3), CallbackForward(a4), + CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +template +struct InvokeHelper { + static void + MakeItSo(Runnable runnable, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { + runnable.Run(CallbackForward(a1), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +template +struct InvokeHelper { + static void MakeItSo(Runnable runnable, + BoundWeakPtr weak_ptr, + A2 a2, + A3 a3, + A4 a4, + A5 a5, + A6 a6, + A7 a7) { + if (!weak_ptr.get()) { + return; + } + runnable.Run(weak_ptr.get(), CallbackForward(a2), CallbackForward(a3), + CallbackForward(a4), CallbackForward(a5), CallbackForward(a6), + CallbackForward(a7)); + } +}; + +#if !defined(_MSC_VER) + +template +struct InvokeHelper { + // WeakCalls are only supported for functions with a void return type. + // Otherwise, the function result would be undefined if the the WeakPtr<> + // is invalidated. + COMPILE_ASSERT(is_void::value, + weak_ptrs_can_only_bind_to_methods_without_return_values); +}; + +#endif + +// Invoker<> +// +// See description at the top of the file. +template +struct Invoker; + +// Arity 0 -> 0. +template +struct Invoker<0, StorageType, R()> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::MakeItSo(storage->runnable_); + } +}; + +// Arity 1 -> 1. +template +struct Invoker<0, StorageType, R(X1)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType + x1)>::MakeItSo(storage->runnable_, + CallbackForward(x1)); + } +}; + +// Arity 1 -> 0. +template +struct Invoker<1, StorageType, R(X1)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1)); + } +}; + +// Arity 2 -> 2. +template +struct Invoker<0, StorageType, R(X1, X2)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType x1, + typename CallbackParamTraits::ForwardType + x2)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2)); + } +}; + +// Arity 2 -> 1. +template +struct Invoker<1, StorageType, R(X1, X2)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper::ForwardType + x2)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2)); + } +}; + +// Arity 2 -> 0. +template +struct Invoker<2, StorageType, R(X1, X2)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2)); + } +}; + +// Arity 3 -> 3. +template +struct Invoker<0, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 3 -> 2. +template +struct Invoker<1, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper::ForwardType x2, + typename CallbackParamTraits::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 3 -> 1. +template +struct Invoker<2, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper::ForwardType + x3)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 3 -> 0. +template +struct Invoker<3, StorageType, R(X1, X2, X3)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3)); + } +}; + +// Arity 4 -> 4. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 3. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 2. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper::ForwardType x3, + typename CallbackParamTraits::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 1. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper::ForwardType + x4)>::MakeItSo(storage->runnable_, + CallbackForward(x1), + CallbackForward(x2), + CallbackForward(x3), + CallbackForward(x4)); + } +}; + +// Arity 4 -> 0. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4)); + } +}; + +// Arity 5 -> 5. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 4. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 3. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 2. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4, X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 1. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X5); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x5) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x5)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 5 -> 0. +template +struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5)); + } +}; + +// Arity 6 -> 6. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 5. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 4. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 3. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4, X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 2. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X5, X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 1. +template +struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X6); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x6) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x6)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 6 -> 0. +template +struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + typename Bound6UnwrapTraits::ForwardType x6 = + Bound6UnwrapTraits::Unwrap(storage->p6_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6)); + } +}; + +// Arity 7 -> 7. +template +struct Invoker<0, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X1, X2, X3, X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename CallbackParamTraits::ForwardType x1, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 6. +template +struct Invoker<1, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X2, X3, X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x2, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 5. +template +struct Invoker<2, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X3, X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x3, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 4. +template +struct Invoker<3, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X4, X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x4, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 3. +template +struct Invoker<4, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X5, X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x5, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 2. +template +struct Invoker<5, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X6, X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType x6, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 1. +template +struct Invoker<6, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*, + typename CallbackParamTraits::ForwardType); + + typedef R(UnboundRunType)(X7); + + static R Run(BindStateBase* base, + typename CallbackParamTraits::ForwardType x7) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + typename Bound6UnwrapTraits::ForwardType x6 = + Bound6UnwrapTraits::Unwrap(storage->p6_); + return InvokeHelper< + StorageType::IsWeakCall::value, R, typename StorageType::RunnableType, + void(typename Bound1UnwrapTraits::ForwardType, + typename Bound2UnwrapTraits::ForwardType, + typename Bound3UnwrapTraits::ForwardType, + typename Bound4UnwrapTraits::ForwardType, + typename Bound5UnwrapTraits::ForwardType, + typename Bound6UnwrapTraits::ForwardType, + typename CallbackParamTraits::ForwardType + x7)>::MakeItSo(storage->runnable_, CallbackForward(x1), + CallbackForward(x2), CallbackForward(x3), + CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// Arity 7 -> 0. +template +struct Invoker<7, StorageType, R(X1, X2, X3, X4, X5, X6, X7)> { + typedef R(RunType)(BindStateBase*); + + typedef R(UnboundRunType)(); + + static R Run(BindStateBase* base) { + StorageType* storage = static_cast(base); + + // Local references to make debugger stepping easier. If in a debugger, + // you really want to warp ahead and step through the + // InvokeHelper<>::MakeItSo() call below. + typedef typename StorageType::Bound1UnwrapTraits Bound1UnwrapTraits; + typedef typename StorageType::Bound2UnwrapTraits Bound2UnwrapTraits; + typedef typename StorageType::Bound3UnwrapTraits Bound3UnwrapTraits; + typedef typename StorageType::Bound4UnwrapTraits Bound4UnwrapTraits; + typedef typename StorageType::Bound5UnwrapTraits Bound5UnwrapTraits; + typedef typename StorageType::Bound6UnwrapTraits Bound6UnwrapTraits; + typedef typename StorageType::Bound7UnwrapTraits Bound7UnwrapTraits; + + typename Bound1UnwrapTraits::ForwardType x1 = + Bound1UnwrapTraits::Unwrap(storage->p1_); + typename Bound2UnwrapTraits::ForwardType x2 = + Bound2UnwrapTraits::Unwrap(storage->p2_); + typename Bound3UnwrapTraits::ForwardType x3 = + Bound3UnwrapTraits::Unwrap(storage->p3_); + typename Bound4UnwrapTraits::ForwardType x4 = + Bound4UnwrapTraits::Unwrap(storage->p4_); + typename Bound5UnwrapTraits::ForwardType x5 = + Bound5UnwrapTraits::Unwrap(storage->p5_); + typename Bound6UnwrapTraits::ForwardType x6 = + Bound6UnwrapTraits::Unwrap(storage->p6_); + typename Bound7UnwrapTraits::ForwardType x7 = + Bound7UnwrapTraits::Unwrap(storage->p7_); + return InvokeHelper:: + MakeItSo(storage->runnable_, CallbackForward(x1), CallbackForward(x2), + CallbackForward(x3), CallbackForward(x4), CallbackForward(x5), + CallbackForward(x6), CallbackForward(x7)); + } +}; + +// BindState<> +// +// This stores all the state passed into Bind() and is also where most +// of the template resolution magic occurs. +// +// Runnable is the functor we are binding arguments to. +// RunType is type of the Run() function that the Invoker<> should use. +// Normally, this is the same as the RunType of the Runnable, but it can +// be different if an adapter like IgnoreResult() has been used. +// +// BoundArgsType contains the storage type for all the bound arguments by +// (ab)using a function type. +template +struct BindState; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef false_type IsWeakCall; + typedef Invoker<0, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + explicit BindState(const Runnable& runnable) + : BindStateBase(&Destroy), runnable_(runnable) {} + + ~BindState() {} + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; +}; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<1, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + + BindState(const Runnable& runnable, const P1& p1) + : BindStateBase(&Destroy), runnable_(runnable), p1_(p1) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; +}; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<2, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + + BindState(const Runnable& runnable, const P1& p1, const P2& p2) + : BindStateBase(&Destroy), runnable_(runnable), p1_(p1), p2_(p2) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; +}; + +template +struct BindState : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<3, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + + BindState(const Runnable& runnable, const P1& p1, const P2& p2, const P3& p3) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<4, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<5, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + typedef UnwrapTraits Bound5UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4), + p5_(p5) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; + P5 p5_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<6, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + typedef UnwrapTraits Bound5UnwrapTraits; + typedef UnwrapTraits Bound6UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4), + p5_(p5), + p6_(p6) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; + P5 p5_; + P6 p6_; +}; + +template +struct BindState + : public BindStateBase { + typedef Runnable RunnableType; + typedef IsWeakMethod::value, P1> IsWeakCall; + typedef Invoker<7, BindState, RunType> InvokerType; + typedef typename InvokerType::UnboundRunType UnboundRunType; + + // Convenience typedefs for bound argument types. + typedef UnwrapTraits Bound1UnwrapTraits; + typedef UnwrapTraits Bound2UnwrapTraits; + typedef UnwrapTraits Bound3UnwrapTraits; + typedef UnwrapTraits Bound4UnwrapTraits; + typedef UnwrapTraits Bound5UnwrapTraits; + typedef UnwrapTraits Bound6UnwrapTraits; + typedef UnwrapTraits Bound7UnwrapTraits; + + BindState(const Runnable& runnable, + const P1& p1, + const P2& p2, + const P3& p3, + const P4& p4, + const P5& p5, + const P6& p6, + const P7& p7) + : BindStateBase(&Destroy), + runnable_(runnable), + p1_(p1), + p2_(p2), + p3_(p3), + p4_(p4), + p5_(p5), + p6_(p6), + p7_(p7) { + MaybeRefcount::value, P1>::AddRef(p1_); + } + + ~BindState() { + MaybeRefcount::value, P1>::Release(p1_); + } + + static void Destroy(BindStateBase* self) { + delete static_cast(self); + } + + RunnableType runnable_; + P1 p1_; + P2 p2_; + P3 p3_; + P4 p4_; + P5 p5_; + P6 p6_; + P7 p7_; +}; + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_BIND_INTERNAL_H_ diff --git a/src/include/base/internal/cef_bind_internal_win.h b/src/include.old/base/internal/cef_bind_internal_win.h similarity index 100% rename from src/include/base/internal/cef_bind_internal_win.h rename to src/include.old/base/internal/cef_bind_internal_win.h diff --git a/src/include.old/base/internal/cef_callback_internal.h b/src/include.old/base/internal/cef_callback_internal.h new file mode 100644 index 000000000..1f2e16c97 --- /dev/null +++ b/src/include.old/base/internal/cef_callback_internal.h @@ -0,0 +1,224 @@ +// Copyright (c) 2012 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Do not include this header file directly. Use base/cef_bind.h or +// base/cef_callback.h instead. + +// This file contains utility functions and classes that help the +// implementation, and management of the Callback objects. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ + +#include + +#include "include/base/cef_atomic_ref_count.h" +#include "include/base/cef_macros.h" +#include "include/base/cef_ref_counted.h" +#include "include/base/cef_scoped_ptr.h" +#include "include/base/cef_template_util.h" + +template +class ScopedVector; + +namespace base { +namespace cef_internal { +class CallbackBase; + +// At the base level, the only task is to add reference counting data. Don't use +// RefCountedThreadSafe since it requires the destructor to be a virtual method. +// Creating a vtable for every BindState template instantiation results in a lot +// of bloat. Its only task is to call the destructor which can be done with a +// function pointer. +class BindStateBase { + protected: + explicit BindStateBase(void (*destructor)(BindStateBase*)) + : ref_count_(0), destructor_(destructor) {} + ~BindStateBase() {} + + private: + friend class scoped_refptr; + friend class CallbackBase; + + void AddRef(); + void Release(); + + AtomicRefCount ref_count_; + + // Pointer to a function that will properly destroy |this|. + void (*destructor_)(BindStateBase*); + + DISALLOW_COPY_AND_ASSIGN(BindStateBase); +}; + +// Holds the Callback methods that don't require specialization to reduce +// template bloat. +class CallbackBase { + public: + // Returns true if Callback is null (doesn't refer to anything). + bool is_null() const { return bind_state_.get() == NULL; } + + // Returns the Callback into an uninitialized state. + void Reset(); + + protected: + // In C++, it is safe to cast function pointers to function pointers of + // another type. It is not okay to use void*. We create a InvokeFuncStorage + // that that can store our function pointer, and then cast it back to + // the original type on usage. + typedef void (*InvokeFuncStorage)(void); + + // Returns true if this callback equals |other|. |other| may be null. + bool Equals(const CallbackBase& other) const; + + // Allow initializing of |bind_state_| via the constructor to avoid default + // initialization of the scoped_refptr. We do not also initialize + // |polymorphic_invoke_| here because doing a normal assignment in the + // derived Callback templates makes for much nicer compiler errors. + explicit CallbackBase(BindStateBase* bind_state); + + // Force the destructor to be instantiated inside this translation unit so + // that our subclasses will not get inlined versions. Avoids more template + // bloat. + ~CallbackBase(); + + scoped_refptr bind_state_; + InvokeFuncStorage polymorphic_invoke_; +}; + +// A helper template to determine if given type is non-const move-only-type, +// i.e. if a value of the given type should be passed via .Pass() in a +// destructive way. +template +struct IsMoveOnlyType { + template + static YesType Test(const typename U::MoveOnlyTypeForCPP03*); + + template + static NoType Test(...); + + static const bool value = + sizeof(Test(0)) == sizeof(YesType) && !is_const::value; +}; + +// This is a typetraits object that's used to take an argument type, and +// extract a suitable type for storing and forwarding arguments. +// +// In particular, it strips off references, and converts arrays to +// pointers for storage; and it avoids accidentally trying to create a +// "reference of a reference" if the argument is a reference type. +// +// This array type becomes an issue for storage because we are passing bound +// parameters by const reference. In this case, we end up passing an actual +// array type in the initializer list which C++ does not allow. This will +// break passing of C-string literals. +template ::value> +struct CallbackParamTraits { + typedef const T& ForwardType; + typedef T StorageType; +}; + +// The Storage should almost be impossible to trigger unless someone manually +// specifies type of the bind parameters. However, in case they do, +// this will guard against us accidentally storing a reference parameter. +// +// The ForwardType should only be used for unbound arguments. +template +struct CallbackParamTraits { + typedef T& ForwardType; + typedef T StorageType; +}; + +// Note that for array types, we implicitly add a const in the conversion. This +// means that it is not possible to bind array arguments to functions that take +// a non-const pointer. Trying to specialize the template based on a "const +// T[n]" does not seem to match correctly, so we are stuck with this +// restriction. +template +struct CallbackParamTraits { + typedef const T* ForwardType; + typedef const T* StorageType; +}; + +// See comment for CallbackParamTraits. +template +struct CallbackParamTraits { + typedef const T* ForwardType; + typedef const T* StorageType; +}; + +// Parameter traits for movable-but-not-copyable scopers. +// +// Callback<>/Bind() understands movable-but-not-copyable semantics where +// the type cannot be copied but can still have its state destructively +// transferred (aka. moved) to another instance of the same type by calling a +// helper function. When used with Bind(), this signifies transferal of the +// object's state to the target function. +// +// For these types, the ForwardType must not be a const reference, or a +// reference. A const reference is inappropriate, and would break const +// correctness, because we are implementing a destructive move. A non-const +// reference cannot be used with temporaries which means the result of a +// function or a cast would not be usable with Callback<> or Bind(). +template +struct CallbackParamTraits { + typedef T ForwardType; + typedef T StorageType; +}; + +// CallbackForward() is a very limited simulation of C++11's std::forward() +// used by the Callback/Bind system for a set of movable-but-not-copyable +// types. It is needed because forwarding a movable-but-not-copyable +// argument to another function requires us to invoke the proper move +// operator to create a rvalue version of the type. The supported types are +// whitelisted below as overloads of the CallbackForward() function. The +// default template compiles out to be a no-op. +// +// In C++11, std::forward would replace all uses of this function. However, it +// is impossible to implement a general std::forward with C++11 due to a lack +// of rvalue references. +// +// In addition to Callback/Bind, this is used by PostTaskAndReplyWithResult to +// simulate std::forward() and forward the result of one Callback as a +// parameter to another callback. This is to support Callbacks that return +// the movable-but-not-copyable types whitelisted above. +template +typename enable_if::value, T>::type& CallbackForward(T& t) { + return t; +} + +template +typename enable_if::value, T>::type CallbackForward(T& t) { + return t.Pass(); +} + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ diff --git a/src/include.old/base/internal/cef_lock_impl.h b/src/include.old/base/internal/cef_lock_impl.h new file mode 100644 index 000000000..470547fe0 --- /dev/null +++ b/src/include.old/base/internal/cef_lock_impl.h @@ -0,0 +1,87 @@ +// Copyright (c) 2011 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Do not include this header file directly. Use base/cef_lock.h instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_ + +#include "include/base/cef_build.h" + +#if defined(OS_WIN) +#include +#elif defined(OS_POSIX) +#include +#endif + +#include "include/base/cef_macros.h" + +namespace base { +namespace cef_internal { + +// This class implements the underlying platform-specific spin-lock mechanism +// used for the Lock class. Most users should not use LockImpl directly, but +// should instead use Lock. +class LockImpl { + public: +#if defined(OS_WIN) + typedef CRITICAL_SECTION NativeHandle; +#elif defined(OS_POSIX) + typedef pthread_mutex_t NativeHandle; +#endif + + LockImpl(); + ~LockImpl(); + + // If the lock is not held, take it and return true. If the lock is already + // held by something else, immediately return false. + bool Try(); + + // Take the lock, blocking until it is available if necessary. + void Lock(); + + // Release the lock. This must only be called by the lock's holder: after + // a successful call to Try, or a call to Lock. + void Unlock(); + + // Return the native underlying lock. + // TODO(awalker): refactor lock and condition variables so that this is + // unnecessary. + NativeHandle* native_handle() { return &native_handle_; } + + private: + NativeHandle native_handle_; + + DISALLOW_COPY_AND_ASSIGN(LockImpl); +}; + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_LOCK_IMPL_H_ diff --git a/src/include.old/base/internal/cef_raw_scoped_refptr_mismatch_checker.h b/src/include.old/base/internal/cef_raw_scoped_refptr_mismatch_checker.h new file mode 100644 index 000000000..9f2f932fe --- /dev/null +++ b/src/include.old/base/internal/cef_raw_scoped_refptr_mismatch_checker.h @@ -0,0 +1,181 @@ +// Copyright (c) 2011 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Do not include this header file directly. Use base/cef_callback.h instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ +#define CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ + +#include "include/base/cef_build.h" +#include "include/base/cef_ref_counted.h" +#include "include/base/cef_template_util.h" +#include "include/base/cef_tuple.h" + +// It is dangerous to post a task with a T* argument where T is a subtype of +// RefCounted(Base|ThreadSafeBase), since by the time the parameter is used, the +// object may already have been deleted since it was not held with a +// scoped_refptr. Example: http://crbug.com/27191 +// The following set of traits are designed to generate a compile error +// whenever this antipattern is attempted. + +namespace base { + +namespace cef_internal { + +template +struct NeedsScopedRefptrButGetsRawPtr { +#if defined(OS_WIN) + enum { value = base::false_type::value }; +#else + enum { + // Human readable translation: you needed to be a scoped_refptr if you are a + // raw pointer type and are convertible to a RefCounted(Base|ThreadSafeBase) + // type. + value = (is_pointer::value && + (is_convertible::value || + is_convertible::value)) + }; +#endif +}; + +template +struct ParamsUseScopedRefptrCorrectly { + enum { value = 0 }; +}; + +template <> +struct ParamsUseScopedRefptrCorrectly { + enum { value = 1 }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { value = !NeedsScopedRefptrButGetsRawPtr::value }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +template +struct ParamsUseScopedRefptrCorrectly> { + enum { + value = !(NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value || + NeedsScopedRefptrButGetsRawPtr::value) + }; +}; + +} // namespace cef_internal + +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_RAW_SCOPED_REFPTR_MISMATCH_CHECKER_H_ diff --git a/src/include.old/base/internal/cef_thread_checker_impl.h b/src/include.old/base/internal/cef_thread_checker_impl.h new file mode 100644 index 000000000..265469816 --- /dev/null +++ b/src/include.old/base/internal/cef_thread_checker_impl.h @@ -0,0 +1,72 @@ +// Copyright (c) 2011 Google Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Do not include this header file directly. Use base/cef_thread_checker.h +// instead. + +#ifndef CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_ +#define CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_ + +#include "include/base/cef_lock.h" +#include "include/base/cef_platform_thread.h" + +namespace base { +namespace cef_internal { + +// Real implementation of ThreadChecker, for use in debug mode, or +// for temporary use in release mode (e.g. to CHECK on a threading issue +// seen only in the wild). +// +// Note: You should almost always use the ThreadChecker class to get the +// right version for your build configuration. +class ThreadCheckerImpl { + public: + ThreadCheckerImpl(); + ~ThreadCheckerImpl(); + + bool CalledOnValidThread() const; + + // Changes the thread that is checked for in CalledOnValidThread. This may + // be useful when an object may be created on one thread and then used + // exclusively on another thread. + void DetachFromThread(); + + private: + void EnsureThreadIdAssigned() const; + + mutable base::Lock lock_; + // This is mutable so that CalledOnValidThread can set it. + // It's guarded by |lock_|. + mutable PlatformThreadRef valid_thread_id_; +}; + +} // namespace cef_internal +} // namespace base + +#endif // CEF_INCLUDE_BASE_INTERNAL_THREAD_CHECKER_IMPL_H_ diff --git a/src/include.old/cef_accessibility_handler.h b/src/include.old/cef_accessibility_handler.h new file mode 100644 index 000000000..c34e0c577 --- /dev/null +++ b/src/include.old/cef_accessibility_handler.h @@ -0,0 +1,66 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_ACCESSIBILITY_HANDLER_H_ +#define CEF_INCLUDE_CEF_ACCESSIBILITY_HANDLER_H_ +#pragma once + +#include "include/cef_values.h" + +/// +// Implement this interface to receive accessibility notification when +// accessibility events have been registered. The methods of this class will +// be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefAccessibilityHandler : public virtual CefBaseRefCounted { + public: + /// + // Called after renderer process sends accessibility tree changes to the + // browser process. + /// + /*--cef()--*/ + virtual void OnAccessibilityTreeChange(CefRefPtr value) = 0; + + /// + // Called after renderer process sends accessibility location changes to the + // browser process. + /// + /*--cef()--*/ + virtual void OnAccessibilityLocationChange(CefRefPtr value) = 0; +}; + +#endif // CEF_INCLUDE_CEF_ACCESSIBILITY_HANDLER_H_ diff --git a/src/include.old/cef_app.h b/src/include.old/cef_app.h new file mode 100644 index 000000000..3962a09c0 --- /dev/null +++ b/src/include.old/cef_app.h @@ -0,0 +1,203 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_APP_H_ +#define CEF_INCLUDE_CEF_APP_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser_process_handler.h" +#include "include/cef_command_line.h" +#include "include/cef_render_process_handler.h" +#include "include/cef_resource_bundle_handler.h" +#include "include/cef_scheme.h" + +class CefApp; + +/// +// This function should be called from the application entry point function to +// execute a secondary process. It can be used to run secondary processes from +// the browser client executable (default behavior) or from a separate +// executable specified by the CefSettings.browser_subprocess_path value. If +// called for the browser process (identified by no "type" command-line value) +// it will return immediately with a value of -1. If called for a recognized +// secondary process it will block until the process should exit and then return +// the process exit code. The |application| parameter may be empty. The +// |windows_sandbox_info| parameter is only used on Windows and may be NULL (see +// cef_sandbox_win.h for details). +/// +/*--cef(api_hash_check,optional_param=application, + optional_param=windows_sandbox_info)--*/ +int CefExecuteProcess(const CefMainArgs& args, + CefRefPtr application, + void* windows_sandbox_info); + +/// +// This function should be called on the main application thread to initialize +// the CEF browser process. The |application| parameter may be empty. A return +// value of true indicates that it succeeded and false indicates that it failed. +// The |windows_sandbox_info| parameter is only used on Windows and may be NULL +// (see cef_sandbox_win.h for details). +/// +/*--cef(api_hash_check,optional_param=application, + optional_param=windows_sandbox_info)--*/ +bool CefInitialize(const CefMainArgs& args, + const CefSettings& settings, + CefRefPtr application, + void* windows_sandbox_info); + +/// +// This function should be called on the main application thread to shut down +// the CEF browser process before the application exits. +/// +/*--cef()--*/ +void CefShutdown(); + +/// +// Perform a single iteration of CEF message loop processing. This function is +// provided for cases where the CEF message loop must be integrated into an +// existing application message loop. Use of this function is not recommended +// for most users; use either the CefRunMessageLoop() function or +// CefSettings.multi_threaded_message_loop if possible. When using this function +// care must be taken to balance performance against excessive CPU usage. It is +// recommended to enable the CefSettings.external_message_pump option when using +// this function so that CefBrowserProcessHandler::OnScheduleMessagePumpWork() +// callbacks can facilitate the scheduling process. This function should only be +// called on the main application thread and only if CefInitialize() is called +// with a CefSettings.multi_threaded_message_loop value of false. This function +// will not block. +/// +/*--cef()--*/ +void CefDoMessageLoopWork(); + +/// +// Run the CEF message loop. Use this function instead of an application- +// provided message loop to get the best balance between performance and CPU +// usage. This function should only be called on the main application thread and +// only if CefInitialize() is called with a +// CefSettings.multi_threaded_message_loop value of false. This function will +// block until a quit message is received by the system. +/// +/*--cef()--*/ +void CefRunMessageLoop(); + +/// +// Quit the CEF message loop that was started by calling CefRunMessageLoop(). +// This function should only be called on the main application thread and only +// if CefRunMessageLoop() was used. +/// +/*--cef()--*/ +void CefQuitMessageLoop(); + +/// +// Set to true before calling Windows APIs like TrackPopupMenu that enter a +// modal message loop. Set to false after exiting the modal message loop. +/// +/*--cef()--*/ +void CefSetOSModalLoop(bool osModalLoop); + +/// +// Call during process startup to enable High-DPI support on Windows 7 or newer. +// Older versions of Windows should be left DPI-unaware because they do not +// support DirectWrite and GDI fonts are kerned very badly. +/// +/*--cef(capi_name=cef_enable_highdpi_support)--*/ +void CefEnableHighDPISupport(); + +/// +// Implement this interface to provide handler implementations. Methods will be +// called by the process and/or thread indicated. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefApp : public virtual CefBaseRefCounted { + public: + /// + // Provides an opportunity to view and/or modify command-line arguments before + // processing by CEF and Chromium. The |process_type| value will be empty for + // the browser process. Do not keep a reference to the CefCommandLine object + // passed to this method. The CefSettings.command_line_args_disabled value + // can be used to start with an empty command-line object. Any values + // specified in CefSettings that equate to command-line arguments will be set + // before this method is called. Be cautious when using this method to modify + // command-line arguments for non-browser processes as this may result in + // undefined behavior including crashes. + /// + /*--cef(optional_param=process_type)--*/ + virtual void OnBeforeCommandLineProcessing( + const CefString& process_type, + CefRefPtr command_line) {} + + /// + // Provides an opportunity to register custom schemes. Do not keep a reference + // to the |registrar| object. This method is called on the main thread for + // each process and the registered schemes should be the same across all + // processes. + /// + /*--cef()--*/ + virtual void OnRegisterCustomSchemes( + CefRawPtr registrar) {} + + /// + // Return the handler for resource bundle events. If + // CefSettings.pack_loading_disabled is true a handler must be returned. If no + // handler is returned resources will be loaded from pack files. This method + // is called by the browser and render processes on multiple threads. + /// + /*--cef()--*/ + virtual CefRefPtr GetResourceBundleHandler() { + return NULL; + } + + /// + // Return the handler for functionality specific to the browser process. This + // method is called on multiple threads in the browser process. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowserProcessHandler() { + return NULL; + } + + /// + // Return the handler for functionality specific to the render process. This + // method is called on the render process main thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetRenderProcessHandler() { + return NULL; + } +}; + +#endif // CEF_INCLUDE_CEF_APP_H_ diff --git a/src/include/cef_application_mac.h b/src/include.old/cef_application_mac.h similarity index 100% rename from src/include/cef_application_mac.h rename to src/include.old/cef_application_mac.h diff --git a/src/include.old/cef_auth_callback.h b/src/include.old/cef_auth_callback.h new file mode 100644 index 000000000..fc8a10a9e --- /dev/null +++ b/src/include.old/cef_auth_callback.h @@ -0,0 +1,64 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_AUTH_CALLBACK_H_ +#define CEF_INCLUDE_CEF_AUTH_CALLBACK_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Callback interface used for asynchronous continuation of authentication +// requests. +/// +/*--cef(source=library)--*/ +class CefAuthCallback : public virtual CefBaseRefCounted { + public: + /// + // Continue the authentication request. + /// + /*--cef(capi_name=cont,optional_param=username,optional_param=password)--*/ + virtual void Continue(const CefString& username, + const CefString& password) = 0; + + /// + // Cancel the authentication request. + /// + /*--cef()--*/ + virtual void Cancel() = 0; +}; + +#endif // CEF_INCLUDE_CEF_AUTH_CALLBACK_H_ diff --git a/src/include.old/cef_base.h b/src/include.old/cef_base.h new file mode 100644 index 000000000..816108e2a --- /dev/null +++ b/src/include.old/cef_base.h @@ -0,0 +1,179 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef CEF_INCLUDE_CEF_BASE_H_ +#define CEF_INCLUDE_CEF_BASE_H_ +#pragma once + +#include "include/base/cef_atomic_ref_count.h" +#include "include/base/cef_build.h" +#include "include/base/cef_macros.h" + +// Bring in common C++ type definitions used by CEF consumers. +#include "include/internal/cef_ptr.h" +#include "include/internal/cef_types_wrappers.h" +#if defined(OS_WIN) +#include "include/internal/cef_win.h" +#elif defined(OS_MACOSX) +#include "include/internal/cef_mac.h" +#elif defined(OS_LINUX) +#include "include/internal/cef_linux.h" +#endif + +/// +// All ref-counted framework classes must extend this class. +/// +class CefBaseRefCounted { + public: + /// + // Called to increment the reference count for the object. Should be called + // for every new copy of a pointer to a given object. + /// + virtual void AddRef() const = 0; + + /// + // Called to decrement the reference count for the object. Returns true if + // the reference count is 0, in which case the object should self-delete. + /// + virtual bool Release() const = 0; + + /// + // Returns true if the reference count is 1. + /// + virtual bool HasOneRef() const = 0; + + protected: + virtual ~CefBaseRefCounted() {} +}; + +/// +// All scoped framework classes must extend this class. +/// +class CefBaseScoped { + public: + virtual ~CefBaseScoped() {} +}; + +/// +// Class that implements atomic reference counting. +/// +class CefRefCount { + public: + CefRefCount() : ref_count_(0) {} + + /// + // Increment the reference count. + /// + void AddRef() const { base::AtomicRefCountInc(&ref_count_); } + + /// + // Decrement the reference count. Returns true if the reference count is 0. + /// + bool Release() const { return !base::AtomicRefCountDec(&ref_count_); } + + /// + // Returns true if the reference count is 1. + /// + bool HasOneRef() const { return base::AtomicRefCountIsOne(&ref_count_); } + + private: + mutable base::AtomicRefCount ref_count_; + DISALLOW_COPY_AND_ASSIGN(CefRefCount); +}; + +/// +// Macro that provides a reference counting implementation for classes extending +// CefBase. +/// +#define IMPLEMENT_REFCOUNTING(ClassName) \ + public: \ + void AddRef() const OVERRIDE { ref_count_.AddRef(); } \ + bool Release() const OVERRIDE { \ + if (ref_count_.Release()) { \ + delete static_cast(this); \ + return true; \ + } \ + return false; \ + } \ + bool HasOneRef() const OVERRIDE { return ref_count_.HasOneRef(); } \ + \ + private: \ + CefRefCount ref_count_; + +/// +// Macro that provides a locking implementation. Use the Lock() and Unlock() +// methods to protect a section of code from simultaneous access by multiple +// threads. The AutoLock class is a helper that will hold the lock while in +// scope. +// +// THIS MACRO IS DEPRECATED. Use an explicit base::Lock member variable and +// base::AutoLock instead. For example: +// +// #include "include/base/cef_lock.h" +// +// // Class declaration. +// class MyClass : public CefBaseRefCounted { +// public: +// MyClass() : value_(0) {} +// // Method that may be called on multiple threads. +// void IncrementValue(); +// private: +// // Value that may be accessed on multiple theads. +// int value_; +// // Lock used to protect access to |value_|. +// base::Lock lock_; +// IMPLEMENT_REFCOUNTING(MyClass); +// }; +// +// // Class implementation. +// void MyClass::IncrementValue() { +// // Acquire the lock for the scope of this method. +// base::AutoLock lock_scope(lock_); +// // |value_| can now be modified safely. +// value_++; +// } +/// +#define IMPLEMENT_LOCKING(ClassName) \ + public: \ + class AutoLock { \ + public: \ + explicit AutoLock(ClassName* base) : base_(base) { base_->Lock(); } \ + ~AutoLock() { base_->Unlock(); } \ + \ + private: \ + ClassName* base_; \ + DISALLOW_COPY_AND_ASSIGN(AutoLock); \ + }; \ + void Lock() { lock_.Acquire(); } \ + void Unlock() { lock_.Release(); } \ + \ + private: \ + base::Lock lock_; + +#endif // CEF_INCLUDE_CEF_BASE_H_ diff --git a/src/include.old/cef_browser.h b/src/include.old/cef_browser.h new file mode 100644 index 000000000..72d9b3bae --- /dev/null +++ b/src/include.old/cef_browser.h @@ -0,0 +1,863 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_BROWSER_H_ +#define CEF_INCLUDE_CEF_BROWSER_H_ +#pragma once + +#include +#include "include/cef_base.h" +#include "include/cef_drag_data.h" +#include "include/cef_frame.h" +#include "include/cef_image.h" +#include "include/cef_navigation_entry.h" +#include "include/cef_process_message.h" +#include "include/cef_request_context.h" + +class CefBrowserHost; +class CefClient; + +/// +// Class used to represent a browser window. When used in the browser process +// the methods of this class may be called on any thread unless otherwise +// indicated in the comments. When used in the render process the methods of +// this class may only be called on the main thread. +/// +/*--cef(source=library)--*/ +class CefBrowser : public virtual CefBaseRefCounted { + public: + /// + // Returns the browser host object. This method can only be called in the + // browser process. + /// + /*--cef()--*/ + virtual CefRefPtr GetHost() = 0; + + /// + // Returns true if the browser can navigate backwards. + /// + /*--cef()--*/ + virtual bool CanGoBack() = 0; + + /// + // Navigate backwards. + /// + /*--cef()--*/ + virtual void GoBack() = 0; + + /// + // Returns true if the browser can navigate forwards. + /// + /*--cef()--*/ + virtual bool CanGoForward() = 0; + + /// + // Navigate forwards. + /// + /*--cef()--*/ + virtual void GoForward() = 0; + + /// + // Returns true if the browser is currently loading. + /// + /*--cef()--*/ + virtual bool IsLoading() = 0; + + /// + // Reload the current page. + /// + /*--cef()--*/ + virtual void Reload() = 0; + + /// + // Reload the current page ignoring any cached data. + /// + /*--cef()--*/ + virtual void ReloadIgnoreCache() = 0; + + /// + // Stop loading the page. + /// + /*--cef()--*/ + virtual void StopLoad() = 0; + + /// + // Returns the globally unique identifier for this browser. This value is also + // used as the tabId for extension APIs. + /// + /*--cef()--*/ + virtual int GetIdentifier() = 0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) = 0; + + /// + // Returns true if the window is a popup window. + /// + /*--cef()--*/ + virtual bool IsPopup() = 0; + + /// + // Returns true if a document has been loaded in the browser. + /// + /*--cef()--*/ + virtual bool HasDocument() = 0; + + /// + // Returns the main (top-level) frame for the browser window. + /// + /*--cef()--*/ + virtual CefRefPtr GetMainFrame() = 0; + + /// + // Returns the focused frame for the browser window. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusedFrame() = 0; + + /// + // Returns the frame with the specified identifier, or NULL if not found. + /// + /*--cef(capi_name=get_frame_byident)--*/ + virtual CefRefPtr GetFrame(int64 identifier) = 0; + + /// + // Returns the frame with the specified name, or NULL if not found. + /// + /*--cef(optional_param=name)--*/ + virtual CefRefPtr GetFrame(const CefString& name) = 0; + + /// + // Returns the number of frames that currently exist. + /// + /*--cef()--*/ + virtual size_t GetFrameCount() = 0; + + /// + // Returns the identifiers of all existing frames. + /// + /*--cef(count_func=identifiers:GetFrameCount)--*/ + virtual void GetFrameIdentifiers(std::vector& identifiers) = 0; + + /// + // Returns the names of all existing frames. + /// + /*--cef()--*/ + virtual void GetFrameNames(std::vector& names) = 0; + + /// + // Send a message to the specified |target_process|. Returns true if the + // message was sent successfully. + /// + /*--cef()--*/ + virtual bool SendProcessMessage(CefProcessId target_process, + CefRefPtr message) = 0; +}; + +/// +// Callback interface for CefBrowserHost::RunFileDialog. The methods of this +// class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefRunFileDialogCallback : public virtual CefBaseRefCounted { + public: + /// + // Called asynchronously after the file dialog is dismissed. + // |selected_accept_filter| is the 0-based index of the value selected from + // the accept filters array passed to CefBrowserHost::RunFileDialog. + // |file_paths| will be a single value or a list of values depending on the + // dialog mode. If the selection was cancelled |file_paths| will be empty. + /// + /*--cef(index_param=selected_accept_filter,optional_param=file_paths)--*/ + virtual void OnFileDialogDismissed( + int selected_accept_filter, + const std::vector& file_paths) = 0; +}; + +/// +// Callback interface for CefBrowserHost::GetNavigationEntries. The methods of +// this class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefNavigationEntryVisitor : public virtual CefBaseRefCounted { + public: + /// + // Method that will be executed. Do not keep a reference to |entry| outside of + // this callback. Return true to continue visiting entries or false to stop. + // |current| is true if this entry is the currently loaded navigation entry. + // |index| is the 0-based index of this entry and |total| is the total number + // of entries. + /// + /*--cef()--*/ + virtual bool Visit(CefRefPtr entry, + bool current, + int index, + int total) = 0; +}; + +/// +// Callback interface for CefBrowserHost::PrintToPDF. The methods of this class +// will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefPdfPrintCallback : public virtual CefBaseRefCounted { + public: + /// + // Method that will be executed when the PDF printing has completed. |path| + // is the output path. |ok| will be true if the printing completed + // successfully or false otherwise. + /// + /*--cef()--*/ + virtual void OnPdfPrintFinished(const CefString& path, bool ok) = 0; +}; + +/// +// Callback interface for CefBrowserHost::DownloadImage. The methods of this +// class will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefDownloadImageCallback : public virtual CefBaseRefCounted { + public: + /// + // Method that will be executed when the image download has completed. + // |image_url| is the URL that was downloaded and |http_status_code| is the + // resulting HTTP status code. |image| is the resulting image, possibly at + // multiple scale factors, or empty if the download failed. + /// + /*--cef(optional_param=image)--*/ + virtual void OnDownloadImageFinished(const CefString& image_url, + int http_status_code, + CefRefPtr image) = 0; +}; + +/// +// Class used to represent the browser process aspects of a browser window. The +// methods of this class can only be called in the browser process. They may be +// called on any thread in that process unless otherwise indicated in the +// comments. +/// +/*--cef(source=library)--*/ +class CefBrowserHost : public virtual CefBaseRefCounted { + public: + typedef cef_drag_operations_mask_t DragOperationsMask; + typedef cef_file_dialog_mode_t FileDialogMode; + typedef cef_mouse_button_type_t MouseButtonType; + typedef cef_paint_element_type_t PaintElementType; + + /// + // Create a new browser window using the window parameters specified by + // |windowInfo|. All values will be copied internally and the actual window + // will be created on the UI thread. If |request_context| is empty the + // global request context will be used. This method can be called on any + // browser process thread and will not block. + /// + /*--cef(optional_param=client,optional_param=url, + optional_param=request_context)--*/ + static bool CreateBrowser(const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings, + CefRefPtr request_context); + + /// + // Create a new browser window using the window parameters specified by + // |windowInfo|. If |request_context| is empty the global request context + // will be used. This method can only be called on the browser process UI + // thread. + /// + /*--cef(optional_param=client,optional_param=url, + optional_param=request_context)--*/ + static CefRefPtr CreateBrowserSync( + const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefString& url, + const CefBrowserSettings& settings, + CefRefPtr request_context); + + /// + // Returns the hosted browser object. + /// + /*--cef()--*/ + virtual CefRefPtr GetBrowser() = 0; + + /// + // Request that the browser close. The JavaScript 'onbeforeunload' event will + // be fired. If |force_close| is false the event handler, if any, will be + // allowed to prompt the user and the user can optionally cancel the close. + // If |force_close| is true the prompt will not be displayed and the close + // will proceed. Results in a call to CefLifeSpanHandler::DoClose() if the + // event handler allows the close or if |force_close| is true. See + // CefLifeSpanHandler::DoClose() documentation for additional usage + // information. + /// + /*--cef()--*/ + virtual void CloseBrowser(bool force_close) = 0; + + /// + // 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. + /// + /*--cef()--*/ + virtual bool TryCloseBrowser() = 0; + + /// + // Set whether the browser is focused. + /// + /*--cef()--*/ + virtual void SetFocus(bool focus) = 0; + + /// + // Retrieve the window handle for this browser. If this browser is wrapped in + // a CefBrowserView this method should be called on the browser process UI + // thread and it will return the handle for the top-level native window. + /// + /*--cef()--*/ + virtual CefWindowHandle GetWindowHandle() = 0; + + /// + // Retrieve the window handle of the browser that opened this browser. Will + // return NULL for non-popup windows or if this browser is wrapped in a + // CefBrowserView. This method can be used in combination with custom handling + // of modal windows. + /// + /*--cef()--*/ + virtual CefWindowHandle GetOpenerWindowHandle() = 0; + + /// + // Returns true if this browser is wrapped in a CefBrowserView. + /// + /*--cef()--*/ + virtual bool HasView() = 0; + + /// + // Returns the client for this browser. + /// + /*--cef()--*/ + virtual CefRefPtr GetClient() = 0; + + /// + // Returns the request context for this browser. + /// + /*--cef()--*/ + virtual CefRefPtr GetRequestContext() = 0; + + /// + // Get the current zoom level. The default zoom level is 0.0. This method can + // only be called on the UI thread. + /// + /*--cef()--*/ + virtual double GetZoomLevel() = 0; + + /// + // Change the zoom level to the specified value. Specify 0.0 to reset the + // zoom level. If called on the UI thread the change will be applied + // immediately. Otherwise, the change will be applied asynchronously on the + // UI thread. + /// + /*--cef()--*/ + virtual void SetZoomLevel(double zoomLevel) = 0; + + /// + // Call to run a file chooser dialog. Only a single file chooser dialog may be + // pending at any given time. |mode| represents the type of dialog to display. + // |title| to the title to be used for the dialog and may be empty to show the + // default title ("Open" or "Save" depending on the mode). |default_file_path| + // is the path with optional directory and/or file name component that will be + // initially selected in the dialog. |accept_filters| are used to restrict the + // selectable file types and may any combination of (a) valid lower-cased MIME + // types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. + // ".txt" or ".png"), or (c) combined description and file extension delimited + // using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg"). + // |selected_accept_filter| is the 0-based index of the filter that will be + // selected by default. |callback| will be executed after the dialog is + // dismissed or immediately if another dialog is already pending. The dialog + // will be initiated asynchronously on the UI thread. + /// + /*--cef(optional_param=title,optional_param=default_file_path, + optional_param=accept_filters,index_param=selected_accept_filter)--*/ + virtual void RunFileDialog(FileDialogMode mode, + const CefString& title, + const CefString& default_file_path, + const std::vector& accept_filters, + int selected_accept_filter, + CefRefPtr callback) = 0; + + /// + // Download the file at |url| using CefDownloadHandler. + /// + /*--cef()--*/ + virtual void StartDownload(const CefString& url) = 0; + + /// + // Download |image_url| and execute |callback| on completion with the images + // received from the renderer. If |is_favicon| is true then cookies are not + // sent and not accepted during download. Images with density independent + // pixel (DIP) sizes larger than |max_image_size| are filtered out from the + // image results. Versions of the image at different scale factors may be + // downloaded up to the maximum scale factor supported by the system. If there + // are no image results <= |max_image_size| then the smallest image is resized + // to |max_image_size| and is the only result. A |max_image_size| of 0 means + // unlimited. If |bypass_cache| is true then |image_url| is requested from the + // server even if it is present in the browser cache. + /// + /*--cef()--*/ + virtual void DownloadImage(const CefString& image_url, + bool is_favicon, + uint32 max_image_size, + bool bypass_cache, + CefRefPtr callback) = 0; + + /// + // Print the current browser contents. + /// + /*--cef()--*/ + virtual void Print() = 0; + + /// + // Print the current browser contents to the PDF file specified by |path| and + // execute |callback| on completion. The caller is responsible for deleting + // |path| when done. For PDF printing to work on Linux you must implement the + // CefPrintHandler::GetPdfPaperSize method. + /// + /*--cef(optional_param=callback)--*/ + virtual void PrintToPDF(const CefString& path, + const CefPdfPrintSettings& settings, + CefRefPtr callback) = 0; + + /// + // Search for |searchText|. |identifier| must be a unique ID and these IDs + // must strictly increase so that newer requests always have greater IDs than + // older requests. If |identifier| is zero or less than the previous ID value + // then it will be automatically assigned a new valid ID. |forward| indicates + // whether to search forward or backward within the page. |matchCase| + // indicates whether the search should be case-sensitive. |findNext| indicates + // whether this is the first request or a follow-up. The CefFindHandler + // instance, if any, returned via CefClient::GetFindHandler will be called to + // report find results. + /// + /*--cef()--*/ + virtual void Find(int identifier, + const CefString& searchText, + bool forward, + bool matchCase, + bool findNext) = 0; + + /// + // Cancel all searches that are currently going on. + /// + /*--cef()--*/ + virtual void StopFinding(bool clearSelection) = 0; + + /// + // 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. + /// + /*--cef(optional_param=windowInfo,optional_param=client, + optional_param=settings,optional_param=inspect_element_at)--*/ + virtual void ShowDevTools(const CefWindowInfo& windowInfo, + CefRefPtr client, + const CefBrowserSettings& settings, + const CefPoint& inspect_element_at) = 0; + + /// + // Explicitly close the associated DevTools browser, if any. + /// + /*--cef()--*/ + virtual void CloseDevTools() = 0; + + /// + // Returns true if this browser currently has an associated DevTools browser. + // Must be called on the browser process UI thread. + /// + /*--cef()--*/ + virtual bool HasDevTools() = 0; + + /// + // Retrieve a snapshot of current navigation entries as values sent to the + // specified visitor. If |current_only| is true only the current navigation + // entry will be sent, otherwise all navigation entries will be sent. + /// + /*--cef()--*/ + virtual void GetNavigationEntries( + CefRefPtr visitor, + bool current_only) = 0; + + /// + // Set whether mouse cursor change is disabled. + /// + /*--cef()--*/ + virtual void SetMouseCursorChangeDisabled(bool disabled) = 0; + + /// + // Returns true if mouse cursor change is disabled. + /// + /*--cef()--*/ + virtual bool IsMouseCursorChangeDisabled() = 0; + + /// + // If a misspelled word is currently selected in an editable node calling + // this method will replace it with the specified |word|. + /// + /*--cef()--*/ + virtual void ReplaceMisspelling(const CefString& word) = 0; + + /// + // Add the specified |word| to the spelling dictionary. + /// + /*--cef()--*/ + virtual void AddWordToDictionary(const CefString& word) = 0; + + /// + // Returns true if window rendering is disabled. + /// + /*--cef()--*/ + virtual bool IsWindowRenderingDisabled() = 0; + + /// + // Notify the browser that the widget has been resized. The browser will first + // call CefRenderHandler::GetViewRect to get the new size and then call + // CefRenderHandler::OnPaint asynchronously with the updated regions. This + // method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void WasResized() = 0; + + /// + // Notify the browser that it has been hidden or shown. Layouting and + // CefRenderHandler::OnPaint notification will stop when the browser is + // hidden. This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void WasHidden(bool hidden) = 0; + + /// + // Send a notification to the browser that the screen info has changed. The + // browser will then call CefRenderHandler::GetScreenInfo to update the + // screen information with the new values. This simulates moving the webview + // window from one display to another, or changing the properties of the + // current display. This method is only used when window rendering is + // disabled. + /// + /*--cef()--*/ + virtual void NotifyScreenInfoChanged() = 0; + + /// + // Invalidate the view. The browser will call CefRenderHandler::OnPaint + // asynchronously. This method is only used when window rendering is + // disabled. + /// + /*--cef()--*/ + virtual void Invalidate(PaintElementType type) = 0; + + /// + // Send a key event to the browser. + /// + /*--cef()--*/ + virtual void SendKeyEvent(const CefKeyEvent& event) = 0; + + /// + // Send a mouse click event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseClickEvent(const CefMouseEvent& event, + MouseButtonType type, + bool mouseUp, + int clickCount) = 0; + + /// + // Send a mouse move event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. + /// + /*--cef()--*/ + virtual void SendMouseMoveEvent(const CefMouseEvent& event, + bool mouseLeave) = 0; + + /// + // Send a mouse wheel event to the browser. The |x| and |y| coordinates are + // relative to the upper-left corner of the view. The |deltaX| and |deltaY| + // values represent the movement delta in the X and Y directions respectively. + // In order to scroll inside select popups with window rendering disabled + // CefRenderHandler::GetScreenPoint should be implemented properly. + /// + /*--cef()--*/ + virtual void SendMouseWheelEvent(const CefMouseEvent& event, + int deltaX, + int deltaY) = 0; + + /// + // Send a focus event to the browser. + /// + /*--cef()--*/ + virtual void SendFocusEvent(bool setFocus) = 0; + + /// + // Send a capture lost event to the browser. + /// + /*--cef()--*/ + virtual void SendCaptureLostEvent() = 0; + + /// + // Notify the browser that the window hosting it is about to be moved or + // resized. This method is only used on Windows and Linux. + /// + /*--cef()--*/ + virtual void NotifyMoveOrResizeStarted() = 0; + + /// + // Returns the maximum rate in frames per second (fps) that CefRenderHandler:: + // OnPaint will be called for a windowless browser. The actual fps may be + // lower if the browser cannot generate frames at the requested rate. The + // minimum value is 1 and the maximum value is 60 (default 30). This method + // can only be called on the UI thread. + /// + /*--cef()--*/ + virtual int GetWindowlessFrameRate() = 0; + + /// + // Set the maximum rate in frames per second (fps) that CefRenderHandler:: + // OnPaint will be called for a windowless browser. The actual fps may be + // lower if the browser cannot generate frames at the requested rate. The + // minimum value is 1 and the maximum value is 60 (default 30). Can also be + // set at browser creation via CefBrowserSettings.windowless_frame_rate. + /// + /*--cef()--*/ + virtual void SetWindowlessFrameRate(int frame_rate) = 0; + + /// + // Begins a new composition or updates the existing composition. Blink has a + // special node (a composition node) that allows the input method to change + // text without affecting other DOM nodes. |text| is the optional text that + // will be inserted into the composition node. |underlines| is an optional set + // of ranges that will be underlined in the resulting text. + // |replacement_range| is an optional range of the existing text that will be + // replaced. |selection_range| is an optional range of the resulting text that + // will be selected after insertion or replacement. The |replacement_range| + // value is only used on OS X. + // + // This method may be called multiple times as the composition changes. When + // the client is done making changes the composition should either be canceled + // or completed. To cancel the composition call ImeCancelComposition. To + // complete the composition call either ImeCommitText or + // ImeFinishComposingText. Completion is usually signaled when: + // A. The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR + // flag (on Windows), or; + // B. The client receives a "commit" signal of GtkIMContext (on Linux), or; + // C. insertText of NSTextInput is called (on Mac). + // + // This method is only used when window rendering is disabled. + /// + /*--cef(optional_param=text, optional_param=underlines)--*/ + virtual void ImeSetComposition( + const CefString& text, + const std::vector& underlines, + const CefRange& replacement_range, + const CefRange& selection_range) = 0; + + /// + // Completes the existing composition by optionally inserting the specified + // |text| into the composition node. |replacement_range| is an optional range + // of the existing text that will be replaced. |relative_cursor_pos| is where + // the cursor will be positioned relative to the current cursor position. See + // comments on ImeSetComposition for usage. The |replacement_range| and + // |relative_cursor_pos| values are only used on OS X. + // This method is only used when window rendering is disabled. + /// + /*--cef(optional_param=text)--*/ + virtual void ImeCommitText(const CefString& text, + const CefRange& replacement_range, + int relative_cursor_pos) = 0; + + /// + // Completes the existing composition by applying the current composition node + // contents. If |keep_selection| is false the current selection, if any, will + // be discarded. See comments on ImeSetComposition for usage. + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void ImeFinishComposingText(bool keep_selection) = 0; + + /// + // Cancels the existing composition and discards the composition node + // contents without applying them. See comments on ImeSetComposition for + // usage. + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void ImeCancelComposition() = 0; + + /// + // Call this method when the user drags the mouse into the web view (before + // calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). + // |drag_data| should not contain file contents as this type of data is not + // allowed to be dragged into the web view. File contents can be removed using + // CefDragData::ResetFileContents (for example, if |drag_data| comes from + // CefRenderHandler::StartDragging). + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void DragTargetDragEnter(CefRefPtr drag_data, + const CefMouseEvent& event, + DragOperationsMask allowed_ops) = 0; + + /// + // Call this method each time the mouse is moved across the web view during + // a drag operation (after calling DragTargetDragEnter and before calling + // DragTargetDragLeave/DragTargetDrop). + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void DragTargetDragOver(const CefMouseEvent& event, + DragOperationsMask allowed_ops) = 0; + + /// + // Call this method when the user drags the mouse out of the web view (after + // calling DragTargetDragEnter). + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void DragTargetDragLeave() = 0; + + /// + // Call this method when the user completes the drag operation by dropping + // the object onto the web view (after calling DragTargetDragEnter). + // The object being dropped is |drag_data|, given as an argument to + // the previous DragTargetDragEnter call. + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void DragTargetDrop(const CefMouseEvent& event) = 0; + + /// + // Call this method when the drag operation started by a + // CefRenderHandler::StartDragging call has ended either in a drop or + // by being cancelled. |x| and |y| are mouse coordinates relative to the + // upper-left corner of the view. If the web view is both the drag source + // and the drag target then all DragTarget* methods should be called before + // DragSource* mthods. + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void DragSourceEndedAt(int x, int y, DragOperationsMask op) = 0; + + /// + // Call this method when the drag operation started by a + // CefRenderHandler::StartDragging call has completed. This method may be + // called immediately without first calling DragSourceEndedAt to cancel a + // drag operation. If the web view is both the drag source and the drag + // target then all DragTarget* methods should be called before DragSource* + // mthods. + // This method is only used when window rendering is disabled. + /// + /*--cef()--*/ + virtual void DragSourceSystemDragEnded() = 0; + + /// + // Returns the current visible navigation entry for this browser. This method + // can only be called on the UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetVisibleNavigationEntry() = 0; + + /// + // Set accessibility state for all frames. |accessibility_state| may be + // default, enabled or disabled. If |accessibility_state| is STATE_DEFAULT + // then accessibility will be disabled by default and the state may be further + // controlled with the "force-renderer-accessibility" and + // "disable-renderer-accessibility" command-line switches. If + // |accessibility_state| is STATE_ENABLED then accessibility will be enabled. + // If |accessibility_state| is STATE_DISABLED then accessibility will be + // completely disabled. + // + // For windowed browsers accessibility will be enabled in Complete mode (which + // corresponds to kAccessibilityModeComplete in Chromium). In this mode all + // platform accessibility objects will be created and managed by Chromium's + // internal implementation. The client needs only to detect the screen reader + // and call this method appropriately. For example, on macOS the client can + // handle the @"AXEnhancedUserInterface" accessibility attribute to detect + // VoiceOver state changes and on Windows the client can handle WM_GETOBJECT + // with OBJID_CLIENT to detect accessibility readers. + // + // For windowless browsers accessibility will be enabled in TreeOnly mode + // (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In + // this mode renderer accessibility is enabled, the full tree is computed, and + // events are passed to CefAccessibiltyHandler, but platform accessibility + // objects are not created. The client may implement platform accessibility + // objects using CefAccessibiltyHandler callbacks if desired. + /// + /*--cef()--*/ + virtual void SetAccessibilityState(cef_state_t accessibility_state) = 0; + + /// + // Enable notifications of auto resize via CefDisplayHandler::OnAutoResize. + // Notifications are disabled by default. |min_size| and |max_size| define the + // range of allowed sizes. + /// + /*--cef()--*/ + virtual void SetAutoResizeEnabled(bool enabled, + const CefSize& min_size, + const CefSize& max_size) = 0; + + /// + // Returns the extension hosted in this browser or NULL if no extension is + // hosted. See CefRequestContext::LoadExtension for details. + /// + /*--cef()--*/ + virtual CefRefPtr GetExtension() = 0; + + /// + // Returns true if this browser is hosting an extension background script. + // Background hosts do not have a window and are not displayable. See + // CefRequestContext::LoadExtension for details. + /// + /*--cef()--*/ + virtual bool IsBackgroundHost() = 0; +}; + +#endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/src/include.old/cef_browser_process_handler.h b/src/include.old/cef_browser_process_handler.h new file mode 100644 index 000000000..fb770997b --- /dev/null +++ b/src/include.old/cef_browser_process_handler.h @@ -0,0 +1,106 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ +#define CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_command_line.h" +#include "include/cef_print_handler.h" +#include "include/cef_values.h" + +/// +// Class used to implement browser process callbacks. The methods of this class +// will be called on the browser process main thread unless otherwise indicated. +/// +/*--cef(source=client)--*/ +class CefBrowserProcessHandler : public virtual CefBaseRefCounted { + public: + /// + // Called on the browser process UI thread immediately after the CEF context + // has been initialized. + /// + /*--cef()--*/ + virtual void OnContextInitialized() {} + + /// + // Called before a child process is launched. Will be called on the browser + // process UI thread when launching a render process and on the browser + // process IO thread when launching a GPU or plugin process. Provides an + // opportunity to modify the child process command line. Do not keep a + // reference to |command_line| outside of this method. + /// + /*--cef()--*/ + virtual void OnBeforeChildProcessLaunch( + CefRefPtr command_line) {} + + /// + // Called on the browser process IO thread after the main thread has been + // created for a new render process. Provides an opportunity to specify extra + // information that will be passed to + // CefRenderProcessHandler::OnRenderThreadCreated() in the render process. Do + // not keep a reference to |extra_info| outside of this method. + /// + /*--cef()--*/ + virtual void OnRenderProcessThreadCreated( + CefRefPtr extra_info) {} + + /// + // Return the handler for printing on Linux. If a print handler is not + // provided then printing will not be supported on the Linux platform. + /// + /*--cef()--*/ + virtual CefRefPtr GetPrintHandler() { return NULL; } + + /// + // Called from any thread when work has been scheduled for the browser process + // main (UI) thread. This callback is used in combination with CefSettings. + // external_message_pump and CefDoMessageLoopWork() in cases where the CEF + // message loop must be integrated into an existing application message loop + // (see additional comments and warnings on CefDoMessageLoopWork). This + // callback should schedule a CefDoMessageLoopWork() call to happen on the + // main (UI) thread. |delay_ms| is the requested delay in milliseconds. If + // |delay_ms| is <= 0 then the call should happen reasonably soon. If + // |delay_ms| is > 0 then the call should be scheduled to happen after the + // specified delay and any currently pending scheduled call should be + // cancelled. + /// + /*--cef()--*/ + virtual void OnScheduleMessagePumpWork(int64 delay_ms) {} +}; + +#endif // CEF_INCLUDE_CEF_BROWSER_PROCESS_HANDLER_H_ diff --git a/src/include.old/cef_callback.h b/src/include.old/cef_callback.h new file mode 100644 index 000000000..e206cb976 --- /dev/null +++ b/src/include.old/cef_callback.h @@ -0,0 +1,75 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CALLBACK_H_ +#define CEF_INCLUDE_CEF_CALLBACK_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Generic callback interface used for asynchronous continuation. +/// +/*--cef(source=library)--*/ +class CefCallback : public virtual CefBaseRefCounted { + public: + /// + // Continue processing. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue() = 0; + + /// + // Cancel processing. + /// + /*--cef()--*/ + virtual void Cancel() = 0; +}; + +/// +// Generic callback interface used for asynchronous completion. +/// +/*--cef(source=client)--*/ +class CefCompletionCallback : public virtual CefBaseRefCounted { + public: + /// + // Method that will be called once the task is complete. + /// + /*--cef()--*/ + virtual void OnComplete() = 0; +}; + +#endif // CEF_INCLUDE_CEF_CALLBACK_H_ diff --git a/src/include.old/cef_client.h b/src/include.old/cef_client.h new file mode 100644 index 000000000..59173c778 --- /dev/null +++ b/src/include.old/cef_client.h @@ -0,0 +1,160 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CLIENT_H_ +#define CEF_INCLUDE_CEF_CLIENT_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_context_menu_handler.h" +#include "include/cef_dialog_handler.h" +#include "include/cef_display_handler.h" +#include "include/cef_download_handler.h" +#include "include/cef_drag_handler.h" +#include "include/cef_find_handler.h" +#include "include/cef_focus_handler.h" +#include "include/cef_jsdialog_handler.h" +#include "include/cef_keyboard_handler.h" +#include "include/cef_life_span_handler.h" +#include "include/cef_load_handler.h" +#include "include/cef_process_message.h" +#include "include/cef_render_handler.h" +#include "include/cef_request_handler.h" + +/// +// Implement this interface to provide handler implementations. +/// +/*--cef(source=client,no_debugct_check)--*/ +class CefClient : public virtual CefBaseRefCounted { + public: + /// + // Return the handler for context menus. If no handler is provided the default + // implementation will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetContextMenuHandler() { + return NULL; + } + + /// + // Return the handler for dialogs. If no handler is provided the default + // implementation will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetDialogHandler() { return NULL; } + + /// + // Return the handler for browser display state events. + /// + /*--cef()--*/ + virtual CefRefPtr GetDisplayHandler() { return NULL; } + + /// + // Return the handler for download events. If no handler is returned downloads + // will not be allowed. + /// + /*--cef()--*/ + virtual CefRefPtr GetDownloadHandler() { return NULL; } + + /// + // Return the handler for drag events. + /// + /*--cef()--*/ + virtual CefRefPtr GetDragHandler() { return NULL; } + + /// + // Return the handler for find result events. + /// + /*--cef()--*/ + virtual CefRefPtr GetFindHandler() { return NULL; } + + /// + // Return the handler for focus events. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusHandler() { return NULL; } + + /// + // Return the handler for JavaScript dialogs. If no handler is provided the + // default implementation will be used. + /// + /*--cef()--*/ + virtual CefRefPtr GetJSDialogHandler() { return NULL; } + + /// + // Return the handler for keyboard events. + /// + /*--cef()--*/ + virtual CefRefPtr GetKeyboardHandler() { return NULL; } + + /// + // Return the handler for browser life span events. + /// + /*--cef()--*/ + virtual CefRefPtr GetLifeSpanHandler() { return NULL; } + + /// + // Return the handler for browser load status events. + /// + /*--cef()--*/ + virtual CefRefPtr GetLoadHandler() { return NULL; } + + /// + // Return the handler for off-screen rendering events. + /// + /*--cef()--*/ + virtual CefRefPtr GetRenderHandler() { return NULL; } + + /// + // Return the handler for browser request events. + /// + /*--cef()--*/ + virtual CefRefPtr GetRequestHandler() { return NULL; } + + /// + // Called when a new message is received from a different process. Return true + // if the message was handled or false otherwise. Do not keep a reference to + // or attempt to access the message outside of this callback. + /// + /*--cef()--*/ + virtual bool OnProcessMessageReceived(CefRefPtr browser, + CefProcessId source_process, + CefRefPtr message) { + return false; + } +}; + +#endif // CEF_INCLUDE_CEF_CLIENT_H_ diff --git a/src/include.old/cef_command_line.h b/src/include.old/cef_command_line.h new file mode 100644 index 000000000..dd5491cd2 --- /dev/null +++ b/src/include.old/cef_command_line.h @@ -0,0 +1,208 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_COMMAND_LINE_H_ +#define CEF_INCLUDE_CEF_COMMAND_LINE_H_ +#pragma once + +#include +#include +#include "include/cef_base.h" + +/// +// Class used to create and/or parse command line arguments. Arguments with +// '--', '-' and, on Windows, '/' prefixes are considered switches. Switches +// will always precede any arguments without switch prefixes. Switches can +// optionally have a value specified using the '=' delimiter (e.g. +// "-switch=value"). An argument of "--" will terminate switch parsing with all +// subsequent tokens, regardless of prefix, being interpreted as non-switch +// arguments. Switch names are considered case-insensitive. This class can be +// used before CefInitialize() is called. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefCommandLine : public virtual CefBaseRefCounted { + public: + typedef std::vector ArgumentList; + typedef std::map SwitchMap; + + /// + // Create a new CefCommandLine instance. + /// + /*--cef(api_hash_check)--*/ + static CefRefPtr CreateCommandLine(); + + /// + // Returns the singleton global CefCommandLine object. The returned object + // will be read-only. + /// + /*--cef(api_hash_check)--*/ + static CefRefPtr GetGlobalCommandLine(); + + /// + // Returns true if this object is valid. Do not call any other methods if this + // function returns false. + /// + /*--cef()--*/ + virtual bool IsValid() = 0; + + /// + // Returns true if the values of this object are read-only. Some APIs may + // expose read-only objects. + /// + /*--cef()--*/ + virtual bool IsReadOnly() = 0; + + /// + // Returns a writable copy of this object. + /// + /*--cef()--*/ + virtual CefRefPtr Copy() = 0; + + /// + // Initialize the command line with the specified |argc| and |argv| values. + // The first argument must be the name of the program. This method is only + // supported on non-Windows platforms. + /// + /*--cef()--*/ + virtual void InitFromArgv(int argc, const char* const* argv) = 0; + + /// + // Initialize the command line with the string returned by calling + // GetCommandLineW(). This method is only supported on Windows. + /// + /*--cef()--*/ + virtual void InitFromString(const CefString& command_line) = 0; + + /// + // Reset the command-line switches and arguments but leave the program + // component unchanged. + /// + /*--cef()--*/ + virtual void Reset() = 0; + + /// + // Retrieve the original command line string as a vector of strings. + // The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } + /// + /*--cef()--*/ + virtual void GetArgv(std::vector& argv) = 0; + + /// + // Constructs and returns the represented command line string. Use this method + // cautiously because quoting behavior is unclear. + /// + /*--cef()--*/ + virtual CefString GetCommandLineString() = 0; + + /// + // Get the program part of the command line string (the first item). + /// + /*--cef()--*/ + virtual CefString GetProgram() = 0; + + /// + // Set the program part of the command line string (the first item). + /// + /*--cef()--*/ + virtual void SetProgram(const CefString& program) = 0; + + /// + // Returns true if the command line has switches. + /// + /*--cef()--*/ + virtual bool HasSwitches() = 0; + + /// + // Returns true if the command line contains the given switch. + /// + /*--cef()--*/ + virtual bool HasSwitch(const CefString& name) = 0; + + /// + // Returns the value associated with the given switch. If the switch has no + // value or isn't present this method returns the empty string. + /// + /*--cef()--*/ + virtual CefString GetSwitchValue(const CefString& name) = 0; + + /// + // Returns the map of switch names and values. If a switch has no value an + // empty string is returned. + /// + /*--cef()--*/ + virtual void GetSwitches(SwitchMap& switches) = 0; + + /// + // Add a switch to the end of the command line. If the switch has no value + // pass an empty value string. + /// + /*--cef()--*/ + virtual void AppendSwitch(const CefString& name) = 0; + + /// + // Add a switch with the specified value to the end of the command line. + /// + /*--cef()--*/ + virtual void AppendSwitchWithValue(const CefString& name, + const CefString& value) = 0; + + /// + // True if there are remaining command line arguments. + /// + /*--cef()--*/ + virtual bool HasArguments() = 0; + + /// + // Get the remaining command line arguments. + /// + /*--cef()--*/ + virtual void GetArguments(ArgumentList& arguments) = 0; + + /// + // Add an argument to the end of the command line. + /// + /*--cef()--*/ + virtual void AppendArgument(const CefString& argument) = 0; + + /// + // Insert a command before the current command. + // Common for debuggers, like "valgrind" or "gdb --args". + /// + /*--cef()--*/ + virtual void PrependWrapper(const CefString& wrapper) = 0; +}; + +#endif // CEF_INCLUDE_CEF_COMMAND_LINE_H_ diff --git a/src/include.old/cef_context_menu_handler.h b/src/include.old/cef_context_menu_handler.h new file mode 100644 index 000000000..2a2a73e61 --- /dev/null +++ b/src/include.old/cef_context_menu_handler.h @@ -0,0 +1,292 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ +#define CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" +#include "include/cef_menu_model.h" + +class CefContextMenuParams; + +/// +// Callback interface used for continuation of custom context menu display. +/// +/*--cef(source=library)--*/ +class CefRunContextMenuCallback : public virtual CefBaseRefCounted { + public: + typedef cef_event_flags_t EventFlags; + + /// + // Complete context menu display by selecting the specified |command_id| and + // |event_flags|. + /// + /*--cef(capi_name=cont)--*/ + virtual void Continue(int command_id, EventFlags event_flags) = 0; + + /// + // Cancel context menu display. + /// + /*--cef()--*/ + virtual void Cancel() = 0; +}; + +/// +// Implement this interface to handle context menu events. The methods of this +// class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefContextMenuHandler : public virtual CefBaseRefCounted { + public: + typedef cef_event_flags_t EventFlags; + + /// + // Called before a context menu is displayed. |params| provides information + // about the context menu state. |model| initially contains the default + // context menu. The |model| can be cleared to show no context menu or + // modified to show a custom menu. Do not keep references to |params| or + // |model| outside of this callback. + /// + /*--cef()--*/ + virtual void OnBeforeContextMenu(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + CefRefPtr model) {} + + /// + // Called to allow custom display of the context menu. |params| provides + // information about the context menu state. |model| contains the context menu + // model resulting from OnBeforeContextMenu. For custom display return true + // and execute |callback| either synchronously or asynchronously with the + // selected command ID. For default display return false. Do not keep + // references to |params| or |model| outside of this callback. + /// + /*--cef()--*/ + virtual bool RunContextMenu(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + CefRefPtr model, + CefRefPtr callback) { + return false; + } + + /// + // Called to execute a command selected from the context menu. Return true if + // the command was handled or false for the default implementation. See + // cef_menu_id_t for the command ids that have default implementations. All + // user-defined command ids should be between MENU_ID_USER_FIRST and + // MENU_ID_USER_LAST. |params| will have the same values as what was passed to + // OnBeforeContextMenu(). Do not keep a reference to |params| outside of this + // callback. + /// + /*--cef()--*/ + virtual bool OnContextMenuCommand(CefRefPtr browser, + CefRefPtr frame, + CefRefPtr params, + int command_id, + EventFlags event_flags) { + return false; + } + + /// + // Called when the context menu is dismissed irregardless of whether the menu + // was empty or a command was selected. + /// + /*--cef()--*/ + virtual void OnContextMenuDismissed(CefRefPtr browser, + CefRefPtr frame) {} +}; + +/// +// Provides information about the context menu state. The ethods of this class +// can only be accessed on browser process the UI thread. +/// +/*--cef(source=library)--*/ +class CefContextMenuParams : public virtual CefBaseRefCounted { + public: + typedef cef_context_menu_type_flags_t TypeFlags; + typedef cef_context_menu_media_type_t MediaType; + typedef cef_context_menu_media_state_flags_t MediaStateFlags; + typedef cef_context_menu_edit_state_flags_t EditStateFlags; + + /// + // Returns the X coordinate of the mouse where the context menu was invoked. + // Coords are relative to the associated RenderView's origin. + /// + /*--cef()--*/ + virtual int GetXCoord() = 0; + + /// + // Returns the Y coordinate of the mouse where the context menu was invoked. + // Coords are relative to the associated RenderView's origin. + /// + /*--cef()--*/ + virtual int GetYCoord() = 0; + + /// + // Returns flags representing the type of node that the context menu was + // invoked on. + /// + /*--cef(default_retval=CM_TYPEFLAG_NONE)--*/ + virtual TypeFlags GetTypeFlags() = 0; + + /// + // Returns the URL of the link, if any, that encloses the node that the + // context menu was invoked on. + /// + /*--cef()--*/ + virtual CefString GetLinkUrl() = 0; + + /// + // Returns the link URL, if any, to be used ONLY for "copy link address". We + // don't validate this field in the frontend process. + /// + /*--cef()--*/ + virtual CefString GetUnfilteredLinkUrl() = 0; + + /// + // Returns the source URL, if any, for the element that the context menu was + // invoked on. Example of elements with source URLs are img, audio, and video. + /// + /*--cef()--*/ + virtual CefString GetSourceUrl() = 0; + + /// + // Returns true if the context menu was invoked on an image which has + // non-empty contents. + /// + /*--cef()--*/ + virtual bool HasImageContents() = 0; + + /// + // Returns the title text or the alt text if the context menu was invoked on + // an image. + /// + /*--cef()--*/ + virtual CefString GetTitleText() = 0; + + /// + // Returns the URL of the top level page that the context menu was invoked on. + /// + /*--cef()--*/ + virtual CefString GetPageUrl() = 0; + + /// + // Returns the URL of the subframe that the context menu was invoked on. + /// + /*--cef()--*/ + virtual CefString GetFrameUrl() = 0; + + /// + // Returns the character encoding of the subframe that the context menu was + // invoked on. + /// + /*--cef()--*/ + virtual CefString GetFrameCharset() = 0; + + /// + // Returns the type of context node that the context menu was invoked on. + /// + /*--cef(default_retval=CM_MEDIATYPE_NONE)--*/ + virtual MediaType GetMediaType() = 0; + + /// + // Returns flags representing the actions supported by the media element, if + // any, that the context menu was invoked on. + /// + /*--cef(default_retval=CM_MEDIAFLAG_NONE)--*/ + virtual MediaStateFlags GetMediaStateFlags() = 0; + + /// + // Returns the text of the selection, if any, that the context menu was + // invoked on. + /// + /*--cef()--*/ + virtual CefString GetSelectionText() = 0; + + /// + // Returns the text of the misspelled word, if any, that the context menu was + // invoked on. + /// + /*--cef()--*/ + virtual CefString GetMisspelledWord() = 0; + + /// + // Returns true if suggestions exist, false otherwise. Fills in |suggestions| + // from the spell check service for the misspelled word if there is one. + /// + /*--cef()--*/ + virtual bool GetDictionarySuggestions( + std::vector& suggestions) = 0; + + /// + // Returns true if the context menu was invoked on an editable node. + /// + /*--cef()--*/ + virtual bool IsEditable() = 0; + + /// + // Returns true if the context menu was invoked on an editable node where + // spell-check is enabled. + /// + /*--cef()--*/ + virtual bool IsSpellCheckEnabled() = 0; + + /// + // Returns flags representing the actions supported by the editable node, if + // any, that the context menu was invoked on. + /// + /*--cef(default_retval=CM_EDITFLAG_NONE)--*/ + virtual EditStateFlags GetEditStateFlags() = 0; + + /// + // Returns true if the context menu contains items specified by the renderer + // process (for example, plugin placeholder or pepper plugin menu items). + /// + /*--cef()--*/ + virtual bool IsCustomMenu() = 0; + + /// + // Returns true if the context menu was invoked from a pepper plugin. + /// + /*--cef()--*/ + virtual bool IsPepperMenu() = 0; +}; + +#endif // CEF_INCLUDE_CEF_CONTEXT_MENU_HANDLER_H_ diff --git a/src/include.old/cef_cookie.h b/src/include.old/cef_cookie.h new file mode 100644 index 000000000..eb57630ab --- /dev/null +++ b/src/include.old/cef_cookie.h @@ -0,0 +1,230 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_COOKIE_H_ +#define CEF_INCLUDE_CEF_COOKIE_H_ +#pragma once + +#include +#include "include/cef_base.h" +#include "include/cef_callback.h" + +class CefCookieVisitor; +class CefSetCookieCallback; +class CefDeleteCookiesCallback; + +/// +// Class used for managing cookies. The methods of this class may be called on +// any thread unless otherwise indicated. +/// +/*--cef(source=library,no_debugct_check)--*/ +class CefCookieManager : public virtual CefBaseRefCounted { + public: + /// + // Returns the global cookie manager. By default data will be stored at + // CefSettings.cache_path if specified or in memory otherwise. If |callback| + // is non-NULL it will be executed asnychronously on the IO thread after the + // manager's storage has been initialized. Using this method is equivalent to + // calling CefRequestContext::GetGlobalContext()->GetDefaultCookieManager(). + /// + /*--cef(optional_param=callback)--*/ + static CefRefPtr GetGlobalManager( + CefRefPtr callback); + + /// + // Returns a cookie manager that neither stores nor retrieves cookies. All + // usage of cookies will be blocked including cookies accessed via the network + // (request/response headers), via JavaScript (document.cookie), and via + // CefCookieManager methods. No cookies will be displayed in DevTools. If you + // wish to only block cookies sent via the network use the CefRequestHandler + // CanGetCookies and CanSetCookie methods instead. + /// + /*--cef()--*/ + static CefRefPtr GetBlockingManager(); + + /// + // Creates a new cookie manager. If |path| is empty data will be stored in + // memory only. Otherwise, data will be stored at the specified |path|. To + // persist session cookies (cookies without an expiry date or validity + // interval) set |persist_session_cookies| to true. Session cookies are + // generally intended to be transient and most Web browsers do not persist + // them. If |callback| is non-NULL it will be executed asnychronously on the + // IO thread after the manager's storage has been initialized. + /// + /*--cef(optional_param=path,optional_param=callback)--*/ + static CefRefPtr CreateManager( + const CefString& path, + bool persist_session_cookies, + CefRefPtr callback); + + /// + // Set the schemes supported by this manager. The default schemes ("http", + // "https", "ws" and "wss") will always be supported. If |callback| is non- + // NULL it will be executed asnychronously on the IO thread after the change + // has been applied. Must be called before any cookies are accessed. + /// + /*--cef(optional_param=callback)--*/ + virtual void SetSupportedSchemes( + const std::vector& schemes, + CefRefPtr callback) = 0; + + /// + // Visit all cookies on the IO thread. The returned cookies are ordered by + // longest path, then by earliest creation date. Returns false if cookies + // cannot be accessed. + /// + /*--cef()--*/ + virtual bool VisitAllCookies(CefRefPtr visitor) = 0; + + /// + // Visit a subset of cookies on the IO thread. The results are filtered by the + // given url scheme, host, domain and path. If |includeHttpOnly| is true + // HTTP-only cookies will also be included in the results. The returned + // cookies are ordered by longest path, then by earliest creation date. + // Returns false if cookies cannot be accessed. + /// + /*--cef()--*/ + virtual bool VisitUrlCookies(const CefString& url, + bool includeHttpOnly, + CefRefPtr visitor) = 0; + + /// + // Sets a cookie given a valid URL and explicit user-provided cookie + // attributes. This function expects each attribute to be well-formed. It will + // check for disallowed characters (e.g. the ';' character is disallowed + // within the cookie value attribute) and fail without setting the cookie if + // such characters are found. If |callback| is non-NULL it will be executed + // asnychronously on the IO thread after the cookie has been set. Returns + // false if an invalid URL is specified or if cookies cannot be accessed. + /// + /*--cef(optional_param=callback)--*/ + virtual bool SetCookie(const CefString& url, + const CefCookie& cookie, + CefRefPtr callback) = 0; + + /// + // Delete all cookies that match the specified parameters. If both |url| and + // |cookie_name| values are specified all host and domain cookies matching + // both will be deleted. If only |url| is specified all host cookies (but not + // domain cookies) irrespective of path will be deleted. If |url| is empty all + // cookies for all hosts and domains will be deleted. If |callback| is + // non-NULL it will be executed asnychronously on the IO thread after the + // cookies have been deleted. Returns false if a non-empty invalid URL is + // specified or if cookies cannot be accessed. Cookies can alternately be + // deleted using the Visit*Cookies() methods. + /// + /*--cef(optional_param=url,optional_param=cookie_name, + optional_param=callback)--*/ + virtual bool DeleteCookies(const CefString& url, + const CefString& cookie_name, + CefRefPtr callback) = 0; + + /// + // Sets the directory path that will be used for storing cookie data. If + // |path| is empty data will be stored in memory only. Otherwise, data will be + // stored at the specified |path|. To persist session cookies (cookies without + // an expiry date or validity interval) set |persist_session_cookies| to true. + // Session cookies are generally intended to be transient and most Web + // browsers do not persist them. If |callback| is non-NULL it will be executed + // asnychronously on the IO thread after the manager's storage has been + // initialized. Returns false if cookies cannot be accessed. + /// + /*--cef(optional_param=path,optional_param=callback)--*/ + virtual bool SetStoragePath(const CefString& path, + bool persist_session_cookies, + CefRefPtr callback) = 0; + + /// + // Flush the backing store (if any) to disk. If |callback| is non-NULL it will + // be executed asnychronously on the IO thread after the flush is complete. + // Returns false if cookies cannot be accessed. + /// + /*--cef(optional_param=callback)--*/ + virtual bool FlushStore(CefRefPtr callback) = 0; +}; + +/// +// Interface to implement for visiting cookie values. The methods of this class +// will always be called on the IO thread. +/// +/*--cef(source=client)--*/ +class CefCookieVisitor : public virtual CefBaseRefCounted { + public: + /// + // Method that will be called once for each cookie. |count| is the 0-based + // index for the current cookie. |total| is the total number of cookies. + // Set |deleteCookie| to true to delete the cookie currently being visited. + // Return false to stop visiting cookies. This method may never be called if + // no cookies are found. + /// + /*--cef()--*/ + virtual bool Visit(const CefCookie& cookie, + int count, + int total, + bool& deleteCookie) = 0; +}; + +/// +// Interface to implement to be notified of asynchronous completion via +// CefCookieManager::SetCookie(). +/// +/*--cef(source=client)--*/ +class CefSetCookieCallback : public virtual CefBaseRefCounted { + public: + /// + // Method that will be called upon completion. |success| will be true if the + // cookie was set successfully. + /// + /*--cef()--*/ + virtual void OnComplete(bool success) = 0; +}; + +/// +// Interface to implement to be notified of asynchronous completion via +// CefCookieManager::DeleteCookies(). +/// +/*--cef(source=client)--*/ +class CefDeleteCookiesCallback : public virtual CefBaseRefCounted { + public: + /// + // Method that will be called upon completion. |num_deleted| will be the + // number of cookies that were deleted or -1 if unknown. + /// + /*--cef()--*/ + virtual void OnComplete(int num_deleted) = 0; +}; + +#endif // CEF_INCLUDE_CEF_COOKIE_H_ diff --git a/src/include.old/cef_crash_util.h b/src/include.old/cef_crash_util.h new file mode 100644 index 000000000..e569df74a --- /dev/null +++ b/src/include.old/cef_crash_util.h @@ -0,0 +1,142 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_CRASH_UTIL_H_ +#define CEF_INCLUDE_CEF_CRASH_UTIL_H_ +#pragma once + +/// +// Crash reporting is configured using an INI-style config file named +// "crash_reporter.cfg". On Windows and Linux this file must be placed next to +// the main application executable. On macOS this file must be placed in the +// top-level app bundle Resources directory (e.g. +// ".app/Contents/Resources"). File contents are as follows: +// +// # Comments start with a hash character and must be on their own line. +// +// [Config] +// ProductName= +// ProductVersion= +// AppName= +// ExternalHandler= +// BrowserCrashForwardingEnabled= +// ServerURL= +// RateLimitEnabled= +// MaxUploadsPerDay= +// MaxDatabaseSizeInMb= +// MaxDatabaseAgeInDays= +// +// [CrashKeys] +// my_key1= +// my_key2= +// +// Config section: +// +// If "ProductName" and/or "ProductVersion" are set then the specified values +// will be included in the crash dump metadata. On macOS if these values are set +// to empty then they will be retrieved from the Info.plist file using the +// "CFBundleName" and "CFBundleShortVersionString" keys respectively. +// +// If "AppName" is set on Windows then crash report information (metrics, +// database and dumps) will be stored locally on disk under the +// "C:\Users\[CurrentUser]\AppData\Local\[AppName]\User Data" folder. On other +// platforms the CefSettings.user_data_path value will be used. +// +// If "ExternalHandler" is set on Windows then the specified exe will be +// launched as the crashpad-handler instead of re-launching the main process +// exe. The value can be an absolute path or a path relative to the main exe +// directory. On Linux the CefSettings.browser_subprocess_path value will be +// used. On macOS the existing subprocess app bundle will be used. +// +// If "BrowserCrashForwardingEnabled" is set to true on macOS then browser +// process crashes will be forwarded to the system crash reporter. This results +// in the crash UI dialog being displayed to the user and crash reports being +// logged under "~/Library/Logs/DiagnosticReports". Forwarding of crash reports +// from non-browser processes and Debug builds is always disabled. +// +// If "ServerURL" is set then crashes will be uploaded as a multi-part POST +// request to the specified URL. Otherwise, reports will only be stored locally +// on disk. +// +// If "RateLimitEnabled" is set to true then crash report uploads will be rate +// limited as follows: +// 1. If "MaxUploadsPerDay" is set to a positive value then at most the +// specified number of crashes will be uploaded in each 24 hour period. +// 2. If crash upload fails due to a network or server error then an +// incremental backoff delay up to a maximum of 24 hours will be applied for +// retries. +// 3. If a backoff delay is applied and "MaxUploadsPerDay" is > 1 then the +// "MaxUploadsPerDay" value will be reduced to 1 until the client is +// restarted. This helps to avoid an upload flood when the network or +// server error is resolved. +// Rate limiting is not supported on Linux. +// +// If "MaxDatabaseSizeInMb" is set to a positive value then crash report storage +// on disk will be limited to that size in megabytes. For example, on Windows +// each dump is about 600KB so a "MaxDatabaseSizeInMb" value of 20 equates to +// about 34 crash reports stored on disk. Not supported on Linux. +// +// If "MaxDatabaseAgeInDays" is set to a positive value then crash reports older +// than the specified age in days will be deleted. Not supported on Linux. +// +// CrashKeys section: +// +// A maximum of 26 crash keys of each size can be specified for use by the +// application. Crash key values will be truncated based on the specified size +// (small = 64 bytes, medium = 256 bytes, large = 1024 bytes). The value of +// crash keys can be set from any thread or process using the +// CefSetCrashKeyValue function. These key/value pairs will be sent to the crash +// server along with the crash dump file. +/// +/*--cef()--*/ +bool CefCrashReportingEnabled(); + +#include "include/cef_base.h" + +/// +// Sets or clears a specific key-value pair from the crash metadata. +/// +/*--cef(optional_param=value)--*/ +void CefSetCrashKeyValue(const CefString& key, const CefString& value); + +#endif // CEF_INCLUDE_CEF_CRASH_UTIL_H_ diff --git a/src/include.old/cef_dialog_handler.h b/src/include.old/cef_dialog_handler.h new file mode 100644 index 000000000..3ce02e6c1 --- /dev/null +++ b/src/include.old/cef_dialog_handler.h @@ -0,0 +1,106 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DIALOG_HANDLER_H_ +#define CEF_INCLUDE_CEF_DIALOG_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" + +/// +// Callback interface for asynchronous continuation of file dialog requests. +/// +/*--cef(source=library)--*/ +class CefFileDialogCallback : public virtual CefBaseRefCounted { + public: + /// + // Continue the file selection. |selected_accept_filter| should be the 0-based + // index of the value selected from the accept filters array passed to + // CefDialogHandler::OnFileDialog. |file_paths| should be a single value or a + // list of values depending on the dialog mode. An empty |file_paths| value is + // treated the same as calling Cancel(). + /// + /*--cef(capi_name=cont,index_param=selected_accept_filter, + optional_param=file_paths)--*/ + virtual void Continue(int selected_accept_filter, + const std::vector& file_paths) = 0; + + /// + // Cancel the file selection. + /// + /*--cef()--*/ + virtual void Cancel() = 0; +}; + +/// +// Implement this interface to handle dialog events. The methods of this class +// will be called on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefDialogHandler : public virtual CefBaseRefCounted { + public: + typedef cef_file_dialog_mode_t FileDialogMode; + + /// + // Called to run a file chooser dialog. |mode| represents the type of dialog + // to display. |title| to the title to be used for the dialog and may be empty + // to show the default title ("Open" or "Save" depending on the mode). + // |default_file_path| is the path with optional directory and/or file name + // component that should be initially selected in the dialog. |accept_filters| + // are used to restrict the selectable file types and may any combination of + // (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), + // (b) individual file extensions (e.g. ".txt" or ".png"), or (c) combined + // description and file extension delimited using "|" and ";" (e.g. + // "Image Types|.png;.gif;.jpg"). |selected_accept_filter| is the 0-based + // index of the filter that should be selected by default. To display a custom + // dialog return true and execute |callback| either inline or at a later time. + // To display the default dialog return false. + /// + /*--cef(optional_param=title,optional_param=default_file_path, + optional_param=accept_filters,index_param=selected_accept_filter)--*/ + virtual bool OnFileDialog(CefRefPtr browser, + FileDialogMode mode, + const CefString& title, + const CefString& default_file_path, + const std::vector& accept_filters, + int selected_accept_filter, + CefRefPtr callback) { + return false; + } +}; + +#endif // CEF_INCLUDE_CEF_DIALOG_HANDLER_H_ diff --git a/src/include.old/cef_display_handler.h b/src/include.old/cef_display_handler.h new file mode 100644 index 000000000..4fdc3c312 --- /dev/null +++ b/src/include.old/cef_display_handler.h @@ -0,0 +1,140 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ +#define CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_frame.h" + +/// +// Implement this interface to handle events related to browser display state. +// The methods of this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefDisplayHandler : public virtual CefBaseRefCounted { + public: + /// + // Called when a frame's address has changed. + /// + /*--cef()--*/ + virtual void OnAddressChange(CefRefPtr browser, + CefRefPtr frame, + const CefString& url) {} + + /// + // Called when the page title changes. + /// + /*--cef(optional_param=title)--*/ + virtual void OnTitleChange(CefRefPtr browser, + const CefString& title) {} + + /// + // Called when the page icon changes. + /// + /*--cef(optional_param=icon_urls)--*/ + virtual void OnFaviconURLChange(CefRefPtr browser, + const std::vector& icon_urls) {} + + /// + // Called when web content in the page has toggled fullscreen mode. If + // |fullscreen| is true the content will automatically be sized to fill the + // browser content area. If |fullscreen| is false the content will + // automatically return to its original size and position. The client is + // responsible for resizing the browser if desired. + /// + /*--cef()--*/ + virtual void OnFullscreenModeChange(CefRefPtr browser, + bool fullscreen) {} + + /// + // Called when the browser is about to display a tooltip. |text| contains the + // text that will be displayed in the tooltip. To handle the display of the + // tooltip yourself return true. Otherwise, you can optionally modify |text| + // and then return false to allow the browser to display the tooltip. + // When window rendering is disabled the application is responsible for + // drawing tooltips and the return value is ignored. + /// + /*--cef(optional_param=text)--*/ + virtual bool OnTooltip(CefRefPtr browser, CefString& text) { + return false; + } + + /// + // Called when the browser receives a status message. |value| contains the + // text that will be displayed in the status message. + /// + /*--cef(optional_param=value)--*/ + virtual void OnStatusMessage(CefRefPtr browser, + const CefString& value) {} + + /// + // Called to display a console message. Return true to stop the message from + // being output to the console. + /// + /*--cef(optional_param=message,optional_param=source)--*/ + virtual bool OnConsoleMessage(CefRefPtr browser, + cef_log_severity_t level, + const CefString& message, + const CefString& source, + int line) { + return false; + } + + /// + // Called when auto-resize is enabled via CefBrowserHost::SetAutoResizeEnabled + // and the contents have auto-resized. |new_size| will be the desired size in + // view coordinates. Return true if the resize was handled or false for + // default handling. + /// + /*--cef()--*/ + virtual bool OnAutoResize(CefRefPtr browser, + const CefSize& new_size) { + return false; + } + + /// + // Called when the overall page loading progress has changed. |progress| + // ranges from 0.0 to 1.0. + /// + /*--cef()--*/ + virtual void OnLoadingProgressChange(CefRefPtr browser, + double progress) {} +}; + +#endif // CEF_INCLUDE_CEF_DISPLAY_HANDLER_H_ diff --git a/src/include.old/cef_dom.h b/src/include.old/cef_dom.h new file mode 100644 index 000000000..382b19305 --- /dev/null +++ b/src/include.old/cef_dom.h @@ -0,0 +1,332 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DOM_H_ +#define CEF_INCLUDE_CEF_DOM_H_ +#pragma once + +#include +#include "include/cef_base.h" + +class CefDOMDocument; +class CefDOMNode; + +/// +// Interface to implement for visiting the DOM. The methods of this class will +// be called on the render process main thread. +/// +/*--cef(source=client)--*/ +class CefDOMVisitor : public virtual CefBaseRefCounted { + public: + /// + // Method executed for visiting the DOM. The document object passed to this + // method represents a snapshot of the DOM at the time this method is + // executed. DOM objects are only valid for the scope of this method. Do not + // keep references to or attempt to access any DOM objects outside the scope + // of this method. + /// + /*--cef()--*/ + virtual void Visit(CefRefPtr document) = 0; +}; + +/// +// Class used to represent a DOM document. The methods of this class should only +// be called on the render process main thread thread. +/// +/*--cef(source=library)--*/ +class CefDOMDocument : public virtual CefBaseRefCounted { + public: + typedef cef_dom_document_type_t Type; + + /// + // Returns the document type. + /// + /*--cef(default_retval=DOM_DOCUMENT_TYPE_UNKNOWN)--*/ + virtual Type GetType() = 0; + + /// + // Returns the root document node. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() = 0; + + /// + // Returns the BODY node of an HTML document. + /// + /*--cef()--*/ + virtual CefRefPtr GetBody() = 0; + + /// + // Returns the HEAD node of an HTML document. + /// + /*--cef()--*/ + virtual CefRefPtr GetHead() = 0; + + /// + // Returns the title of an HTML document. + /// + /*--cef()--*/ + virtual CefString GetTitle() = 0; + + /// + // Returns the document element with the specified ID value. + /// + /*--cef()--*/ + virtual CefRefPtr GetElementById(const CefString& id) = 0; + + /// + // Returns the node that currently has keyboard focus. + /// + /*--cef()--*/ + virtual CefRefPtr GetFocusedNode() = 0; + + /// + // Returns true if a portion of the document is selected. + /// + /*--cef()--*/ + virtual bool HasSelection() = 0; + + /// + // Returns the selection offset within the start node. + /// + /*--cef()--*/ + virtual int GetSelectionStartOffset() = 0; + + /// + // Returns the selection offset within the end node. + /// + /*--cef()--*/ + virtual int GetSelectionEndOffset() = 0; + + /// + // Returns the contents of this selection as markup. + /// + /*--cef()--*/ + virtual CefString GetSelectionAsMarkup() = 0; + + /// + // Returns the contents of this selection as text. + /// + /*--cef()--*/ + virtual CefString GetSelectionAsText() = 0; + + /// + // Returns the base URL for the document. + /// + /*--cef()--*/ + virtual CefString GetBaseURL() = 0; + + /// + // Returns a complete URL based on the document base URL and the specified + // partial URL. + /// + /*--cef()--*/ + virtual CefString GetCompleteURL(const CefString& partialURL) = 0; +}; + +/// +// Class used to represent a DOM node. The methods of this class should only be +// called on the render process main thread. +/// +/*--cef(source=library)--*/ +class CefDOMNode : public virtual CefBaseRefCounted { + public: + typedef std::map AttributeMap; + typedef cef_dom_node_type_t Type; + + /// + // Returns the type for this node. + /// + /*--cef(default_retval=DOM_NODE_TYPE_UNSUPPORTED)--*/ + virtual Type GetType() = 0; + + /// + // Returns true if this is a text node. + /// + /*--cef()--*/ + virtual bool IsText() = 0; + + /// + // Returns true if this is an element node. + /// + /*--cef()--*/ + virtual bool IsElement() = 0; + + /// + // Returns true if this is an editable node. + /// + /*--cef()--*/ + virtual bool IsEditable() = 0; + + /// + // Returns true if this is a form control element node. + /// + /*--cef()--*/ + virtual bool IsFormControlElement() = 0; + + /// + // Returns the type of this form control element node. + /// + /*--cef()--*/ + virtual CefString GetFormControlElementType() = 0; + + /// + // Returns true if this object is pointing to the same handle as |that| + // object. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) = 0; + + /// + // Returns the name of this node. + /// + /*--cef()--*/ + virtual CefString GetName() = 0; + + /// + // Returns the value of this node. + /// + /*--cef()--*/ + virtual CefString GetValue() = 0; + + /// + // Set the value of this node. Returns true on success. + /// + /*--cef()--*/ + virtual bool SetValue(const CefString& value) = 0; + + /// + // Returns the contents of this node as markup. + /// + /*--cef()--*/ + virtual CefString GetAsMarkup() = 0; + + /// + // Returns the document associated with this node. + /// + /*--cef()--*/ + virtual CefRefPtr GetDocument() = 0; + + /// + // Returns the parent node. + /// + /*--cef()--*/ + virtual CefRefPtr GetParent() = 0; + + /// + // Returns the previous sibling node. + /// + /*--cef()--*/ + virtual CefRefPtr GetPreviousSibling() = 0; + + /// + // Returns the next sibling node. + /// + /*--cef()--*/ + virtual CefRefPtr GetNextSibling() = 0; + + /// + // Returns true if this node has child nodes. + /// + /*--cef()--*/ + virtual bool HasChildren() = 0; + + /// + // Return the first child node. + /// + /*--cef()--*/ + virtual CefRefPtr GetFirstChild() = 0; + + /// + // Returns the last child node. + /// + /*--cef()--*/ + virtual CefRefPtr GetLastChild() = 0; + + // The following methods are valid only for element nodes. + + /// + // Returns the tag name of this element. + /// + /*--cef()--*/ + virtual CefString GetElementTagName() = 0; + + /// + // Returns true if this element has attributes. + /// + /*--cef()--*/ + virtual bool HasElementAttributes() = 0; + + /// + // Returns true if this element has an attribute named |attrName|. + /// + /*--cef()--*/ + virtual bool HasElementAttribute(const CefString& attrName) = 0; + + /// + // Returns the element attribute named |attrName|. + /// + /*--cef()--*/ + virtual CefString GetElementAttribute(const CefString& attrName) = 0; + + /// + // Returns a map of all element attributes. + /// + /*--cef()--*/ + virtual void GetElementAttributes(AttributeMap& attrMap) = 0; + + /// + // Set the value for the element attribute named |attrName|. Returns true on + // success. + /// + /*--cef()--*/ + virtual bool SetElementAttribute(const CefString& attrName, + const CefString& value) = 0; + + /// + // Returns the inner text of the element. + /// + /*--cef()--*/ + virtual CefString GetElementInnerText() = 0; + + /// + // Returns the bounds of the element. + /// + /*--cef()--*/ + virtual CefRect GetElementBounds() = 0; +}; + +#endif // CEF_INCLUDE_CEF_DOM_H_ diff --git a/src/include.old/cef_download_handler.h b/src/include.old/cef_download_handler.h new file mode 100644 index 000000000..dfaeba500 --- /dev/null +++ b/src/include.old/cef_download_handler.h @@ -0,0 +1,120 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ +#define CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_download_item.h" + +/// +// Callback interface used to asynchronously continue a download. +/// +/*--cef(source=library)--*/ +class CefBeforeDownloadCallback : public virtual CefBaseRefCounted { + public: + /// + // Call to continue the download. Set |download_path| to the full file path + // for the download including the file name or leave blank to use the + // suggested name and the default temp directory. Set |show_dialog| to true + // if you do wish to show the default "Save As" dialog. + /// + /*--cef(capi_name=cont,optional_param=download_path)--*/ + virtual void Continue(const CefString& download_path, bool show_dialog) = 0; +}; + +/// +// Callback interface used to asynchronously cancel a download. +/// +/*--cef(source=library)--*/ +class CefDownloadItemCallback : public virtual CefBaseRefCounted { + public: + /// + // Call to cancel the download. + /// + /*--cef()--*/ + virtual void Cancel() = 0; + + /// + // Call to pause the download. + /// + /*--cef()--*/ + virtual void Pause() = 0; + + /// + // Call to resume the download. + /// + /*--cef()--*/ + virtual void Resume() = 0; +}; + +/// +// Class used to handle file downloads. The methods of this class will called +// on the browser process UI thread. +/// +/*--cef(source=client)--*/ +class CefDownloadHandler : public virtual CefBaseRefCounted { + public: + /// + // Called before a download begins. |suggested_name| is the suggested name for + // the download file. By default the download will be canceled. Execute + // |callback| either asynchronously or in this method to continue the download + // if desired. Do not keep a reference to |download_item| outside of this + // method. + /// + /*--cef()--*/ + virtual void OnBeforeDownload( + CefRefPtr browser, + CefRefPtr download_item, + const CefString& suggested_name, + CefRefPtr callback) = 0; + + /// + // Called when a download's status or progress information has been updated. + // This may be called multiple times before and after OnBeforeDownload(). + // Execute |callback| either asynchronously or in this method to cancel the + // download if desired. Do not keep a reference to |download_item| outside of + // this method. + /// + /*--cef()--*/ + virtual void OnDownloadUpdated(CefRefPtr browser, + CefRefPtr download_item, + CefRefPtr callback) {} +}; + +#endif // CEF_INCLUDE_CEF_DOWNLOAD_HANDLER_H_ diff --git a/src/include.old/cef_download_item.h b/src/include.old/cef_download_item.h new file mode 100644 index 000000000..930f53bb4 --- /dev/null +++ b/src/include.old/cef_download_item.h @@ -0,0 +1,154 @@ +// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ +#define CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ +#pragma once + +#include "include/cef_base.h" + +/// +// Class used to represent a download item. +/// +/*--cef(source=library)--*/ +class CefDownloadItem : public virtual CefBaseRefCounted { + public: + /// + // Returns true if this object is valid. Do not call any other methods if this + // function returns false. + /// + /*--cef()--*/ + virtual bool IsValid() = 0; + + /// + // Returns true if the download is in progress. + /// + /*--cef()--*/ + virtual bool IsInProgress() = 0; + + /// + // Returns true if the download is complete. + /// + /*--cef()--*/ + virtual bool IsComplete() = 0; + + /// + // Returns true if the download has been canceled or interrupted. + /// + /*--cef()--*/ + virtual bool IsCanceled() = 0; + + /// + // Returns a simple speed estimate in bytes/s. + /// + /*--cef()--*/ + virtual int64 GetCurrentSpeed() = 0; + + /// + // Returns the rough percent complete or -1 if the receive total size is + // unknown. + /// + /*--cef()--*/ + virtual int GetPercentComplete() = 0; + + /// + // Returns the total number of bytes. + /// + /*--cef()--*/ + virtual int64 GetTotalBytes() = 0; + + /// + // Returns the number of received bytes. + /// + /*--cef()--*/ + virtual int64 GetReceivedBytes() = 0; + + /// + // Returns the time that the download started. + /// + /*--cef()--*/ + virtual CefTime GetStartTime() = 0; + + /// + // Returns the time that the download ended. + /// + /*--cef()--*/ + virtual CefTime GetEndTime() = 0; + + /// + // Returns the full path to the downloaded or downloading file. + /// + /*--cef()--*/ + virtual CefString GetFullPath() = 0; + + /// + // Returns the unique identifier for this download. + /// + /*--cef()--*/ + virtual uint32 GetId() = 0; + + /// + // Returns the URL. + /// + /*--cef()--*/ + virtual CefString GetURL() = 0; + + /// + // Returns the original URL before any redirections. + /// + /*--cef()--*/ + virtual CefString GetOriginalUrl() = 0; + + /// + // Returns the suggested file name. + /// + /*--cef()--*/ + virtual CefString GetSuggestedFileName() = 0; + + /// + // Returns the content disposition. + /// + /*--cef()--*/ + virtual CefString GetContentDisposition() = 0; + + /// + // Returns the mime type. + /// + /*--cef()--*/ + virtual CefString GetMimeType() = 0; +}; + +#endif // CEF_INCLUDE_CEF_DOWNLOAD_ITEM_H_ diff --git a/src/include.old/cef_drag_data.h b/src/include.old/cef_drag_data.h new file mode 100644 index 000000000..35661f870 --- /dev/null +++ b/src/include.old/cef_drag_data.h @@ -0,0 +1,219 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DRAG_DATA_H_ +#define CEF_INCLUDE_CEF_DRAG_DATA_H_ +#pragma once + +#include +#include "include/cef_base.h" +#include "include/cef_image.h" +#include "include/cef_stream.h" + +/// +// Class used to represent drag data. The methods of this class may be called +// on any thread. +/// +/*--cef(source=library)--*/ +class CefDragData : public virtual CefBaseRefCounted { + public: + /// + // Create a new CefDragData object. + /// + /*--cef()--*/ + static CefRefPtr Create(); + + /// + // Returns a copy of the current object. + /// + /*--cef()--*/ + virtual CefRefPtr Clone() = 0; + + /// + // Returns true if this object is read-only. + /// + /*--cef()--*/ + virtual bool IsReadOnly() = 0; + + /// + // Returns true if the drag data is a link. + /// + /*--cef()--*/ + virtual bool IsLink() = 0; + + /// + // Returns true if the drag data is a text or html fragment. + /// + /*--cef()--*/ + virtual bool IsFragment() = 0; + + /// + // Returns true if the drag data is a file. + /// + /*--cef()--*/ + virtual bool IsFile() = 0; + + /// + // Return the link URL that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkURL() = 0; + + /// + // Return the title associated with the link being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkTitle() = 0; + + /// + // Return the metadata, if any, associated with the link being dragged. + /// + /*--cef()--*/ + virtual CefString GetLinkMetadata() = 0; + + /// + // Return the plain text fragment that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetFragmentText() = 0; + + /// + // Return the text/html fragment that is being dragged. + /// + /*--cef()--*/ + virtual CefString GetFragmentHtml() = 0; + + /// + // Return the base URL that the fragment came from. This value is used for + // resolving relative URLs and may be empty. + /// + /*--cef()--*/ + virtual CefString GetFragmentBaseURL() = 0; + + /// + // Return the name of the file being dragged out of the browser window. + /// + /*--cef()--*/ + virtual CefString GetFileName() = 0; + + /// + // Write the contents of the file being dragged out of the web view into + // |writer|. Returns the number of bytes sent to |writer|. If |writer| is + // NULL this method will return the size of the file contents in bytes. + // Call GetFileName() to get a suggested name for the file. + /// + /*--cef(optional_param=writer)--*/ + virtual size_t GetFileContents(CefRefPtr writer) = 0; + + /// + // Retrieve the list of file names that are being dragged into the browser + // window. + /// + /*--cef()--*/ + virtual bool GetFileNames(std::vector& names) = 0; + + /// + // Set the link URL that is being dragged. + /// + /*--cef(optional_param=url)--*/ + virtual void SetLinkURL(const CefString& url) = 0; + + /// + // Set the title associated with the link being dragged. + /// + /*--cef(optional_param=title)--*/ + virtual void SetLinkTitle(const CefString& title) = 0; + + /// + // Set the metadata associated with the link being dragged. + /// + /*--cef(optional_param=data)--*/ + virtual void SetLinkMetadata(const CefString& data) = 0; + + /// + // Set the plain text fragment that is being dragged. + /// + /*--cef(optional_param=text)--*/ + virtual void SetFragmentText(const CefString& text) = 0; + + /// + // Set the text/html fragment that is being dragged. + /// + /*--cef(optional_param=html)--*/ + virtual void SetFragmentHtml(const CefString& html) = 0; + + /// + // Set the base URL that the fragment came from. + /// + /*--cef(optional_param=base_url)--*/ + virtual void SetFragmentBaseURL(const CefString& base_url) = 0; + + /// + // Reset the file contents. You should do this before calling + // CefBrowserHost::DragTargetDragEnter as the web view does not allow us to + // drag in this kind of data. + /// + /*--cef()--*/ + virtual void ResetFileContents() = 0; + + /// + // Add a file that is being dragged into the webview. + /// + /*--cef(optional_param=display_name)--*/ + virtual void AddFile(const CefString& path, + const CefString& display_name) = 0; + + /// + // Get the image representation of drag data. May return NULL if no image + // representation is available. + /// + /*--cef()--*/ + virtual CefRefPtr GetImage() = 0; + + /// + // Get the image hotspot (drag start location relative to image dimensions). + /// + /*--cef()--*/ + virtual CefPoint GetImageHotspot() = 0; + + /// + // Returns true if an image representation of drag data is available. + /// + /*--cef()--*/ + virtual bool HasImage() = 0; +}; + +#endif // CEF_INCLUDE_CEF_DRAG_DATA_H_ diff --git a/src/include.old/cef_drag_handler.h b/src/include.old/cef_drag_handler.h new file mode 100644 index 000000000..0410c0d8d --- /dev/null +++ b/src/include.old/cef_drag_handler.h @@ -0,0 +1,80 @@ +// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_DRAG_HANDLER_H_ +#define CEF_INCLUDE_CEF_DRAG_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_drag_data.h" + +/// +// Implement this interface to handle events related to dragging. The methods of +// this class will be called on the UI thread. +/// +/*--cef(source=client)--*/ +class CefDragHandler : public virtual CefBaseRefCounted { + public: + typedef cef_drag_operations_mask_t DragOperationsMask; + + /// + // Called when an external drag event enters the browser window. |dragData| + // contains the drag event data and |mask| represents the type of drag + // operation. Return false for default drag handling behavior or true to + // cancel the drag event. + /// + /*--cef()--*/ + virtual bool OnDragEnter(CefRefPtr browser, + CefRefPtr dragData, + DragOperationsMask mask) { + return false; + } + + /// + // Called whenever draggable regions for the browser window change. These can + // be specified using the '-webkit-app-region: drag/no-drag' CSS-property. If + // draggable regions are never defined in a document this method will also + // never be called. If the last draggable region is removed from a document + // this method will be called with an empty vector. + /// + /*--cef()--*/ + virtual void OnDraggableRegionsChanged( + CefRefPtr browser, + const std::vector& regions) {} +}; + +#endif // CEF_INCLUDE_CEF_DRAG_HANDLER_H_ diff --git a/src/include.old/cef_extension.h b/src/include.old/cef_extension.h new file mode 100644 index 000000000..c34d01326 --- /dev/null +++ b/src/include.old/cef_extension.h @@ -0,0 +1,117 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_EXTENSION_H_ +#define CEF_INCLUDE_CEF_EXTENSION_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_values.h" + +class CefExtensionHandler; +class CefRequestContext; + +/// +// Object representing an extension. Methods may be called on any thread unless +// otherwise indicated. +/// +/*--cef(source=library)--*/ +class CefExtension : public CefBaseRefCounted { + public: + /// + // Returns the unique extension identifier. This is calculated based on the + // extension public key, if available, or on the extension path. See + // https://developer.chrome.com/extensions/manifest/key for details. + /// + /*--cef()--*/ + virtual CefString GetIdentifier() = 0; + + /// + // Returns the absolute path to the extension directory on disk. This value + // will be prefixed with PK_DIR_RESOURCES if a relative path was passed to + // CefRequestContext::LoadExtension. + /// + /*--cef()--*/ + virtual CefString GetPath() = 0; + + /// + // Returns the extension manifest contents as a CefDictionaryValue object. See + // https://developer.chrome.com/extensions/manifest for details. + /// + /*--cef()--*/ + virtual CefRefPtr GetManifest() = 0; + + /// + // Returns true if this object is the same extension as |that| object. + // Extensions are considered the same if identifier, path and loader context + // match. + /// + /*--cef()--*/ + virtual bool IsSame(CefRefPtr that) = 0; + + /// + // Returns the handler for this extension. Will return NULL for internal + // extensions or if no handler was passed to CefRequestContext::LoadExtension. + /// + /*--cef()--*/ + virtual CefRefPtr GetHandler() = 0; + + /// + // Returns the request context that loaded this extension. Will return NULL + // for internal extensions or if the extension has been unloaded. See the + // CefRequestContext::LoadExtension documentation for more information about + // loader contexts. Must be called on the browser process UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetLoaderContext() = 0; + + /// + // Returns true if this extension is currently loaded. Must be called on the + // browser process UI thread. + /// + /*--cef()--*/ + virtual bool IsLoaded() = 0; + + /// + // Unload this extension if it is not an internal extension and is currently + // loaded. Will result in a call to CefExtensionHandler::OnExtensionUnloaded + // on success. + /// + /*--cef()--*/ + virtual void Unload() = 0; +}; + +#endif // CEF_INCLUDE_CEF_EXTENSION_H_ diff --git a/src/include.old/cef_extension_handler.h b/src/include.old/cef_extension_handler.h new file mode 100644 index 000000000..7b0b86a36 --- /dev/null +++ b/src/include.old/cef_extension_handler.h @@ -0,0 +1,199 @@ +// Copyright (c) 2017 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_ +#define CEF_INCLUDE_CEF_EXTENSION_HANDLER_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_browser.h" +#include "include/cef_extension.h" +#include "include/cef_stream.h" + +class CefClient; + +/// +// Callback interface used for asynchronous continuation of +// CefExtensionHandler::GetExtensionResource. +/// +/*--cef(source=library)--*/ +class CefGetExtensionResourceCallback : public CefBaseRefCounted { + public: + /// + // Continue the request. Read the resource contents from |stream|. + /// + /*--cef(capi_name=cont,optional_param=stream)--*/ + virtual void Continue(CefRefPtr stream) = 0; + + /// + // Cancel the request. + /// + /*--cef()--*/ + virtual void Cancel() = 0; +}; + +/// +// Implement this interface to handle events related to browser extensions. +// The methods of this class will be called on the UI thread. See +// CefRequestContext::LoadExtension for information about extension loading. +/// +/*--cef(source=client)--*/ +class CefExtensionHandler : public virtual CefBaseRefCounted { + public: + /// + // Called if the CefRequestContext::LoadExtension request fails. |result| will + // be the error code. + /// + /*--cef()--*/ + virtual void OnExtensionLoadFailed(cef_errorcode_t result) {} + + /// + // Called if the CefRequestContext::LoadExtension request succeeds. + // |extension| is the loaded extension. + /// + /*--cef()--*/ + virtual void OnExtensionLoaded(CefRefPtr extension) {} + + /// + // Called after the CefExtension::Unload request has completed. + /// + /*--cef()--*/ + virtual void OnExtensionUnloaded(CefRefPtr extension) {} + + /// + // Called when an extension needs a browser to host a background script + // specified via the "background" manifest key. The browser will have no + // visible window and cannot be displayed. |extension| is the extension that + // is loading the background script. |url| is an internally generated + // reference to an HTML page that will be used to load the background script + // via a