I want to run browser on click. Below mentioned "runBrowser" function is called on each click. But once any one browser is closed that cause CEF ShutDown and next time if I click on button ""runBrowser" function throws exception. I am working with CEF3 latest version on mac. Please help. Attahed Log for the same.
Any input will be greatly appreciated.
bool initialize = false;
CefRefPtr<CefClient> client = NULL;
CefRefPtr<ClientApp> app = NULL;
void runBrowser(){
if(! initialize){
CefMainArgs main_args;
// [ClientApplication sharedApplication];
app = new ClientApp(new ScriptingPbj());
int exit_code = CefExecuteProcess( main_args, app.get(), NULL );
if ( exit_code >= 0 ) {
exit(exit_code);
}
char cwd[1024];
getcwd( cwd, sizeof(cwd) );
CefSettings settings;
CefInitialize( main_args, settings, app.get(), NULL );
client = new ClientHandler();
}
initialize = true;
CefWindowInfo info;
CefBrowserSettings b_settings;
std::string path;
path = "https://www.google.com";
info.SetAsChild(NULL, 0, 0, 512, 270);
CefBrowserHost::CreateBrowser(info, client.get(), path, b_settings, NULL);
CefRunMessageLoop();
CefShutdown();
}
@implementation HandleEvents
- (IBAction)runBrowser:(id)sender
{
runBrowser();
}
@end