mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-09 16:48:49 +01:00
- Linux: Implement resource loading in cefclient.
- Fix incorrect svn:eol-style properties. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@375 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
1dab15313a
commit
f211cbbc2e
6
cef.gyp
6
cef.gyp
@ -281,6 +281,12 @@
|
|||||||
'<(INTERMEDIATE_DIR)/repack/chrome.pak'
|
'<(INTERMEDIATE_DIR)/repack/chrome.pak'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'destination': '<(PRODUCT_DIR)/files',
|
||||||
|
'files': [
|
||||||
|
'<@(cefclient_bundle_resources_linux)',
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
],
|
],
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
'tests/cefclient/res/domaccess.html',
|
'tests/cefclient/res/domaccess.html',
|
||||||
'tests/cefclient/res/extensionperf.html',
|
'tests/cefclient/res/extensionperf.html',
|
||||||
'tests/cefclient/res/localstorage.html',
|
'tests/cefclient/res/localstorage.html',
|
||||||
|
'tests/cefclient/res/logo.png',
|
||||||
'tests/cefclient/res/xmlhttprequest.html',
|
'tests/cefclient/res/xmlhttprequest.html',
|
||||||
'tests/cefclient/resource_util.h',
|
'tests/cefclient/resource_util.h',
|
||||||
'tests/cefclient/scheme_test.cpp',
|
'tests/cefclient/scheme_test.cpp',
|
||||||
@ -77,7 +78,6 @@
|
|||||||
'tests/cefclient/plugin_test.h',
|
'tests/cefclient/plugin_test.h',
|
||||||
'tests/cefclient/Resource.h',
|
'tests/cefclient/Resource.h',
|
||||||
'tests/cefclient/res/cefclient.ico',
|
'tests/cefclient/res/cefclient.ico',
|
||||||
'tests/cefclient/res/logo.png',
|
|
||||||
'tests/cefclient/res/logoball.png',
|
'tests/cefclient/res/logoball.png',
|
||||||
'tests/cefclient/res/modaldialog.html',
|
'tests/cefclient/res/modaldialog.html',
|
||||||
'tests/cefclient/res/modalmain.html',
|
'tests/cefclient/res/modalmain.html',
|
||||||
@ -95,7 +95,6 @@
|
|||||||
'tests/cefclient/cefclient_mac.mm',
|
'tests/cefclient/cefclient_mac.mm',
|
||||||
'tests/cefclient/client_handler_mac.mm',
|
'tests/cefclient/client_handler_mac.mm',
|
||||||
'tests/cefclient/resource_util_mac.mm',
|
'tests/cefclient/resource_util_mac.mm',
|
||||||
'tests/cefclient/res/logo.png',
|
|
||||||
],
|
],
|
||||||
'cefclient_bundle_resources_mac': [
|
'cefclient_bundle_resources_mac': [
|
||||||
'tests/cefclient/mac/cefclient.icns',
|
'tests/cefclient/mac/cefclient.icns',
|
||||||
@ -114,6 +113,13 @@
|
|||||||
'tests/cefclient/client_handler_gtk.cpp',
|
'tests/cefclient/client_handler_gtk.cpp',
|
||||||
'tests/cefclient/resource_util_linux.cpp',
|
'tests/cefclient/resource_util_linux.cpp',
|
||||||
],
|
],
|
||||||
|
'cefclient_bundle_resources_linux': [
|
||||||
|
'tests/cefclient/res/domaccess.html',
|
||||||
|
'tests/cefclient/res/extensionperf.html',
|
||||||
|
'tests/cefclient/res/localstorage.html',
|
||||||
|
'tests/cefclient/res/logo.png',
|
||||||
|
'tests/cefclient/res/xmlhttprequest.html',
|
||||||
|
],
|
||||||
'libcef_dll_wrapper_sources_common': [
|
'libcef_dll_wrapper_sources_common': [
|
||||||
'libcef_dll/cef_logging.h',
|
'libcef_dll/cef_logging.h',
|
||||||
'libcef_dll/cpptoc/base_cpptoc.h',
|
'libcef_dll/cpptoc/base_cpptoc.h',
|
||||||
|
@ -11,20 +11,48 @@
|
|||||||
|
|
||||||
bool GetResourceDir(std::string& dir) {
|
bool GetResourceDir(std::string& dir) {
|
||||||
char buff[1024];
|
char buff[1024];
|
||||||
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
|
|
||||||
|
|
||||||
if (len != -1) {
|
// Retrieve the executable path.
|
||||||
buff[len] = '\0';
|
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
|
||||||
|
if (len == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
buff[len] = 0;
|
||||||
|
|
||||||
|
// Remove the executable name from the path.
|
||||||
|
char* pos = strrchr(buff, '/');
|
||||||
|
if (!pos)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Add "files" to the path.
|
||||||
|
strcpy(pos+1, "files");
|
||||||
dir = std::string(buff);
|
dir = std::string(buff);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
/* handle error condition */
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
|
bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
|
||||||
|
std::string path;
|
||||||
|
if (!GetResourceDir(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
path.append("/");
|
||||||
|
path.append(resource_name);
|
||||||
|
|
||||||
|
FILE* f = fopen(path.c_str(), "rb");
|
||||||
|
if (!f)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t bytes_read;
|
||||||
|
char buff[1024*8];
|
||||||
|
|
||||||
|
do {
|
||||||
|
bytes_read = fread(buff, 1, sizeof(buff)-1, f);
|
||||||
|
if (bytes_read > 0)
|
||||||
|
resource_data.append(buff, bytes_read);
|
||||||
|
} while(bytes_read > 0);
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
|
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
|
||||||
|
@ -105,6 +105,14 @@
|
|||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
|
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
|
||||||
|
'copies': [
|
||||||
|
{
|
||||||
|
'destination': '<(PRODUCT_DIR)/files',
|
||||||
|
'files': [
|
||||||
|
'<@(cefclient_bundle_resources_linux)',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'<@(includes_linux)',
|
'<@(includes_linux)',
|
||||||
'<@(cefclient_sources_linux)',
|
'<@(cefclient_sources_linux)',
|
||||||
|
79
tools/distrib/linux/README.txt
Normal file
79
tools/distrib/linux/README.txt
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
Chromium Embedded Framework (CEF) Binary Distribution
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
CEF Revision: $CEF_REV$
|
||||||
|
Chromium Revision: $CHROMIUM_REV$
|
||||||
|
Date: $DATE$
|
||||||
|
|
||||||
|
This distribution contains all components necessary to build and distribute an
|
||||||
|
application using CEF. Please see the LICENSING section of this document for
|
||||||
|
licensing terms and conditions.
|
||||||
|
|
||||||
|
|
||||||
|
CONTENTS
|
||||||
|
--------
|
||||||
|
|
||||||
|
cefclient Contains the cefclient sample application configured to build
|
||||||
|
using the files in this distribution.
|
||||||
|
|
||||||
|
Debug Contains libcef.so and other components required to run the debug
|
||||||
|
version of CEF-based applications.
|
||||||
|
|
||||||
|
docs Contains C++ API documentation generated from the CEF header files.
|
||||||
|
|
||||||
|
include Contains all required CEF and NPAPI-related header files. Read
|
||||||
|
the include/internal/npapi/README-TRANSFER.txt file for more
|
||||||
|
information about the NPAPI-related header files.
|
||||||
|
|
||||||
|
libcef_dll Contains the source code for the libcef_dll_wrapper static library
|
||||||
|
that all applications using the CEF C++ API must link against.
|
||||||
|
|
||||||
|
Release Contains libcef.so and other components required to run the
|
||||||
|
release version of CEF-based applications.
|
||||||
|
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
-----
|
||||||
|
|
||||||
|
Run 'make -j4 cefclient BUILDTYPE=Debug' to build the cefclient target in
|
||||||
|
Debug mode.
|
||||||
|
|
||||||
|
Please visit the CEF Website for additional usage information.
|
||||||
|
|
||||||
|
http://code.google.com/p/chromiumembedded
|
||||||
|
|
||||||
|
|
||||||
|
REDISTRIBUTION
|
||||||
|
--------------
|
||||||
|
|
||||||
|
This binary distribution contains the below components. Components listed under
|
||||||
|
the "required" section must be redistributed with all applications using CEF.
|
||||||
|
Components listed under the "optional" section may be excluded if the related
|
||||||
|
features will not be used.
|
||||||
|
|
||||||
|
Required components:
|
||||||
|
|
||||||
|
* CEF core library
|
||||||
|
libcef.so
|
||||||
|
|
||||||
|
* Localized resources
|
||||||
|
locales/
|
||||||
|
Note: A .pak file is loaded from this folder based on the value of
|
||||||
|
CefSettings.locale. Only configured locales need to be distributed. If no
|
||||||
|
locale is configured the default locale of "en-US" will be used. The
|
||||||
|
locales folder must exist in the same directory as the executable.
|
||||||
|
|
||||||
|
* Other resources
|
||||||
|
chrome.pak
|
||||||
|
Note: The chrome.pak file must exist in the same directory as the executable.
|
||||||
|
|
||||||
|
|
||||||
|
LICENSING
|
||||||
|
---------
|
||||||
|
|
||||||
|
The CEF project is BSD licensed. Please read the LICENSE.txt file included with
|
||||||
|
this binary distribution for licensing terms and conditions. Other software
|
||||||
|
included in this distribution is provided under other licenses. Please visit the
|
||||||
|
below link for complete Chromium and third-party licensing information.
|
||||||
|
|
||||||
|
http://code.google.com/chromium/terms.html
|
@ -32,7 +32,7 @@ def create_readme(src, output_dir, cef_rev, chromium_rev, date):
|
|||||||
data = data.replace('$CEF_REV$', cef_rev)
|
data = data.replace('$CEF_REV$', cef_rev)
|
||||||
data = data.replace('$CHROMIUM_REV$', chromium_rev)
|
data = data.replace('$CHROMIUM_REV$', chromium_rev)
|
||||||
data = data.replace('$DATE$', date)
|
data = data.replace('$DATE$', date)
|
||||||
write_file(os.path.join(output_dir, 'README.TXT'), data)
|
write_file(os.path.join(output_dir, 'README.txt'), data)
|
||||||
if not options.quiet:
|
if not options.quiet:
|
||||||
sys.stdout.write('Creating README.TXT file.\n')
|
sys.stdout.write('Creating README.TXT file.\n')
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ def transfer_files(cef_dir, script_dir, transfer_cfg, output_dir, quiet):
|
|||||||
readme = os.path.join(dst_path, 'README-TRANSFER.txt')
|
readme = os.path.join(dst_path, 'README-TRANSFER.txt')
|
||||||
if not path_exists(readme):
|
if not path_exists(readme):
|
||||||
copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme)
|
copy_file(os.path.join(script_dir, 'distrib/README-TRANSFER.txt'), readme)
|
||||||
open(readme, 'a').write(cfg['source']+"\n")
|
open(readme, 'ab').write(cfg['source']+"\n")
|
||||||
|
|
||||||
# perform any required post-processing
|
# perform any required post-processing
|
||||||
if 'post-process' in cfg:
|
if 'post-process' in cfg:
|
||||||
@ -205,7 +205,7 @@ transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.c
|
|||||||
|
|
||||||
if platform == 'windows':
|
if platform == 'windows':
|
||||||
# create the README.TXT file
|
# create the README.TXT file
|
||||||
create_readme(os.path.join(script_dir, 'distrib/win/README.TXT'), output_dir, cef_rev, \
|
create_readme(os.path.join(script_dir, 'distrib/win/README.txt'), output_dir, cef_rev, \
|
||||||
chromium_rev, date)
|
chromium_rev, date)
|
||||||
|
|
||||||
# transfer include files
|
# transfer include files
|
||||||
@ -273,7 +273,7 @@ if platform == 'windows':
|
|||||||
|
|
||||||
elif platform == 'macosx':
|
elif platform == 'macosx':
|
||||||
# create the README.TXT file
|
# create the README.TXT file
|
||||||
create_readme(os.path.join(script_dir, 'distrib/mac/README.TXT'), output_dir, cef_rev, \
|
create_readme(os.path.join(script_dir, 'distrib/mac/README.txt'), output_dir, cef_rev, \
|
||||||
chromium_rev, date)
|
chromium_rev, date)
|
||||||
|
|
||||||
# transfer include files
|
# transfer include files
|
||||||
@ -328,11 +328,16 @@ elif platform == 'macosx':
|
|||||||
|
|
||||||
elif platform == 'linux':
|
elif platform == 'linux':
|
||||||
linux_build_dir = os.path.join(cef_dir, os.pardir, 'out')
|
linux_build_dir = os.path.join(cef_dir, os.pardir, 'out')
|
||||||
|
|
||||||
|
# create the README.TXT file
|
||||||
|
create_readme(os.path.join(script_dir, 'distrib/linux/README.txt'), output_dir, cef_rev, \
|
||||||
|
chromium_rev, date)
|
||||||
|
|
||||||
# transfer build/Debug files
|
# transfer build/Debug files
|
||||||
if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Debug')):
|
if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Debug')):
|
||||||
dst_dir = os.path.join(output_dir, 'Debug')
|
dst_dir = os.path.join(output_dir, 'Debug')
|
||||||
make_dir(dst_dir, options.quiet)
|
make_dir(dst_dir, options.quiet)
|
||||||
copy_files(os.path.join(linux_build_dir, 'Debug/lib.target/*'), dst_dir, options.quiet)
|
copy_dir(os.path.join(linux_build_dir, 'Debug/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
|
||||||
copy_file(os.path.join(linux_build_dir, 'Debug/cefclient'), dst_dir, options.quiet)
|
copy_file(os.path.join(linux_build_dir, 'Debug/cefclient'), dst_dir, options.quiet)
|
||||||
copy_file(os.path.join(linux_build_dir, 'Debug/chrome.pak'), dst_dir, options.quiet)
|
copy_file(os.path.join(linux_build_dir, 'Debug/chrome.pak'), dst_dir, options.quiet)
|
||||||
copy_dir(os.path.join(linux_build_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), options.quiet)
|
copy_dir(os.path.join(linux_build_dir, 'Debug/locales'), os.path.join(dst_dir, 'locales'), options.quiet)
|
||||||
@ -344,7 +349,7 @@ elif platform == 'linux':
|
|||||||
if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Release')):
|
if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Release')):
|
||||||
dst_dir = os.path.join(output_dir, 'Release')
|
dst_dir = os.path.join(output_dir, 'Release')
|
||||||
make_dir(dst_dir, options.quiet)
|
make_dir(dst_dir, options.quiet)
|
||||||
copy_files(os.path.join(linux_build_dir, 'Release/lib.target/*'), dst_dir, options.quiet)
|
copy_dir(os.path.join(linux_build_dir, 'Release/lib.target'), os.path.join(dst_dir, 'lib.target'), options.quiet)
|
||||||
copy_file(os.path.join(linux_build_dir, 'Release/cefclient'), dst_dir, options.quiet)
|
copy_file(os.path.join(linux_build_dir, 'Release/cefclient'), dst_dir, options.quiet)
|
||||||
copy_file(os.path.join(linux_build_dir, 'Release/chrome.pak'), dst_dir, options.quiet)
|
copy_file(os.path.join(linux_build_dir, 'Release/chrome.pak'), dst_dir, options.quiet)
|
||||||
copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet)
|
copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user