Commit Graph

111 Commits

Author SHA1 Message Date
amaitland 19a56bd7f9 CefAppUnmanagedWrapper::OnContextCreated - Fixed up merge mistake
IPC message was only sent for main frame

Follow up #2373
2018-10-28 16:52:21 +10:00
Alex Sukhovy 304a300b0c Call OnContextCreated and OnContextReleased for each frame (#2373)
* ContextEvents for each frame

* set CanExecuteJavascriptOnMainFrame

* example and comments

* whitespace fix

* comments

* whitespace

* update comments
2018-10-28 16:48:50 +10: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
amaitland 7450d0d51b JSB - Remove use of CefRegisterExtension and change Promise creator to an anon function
Use CefV8Context::Eval to create the promise using an anonymous function

Attempt to resolve #2432 (though it actually seems upgrading to a newer version resolves the underlying problem)
2018-08-27 13:12:55 +10:00
amaitland 38bc2d8365 CefAppUnmanagedWrapper::OnContextCreated - Send OnContextCreated message after Objects created
Message is now sent once the CefSharp.BindObjectAsync and helper functions are created and Legacy objects
are bound.

It should now be reliable to call CefSharp.BindObjectAsync in OnContextCreated
2018-08-05 19:56:41 +10:00
amaitland ddb2fdcbbc CefAppUnmanagedWrapper - Add comment about mapping layer so code isn't duplicated to handle camel casing of object names 2018-05-15 15:52:31 +10:00
amaitland 8f7692ae6e JSB - Add JavascriptBindingCompleteEventArgs and config options to CefSharp.BindObjectAsync
CefSharp.BindObjectAsync can now take an optional config object as first param
Include additional information when binding complete
Add option for cefSharp.bindObjectAsync (starting with lowercase latters)
Add new syntax options - not entirely complete, no variant for the options object
Add ignore cache option
2018-04-27 16:40:39 +10:00
amaitland f6e58283a6 LegacyBinding - Remove objects from cache if key already exists
Temp fix for #2301 Will be resolved properly in #2306
2018-04-20 10:45:52 +10:00
João Neves 5a713fdf7d Support uncaught exception handling (#2244)
* Added support for uncaught javascript exception in Render Process Message Handler
* Fixed typo
* Added stack frame column numbers
* Code review
* Code review
* Update JavascriptException.cs
2018-03-07 10:21:31 +10:00
amaitland 1b00c277b8 JSB Add Caching
Bound object meta data is cached within a render process
CefSharp.IsObjectCached - JS method to test if object cached
CefSharp.RemoveObjectFromCache - JS method to remove object from cache

If a request is made for multiple objects with not all of them being cached then a IPC message is sent.
When all objects already bound return response object for consistency
FindBrowserWrapper signature change - it's really not safe to throw a managed exception in the middle of unmanaged code, changed to logging and null checking
JavascriptObjectRepository - Add All Constant - Used when All objects are requested for binding (objects can also be requested by name)

TODO: Add a JS library to improve user experience when dealing with cached objects
2018-01-30 10:16:28 +10:00
amaitland 934cd70ed6 JSB BindObjectAsync return response object
Can now return additional properties, still need better error handling
2018-01-29 09:45:24 +10:00
amaitland fd64b079a2 IJavascriptObjectRepository.ObjectBoundInJavascript - Fix bug and add example 2018-01-22 12:19:51 +10:00
amaitland 7c699e3ec6 IJavascriptObjectRepositry - Add ObjectBoundInJavascript event
Executed on the thread pool when objects are bound in JS
2018-01-22 12:19:43 +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
Chris 7e2594d2e3 Added CefCustomScheme.IsCspBypassing
Resolves #2038
2017-08-29 18:00:36 +02:00
amaitland 5b472f7258 Upgrade version numbers to 58 - this is for development purposes only, there is no planned 58 version, next version is 59
Upgrade to CEF 3.3029.1611.g44e39a8 / Chromium 58.0.3029.81
2017-05-05 10:46:54 +10:00
João Neves bc83d6c247 Allow calling managed methods from objects bound with RegisterAsyncJsObject that return arrays of structs (#1981)
* Fixed problem when calling CefV8Value::CreateArray. Needs prior call to V8 context enter
* Call callback dispose in case of failure
* Support serialization of struct arrays to JS side
* Fixed formatting
2017-03-13 21:37:55 +10:00
amaitland e5ecfde20f Upgrade version number to 57.0.0
Upgrade to cef.redist.x86.3.2987.1591
CefSchemeRegistrar::AddCustomScheme has new params - IsSecure and IsCorsEnabled
Also new CefRawPtr type is used for Scheme registra
2017-03-13 10:58:03 +10:00
amaitland 5d459a5d32 Add IRenderProcessMessageHandler.OnContextReleased - native IPC message sent from render process 2017-03-07 09:23:10 +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 f2050a0861 Add scriptUrl and startLine to EvaluateScriptAsync 2016-12-02 06:10:40 +10:00
amaitland 80d6a023df Upgrade to 3.2883.1539 2016-12-01 22:56:06 +10:00
amaitland bdb37881c5 Check extraInfo list for null in OnRenderThreadCreated - one of the suggestions from #1801 (no way to reproduce the problem) 2016-09-25 20:47:23 +10:00
amaitland 4059c76bcf Add cef_logging.h include as CI server seems to be having a problem after upgrading to newer version of CEF 2016-05-30 08:59:13 +10:00
amaitland bae3c28e92 Update copyright to 2016 2016-01-11 14:11:30 +10:00
Rich McNeary a27a097df6 Change from EnableFocusedNodeChanged to FocusedNodeChangedEnabled to match the existing WindowlessRenderingEnabled setting property. 2016-01-05 07:30:23 -05:00
amaitland c18f951a97 Move OnContextCreated from IRequestHandler to IRenderProcessMessageHandler
Manually resolve some merge conflicts
2015-12-09 11:32:24 +10:00
amaitland af02212217 Merge branch 'feature/oncontextcreated' of https://github.com/amaitland/CefSharp 2015-12-09 11:26:07 +10:00
Rich McNeary 443804084e Changed to specifically request FocusNodeChanged messages. 2015-12-08 09:04:22 -05:00
Rich McNeary 1fb54241f7 Add the OptionalMessages property to CefSettings. 2015-12-07 16:27:17 -05:00
Rich McNeary 5323818d7b Fix comment. 2015-12-07 10:54:20 -05:00
Rich McNeary ae49a5385b Fix: tabs to spaces, if and for braces, use frame ID. 2015-12-07 09:48:57 -05:00
Rich McNeary 1ecf2d57b0 Initial implementation complete.
Add support for when an element node in the DOM gets focus. Also invoked
when focus passes from an element node to an non-element node or
nothing.
2015-12-04 16:01:26 -05:00
Rich McNeary ce79f71275 When OnFocusedNodeChanged data is passed from render to browser process. 2015-12-03 15:59:27 -05:00
amaitland 8cd491562d Reorder params for SetInt64, SetJsCallback and SetCefTime - they're not in a logical order 2015-12-02 19:20:54 +10:00
amaitland 6f272833fb Add IRequestHandler.OnContextCreated handler
Send an IPC message when OnContextCreated is called in the render process
Currently only called for the main frame
Should be possible to hook the DOMContentLoaded event
2015-12-02 19:04:19 +10:00
amaitland 3f15b53ab7 Resolves #1407
More the DeserializeV8Object call to within the context->Enter so a V8Object can be created
Change callback to use a struct as it's return type to demo the solution to this bug
Add missing list->SetDictionary call in V8Serialization.cpp
2015-11-18 09:17:16 +10:00
illfang ccedf79114 bind root objects created during the OnProcessMessageReceived upon the context creation triggered by the evaluation of JS.
00c926a4cc
#1354
2015-10-28 20:32:58 +09:00
amaitland 00c926a4cc Proposed solution to #1354
The problem seems to be that OnContextCreated is never called as the page has no javascript code on it.
Keep the same callbackRegistry logic for kJavascriptCallbackRequest as without a context there cannot be a callback
For kEvaluateJavascriptRequest we now manually create a callback registry for the frame if required. Once the script is executed OnContextCreated is called, the wrapper creation is ignored and the context should be released as per normal in OnContextReleased
2015-10-26 18:23:10 +10:00
Alex Maitland 99ef5399e8 Merge pull request #1356 from illfang/feature-sanitized-and-verbose-js-exception-strings
Feature sanitized and verbose js exception strings
2015-10-26 11:47:19 +10:00
illfang cd93572a1e create JS exceptions for callbacks and eval js using string utils, removed check for exception as contained in string utils 2015-10-23 16:40:42 +09:00
illfang 4fb963fc71 do not create two objects in the promis creaton function 2015-10-22 14:17:07 +09:00
amaitland 03f73b5960 Conditionally create response for kEvaluateJavascriptRequest and kJavascriptCallbackRequest (was only going to create the kEvaluateJavascriptResponse before 2015-10-19 13:40:36 +10:00
amaitland 17b7f0ced1 BindingTest - Braces on new lines
Fix CefAppUnmanagedWrapper code formatting
Slightly more descriptive error message when frame not found
2015-10-19 13:24:24 +10:00
Greg Martin a64f25193f This should fix #1336 (IJavascriptCallback.ExecuteAsync never returns when callback no longer exists) and likely fixes as-of-yet undiscovered related callback problems.
The code previously in CefAppUnmanagedWrapper.cpp's OnProcessMessageReceived method did not check for a nullptr callbackWrapper resulting in an exception.
Also note that previously the success and reponse variables were not initialized by default which I believe to have been a mistake after following all of the if..else code paths (most importantly some error conditions would never be returned back).
I added a new test to BindingTest.html entitled "Test Disposed Callback" which makes the same 1.5 second delayed callback that "Test Callback" does, but then immediately navigate the page to www.google.com.  Without the fix in CefAppUnmanagedWrapper.cpp the browser's renderer process will die in about 10 seconds.
2015-10-19 13:24:24 +10:00
illfang 91976cddba create a root object even if no objects have been registered but only bind the root object if objects are available 2015-10-15 11:35:41 +09:00
amaitland 4ba7e95012 Formatting - else if on new line
Minor change to message of callback registry is not available
2015-10-13 18:55:04 +10:00
illfang e9675a2c3e ensure destroyed root objects are not accessed in cef app unmanaged warpper message handling 2015-10-13 13:00:39 +09:00
amaitland 2f3d9f868f Make js callbacks and async methods Frame aware - add FrameId so they can be executed on a specific frame
Resolves a problem where multiple contexts are created and only the first one is dealt with properly (each frame has it's own V8 context)
2015-10-11 20:41:17 +10:00
amaitland 5869b20068 Change CefBrowserWrapper Dictionary to ConcurrentDictionary 2015-10-11 19:50:55 +10:00