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