load pdf resource pak file

This commit is contained in:
deepak1556 2017-01-17 20:25:28 +05:30
parent 28f96f32f9
commit 2b4948d6aa
3 changed files with 18 additions and 10 deletions

View file

@ -49,18 +49,17 @@ void InitializeResourceBundle(const std::string& locale) {
locale, nullptr, ui::ResourceBundle::DO_NOT_LOAD_COMMON_RESOURCES);
// Load other resource files.
base::FilePath path;
#if defined(OS_MACOSX)
path = GetResourcesPakFilePath();
LoadCommonResources();
#else
base::FilePath pak_dir;
base::FilePath path, pak_dir;
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
PathService::Get(base::DIR_MODULE, &pak_dir);
path = pak_dir.Append(FILE_PATH_LITERAL("content_shell.pak"));
#endif
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
bundle.AddDataPackFromPath(path, ui::GetSupportedScaleFactors()[0]);
#if !defined(OS_MACOSX)
bundle.AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("pdf_viewer_resources.pak")),
ui::GetSupportedScaleFactors()[0]);
bundle.AddDataPackFromPath(
pak_dir.Append(FILE_PATH_LITERAL("blink_image_resources_200_percent.pak")),
ui::SCALE_FACTOR_200P);

View file

@ -24,7 +24,7 @@ class BrowserClient;
class ContentClient;
void InitializeResourceBundle(const std::string& locale);
base::FilePath GetResourcesPakFilePath();
void LoadCommonResources();
class MainDelegate : public content::ContentMainDelegate {
public:

View file

@ -16,6 +16,7 @@
#include "base/strings/sys_string_conversions.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
#include "ui/base/resource/resource_bundle.h"
namespace brightray {
@ -27,11 +28,19 @@ base::FilePath GetFrameworksPath() {
}
base::FilePath GetResourcesPakFilePath() {
auto path = [base::mac::FrameworkBundle() pathForResource:@"content_shell" ofType:@"pak"];
base::FilePath GetResourcesPakFilePath(NSString* name) {
auto path = [base::mac::FrameworkBundle() pathForResource:name ofType:@"pak"];
return base::mac::NSStringToFilePath(path);
}
void LoadCommonResources() {
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"content_shell"),
ui::GetSupportedScaleFactors()[0]);
bundle.AddDataPackFromPath(GetResourcesPakFilePath(@"pdf_viewer_resources"),
ui::GetSupportedScaleFactors()[0]);
}
void MainDelegate::OverrideFrameworkBundlePath() {
base::FilePath helper_path = GetFrameworksPath().Append(GetApplicationName() + " Framework.framework");