How to get local files on Chromium Embedded Framework on Mac

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.

How to get local files on Chromium Embedded Framework on Mac

Postby cdiscla » Tue Sep 16, 2014 5:02 am

Hello,
I am using CEF to embed a html5 inside Chromium browser.

If i embed my web app in Windows i can browse files using file:///path

If i use Mac i don't know how to call local files; i've tried to copy files inside .app file in Contents/MacOS or COntents/Resources folders but cannot access that using file:/// protocol.

How can i get local files path on Mac?

Thanks in advance and greetings
c.
cdiscla
Newbie
 
Posts: 5
Joined: Thu May 15, 2014 3:42 am

Re: How to get local files on Chromium Embedded Framework on

Postby magreenblatt » Tue Sep 16, 2014 9:44 am

You should use a custom scheme handler or OnBeforeResourceLoad. See https://code.google.com/p/chromiumembed ... t_Handling.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: How to get local files on Chromium Embedded Framework on

Postby fernandomorgan » Tue Sep 16, 2014 10:44 pm

to load a html file like <app>/Contents/Resources/foo.html in 10.7 or later,

NSString* spath = [@"file:" stringByAppendingString: [[NSBundle mainBundle] resourcePath] ];
std::string path = [spath UTF8String];

(some irrelevant code removed here)
path = path + "/foo.html";

and using path in CreateBrower will load it. On loading resources, make sure you are loading relative paths, not absolutes: (file://css/foo.css for example)
fernandomorgan
Techie
 
Posts: 28
Joined: Tue Jan 14, 2014 5:51 pm

Re: How to get local files on Chromium Embedded Framework on

Postby Mayhew » Thu Oct 30, 2014 5:03 pm

Has anyone noticed that code like
Code: Select all
  NSString* ver = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

and the code mentioned in this thread will fail on mac with the sandbox turned on?
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm

Re: How to get local files on Chromium Embedded Framework on

Postby Mayhew » Thu Oct 30, 2014 5:11 pm

I should clarify that it seems to fail if run in the helper bundle for the renderer subprocess.
Mayhew
Expert
 
Posts: 303
Joined: Mon Apr 18, 2011 8:02 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 62 guests