From f2909b0d90a11c95c8c350107fc5e4e4f5e66549 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Wed, 22 May 2013 11:40:43 -0400 Subject: [PATCH] Set up the resource bundle on Windows --- brightray/common/main_delegate.cc | 22 +++++++++++++++++++++- brightray/common/main_delegate.h | 3 ++- brightray/common/main_delegate_mac.mm | 11 ++--------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/brightray/common/main_delegate.cc b/brightray/common/main_delegate.cc index 09cc8bc103..5578fc7c3a 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 b695c7c326..f5cbe88d4e 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 72ae553ff8..aa7bf0f462 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() {