diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index 6d5c8755c..437ca917f 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -183,6 +183,13 @@ typedef struct _cef_settings_t { /// cef_string_t framework_dir_path; + /// + // The path to the main bundle on macOS. If this value is empty then it + // defaults to the top-level app bundle. Also configurable using + // the "main-bundle-path" command-line switch. + /// + cef_string_t main_bundle_path; + /// // Set to true (1) to have the browser process message loop run in a separate // thread. If false (0) than the CefDoMessageLoopWork() function must be diff --git a/include/internal/cef_types_wrappers.h b/include/internal/cef_types_wrappers.h index 8ac97800c..d0509a6e6 100644 --- a/include/internal/cef_types_wrappers.h +++ b/include/internal/cef_types_wrappers.h @@ -543,6 +543,7 @@ struct CefSettingsTraits { static inline void clear(struct_type* s) { cef_string_clear(&s->browser_subprocess_path); cef_string_clear(&s->framework_dir_path); + cef_string_clear(&s->main_bundle_path); cef_string_clear(&s->cache_path); cef_string_clear(&s->user_data_path); cef_string_clear(&s->user_agent); @@ -565,6 +566,8 @@ struct CefSettingsTraits { &target->browser_subprocess_path, copy); cef_string_set(src->framework_dir_path.str, src->framework_dir_path.length, &target->framework_dir_path, copy); + cef_string_set(src->main_bundle_path.str, src->main_bundle_path.length, + &target->main_bundle_path, copy); target->multi_threaded_message_loop = src->multi_threaded_message_loop; target->external_message_pump = src->external_message_pump; target->windowless_rendering_enabled = src->windowless_rendering_enabled; diff --git a/libcef/browser/content_browser_client.cc b/libcef/browser/content_browser_client.cc index 6b998a544..f424d2f00 100644 --- a/libcef/browser/content_browser_client.cc +++ b/libcef/browser/content_browser_client.cc @@ -783,6 +783,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches( switches::kDisablePackLoading, #if defined(OS_MACOSX) switches::kFrameworkDirPath, + switches::kMainBundlePath, #endif switches::kLocalesDirPath, switches::kLogFile, diff --git a/libcef/common/cef_switches.cc b/libcef/common/cef_switches.cc index 4cfe8ff60..598cbeb8b 100644 --- a/libcef/common/cef_switches.cc +++ b/libcef/common/cef_switches.cc @@ -122,6 +122,7 @@ extern const char kEnablePrintPreview[] = "enable-print-preview"; #if defined(OS_MACOSX) // Path to the framework directory. const char kFrameworkDirPath[] = "framework-dir-path"; +const char kMainBundlePath[] = "main-bundle-path"; #endif } // namespace switches diff --git a/libcef/common/cef_switches.h b/libcef/common/cef_switches.h index 93d5a58f2..8abafbfa9 100644 --- a/libcef/common/cef_switches.h +++ b/libcef/common/cef_switches.h @@ -56,6 +56,7 @@ extern const char kEnablePrintPreview[]; #if defined(OS_MACOSX) extern const char kFrameworkDirPath[]; +extern const char kMainBundlePath[]; #endif } // namespace switches diff --git a/libcef/common/main_delegate.cc b/libcef/common/main_delegate.cc index 68e0f5cd6..bd8c5ce97 100644 --- a/libcef/common/main_delegate.cc +++ b/libcef/common/main_delegate.cc @@ -476,6 +476,13 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) { if (!file_path.empty()) command_line->AppendSwitchPath(switches::kFrameworkDirPath, file_path); } + + if (settings.main_bundle_path.length > 0) { + base::FilePath file_path = + base::FilePath(CefString(&settings.main_bundle_path)); + if (!file_path.empty()) + command_line->AppendSwitchPath(switches::kMainBundlePath, file_path); + } #endif if (no_sandbox) diff --git a/libcef/common/util_mac.mm b/libcef/common/util_mac.mm index 5fea37ce7..dae9b4570 100644 --- a/libcef/common/util_mac.mm +++ b/libcef/common/util_mac.mm @@ -65,6 +65,12 @@ base::FilePath GetMainProcessPath() { } base::FilePath GetMainBundlePath() { + base::FilePath main_bundle_path = + base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( + switches::kMainBundlePath); + if (!main_bundle_path.empty()) + return main_bundle_path; + return base::mac::GetAppBundlePath(GetMainProcessPath()); }