diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc index f76296d8bbe6a..53b22dc4917fb 100644 --- a/chrome/common/chrome_paths_linux.cc +++ b/chrome/common/chrome_paths_linux.cc @@ -97,10 +97,13 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) { #elif 0 //BUILDFLAG(GOOGLE_CHROME_BRANDING) std::string data_dir_basename = "google-chrome"; #else - std::string data_dir_basename = nw::package()->GetName(); + // Headless mode asks for this path from ChromeMain(), before + // ChromeMainDelegate::BasicStartupComplete() has loaded the package. + nw::Package* package = nw::package(); + std::string data_dir_basename = package ? package->GetName() : "nwjs"; #endif - *result = config_dir.Append(nw::package()->GetName()); + *result = config_dir.Append(data_dir_basename); //*result = config_dir.Append(data_dir_basename + GetChannelSuffixForDataDir()); return true; } diff --git a/chrome/common/chrome_paths_mac.mm b/chrome/common/chrome_paths_mac.mm index de1ea50c045ef..53702a34c5d49 100644 --- a/chrome/common/chrome_paths_mac.mm +++ b/chrome/common/chrome_paths_mac.mm @@ -88,7 +88,11 @@ bool GetDefaultUserDataDirectoryForProduct(const std::string& product_dir, namespace chrome { bool GetDefaultUserDataDirectory(base::FilePath* result) { - return GetDefaultUserDataDirectoryForProduct(nw::package()->GetName(), result); + // Headless mode asks for this path from ChromeMain(), before + // ChromeMainDelegate::BasicStartupComplete() has loaded the package. + nw::Package* package = nw::package(); + return GetDefaultUserDataDirectoryForProduct( + package ? package->GetName() : "nwjs", result); } bool GetUserDocumentsDirectory(base::FilePath* result) {