15
15
// #include "string_util.h"
16
16
17
17
char szWorkingDir[512 ]; // The current working directory
18
+ std:: string szInitialUrl;
18
19
19
20
// The global ClientHandler reference.
20
21
extern CefRefPtr<ClientHandler> g_handler;
@@ -250,8 +251,12 @@ int main(int argc, char* argv[]) {
250
251
// Check cache_path setting
251
252
if (CefString (&settings.cache_path ).length () == 0 ) {
252
253
CefString (&settings.cache_path ) = AppGetCachePath ();
254
+ printf (" No cache_path supplied by default\n " );
253
255
}
254
256
257
+ szInitialUrl = CefString (&settings.cache_path );
258
+ szInitialUrl.append (" /www/index.html" );
259
+
255
260
// Initialize CEF.
256
261
CefInitialize (main_args, settings, app.get ());
257
262
@@ -320,12 +325,15 @@ int main(int argc, char* argv[]) {
320
325
// Populate the settings based on command line arguments.
321
326
AppGetBrowserSettings (browserSettings);
322
327
328
+ browserSettings.file_access_from_file_urls_allowed = true ;
329
+ browserSettings.universal_access_from_file_urls_allowed = true ;
330
+
323
331
window_info.SetAsChild (vbox);
324
332
325
- CefBrowserHost::CreateBrowserSync (
333
+ CefBrowserHost::CreateBrowser (
326
334
window_info,
327
335
static_cast <CefRefPtr<CefClient> >(g_handler),
328
- " http://www.google.com " , browserSettings);
336
+ szInitialUrl , browserSettings);
329
337
330
338
gtk_container_add (GTK_CONTAINER (window), vbox);
331
339
gtk_widget_show_all (GTK_WIDGET (window));
@@ -348,7 +356,8 @@ std::string AppGetWorkingDirectory() {
348
356
}
349
357
350
358
CefString 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 ());
352
361
cachePath.append (" /cef_data" );
353
362
354
363
return CefString (cachePath);
0 commit comments