class "SimpleHandler" has no member "On..."

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

class "SimpleHandler" has no member "On..."

Postby codr33 » Wed Aug 30, 2017 6:15 am

Hi, what am I doing wrong extending the cefsimple app, getting the same error with either of functions:

#1 class "SimpleHandler" has no member "OnContextCreated"
simple_handler.h
Code: Select all
#include "include/cef_render_process_handler.h"
class SimpleHandler : ... public CefRenderProcessHandler
...
virtual CefRefPtr<CefRenderProcessHandler> GetRenderProcessHandler();
virtual void OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) OVERRIDE;

simple_handler.cc
Code: Select all
void SimpleHandler::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefV8Context> context) { //do stuff }


#2 class "SimpleHandler" has no member "OnBeforeBrowse"
Code: Select all
class SimpleHandler : ... public CefRequestHandler
...
virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE { return this; }
virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, bool is_redirect) OVERRIDE;

simple_handler.cc
Code: Select all
bool SimpleHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, bool is_redirect) { //do stuff }
codr33
Newbie
 
Posts: 6
Joined: Sat Jul 22, 2017 5:42 am

Re: class "SimpleHandler" has no member "On..."

Postby codr33 » Wed Aug 30, 2017 1:09 pm

Reinstalled everything to the newest version and it worked, for reference if anyone comes across the same problem.

simple_handler.h
Code: Select all
class SimpleHandler :  /* ... */ public CefRequestHandler {
  /* ... */
  virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE { return this; }
  // CefRequestHandler methods:
  bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
                      CefRefPtr<CefFrame> frame,
                      CefRefPtr<CefRequest> request,
                      bool is_redirect) OVERRIDE;
}

simple_handler.cc
Code: Select all
bool SimpleHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
  CefRefPtr<CefFrame> frame,
  CefRefPtr<CefRequest> request,
  bool is_redirect) {
  CEF_REQUIRE_UI_THREAD();

return true; // disable links
}
Last edited by codr33 on Wed Aug 30, 2017 2:57 pm, edited 1 time in total.
codr33
Newbie
 
Posts: 6
Joined: Sat Jul 22, 2017 5:42 am

Re: class "SimpleHandler" has no member "On..."

Postby magreenblatt » Wed Aug 30, 2017 2:38 pm

Make sure you are implementing the interface that contains the method, and that the method signature matches.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: class "SimpleHandler" has no member "On..."

Postby codr33 » Thu Aug 31, 2017 12:32 pm

magreenblatt wrote:Make sure you are implementing the interface that contains the method, and that the method signature matches.


Thank you, that worked, but then I took the exact same route for OnBeforePopup and copied declaration from cef_life_span_handler.h it fails with inherited member is not allowed

Code: Select all
  virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
     CefRefPtr<CefFrame> frame,
     const CefString& target_url,
     const CefString& target_frame_name,
     CefLifeSpanHandler::WindowOpenDisposition target_disposition,
     bool user_gesture,
     const CefPopupFeatures& popupFeatures,
     CefWindowInfo& windowInfo,
     CefRefPtr<CefClient>& client,
     CefBrowserSettings& settings,
     bool* no_javascript_access) OVERRIDE;

and implemented as simply as...

Code: Select all
bool SimpleHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
   CefRefPtr<CefFrame> frame,
   const CefString& target_url,
   const CefString& target_frame_name,
   CefLifeSpanHandler::WindowOpenDisposition target_disposition,
   bool user_gesture,
   const CefPopupFeatures& popupFeatures,
   CefWindowInfo& windowInfo,
   CefRefPtr<CefClient>& client,
   CefBrowserSettings& settings,
   bool* no_javascript_access) { return true; /* true = disable popup */}
codr33
Newbie
 
Posts: 6
Joined: Sat Jul 22, 2017 5:42 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 21 guests