diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc index 09cc8bc1038..5578fc7c3af 100644 --- a/brightray/common/main_delegate.cc +++ b/brightray/common/main_delegate.cc @@ -8,7 +8,9 @@ #include "common/content_client.h" #include "base/command_line.h" +#include "base/path_service.h" #include "content/public/common/content_switches.h" +#include "ui/base/resource/resource_bundle.h" namespace brightray { @@ -32,8 +34,26 @@ void MainDelegate::PreSandboxStartup() { #if defined(OS_MACOSX) OverrideChildProcessPath(); OverrideFrameworkBundlePath(); - InitializeResourceBundle(); #endif + InitializeResourceBundle(); +} + +void MainDelegate::InitializeResourceBundle() { + base::FilePath path; +#if defined(OS_MACOSX) + path = GetResourcesPakFilePath(); +#else + base::FilePath pak_dir; + PathService::Get(base::DIR_MODULE, &pak_dir); + path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak")); +#endif + + ui::ResourceBundle::InitSharedInstanceWithPakPath(path); + + std::vector pak_paths; + AddPakPaths(&pak_paths); + for (auto it = pak_paths.begin(), end = pak_paths.end(); it != end; ++it) + ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(*it, ui::SCALE_FACTOR_NONE); } } diff --git a/brightray/common/main_delegate.h b/brightray/common/main_delegate.h index b695c7c326c..f5cbe88d4e8 100644 --- a/brightray/common/main_delegate.h +++ b/brightray/common/main_delegate.h @@ -34,8 +34,9 @@ protected: virtual void PreSandboxStartup() OVERRIDE; private: -#if defined(OS_MACOSX) void InitializeResourceBundle(); +#if defined(OS_MACOSX) + static base::FilePath GetResourcesPakFilePath(); static void OverrideChildProcessPath(); static void OverrideFrameworkBundlePath(); #endif diff --git a/brightray/common/main_delegate_mac.mm b/brightray/common/main_delegate_mac.mm index 72ae553ff88..aa7bf0f4625 100644 --- a/brightray/common/main_delegate_mac.mm +++ b/brightray/common/main_delegate_mac.mm @@ -12,7 +12,6 @@ #include "base/mac/bundle_locations.h" #include "base/path_service.h" #include "content/public/common/content_paths.h" -#include "ui/base/resource/resource_bundle.h" namespace brightray { @@ -24,15 +23,9 @@ base::FilePath GetFrameworksPath() { } -void MainDelegate::InitializeResourceBundle() { +base::FilePath MainDelegate::GetResourcesPakFilePath() { auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"]; - - ui::ResourceBundle::InitSharedInstanceWithPakPath(base::mac::NSStringToFilePath(path)); - - std::vector pak_paths; - AddPakPaths(&pak_paths); - for (const auto& path : pak_paths) - ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(path, ui::SCALE_FACTOR_NONE); + return base::mac::NSStringToFilePath(path); } void MainDelegate::OverrideFrameworkBundlePath() {