Prevent calling top frame' native methods from an iframe
Posted: Tue Apr 24, 2018 9:48 am
Hi everybody.
I try to explain myself better that I can...
I've implemented some native functions in C++ that can be called by Javascript and I've registered them with CefRegisterExtension in CefRenderProcessHandler::OnWebKitInitialized() method.
My purpose is to avoid that these function being called by an iframe inside the top frame.
For example.
My function in Javascript is triggered calling MyNativeFunction()
With this code I'm able to call this function from an iframe:
I've tried deleting parent object (window.parent) when CefRenderProcessHandler::OnContextCreated() is called from a frame that is not Main Frame (!frame->IsMain()) and it works.
The question is: is there any other solution to get this result without deleting parent object in iframe window object?
Thanks in advance for any suggestions.
I try to explain myself better that I can...
I've implemented some native functions in C++ that can be called by Javascript and I've registered them with CefRegisterExtension in CefRenderProcessHandler::OnWebKitInitialized() method.
My purpose is to avoid that these function being called by an iframe inside the top frame.
For example.
My function in Javascript is triggered calling MyNativeFunction()
With this code I'm able to call this function from an iframe:
- Code: Select all
if(window.parent)
{
if(window.parent.MyNativeFunction)
{
window.parent.MyNativeFunction();
}
}
I've tried deleting parent object (window.parent) when CefRenderProcessHandler::OnContextCreated() is called from a frame that is not Main Frame (!frame->IsMain()) and it works.
The question is: is there any other solution to get this result without deleting parent object in iframe window object?
Thanks in advance for any suggestions.