1515// #include "string_util.h"
1616
1717char szWorkingDir[512 ]; // The current working directory
18+ std:: string szInitialUrl;
1819
1920// The global ClientHandler reference.
2021extern CefRefPtr<ClientHandler> g_handler;
@@ -250,8 +251,12 @@ int main(int argc, char* argv[]) {
250251 // Check cache_path setting
251252 if (CefString (&settings.cache_path ).length () == 0 ) {
252253 CefString (&settings.cache_path ) = AppGetCachePath ();
254+ printf (" No cache_path supplied by default\n " );
253255 }
254256
257+ szInitialUrl = CefString (&settings.cache_path );
258+ szInitialUrl.append (" /www/index.html" );
259+
255260 // Initialize CEF.
256261 CefInitialize (main_args, settings, app.get ());
257262
@@ -320,12 +325,15 @@ int main(int argc, char* argv[]) {
320325 // Populate the settings based on command line arguments.
321326 AppGetBrowserSettings (browserSettings);
322327
328+ browserSettings.file_access_from_file_urls_allowed = true ;
329+ browserSettings.universal_access_from_file_urls_allowed = true ;
330+
323331 window_info.SetAsChild (vbox);
324332
325- CefBrowserHost::CreateBrowserSync (
333+ CefBrowserHost::CreateBrowser (
326334 window_info,
327335 static_cast <CefRefPtr<CefClient> >(g_handler),
328- " http://www.google.com " , browserSettings);
336+ szInitialUrl , browserSettings);
329337
330338 gtk_container_add (GTK_CONTAINER (window), vbox);
331339 gtk_widget_show_all (GTK_WIDGET (window));
@@ -348,7 +356,8 @@ std::string AppGetWorkingDirectory() {
348356}
349357
350358CefString AppGetCachePath () {
351- std::string cachePath = ClientApp::AppGetSupportDirectory ();
359+ std::string cachePath = " file://" ; // To avoid Unix paths being interpreted as http:// URLs
360+ cachePath.append (ClientApp::AppGetSupportDirectory ());
352361 cachePath.append (" /cef_data" );
353362
354363 return CefString (cachePath);
0 commit comments