- 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:
Marshall Greenblatt 2011-11-12 04:47:00 +00:00
parent 1dab15313a
commit f211cbbc2e
11 changed files with 442 additions and 310 deletions

View File

@ -281,6 +281,12 @@
'<(INTERMEDIATE_DIR)/repack/chrome.pak'
],
},
{
'destination': '<(PRODUCT_DIR)/files',
'files': [
'<@(cefclient_bundle_resources_linux)',
],
},
],
}],
],

View File

@ -55,6 +55,7 @@
'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',
'tests/cefclient/resource_util.h',
'tests/cefclient/scheme_test.cpp',
@ -77,7 +78,6 @@
'tests/cefclient/plugin_test.h',
'tests/cefclient/Resource.h',
'tests/cefclient/res/cefclient.ico',
'tests/cefclient/res/logo.png',
'tests/cefclient/res/logoball.png',
'tests/cefclient/res/modaldialog.html',
'tests/cefclient/res/modalmain.html',
@ -95,7 +95,6 @@
'tests/cefclient/cefclient_mac.mm',
'tests/cefclient/client_handler_mac.mm',
'tests/cefclient/resource_util_mac.mm',
'tests/cefclient/res/logo.png',
],
'cefclient_bundle_resources_mac': [
'tests/cefclient/mac/cefclient.icns',
@ -114,6 +113,13 @@
'tests/cefclient/client_handler_gtk.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/cef_logging.h',
'libcef_dll/cpptoc/base_cpptoc.h',

View File

@ -11,20 +11,48 @@
bool GetResourceDir(std::string& dir) {
char buff[1024];
ssize_t len = ::readlink("/proc/self/exe", buff, sizeof(buff)-1);
if (len != -1) {
buff[len] = '\0';
// Retrieve the executable path.
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);
return true;
} else {
/* handle error condition */
return false;
}
}
bool LoadBinaryResource(const char* resource_name, std::string& resource_data) {
std::string path;
if (!GetResourceDir(path))
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) {

View File

@ -105,6 +105,14 @@
],
}],
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
'copies': [
{
'destination': '<(PRODUCT_DIR)/files',
'files': [
'<@(cefclient_bundle_resources_linux)',
],
},
],
'sources': [
'<@(includes_linux)',
'<@(cefclient_sources_linux)',

View 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

View File

@ -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('$CHROMIUM_REV$', chromium_rev)
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:
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')
if not path_exists(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
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':
# 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)
# transfer include files
@ -273,7 +273,7 @@ if platform == 'windows':
elif platform == 'macosx':
# 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)
# transfer include files
@ -328,11 +328,16 @@ elif platform == 'macosx':
elif platform == 'linux':
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
if not options.allowpartial or path_exists(os.path.join(linux_build_dir, 'Debug')):
dst_dir = os.path.join(output_dir, 'Debug')
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/chrome.pak'), dst_dir, 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')):
dst_dir = os.path.join(output_dir, 'Release')
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/chrome.pak'), dst_dir, options.quiet)
copy_dir(os.path.join(linux_build_dir, 'Release/locales'), os.path.join(dst_dir, 'locales'), options.quiet)