mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Move devtools resources to a separate devtools_resources.pak file (issue #714).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@765 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -103,7 +103,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
switches::kLogSeverity,
|
||||
switches::kProductVersion,
|
||||
switches::kLocale,
|
||||
switches::kPackFilePath,
|
||||
switches::kResourcesDirPath,
|
||||
switches::kLocalesDirPath,
|
||||
switches::kPackLoadingDisabled,
|
||||
};
|
||||
|
@@ -24,8 +24,8 @@ const char kLogSeverity_Error[] = "error";
|
||||
const char kLogSeverity_ErrorReport[] = "error-report";
|
||||
const char kLogSeverity_Disable[] = "disable";
|
||||
|
||||
// Path to cef.pak file.
|
||||
const char kPackFilePath[] = "pack-file-path";
|
||||
// Path to resources directory.
|
||||
const char kResourcesDirPath[] = "resources-dir-path";
|
||||
|
||||
// Path to locales directory.
|
||||
const char kLocalesDirPath[] = "locales-dir-path";
|
||||
|
@@ -20,7 +20,7 @@ extern const char kLogSeverity_Warning[];
|
||||
extern const char kLogSeverity_Error[];
|
||||
extern const char kLogSeverity_ErrorReport[];
|
||||
extern const char kLogSeverity_Disable[];
|
||||
extern const char kPackFilePath[];
|
||||
extern const char kResourcesDirPath[];
|
||||
extern const char kLocalesDirPath[];
|
||||
extern const char kPackLoadingDisabled[];
|
||||
|
||||
|
@@ -57,7 +57,7 @@ FilePath GetFrameworkBundlePath() {
|
||||
FILE_PATH_LITERAL("Chromium Embedded Framework.framework"));
|
||||
}
|
||||
|
||||
FilePath GetDefaultPackPath() {
|
||||
FilePath GetResourcesFilePath() {
|
||||
return GetFrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ void OverrideChildProcessPath() {
|
||||
|
||||
#else // !defined(OS_MACOSX)
|
||||
|
||||
FilePath GetDefaultPackPath() {
|
||||
FilePath GetResourcesFilePath() {
|
||||
FilePath pak_dir;
|
||||
PathService::Get(base::DIR_MODULE, &pak_dir);
|
||||
return pak_dir;
|
||||
@@ -228,10 +228,12 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
if (settings.pack_loading_disabled) {
|
||||
command_line->AppendSwitch(switches::kPackLoadingDisabled);
|
||||
} else {
|
||||
if (settings.pack_file_path.length > 0) {
|
||||
FilePath file_path = FilePath(CefString(&settings.pack_file_path));
|
||||
if (!file_path.empty())
|
||||
command_line->AppendSwitchPath(switches::kPackFilePath, file_path);
|
||||
if (settings.resources_dir_path.length > 0) {
|
||||
FilePath file_path = FilePath(CefString(&settings.resources_dir_path));
|
||||
if (!file_path.empty()) {
|
||||
command_line->AppendSwitchPath(switches::kResourcesDirPath,
|
||||
file_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.locales_dir_path.length > 0) {
|
||||
@@ -383,14 +385,22 @@ void CefMainDelegate::ShutdownBrowser() {
|
||||
|
||||
void CefMainDelegate::InitializeResourceBundle() {
|
||||
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
|
||||
FilePath pak_file, locales_dir;
|
||||
FilePath cef_pak_file, devtools_pak_file, locales_dir;
|
||||
|
||||
if (!content_client_.pack_loading_disabled()) {
|
||||
if (command_line.HasSwitch(switches::kPackFilePath))
|
||||
pak_file = command_line.GetSwitchValuePath(switches::kPackFilePath);
|
||||
FilePath resources_dir;
|
||||
if (command_line.HasSwitch(switches::kResourcesDirPath)) {
|
||||
resources_dir =
|
||||
command_line.GetSwitchValuePath(switches::kResourcesDirPath);
|
||||
}
|
||||
if (resources_dir.empty())
|
||||
resources_dir = GetResourcesFilePath();
|
||||
|
||||
if (pak_file.empty())
|
||||
pak_file = GetDefaultPackPath().Append(FILE_PATH_LITERAL("cef.pak"));
|
||||
if (!resources_dir.empty()) {
|
||||
cef_pak_file = resources_dir.Append(FILE_PATH_LITERAL("cef.pak"));
|
||||
devtools_pak_file =
|
||||
resources_dir.Append(FILE_PATH_LITERAL("devtools_resources.pak"));
|
||||
}
|
||||
|
||||
if (command_line.HasSwitch(switches::kLocalesDirPath))
|
||||
locales_dir = command_line.GetSwitchValuePath(switches::kLocalesDirPath);
|
||||
@@ -409,13 +419,20 @@ void CefMainDelegate::InitializeResourceBundle() {
|
||||
if (!content_client_.pack_loading_disabled()) {
|
||||
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale;
|
||||
|
||||
if (file_util::PathExists(pak_file)) {
|
||||
content_client_.set_allow_pack_file_load(true);
|
||||
content_client_.set_allow_pack_file_load(true);
|
||||
|
||||
if (file_util::PathExists(cef_pak_file)) {
|
||||
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
|
||||
pak_file, ui::SCALE_FACTOR_NONE);
|
||||
content_client_.set_allow_pack_file_load(false);
|
||||
cef_pak_file, ui::SCALE_FACTOR_NONE);
|
||||
} else {
|
||||
NOTREACHED() << "Could not load cef.pak";
|
||||
}
|
||||
|
||||
if (file_util::PathExists(devtools_pak_file)) {
|
||||
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
|
||||
devtools_pak_file, ui::SCALE_FACTOR_NONE);
|
||||
}
|
||||
|
||||
content_client_.set_allow_pack_file_load(false);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user