Set up the resource bundle on Windows

This commit is contained in:
Adam Roben 2013-05-22 11:40:43 -04:00
parent 3713ea6403
commit f2909b0d90
3 changed files with 25 additions and 11 deletions

View file

@ -8,7 +8,9 @@
#include "common/content_client.h" #include "common/content_client.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/path_service.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
namespace brightray { namespace brightray {
@ -32,8 +34,26 @@ void MainDelegate::PreSandboxStartup() {
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
OverrideChildProcessPath(); OverrideChildProcessPath();
OverrideFrameworkBundlePath(); OverrideFrameworkBundlePath();
InitializeResourceBundle();
#endif #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<base::FilePath> 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);
} }
} }

View file

@ -34,8 +34,9 @@ protected:
virtual void PreSandboxStartup() OVERRIDE; virtual void PreSandboxStartup() OVERRIDE;
private: private:
#if defined(OS_MACOSX)
void InitializeResourceBundle(); void InitializeResourceBundle();
#if defined(OS_MACOSX)
static base::FilePath GetResourcesPakFilePath();
static void OverrideChildProcessPath(); static void OverrideChildProcessPath();
static void OverrideFrameworkBundlePath(); static void OverrideFrameworkBundlePath();
#endif #endif

View file

@ -12,7 +12,6 @@
#include "base/mac/bundle_locations.h" #include "base/mac/bundle_locations.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "content/public/common/content_paths.h" #include "content/public/common/content_paths.h"
#include "ui/base/resource/resource_bundle.h"
namespace brightray { 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"]; auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"];
return base::mac::NSStringToFilePath(path);
ui::ResourceBundle::InitSharedInstanceWithPakPath(base::mac::NSStringToFilePath(path));
std::vector<base::FilePath> pak_paths;
AddPakPaths(&pak_paths);
for (const auto& path : pak_paths)
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(path, ui::SCALE_FACTOR_NONE);
} }
void MainDelegate::OverrideFrameworkBundlePath() { void MainDelegate::OverrideFrameworkBundlePath() {