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:
Marshall Greenblatt 2012-09-06 17:42:16 +00:00
parent 43bc8b9529
commit 720e87d67b
11 changed files with 87 additions and 36 deletions

32
cef.gyp
View File

@ -138,7 +138,7 @@
], ],
}, },
{ {
'postbuild_name': 'Copy Pack File', 'postbuild_name': 'Copy cef.pak File',
'action': [ 'action': [
'cp', 'cp',
'-f', '-f',
@ -146,6 +146,15 @@
'${BUILT_PRODUCTS_DIR}/cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/cef.pak' '${BUILT_PRODUCTS_DIR}/cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/cef.pak'
], ],
}, },
{
'postbuild_name': 'Copy devtools_resources.pak File',
'action': [
'cp',
'-f',
'${BUILT_PRODUCTS_DIR}/devtools_resources.pak',
'${BUILT_PRODUCTS_DIR}/cefclient.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/devtools_resources.pak'
],
},
{ {
'postbuild_name': 'Copy WebCore Resources', 'postbuild_name': 'Copy WebCore Resources',
'action': [ 'action': [
@ -316,7 +325,7 @@
], ],
}, },
{ {
'postbuild_name': 'Copy Pack File', 'postbuild_name': 'Copy cef.pak File',
'action': [ 'action': [
'cp', 'cp',
'-f', '-f',
@ -324,6 +333,15 @@
'${BUILT_PRODUCTS_DIR}/cef_unittests.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/cef.pak' '${BUILT_PRODUCTS_DIR}/cef_unittests.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/cef.pak'
], ],
}, },
{
'postbuild_name': 'Copy devtools_resources.pak File',
'action': [
'cp',
'-f',
'${BUILT_PRODUCTS_DIR}/devtools_resources.pak',
'${BUILT_PRODUCTS_DIR}/cef_unittests.app/Contents/Frameworks/Chromium Embedded Framework.framework/Resources/devtools_resources.pak'
],
},
{ {
'postbuild_name': 'Copy WebCore Resources', 'postbuild_name': 'Copy WebCore Resources',
'action': [ 'action': [
@ -635,7 +653,6 @@
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources_100_percent.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_chromium_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_resources.pak',
'<(grit_out_dir)/cef_resources.pak', '<(grit_out_dir)/cef_resources.pak',
@ -694,6 +711,15 @@
'<@(header_inputs)'], '<@(header_inputs)'],
}, },
], ],
'copies': [
{
# Keep the devtools_resources.pak file separate.
'destination': '<(PRODUCT_DIR)',
'files': [
'<(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak',
],
},
],
}, },
{ {
'target_name': 'libcef_static', 'target_name': 'libcef_static',

View File

@ -222,18 +222,18 @@ typedef struct _cef_settings_t {
bool auto_detect_proxy_settings_enabled; bool auto_detect_proxy_settings_enabled;
/// ///
// The fully qualified path for the cef.pak file. If this value is empty // The fully qualified path for the resources directory. If this value is
// the cef.pak file must be located in the module directory. This value is // empty the cef.pak and/or devtools_resources.pak files must be located in
// ignored on Mac OS X where pack files are always loaded from the app bundle // the module directory on Windows/Linux or the app bundle Resources directory
// resource directory. // on Mac OS X.
/// ///
cef_string_t pack_file_path; cef_string_t resources_dir_path;
/// ///
// The fully qualified path for the locales directory. If this value is empty // The fully qualified path for the locales directory. If this value is empty
// the locales directory must be located in the module directory. This value // the locales directory must be located in the module directory. This value
// is ignored on Mac OS X where pack files are always loaded from the app // is ignored on Mac OS X where pack files are always loaded from the app
// bundle resource directory. // bundle Resources directory.
/// ///
cef_string_t locales_dir_path; cef_string_t locales_dir_path;

View File

@ -264,7 +264,7 @@ struct CefSettingsTraits {
cef_string_clear(&s->locale); cef_string_clear(&s->locale);
cef_string_clear(&s->log_file); cef_string_clear(&s->log_file);
cef_string_clear(&s->javascript_flags); cef_string_clear(&s->javascript_flags);
cef_string_clear(&s->pack_file_path); cef_string_clear(&s->resources_dir_path);
cef_string_clear(&s->locales_dir_path); cef_string_clear(&s->locales_dir_path);
} }
@ -294,8 +294,8 @@ struct CefSettingsTraits {
target->auto_detect_proxy_settings_enabled = target->auto_detect_proxy_settings_enabled =
src->auto_detect_proxy_settings_enabled; src->auto_detect_proxy_settings_enabled;
cef_string_set(src->pack_file_path.str, src->pack_file_path.length, cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length,
&target->pack_file_path, copy); &target->resources_dir_path, copy);
cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length, cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
&target->locales_dir_path, copy); &target->locales_dir_path, copy);
target->pack_loading_disabled = src->pack_loading_disabled; target->pack_loading_disabled = src->pack_loading_disabled;

View File

@ -103,7 +103,7 @@ void CefContentBrowserClient::AppendExtraCommandLineSwitches(
switches::kLogSeverity, switches::kLogSeverity,
switches::kProductVersion, switches::kProductVersion,
switches::kLocale, switches::kLocale,
switches::kPackFilePath, switches::kResourcesDirPath,
switches::kLocalesDirPath, switches::kLocalesDirPath,
switches::kPackLoadingDisabled, switches::kPackLoadingDisabled,
}; };

View File

@ -24,8 +24,8 @@ const char kLogSeverity_Error[] = "error";
const char kLogSeverity_ErrorReport[] = "error-report"; const char kLogSeverity_ErrorReport[] = "error-report";
const char kLogSeverity_Disable[] = "disable"; const char kLogSeverity_Disable[] = "disable";
// Path to cef.pak file. // Path to resources directory.
const char kPackFilePath[] = "pack-file-path"; const char kResourcesDirPath[] = "resources-dir-path";
// Path to locales directory. // Path to locales directory.
const char kLocalesDirPath[] = "locales-dir-path"; const char kLocalesDirPath[] = "locales-dir-path";

View File

@ -20,7 +20,7 @@ extern const char kLogSeverity_Warning[];
extern const char kLogSeverity_Error[]; extern const char kLogSeverity_Error[];
extern const char kLogSeverity_ErrorReport[]; extern const char kLogSeverity_ErrorReport[];
extern const char kLogSeverity_Disable[]; extern const char kLogSeverity_Disable[];
extern const char kPackFilePath[]; extern const char kResourcesDirPath[];
extern const char kLocalesDirPath[]; extern const char kLocalesDirPath[];
extern const char kPackLoadingDisabled[]; extern const char kPackLoadingDisabled[];

View File

@ -57,7 +57,7 @@ FilePath GetFrameworkBundlePath() {
FILE_PATH_LITERAL("Chromium Embedded Framework.framework")); FILE_PATH_LITERAL("Chromium Embedded Framework.framework"));
} }
FilePath GetDefaultPackPath() { FilePath GetResourcesFilePath() {
return GetFrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources")); return GetFrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
} }
@ -83,7 +83,7 @@ void OverrideChildProcessPath() {
#else // !defined(OS_MACOSX) #else // !defined(OS_MACOSX)
FilePath GetDefaultPackPath() { FilePath GetResourcesFilePath() {
FilePath pak_dir; FilePath pak_dir;
PathService::Get(base::DIR_MODULE, &pak_dir); PathService::Get(base::DIR_MODULE, &pak_dir);
return pak_dir; return pak_dir;
@ -228,10 +228,12 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
if (settings.pack_loading_disabled) { if (settings.pack_loading_disabled) {
command_line->AppendSwitch(switches::kPackLoadingDisabled); command_line->AppendSwitch(switches::kPackLoadingDisabled);
} else { } else {
if (settings.pack_file_path.length > 0) { if (settings.resources_dir_path.length > 0) {
FilePath file_path = FilePath(CefString(&settings.pack_file_path)); FilePath file_path = FilePath(CefString(&settings.resources_dir_path));
if (!file_path.empty()) if (!file_path.empty()) {
command_line->AppendSwitchPath(switches::kPackFilePath, file_path); command_line->AppendSwitchPath(switches::kResourcesDirPath,
file_path);
}
} }
if (settings.locales_dir_path.length > 0) { if (settings.locales_dir_path.length > 0) {
@ -383,14 +385,22 @@ void CefMainDelegate::ShutdownBrowser() {
void CefMainDelegate::InitializeResourceBundle() { void CefMainDelegate::InitializeResourceBundle() {
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 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 (!content_client_.pack_loading_disabled()) {
if (command_line.HasSwitch(switches::kPackFilePath)) FilePath resources_dir;
pak_file = command_line.GetSwitchValuePath(switches::kPackFilePath); if (command_line.HasSwitch(switches::kResourcesDirPath)) {
resources_dir =
command_line.GetSwitchValuePath(switches::kResourcesDirPath);
}
if (resources_dir.empty())
resources_dir = GetResourcesFilePath();
if (pak_file.empty()) if (!resources_dir.empty()) {
pak_file = GetDefaultPackPath().Append(FILE_PATH_LITERAL("cef.pak")); 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)) if (command_line.HasSwitch(switches::kLocalesDirPath))
locales_dir = command_line.GetSwitchValuePath(switches::kLocalesDirPath); locales_dir = command_line.GetSwitchValuePath(switches::kLocalesDirPath);
@ -409,13 +419,20 @@ void CefMainDelegate::InitializeResourceBundle() {
if (!content_client_.pack_loading_disabled()) { if (!content_client_.pack_loading_disabled()) {
CHECK(!loaded_locale.empty()) << "Locale could not be found for " << locale; 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( ResourceBundle::GetSharedInstance().AddDataPackFromPath(
pak_file, ui::SCALE_FACTOR_NONE); cef_pak_file, ui::SCALE_FACTOR_NONE);
content_client_.set_allow_pack_file_load(false);
} else { } else {
NOTREACHED() << "Could not load cef.pak"; 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);
} }
} }

View File

@ -73,9 +73,10 @@ Optional components:
* Other resources * Other resources
cef.pak cef.pak
devtools_resources.pak
Note: Contains WebKit image and inspector resources. Pack file loading can be Note: Contains WebKit image and inspector resources. Pack file loading can be
disabled completely using CefSettings.pack_loading_disabled. The cef.pak file disabled completely using CefSettings.pack_loading_disabled. The resources
path can be customized using CefSettings.pack_file_path. directory path can be customized using CefSettings.resources_dir_path.
LICENSING LICENSING

View File

@ -84,8 +84,10 @@ Optional components:
* Other resources * Other resources
Resources/cef.pak Resources/cef.pak
Resources/devtools_resources.pak
Note: Contains WebKit image and inspector resources. Pack file loading can be Note: Contains WebKit image and inspector resources. Pack file loading can be
disabled completely using CefSettings.pack_loading_disabled. disabled completely using CefSettings.pack_loading_disabled. The resources
directory path can be customized using CefSettings.resources_dir_path.
* FFmpeg audio and video support * FFmpeg audio and video support
ffmpegsumo.so ffmpegsumo.so

View File

@ -83,9 +83,10 @@ Optional components:
* Other resources * Other resources
cef.pak cef.pak
devtools_resources.pak
Note: Contains WebKit image and inspector resources. Pack file loading can be Note: Contains WebKit image and inspector resources. Pack file loading can be
disabled completely using CefSettings.pack_loading_disabled. The cef.pak file disabled completely using CefSettings.pack_loading_disabled. The resources
path can be customized using CefSettings.pack_file_path. directory path can be customized using CefSettings.resources_dir_path.
* FFmpeg audio and video support * FFmpeg audio and video support
avcodec-54.dll avcodec-54.dll

View File

@ -287,6 +287,7 @@ if platform == 'windows':
copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet) copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \ copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \
options.quiet) options.quiet)
@ -306,6 +307,7 @@ if platform == 'windows':
copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet) copy_files(os.path.join(build_dir, '*.dll'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cefclient.exe'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \ copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), \
options.quiet) options.quiet)
@ -422,6 +424,7 @@ elif platform == 'linux':
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet) copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
else: else:
sys.stderr.write("No Debug build files.\n") sys.stderr.write("No Debug build files.\n")
@ -434,6 +437,7 @@ elif platform == 'linux':
copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet) copy_dir(os.path.join(build_dir, 'lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cefclient'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet) copy_file(os.path.join(build_dir, 'cef.pak'), dst_dir, options.quiet)
copy_file(os.path.join(build_dir, 'devtools_resources.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet) copy_dir(os.path.join(build_dir, 'locales'), os.path.join(dst_dir, 'locales'), options.quiet)
else: else:
sys.stderr.write("No Release build files.\n") sys.stderr.write("No Release build files.\n")