I'm trying to implement onBeforeNavigation event to cefsimple example, but I'm really bad in c++ developing and now I am confused about what I'm doing
I've extends two files (my code is marked by [b] tag):
simple_app.h
- Code: Select all
// Implement application-level callbacks for the browser process.
class SimpleApp : public CefApp, public CefBrowserProcessHandler, [b]public CefRenderProcessHandler[/b] {
public:
SimpleApp();
// CefApp methods:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
OVERRIDE {
return this;
}
[b]virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler()
OVERRIDE {
return this;
}[/b]
// CefBrowserProcessHandler methods:
virtual void OnContextInitialized() OVERRIDE;
virtual void OnBeforeCommandLineProcessing(const CefString& process_type, CefRefPtr<CefCommandLine> command_line) OVERRIDE;
// CefRenderProcessHandler methods:
[b]virtual void OnWebKitInitialized() OVERRIDE;[/b]
[b]virtual bool OnBeforeNavigation(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request,
NavigationType navigation_type, bool is_redirect) OVERRIDE;[/b]
private:
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(SimpleApp);
};
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
and add new method to simple_app.cc
- Code: Select all
bool SimpleApp::OnBeforeNavigation(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, NavigationType navigation_type, bool is_redirect)
{
CefString cefval = request->GetURL();
CefString csval = cefval.c_str();
return false;
}
The problem is that my onBeforeNavigation method isn't called. Does anyone can provide some code snippets how to integrate onBeforeNavigation correctly? Also If someone could provide any advices it would be great too!