Allow embedders to specify extra .pak files

This commit is contained in:
Adam Roben 2013-04-26 11:04:51 -04:00
parent 3b879a6178
commit 6908eecd0c
2 changed files with 14 additions and 1 deletions

View file

@ -8,6 +8,11 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "content/public/app/content_main_delegate.h" #include "content/public/app/content_main_delegate.h"
#include <vector>
namespace base {
class FilePath;
}
namespace brightray { namespace brightray {
@ -22,11 +27,14 @@ protected:
// Subclasses can override this to provide their own ContentClient implementation. // Subclasses can override this to provide their own ContentClient implementation.
virtual scoped_ptr<ContentClient> CreateContentClient(); virtual scoped_ptr<ContentClient> CreateContentClient();
// Subclasses can override this to provide additional .pak files to be included in the ui::ResourceBundle.
virtual void AddPakPaths(std::vector<base::FilePath>* pak_paths) {}
virtual bool BasicStartupComplete(int* exit_code) OVERRIDE; virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
virtual void PreSandboxStartup() OVERRIDE; virtual void PreSandboxStartup() OVERRIDE;
private: private:
static void InitializeResourceBundle(); void InitializeResourceBundle();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
static void OverrideChildProcessPath(); static void OverrideChildProcessPath();
static void OverrideFrameworkBundlePath(); static void OverrideFrameworkBundlePath();

View file

@ -28,6 +28,11 @@ void MainDelegate::InitializeResourceBundle() {
auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"]; auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"];
ui::ResourceBundle::InitSharedInstanceWithPakPath(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() {