30 Commits

Author SHA1 Message Date
Santosh M Ghanti 9e0236876c Sync Javascript Binding - Add support for property interception (#3935)
* Core - added support for property interceptor

* Incorporated the review comments

* Incorporated the review comments 2

* Review comments exclude trygetproperty and trysetproperty for .netcore app

* Added the unit test cases for trygetproperty and trysetproperty

* Fixed .net core app build failure

* Added the separate test case for property interceptor

Co-authored-by: sghanti <santosh_ghanti@intuit.com>
2022-02-14 13:58:35 +10:00
Alex Maitland b5a83f526e Enhancement - Pluggable Javascript Naming (#3141)
* Core - Move NameConverter to IJavascriptObjectRepository

- Move NameConverter property from BindingOptions to IJavascriptObjectRepository
- Remove BindingOptions.CamelCaseJavascriptNames

**Breaking Change**

Follow up to https://github.com/cefsharp/CefSharp/commit/898ca38e7a7261b3a42c33b2abf5eac6c022ddde

* Core - Javascript Binding Pluggable Naming Improvements

- Added some basic unit tests (more required)
- DefaultBinder now accepts a IJavascriptNameConverter passed into the constructor
  to allow for conversion of names

* Core - Replace WeakReference with WeakReference<T>
2020-07-27 20:13:16 +10:00
amaitland 898ca38e7a Core - Add BindingOptions.NameConverter
- Allows for the user to provide their own IJavascriptNameConverter implementation
- Defaults to using the CamelCaseJavascriptNameConverter (which is exactly the same very basic
naming conversion used by default currently).
- If CamelCaseJavascriptNames is false then no conversion is used

Naming is now separate from the JavascriptObjectRepository and can be tested in isolation.
2020-05-30 20:02:56 +10:00
amaitland 1c73a64099 JavascriptObjectRepository - Only return Root objects (toplevel/parent objects)
GetObjects was returning all objects, even those that are sub objects
2019-06-25 19:24:57 +10:00
Chris 30ee538ce0 Added EditorConfig (#2514) 2018-09-17 00:46:21 +02:00
Chris bef5dd37c4 Maintenance - Fixed formatting, file encoding, and copyright year (#2504)
* Applied formatting

* Fixed file encoding + Updated copyright year

* Updated License

* Fixed more file encoding

* Copyright notice now shows the year the file was created
2018-09-10 10:41:13 +10:00
Alex Maitland 9b01b69d2f 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 10:24:25 +10:00
João Neves 402b2b9980 Add BindingOptions.MethodInterceptor (#2015)
* Added managed methods interception mechanism
* Introduced requested changes (improved comments and namming)
2017-06-01 10:58:43 +10:00
Chris cd934267c6 Updated copyright year and made sure it used same format everywhere (#1966) 2017-03-06 08:44:37 +10:00
Alex Maitland d4feffb554 Feature - Add IBinder (#1749)
* Add basic ModelBinding which was imported from NancyFx framework - more can be stripped out that's unused

* Add IBinder as a param when registering an object for binding
Binding is disabled by default

* Add license and remove unused using statements

* Make bind method virtual to allow for overriding
Make methods protected

* Add very basic collection support - only primitive types supported for now.
Remove unused exceptions

* Support binding a list of sub objects

* Add null check for null params

* Add BindingOptions class - remove binder and CamelCaseJavascriptNames properties - allow for additional options in the future
Breaking change.

* Add support for List<object> binding type
2016-07-20 13:38:24 +10:00
amaitland bae3c28e92 Update copyright to 2016 2016-01-11 14:11:30 +10:00
Bill Tutt dcd56c27eb Add some descriptive comments about what some of the subprocess classes do. 2015-05-02 02:36:10 -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
amaitland f12643ea47 Cherry picked changes from https://github.com/cefsharp/CefSharp/pull/972
Remove empty set from BoundObject example
Untabify BrowserProcessResponse
Make CamelCaseJavascriptNames (consistency, class should probably be made internal as a whole)
make JavascriptObjectRepository.CreateJavascriptObject private
Remove redundant using
2015-04-25 11:50:52 +10:00
Erguotou fa43ec9997 Pass down camelCaseJavascriptNames to subobjects
For consistency, pass down camelCaseJavascriptNames flag to
sub-objects so that naming remain the same.
2015-04-25 11:50:52 +10:00
amaitland 0b4d80a460 Add License disclaimer 2014-08-29 12:39:53 +10:00
amaitland 5caa457210 Start of restructure of JavascriptObject hierarchy 2014-08-28 14:47:11 +10:00
amaitland 1b1f40c99f Separate Methods and Properties into two distinct types (stored differently) 2014-08-28 13:45:23 +10:00
amaitland 68494b91b4 Move object analysis into JavascriptObjectRepository - start of converting JavascriptObject to more like a DTO 2014-08-28 13:01:45 +10:00
amaitland d82232241f Remove Description classes - simplify code 2014-07-11 16:30:28 +10:00
Per Lundberg 6a5ac3cf9a I didn't quite like the dummy Bind() implementation in JavascriptMember. Here is my attempt at making it working slightly more elegantly, even though it is by no means perfect... 2014-06-12 06:29:25 +03:00
Per Lundberg 2fc573b321 Use the ternary operator here also. 2014-06-12 06:23:13 +03:00
Per Lundberg 599385f373 Whitespace cleanup. 2014-06-12 04:55:19 +03:00
JanEggers 96d19deb34 fine tuning on analyse of .Net Objects so the BoundObject registered by the example does not throw exceptions 2014-06-02 22:39:23 +02:00
JanEggers eec7360204 added ToString for some classes for better debugging 2014-06-02 22:36:50 +02:00
Per Lundberg ce9064731b Minor cleanups. 2014-06-02 12:28:57 +01:00
JanEggers 731ebf67a9 reversed subprocess communication now Browser is host and renderer is client 2014-05-24 19:43:34 +02:00
JanEggers c9ce4b6732 added reflection code in browser process 2014-05-10 20:36:47 +02:00
JanEggers e8d60b32c4 added some more meta data 2014-05-10 15:44:00 +02:00
Per Lundberg a03e5878b0 Let's go with the name "Javascript" everywhere, instead of JavaScript. The latter is arguably more "correct", but the former is also quite widespread and you could very well claim that "Javascript" is a such a common name that it can be normalized to follow normal "name rules", i.e. capitalize first letter only... 2014-04-02 18:18:13 +01:00