Commit Graph

16 Commits

Author SHA1 Message Date
Alex Maitland 44fdfa94c8 Implement Javascript Binding v2 (#2247)
* JSB Rewrite - Add CefSharp.RegisterBoundObject javascript method

To get around the problem of IPC timing, I've reversed the communication, now it's the render process requesting
the bound objects, the implementation is incomplete at this stage, more just a basic proof of concept

Rewrite BindingTest.html using QUnit
One of the tests doesn't map correctly as it requires def user interaction

TODO:

- Get objects by name
- Rename Messages.h values that relate to this change so they are more descriptive
- Better error handling
- Caching of objects within a render process
- Investigate global context options, don't think it's possible to call an async method directly in the global context

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB Improve Request/Response message names

* BindingTest.html - Output stress test results

* Remove JavascriptRootObject was leftover from time we used WCF to transmit objects

* JavascriptObjectRepository - Objects are now sent in the same list with an IsAsync flag

Separation when sending over IPC with two unique lists isn't necessary

* JavascriptObjectRepository - Return objects by name or return all by default

Untabify CefAppUnmanagedWrapper.cpp
Add minor comment to CefBrowserWrapper for a reminder that we use Frame Identifier as dictionary key

* Add //TODO: JSB comments for work that's left to be done

Ideally within a render process we cache bound objects once they've been communicated,
It would also be nice to make multiple binding requests so objects can later be added dynamically

* JSB Allow multiple calls to CefSharp.RegisterBoundObject

Update BindingTest.html to name two distinct calls to different bound objects

* JSB - Add some notes about caching, no working implementation yet

* JSB - Dynamically Register object on Request

* JSB Add ability to unbind an object and rename RegisterBoundObject to BindObjectAsync

# Conflicts:
#	CefSharp.Example/Resources/BindingTest.html

* JSB BindObjectAsync - if objects already bound then return false

* JSB - Ignore Indexer properties

Were previously throwing an exception

* JSB - Add LegacyJavascriptBindingEnabled option so preserve existing behaviour

This is only useful for SPA application and those that only navigate to pages
hosting within a single domain. Any sort of cross-site navigation and a new
render process will be spawned and objects won't be bound automatically
(You can use the new methods to request they're bound yourself, at least in theory,
more testing required on this)

* Add LegacyBindingTest.html

Current disabled by default. To enable uncomment CefSharpSettings.LegacyJavascriptBindingEnabled = true;
in CefExample.cs

* RegisterJsObject and RegisterAsyncJsObject can now only be used when CefSharpSettings.LegacyJavascriptBindingEnabled = true

See https://github.com/cefsharp/CefSharp/issues/2246 for details
2018-01-22 11:33:09 +10:00
Chris cd934267c6 Updated copyright year and made sure it used same format everywhere (#1966) 2017-03-06 08:44:37 +10:00
amaitland bae3c28e92 Update copyright to 2016 2016-01-11 14:11:30 +10:00
illfang 0ddfd1cb21 added a flag indicating if the root object has already been bound 2015-10-28 20:32:12 +09:00
amaitland b236d7711c Restructure code so JavascriptRootObject's are stored and can be used across multiple CefBrowserWrapper instances (popups in this context)
Code is now very much dependant on using --process-per-tab for this structure to work
2015-09-24 18:44:30 +10:00
amaitland 9f08683669 Pass JavascriptObject in as param rather than keeping reference when calling Bind 2015-09-24 18:37:35 +10:00
cefsharp-ms 0b300d5dda Merged master 2015-07-31 17:41:00 +02:00
cefsharp-ms 0333437917 fixed tabs again 2015-07-31 17:30:07 +02:00
cefsharp-ms c395f03ba2 jscallbackregistry lifecycle is managed by javascriptrootobjectwrapper, async methods too bound by javascriptrootobjectwrapper 2015-07-31 17:26:59 +02:00
amaitland 3d19b3a587 Cleanup Binding, rather than keep references to the V8 objects, just use them and then let them be released
Code should be a little easier to debug now.
2015-07-28 22:22:30 +10:00
amaitland 1f74357e40 Going forward constructors/destructors/finalizers all go in the headers 2015-07-09 10:55:12 +10:00
rassilon 431cb511c3 * Move unmanged objects into finalizer and call finalizer from Dispose.
* Remove DisposableResources from ManagedCefBrowserAdapter
* Improve disposing of CefRequestWrapper
* Have callbacks dispose themselves.
* Allow the Application exit handler shutdown CEF from the Winforms example application.
2015-06-13 10:42:33 -04:00
rassilon 7128e40fd1 It's time for copyright updates again. Yay!
Throw in a couple of tab containing files for good measure.
Evil tabs, evil I say.
2015-04-25 02:45:21 -04:00
David Serfozo c950e7a0c8 set callbackregistry on jsobjectwrapper 2015-03-08 16:22:31 +01:00
David Serfozo bb4fe467b8 added JavascriptCallbackRegistry and wired up 2015-03-08 13:11:09 +01:00
David Serfozo 75d8a206e6 moved JavascriptRootObjectWrapper impl to separate cpp 2015-03-08 12:57:51 +01:00