implementing virtual function; no member function declared in class

I get the following error:

1
2
no ‘CefRequestHandler::ReturnValue SimpleHandler::OnBeforeResourceLoad(CefRefPtr<CefBrowser>, CefRefPtr<CefFrame>, CefRefPtr<CefRequest>, CefRefPtr<CefRequestCallback>)’ member function declared in class ‘SimpleHandler’
 CefRequestHandler::ReturnValue SimpleHandler::OnBeforeResourceLoad( CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request, CefRefPtr< CefRequestCallback > callback )




Here is the virtual function I paste my SimpleHandler class from the cef_request_handler.h/CefRequestHandler class:

1
2
3
4
5
virtual  CefRequestHandler::ReturnValue OnBeforeResourceLoad(
      CefRefPtr<CefBrowser> browser,
      CefRefPtr<CefFrame> frame,
      CefRefPtr<CefRequest> request,
      CefRefPtr<CefRequestCallback> callback) OVERRIDE;


this is in my simple_handler.cc file:


1
2
3
4
5
6
7
8
9
10
11
 CefRequestHandler::ReturnValue SimpleHandler::OnBeforeResourceLoad( CefRefPtr< CefBrowser > browser, CefRefPtr< CefFrame > frame, CefRefPtr< CefRequest > request, CefRefPtr< CefRequestCallback > callback )

    {

    CefRequest::ReferrerPolicy origin = REFERRER_POLICY_ALWAYS;
    request->SetReferrer("www.google.com",origin);


        return RV_CONTINUE;

    }

The function is here: http://magpcss.org/ceforum/apidocs/projects/%28default%29/cef_request_handler.h.html

I have tried including the #include "include/cef_request_handler.h" file in both simple_handler.cc and simple_handler.h with no change in error.

I tried pulling the method from the CefRequestHandler but get unable to redefine error. I tried extending the CefRequestHandler class within SimpleHandler and that did nothing. I even removed one extended class that SimpleHandler uses and received no error for doing so when compiling.
get the same error when I include or do not include the " CefRequestHandler::" in the OVERRIDE statement in simple_handler.h/SimpleHandler class


I am mimicking how other virutal method are implemented and I am receiving an error.

Where am I going wrong. It must be something simple. Does it deal with the return value? CefRequestHandler::ReturnValue


thanks
Last edited on
Hi,

Can you try surrounding your code elements with code tags? (Hit the pair of angled brackets when you edit your post).

Cheers,
Joe
concord spark tutor
@Little Captain
> Can you try surrounding your code elements with code tags? (Hit the pair of angled brackets when you edit your post).

They are errors, not code

@wrightpt
What library are you trying to get? Are you closely following their given instructions and is the library compatible with your compiler?
closed account 5a8Ym39o wrote:
They are errors, not code

Had you bothered reading past the first 5 lines of the OP you might've seen code. Of course, it doesn't look much like code since it isn't wrapped in [code]tags[/code].

Here is the virtual function I paste my SimpleHandler class from the cef_request_handler.h/CefRequestHandler class:

1
2
3
4
5
virtual CefRequestHandler::ReturnValue 
        OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser,
                             CefRefPtr<CefFrame> frame,
                             CefRefPtr<CefRequest> request,
                             CefRefPtr<CefRequestCallback> callback) OVERRIDE;


It that is actually present in the definition of your SimpleHandler class, you shouldn't receive the (incomplete) error message you supplied. I'd double check and make sure things are as they should be there. (You didn't supply the context, so we can't check for you.)

Thank you everyone for responding. I am sorry for not formatting my code improperly. I was getting the error because I was modifying the wrong simple_handler.h file. I was modifying the project file but it was located in the binary section.

I am working with the Chromium Embedded Framework.


I think the issue is how I am actually calling the setreferrer method. I modeled it after other functions being called in the Simplehandler class.


2 functions I have added into SimpleHandler class:




1
2
3
4
5
6
7
8
9
10
11
12
13
  // Return the handler for browser request events.
      ///
      /*--cef()--*/
     CefRefPtr<CefRequestHandler> GetRequestHandler() override {
            return this;
          }
    
    
     virtual CefRequestHandler::ReturnValue OnBeforeResourceLoad(
              CefRefPtr<CefBrowser> browser,
              CefRefPtr<CefFrame> frame,
              CefRefPtr<CefRequest> request,
              CefRefPtr<CefRequestCallback> callback) OVERRIDE;



How I call the OnBeforeResourceLoad function (from a simple_handler.cc file):


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
CefRequestHandler::ReturnValue SimpleHandler::OnBeforeResourceLoad(
          CefRefPtr<CefBrowser> browser,
          CefRefPtr<CefFrame> frame,
          CefRefPtr<CefRequest> request,
          CefRefPtr<CefRequestCallback> callback) 
    
    {
    
    CefRequest::ReferrerPolicy origin = REFERRER_POLICY_ALWAYS;
    request->SetReferrer("www.google.com",origin);
    
    
        return RV_CONTINUE;
    
    }


This compiles and runs but the referrer is not set.


If there are issue with either of the above in the below class please let me know.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 class SimpleHandler : public CefClient,
                          public CefDisplayHandler,
                          public CefLifeSpanHandler,
                           public CefLoadHandler,
    			public CefRequestHandler{
     public:
      explicit SimpleHandler(bool use_views);
      ~SimpleHandler();
    
      // Provide access to the single global instance of this object.
      static SimpleHandler* GetInstance();
    
      // CefClient methods:
      virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
        return this;
      }
      virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
        return this;
      }
      virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
        return this;
      }
    
    virtual CefRefPtr<CefRequestHandler> GetRequestHandler() OVERRIDE {
        return this;
      }
    
      // CefDisplayHandler methods:
      virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
                                 const CefString& title) OVERRIDE;
    
      // CefLifeSpanHandler methods:
      virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual bool DoClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
      virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
    
      // CefLoadHandler methods:
      virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
                               CefRefPtr<CefFrame> frame,
                               ErrorCode errorCode,
                               const CefString& errorText,
                               const CefString& failedUrl) OVERRIDE;
    
      // Request that all existing browser windows close.
      void CloseAllBrowsers(bool force_close);
    
      bool IsClosing() const { return is_closing_; }
    
    
    
    virtual CefRequestHandler::ReturnValue OnBeforeResourceLoad(
          CefRefPtr<CefBrowser> browser,
          CefRefPtr<CefFrame> frame,
          CefRefPtr<CefRequest> request,
          CefRefPtr<CefRequestCallback> callback) OVERRIDE;
    
    
     private:
      // Platform-specific implementation.
      void PlatformTitleChange(CefRefPtr<CefBrowser> browser,
                               const CefString& title);
    
      // True if the application is using the Views framework.
      const bool use_views_;
    
      // List of existing browser windows. Only accessed on the CEF UI thread.
      typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
      BrowserList browser_list_;
    
      bool is_closing_;
    
      // Include the default reference counting implementation.
      IMPLEMENT_REFCOUNTING(SimpleHandler);
    };
    
    #endif  // CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_ 





The setpreferrer method I am using to modify behaviour:

1
2
3
4
5
6
7
8
 ///
      // Set the referrer URL and policy. If non-empty the referrer URL must be
      // fully qualified with an HTTP or HTTPS scheme component. Any username,
      // password or ref component will be removed.
      ///
      /*--cef()--*/
      virtual void SetReferrer(const CefString& referrer_url,
                               ReferrerPolicy policy) =0;


Class containing the [SetReferrer][2] method:
http://magpcss.org/ceforum/apidocs3/projects/%28default%29/cef_request.h.html

Class containing OnBeforeResourceLoad function:
http://magpcss.org/ceforum/apidocs/projects/%28default%29/cef_request_handler.h.html
Last edited on
I got this figured out. thank you. I had to reinstall everything and the code worked properly. I had the path variables set to the wrong binary source code.
Topic archived. No new replies allowed.