build for linux using libcef_dll_wrapper.so

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.

Re: build for linux using libcef_dll_wrapper.so

Postby magreenblatt » Wed Jun 22, 2016 10:15 pm

What are the contents of the directory that contains the above CMakeLists.txt file? Does it look like this: https://bitbucket.org/chromiumembedded/ ... stribution
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: build for linux using libcef_dll_wrapper.so

Postby wrightpt » Thu Jun 23, 2016 7:18 am

Running cmake:



c@c:~/Downloads/myproject2/cefsimple/cefsimple$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug ..



output:


-- *** CEF CONFIGURATION SETTINGS ***
-- Generator: Unix Makefiles
-- Platform: Linux
-- Project architecture: x86_64
-- Build type: Debug
-- Binary distribution root: /home/c/Downloads/myproject2
-- Standard libraries: X11
-- Compile defines: __STDC_CONSTANT_MACROS;__STDC_FORMAT_MACROS;_FILE_OFFSET_BITS=64
-- Compile defines (Debug):
-- Compile defines (Release): NDEBUG
-- C compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-m64;-march=x86-64 -std=c99;-Wno-unused-local-typedefs
-- C compile flags (Debug): -O0;-g
-- C compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2
-- C++ compile flags: -fno-strict-aliasing;-fPIC;-fstack-protector;-funwind-tables;-fvisibility=hidden;--param=ssp-buffer-size=4;-pipe;-pthread;-Wall;-Werror;-Wno-missing-field-initializers;-Wno-unused-parameter;-m64;-march=x86-64 -fno-exceptions;-fno-rtti;-fno-threadsafe-statics;-fvisibility-inlines-hidden;-std=gnu++11;-Wsign-compare;-Wno-literal-suffix;-Wno-narrowing
-- C++ compile flags (Debug): -O0;-g
-- C++ compile flags (Release): -O2;-fdata-sections;-ffunction-sections;-fno-ident;-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2
-- Exe link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64
-- Exe link flags (Debug):
-- Exe link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections
-- Shared link flags: -fPIC;-pthread;-Wl,--disable-new-dtags;-Wl,--fatal-warnings;-Wl,-rpath,.;-Wl,-z,noexecstack;-Wl,-z,now;-Wl,-z,relro;-m64
-- Shared link flags (Debug):
-- Shared link flags (Release): -Wl,-O1;-Wl,--as-needed;-Wl,--gc-sections
-- CEF Binary files: chrome-sandbox;libcef.so;natives_blob.bin;snapshot_blob.bin
-- CEF Resource files: cef.pak;cef_100_percent.pak;cef_200_percent.pak;cef_extensions.pak;devtools_resources.pak;icudtl.dat;locales
-- Configuring done
-- Generating done
-- Build files have been written to: /home/c/Downloads/myproject2/cefsimple
c@c:~/Downloads/myproject2/cefsimple/cefsimple$
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: build for linux using libcef_dll_wrapper.so

Postby wrightpt » Thu Jun 23, 2016 8:48 am

I was able to get it to build. I was not setting the CEF_ROOT to the proper binary I think, however the Release version upon executing the executable:

X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 42 (X_SetInputFocus)
Serial number of failed request: 290
Current serial number in output stream: 292


The Debug version


X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 42 (X_SetInputFocus)
Serial number of failed request: 290
Current serial number in output stream: 292
[0623/092626:FATAL:context.cc(211)] Check failed: false. context not valid
#0 0x7f71822bc4ae base::debug::StackTrace::StackTrace()
#1 0x7f71823085ef logging::LogMessage::~LogMessage()
#2 0x7f7181f8de09 CefQuitMessageLoop()
#3 0x7f7181dd84c9 cef_quit_message_loop
#4 0x00000043b3ca CefQuitMessageLoop()
#5 0x0000004097cc SimpleHandler::OnBeforeClose()
#6 0x00000045e13d (anonymous namespace)::life_span_handler_on_before_close()
#7 0x7f7181e5595f CefLifeSpanHandlerCToCpp::OnBeforeClose()
#8 0x7f7181f30f1e CefBrowserHostImpl::DestroyBrowser()
#9 0x7f7181f6320f CefBrowserInfoManager::DestroyAllBrowsers()
#10 0x7f7181f8e3c0 CefContext::FinishShutdownOnUIThread()
#11 0x7f7181f8d9ed CefContext::Shutdown()
#12 0x7f7181f8cd26 (anonymous namespace)::CefForceShutdown::~CefForceShutdown()
#13 0x7f718080353a __cxa_finalize
#14 0x7f7181dd2553 <unknown>

Aborted (core dumped)



Here is a solution I am trying and will report back.


Found on StackOverflow: http://stackoverflow.com/questions/16720961/many-xsetinputfocuss-and-xsync-causes-error

From the documentation, it states the following:

The specified focus window must be viewable at the time XSetInputFocus is called, or a BadMatch error results. If the focus window later becomes not viewable, the X server evaluates the revert_to argument to determine the new focus window as follows:

If revert_to is RevertToParent, the focus reverts to the parent (or the closest viewable ancestor), and the new revert_to value is taken to be RevertToNone.

If revert_to is RevertToPointerRoot or RevertToNone, the focus reverts to PointerRoot or None, respectively. When the focus reverts, the X server generates FocusIn and FocusOut events, but the last-focus-change time is not affected.

XSetInputFocus can generate BadMatch, BadValue, and BadWindow errors.


So, I was missing a check to determine whether the window is viewable or not. The following change will fix the problem:

main()
{
// Obtain the X11 display.
Display *display = XOpenDisplay(0);
if(display == NULL)
return -1;

// Get the root window for the current display.
Window winRoot = XDefaultRootWindow(display);

WindowsMatchingPid wmp(display,winRoot,4344);
list<Window> lw = wmp.result();

for(list<Window>::iterator it=lw.begin(); it != lw.end(); it++ ){
XWindowAttributes attribute; // <-- Added
XGetWindowAttributes(display,*it,&attribute); // <-- Added
if(attribute.map_state == IsViewable ){ // <-- Added
XSetInputFocus(display,*it,RevertToParent,CurrentTime);
} // <-- Added
}
XCloseDisplay(display);
return 0;
}
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: build for linux using libcef_dll_wrapper.so

Postby magreenblatt » Thu Jun 23, 2016 8:50 am

Looks OK to me.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

2 things: implement class into build & modify ResourceHandl

Postby wrightpt » Thu Jun 23, 2016 12:01 pm

Not sure how to do 2 things:

1) Implement custom class into CEF build and
2) showing, through resourcehandler, that I came from previous site

I am loading custom html with an iframe containing youtube, shown below.

I received the following message : "This video contains content from WMG. It is restricted form playback on certain sites. Watch on youtube"

The video will play by allowing CEF to say I have come from previous site such as youtube.com or google.com

How would I set the header so it seems like I am coming from a site such as google.com or youtube.com and then how would I entegrate the new class "MyResponseHeader" back into my CEF build. ?

Any push forward from what is below is appreciated:


from cef_request_handler.h:

virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {

return new MyResourceHandler();
//return NULL;
}

Below is a model for how to create a "MyResourceHandler class"




class MyResourceHandler : public CefResourceHandler
{
public:
MyResourceHandler() :
offset_(0)
{}

virtual bool ProcessRequest (CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback)
OVERRIDE;
virtual void GetResponseHeaders (CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE;
virtual void Cancel () OVERRIDE;

virtual bool ReadResponse (void* data_out, int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback)
OVERRIDE;

private:
CefRefPtr<CefRequest> request_;
std::string data_;
std::string mime_type_;
size_t offset_;

IMPLEMENT_REFCOUNTING(MyResourceHandler);
IMPLEMENT_LOCKING(MyResourceHandler);
};



HTML:


<!DOCTYPE html>
<html>
<body>
<iframe id="player" type="text/html" width="640" height="390"
src="http://www.youtube.com/embed/mt84J7U75e0?enablejsapi=1&origin=http://example.com"
frameborder="0"></iframe>
</body>
</html>
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: build for linux using libcef_dll_wrapper.so

Postby wrightpt » Thu Jun 23, 2016 4:25 pm

any thoughts on how to shop that CEF was at a previous site.

I was able to do this with Crosswalk by actually going to different sites then returning to the site and the video played fine.

How to set it in CEF code?
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: build for linux using libcef_dll_wrapper.so

Postby wrightpt » Thu Jun 23, 2016 4:34 pm

Marshall

im really just confused about how to modify the source code. How do I override either of the following methods. preferrably the second one?

virtual bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
bool is_redirect) {
return false;
}

virtual CefRefPtr<CefResourceHandler> GetResourceHandler(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {

// return new MyResourceHandler();
return NULL;

class MyResourceHandler : public CefResourceHandler
{
public:
MyResourceHandler() :
offset_(0)
{}

virtual bool ProcessRequest (CefRefPtr<CefRequest> request,
CefRefPtr<CefCallback> callback)
OVERRIDE;
virtual void GetResponseHeaders (CefRefPtr<CefResponse> response,
int64& response_length,
CefString& redirectUrl) OVERRIDE;
virtual void Cancel () OVERRIDE;

virtual bool ReadResponse (void* data_out, int bytes_to_read,
int& bytes_read,
CefRefPtr<CefCallback> callback)
OVERRIDE;

private:
CefRefPtr<CefRequest> request_;
std::string data_;
std::string mime_type_;
size_t offset_;

IMPLEMENT_REFCOUNTING(MyResourceHandler);
IMPLEMENT_LOCKING(MyResourceHandler);
};


Above, I have extended the CEFResourceHandler. How would I actually handle the new Request or the overwritten request. Where should I put this in the code and how do I go about actually creating the new request.
It seems it would involve what is below:

private:
CefRefPtr<CefRequest> request_;
std::string data_;
std::string mime_type_;
size_t offset_;

any input would be awesome. A short comment could potentially save me days at this point.

thanks
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: build for linux using libcef_dll_wrapper.so

Postby magreenblatt » Thu Jun 23, 2016 4:59 pm

Unfortunately I don't have time to give you detailed assistance. You should check the documentation and examples included with cefclient.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Previous

Return to Support Forum

Who is online

Users browsing this forum: No registered users and 65 guests

cron