0

Until a very recent OSX security patch, I had a method that worked just fine:

void ShowWebPage(CStdString WebPage)
{
CFStringRef URL =  CFStringCreateWithCString(NULL, WebPage.c_str(), kCFStringEncodingASCII);
CFURLRef pathRef = CFURLCreateWithString( NULL, URL, NULL );

if( pathRef )
{
    LSOpenCFURLRef(pathRef, NULL);
    CFRelease(pathRef);
}

CFRelease(URL);
}

Now this no longer works. I also found this article: C++ OS X open default browser Which gives pretty much the same soliton. I also tried the first system("open URL") answer and that did not work either.

I had a Mac that had been off for a while and our app worked fine, then it got the latest patches and now this no longer works.

I have also tried googling this and I can only come up with objective C stuff.

Anyway, does anyone know how to open a web page from a cpp app now? I think there may be some kind of security setting that is blocking this, but I have no idea what it would be.

Community
  • 1
  • 1
TheSilverHammer
  • 59
  • 2
  • 10
  • 2
    What are the contents of the `WebPage` variable? Also: Is your app sandboxed? –  May 20 '15 at 21:10
  • This approach is still the right way, so duskwuff's questions are good ones. Also, what happens if you use the `open ` command in Terminal? – Ken Thomases May 20 '15 at 21:23
  • opening the URL on the terminal works fine. IE: If I just do www.google.com, it fails to load. The web browser doesn't even open / launch. As for our app being "sandboxed" I do not know what that really means. This application was written many, many years ago. I just booted the old dev machine after it had not really been used in years. Is there some kind of config file I need to allow me to launch web pages? Something in the package? – TheSilverHammer May 20 '15 at 22:51
  • I was reading some docs on app sandboxing, and it seems to be something you intentionally do. You have to tell xcode to make it a sandboxed app. I am fairly sure this is not the case. Even the version of xcode is old, like 4.2 since that version still had some features we wanted like the ability to compile for the old non-intel architecture. – TheSilverHammer May 20 '15 at 23:02
  • It is complied using XCode version 3.2.6, and linked against the 10.4 target libraries if this matters at all. – TheSilverHammer May 21 '15 at 12:55

0 Answers0