mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-02 20:26:59 +01:00
Add the cefsimple sample application which demonstrates the minimal functionality required to create a browser window.
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1535 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
19379d98c2
commit
916d8d08c4
270
cef.gyp
270
cef.gyp
@ -188,6 +188,7 @@
|
||||
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
|
||||
'dependencies': [
|
||||
'gtk',
|
||||
'gtkglext',
|
||||
'libcef',
|
||||
],
|
||||
'sources': [
|
||||
@ -205,6 +206,179 @@
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'cefsimple',
|
||||
'type': 'executable',
|
||||
'mac_bundle': 1,
|
||||
'msvs_guid': 'A5DCDE19-F4B1-4E3A-BD4F-BFE688B24D34',
|
||||
'dependencies': [
|
||||
'libcef_dll_wrapper',
|
||||
],
|
||||
'defines': [
|
||||
'USING_CEF_SHARED',
|
||||
],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
# cefsimple includes are relative to the tests directory to make
|
||||
# creation of binary releases easier.
|
||||
'tests'
|
||||
],
|
||||
'sources': [
|
||||
'<@(includes_common)',
|
||||
'<@(includes_wrapper)',
|
||||
'<@(cefsimple_sources_common)',
|
||||
],
|
||||
'mac_bundle_resources': [
|
||||
'<@(cefsimple_bundle_resources_mac)',
|
||||
],
|
||||
'mac_bundle_resources!': [
|
||||
# TODO(mark): Come up with a fancier way to do this (mac_info_plist?)
|
||||
# that automatically sets the correct INFOPLIST_FILE setting and adds
|
||||
# the file to a source group.
|
||||
'tests/cefsimple/mac/Info.plist',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'tests/cefsimple/mac/Info.plist',
|
||||
# Necessary to avoid an "install_name_tool: changing install names or
|
||||
# rpaths can't be redone" error.
|
||||
'OTHER_LDFLAGS': ['-Wl,-headerpad_max_install_names'],
|
||||
},
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'dependencies': [
|
||||
'cef_sandbox',
|
||||
'libcef',
|
||||
],
|
||||
'configurations': {
|
||||
'Debug_Base': {
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'LinkIncremental': '<(msvs_large_module_debug_link_mode)',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
# Set /SUBSYSTEM:WINDOWS.
|
||||
'SubSystem': '2',
|
||||
},
|
||||
'VCManifestTool': {
|
||||
'AdditionalManifestFiles': [
|
||||
'tests/cefsimple/cefsimple.exe.manifest',
|
||||
],
|
||||
},
|
||||
},
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-lcomctl32.lib',
|
||||
'-lshlwapi.lib',
|
||||
'-lrpcrt4.lib',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(includes_win)',
|
||||
'<@(cefsimple_sources_win)',
|
||||
],
|
||||
}],
|
||||
[ 'toolkit_uses_gtk == 1', {
|
||||
'dependencies': [
|
||||
'<(DEPTH)/sandbox/sandbox.gyp:sandbox',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="mac"', {
|
||||
'product_name': 'cefsimple',
|
||||
'dependencies': [
|
||||
'cef_framework',
|
||||
'cefsimple_helper_app',
|
||||
'interpose_dependency_shim',
|
||||
],
|
||||
'variables': {
|
||||
'PRODUCT_NAME': 'cefsimple',
|
||||
},
|
||||
'copies': [
|
||||
{
|
||||
# Add the helper app.
|
||||
'destination': '<(PRODUCT_DIR)/<(PRODUCT_NAME).app/Contents/Frameworks',
|
||||
'files': [
|
||||
'<(PRODUCT_DIR)/<(PRODUCT_NAME) Helper.app',
|
||||
'<(PRODUCT_DIR)/libplugin_carbon_interpose.dylib',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Copy <(framework_name).framework',
|
||||
'action': [
|
||||
'../build/mac/copy_framework_unversioned.sh',
|
||||
'${BUILT_PRODUCTS_DIR}/<(framework_name).framework',
|
||||
'${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Frameworks',
|
||||
],
|
||||
},
|
||||
{
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'install_name_tool',
|
||||
'-change',
|
||||
'@executable_path/<(framework_name)',
|
||||
'@executable_path/../Frameworks/<(framework_name).framework/<(framework_name)',
|
||||
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
|
||||
],
|
||||
},
|
||||
{
|
||||
'postbuild_name': 'Copy locale Resources',
|
||||
'action': [
|
||||
'cp',
|
||||
'-Rf',
|
||||
'${BUILT_PRODUCTS_DIR}/locales/',
|
||||
'${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Frameworks/<(framework_name).framework/Resources/'
|
||||
],
|
||||
},
|
||||
{
|
||||
# Modify the Info.plist as needed.
|
||||
'postbuild_name': 'Tweak Info.plist',
|
||||
'action': ['../build/mac/tweak_info_plist.py',
|
||||
'--scm=1'],
|
||||
},
|
||||
{
|
||||
# This postbuid step is responsible for creating the following
|
||||
# helpers:
|
||||
#
|
||||
# cefsimple Helper EH.app and cefsimple Helper NP.app are created
|
||||
# from cefsimple Helper.app.
|
||||
#
|
||||
# The EH helper is marked for an executable heap. The NP helper
|
||||
# is marked for no PIE (ASLR).
|
||||
'postbuild_name': 'Make More Helpers',
|
||||
'action': [
|
||||
'../build/mac/make_more_helpers.sh',
|
||||
'Frameworks',
|
||||
'cefsimple',
|
||||
],
|
||||
},
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(includes_mac)',
|
||||
'<@(cefsimple_sources_mac)',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
|
||||
'dependencies': [
|
||||
'gtk',
|
||||
'libcef',
|
||||
],
|
||||
'sources': [
|
||||
'<@(includes_linux)',
|
||||
'<@(cefsimple_sources_linux)',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'cef_unittests',
|
||||
'type': 'executable',
|
||||
@ -1248,6 +1422,80 @@
|
||||
},
|
||||
],
|
||||
}, # target cefclient_helper_app
|
||||
{
|
||||
'target_name': 'cefsimple_helper_app',
|
||||
'type': 'executable',
|
||||
'variables': { 'enable_wexit_time_destructors': 1, },
|
||||
'product_name': 'cefsimple Helper',
|
||||
'mac_bundle': 1,
|
||||
'dependencies': [
|
||||
'cef_framework',
|
||||
'libcef_dll_wrapper',
|
||||
],
|
||||
'defines': [
|
||||
'USING_CEF_SHARED',
|
||||
],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
# cefsimple includes are relative to the tests directory to make
|
||||
# creation of binary releases easier.
|
||||
'tests'
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(cefsimple_sources_mac_helper)',
|
||||
],
|
||||
# TODO(mark): Come up with a fancier way to do this. It should only
|
||||
# be necessary to list helper-Info.plist once, not the three times it
|
||||
# is listed here.
|
||||
'mac_bundle_resources!': [
|
||||
'tests/cefsimple/mac/helper-Info.plist',
|
||||
],
|
||||
# TODO(mark): For now, don't put any resources into this app. Its
|
||||
# resources directory will be a symbolic link to the browser app's
|
||||
# resources directory.
|
||||
'mac_bundle_resources/': [
|
||||
['exclude', '.*'],
|
||||
],
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'tests/cefsimple/mac/helper-Info.plist',
|
||||
# Necessary to avoid an "install_name_tool: changing install names or
|
||||
# rpaths can't be redone" error.
|
||||
'OTHER_LDFLAGS': ['-Wl,-headerpad_max_install_names'],
|
||||
},
|
||||
'postbuilds': [
|
||||
{
|
||||
# The framework defines its load-time path
|
||||
# (DYLIB_INSTALL_NAME_BASE) relative to the main executable
|
||||
# (chrome). A different relative path needs to be used in
|
||||
# cefsimple_helper_app.
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'install_name_tool',
|
||||
'-change',
|
||||
'@executable_path/<(framework_name)',
|
||||
'@executable_path/../../../../Frameworks/<(framework_name).framework/<(framework_name)',
|
||||
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
|
||||
],
|
||||
},
|
||||
{
|
||||
# Modify the Info.plist as needed. The script explains why this
|
||||
# is needed. This is also done in the chrome and chrome_dll
|
||||
# targets. In this case, --breakpad=0, --keystone=0, and --scm=0
|
||||
# are used because Breakpad, Keystone, and SCM keys are
|
||||
# never placed into the helper.
|
||||
'postbuild_name': 'Tweak Info.plist',
|
||||
'action': ['../build/mac/tweak_info_plist.py',
|
||||
'--breakpad=0',
|
||||
'--keystone=0',
|
||||
'--scm=0'],
|
||||
},
|
||||
],
|
||||
}, # target cefsimple_helper_app
|
||||
{
|
||||
'target_name': 'cef_unittests_helper_app',
|
||||
'type': 'executable',
|
||||
@ -1420,8 +1668,28 @@
|
||||
'variables': {
|
||||
# gtk requires gmodule, but it does not list it as a dependency
|
||||
# in some misconfigured systems.
|
||||
'gtk_packages': 'gmodule-2.0 gtk+-2.0 gthread-2.0 gtk+-unix-print-2.0',
|
||||
},
|
||||
'direct_dependent_settings': {
|
||||
'cflags': [
|
||||
'<!@(pkg-config --cflags <(gtk_packages))',
|
||||
],
|
||||
},
|
||||
'link_settings': {
|
||||
'ldflags': [
|
||||
'<!@(pkg-config --libs-only-L --libs-only-other <(gtk_packages))',
|
||||
],
|
||||
'libraries': [
|
||||
'<!@(pkg-config --libs-only-l <(gtk_packages))',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'gtkglext',
|
||||
'type': 'none',
|
||||
'variables': {
|
||||
# gtkglext is required by the cefclient OSR example.
|
||||
'gtk_packages': 'gmodule-2.0 gtk+-2.0 gthread-2.0 gtkglext-1.0 gtk+-unix-print-2.0',
|
||||
'gtk_packages': 'gtkglext-1.0',
|
||||
},
|
||||
'direct_dependent_settings': {
|
||||
'cflags': [
|
||||
|
@ -204,5 +204,38 @@
|
||||
'cefclient_bundle_resources_linux': [
|
||||
'<@(cefclient_bundle_resources_common)',
|
||||
],
|
||||
'cefsimple_sources_common': [
|
||||
'tests/cefsimple/simple_app.cpp',
|
||||
'tests/cefsimple/simple_app.h',
|
||||
'tests/cefsimple/simple_handler.cpp',
|
||||
'tests/cefsimple/simple_handler.h',
|
||||
'tests/cefsimple/util.h',
|
||||
],
|
||||
'cefsimple_sources_win': [
|
||||
'tests/cefsimple/cefsimple.exe.manifest',
|
||||
'tests/cefsimple/cefsimple.rc',
|
||||
'tests/cefsimple/cefsimple_win.cpp',
|
||||
'tests/cefsimple/simple_handler_win.cpp',
|
||||
'tests/cefsimple/resource.h',
|
||||
'tests/cefsimple/res/cefsimple.ico',
|
||||
'tests/cefsimple/res/small.ico',
|
||||
],
|
||||
'cefsimple_sources_mac': [
|
||||
'tests/cefsimple/cefsimple_mac.mm',
|
||||
'tests/cefsimple/simple_handler_mac.mm',
|
||||
],
|
||||
'cefsimple_sources_mac_helper': [
|
||||
'tests/cefsimple/process_helper_mac.cpp',
|
||||
],
|
||||
'cefsimple_bundle_resources_mac': [
|
||||
'tests/cefsimple/mac/cefsimple.icns',
|
||||
'tests/cefsimple/mac/English.lproj/InfoPlist.strings',
|
||||
'tests/cefsimple/mac/English.lproj/MainMenu.xib',
|
||||
'tests/cefsimple/mac/Info.plist',
|
||||
],
|
||||
'cefsimple_sources_linux': [
|
||||
'tests/cefsimple/cefsimple_gtk.cpp',
|
||||
'tests/cefsimple/simple_handler_gtk.cpp',
|
||||
],
|
||||
},
|
||||
}
|
||||
|
20
tests/cefsimple/cefsimple.exe.manifest
Normal file
20
tests/cefsimple/cefsimple.exe.manifest
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
|
||||
<!--The compatibility section will be merged from build/win/compatibility.manifest -->
|
||||
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
</assembly>
|
79
tests/cefsimple/cefsimple.rc
Normal file
79
tests/cefsimple/cefsimple.rc
Normal file
@ -0,0 +1,79 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_CEFSIMPLE ICON "res\cefsimple.ico"
|
||||
IDI_SMALL ICON "res\small.ico"
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
44
tests/cefsimple/cefsimple_gtk.cpp
Normal file
44
tests/cefsimple/cefsimple_gtk.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "cefsimple/simple_app.h"
|
||||
|
||||
// Entry point function for all processes.
|
||||
int main(int argc, char* argv[]) {
|
||||
// Provide CEF with command-line arguments.
|
||||
CefMainArgs main_args(argc, argv);
|
||||
|
||||
// SimpleApp implements application-level callbacks. It will create the first
|
||||
// browser instance in OnContextInitialized() after CEF has initialized.
|
||||
CefRefPtr<SimpleApp> app(new SimpleApp);
|
||||
|
||||
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
|
||||
// that share the same executable. This function checks the command-line and,
|
||||
// if this is a sub-process, executes the appropriate logic.
|
||||
int exit_code = CefExecuteProcess(main_args, app.get(), NULL);
|
||||
if (exit_code >= 0) {
|
||||
// The sub-process has completed so return here.
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
// Initialize GTK.
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
// Specify CEF global settings here.
|
||||
CefSettings settings;
|
||||
|
||||
// Initialize CEF for the browser process.
|
||||
CefInitialize(main_args, settings, app.get(), NULL);
|
||||
|
||||
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
|
||||
// called.
|
||||
CefRunMessageLoop();
|
||||
|
||||
// Shut down CEF.
|
||||
CefShutdown();
|
||||
|
||||
return 0;
|
||||
}
|
113
tests/cefsimple/cefsimple_mac.mm
Normal file
113
tests/cefsimple/cefsimple_mac.mm
Normal file
@ -0,0 +1,113 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "cefsimple/simple_app.h"
|
||||
#include "cefsimple/simple_handler.h"
|
||||
#include "cefsimple/util.h"
|
||||
#include "include/cef_application_mac.h"
|
||||
|
||||
// Provide the CefAppProtocol implementation required by CEF.
|
||||
@interface SimpleApplication : NSApplication<CefAppProtocol> {
|
||||
@private
|
||||
BOOL handlingSendEvent_;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation SimpleApplication
|
||||
- (BOOL)isHandlingSendEvent {
|
||||
return handlingSendEvent_;
|
||||
}
|
||||
|
||||
- (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
|
||||
handlingSendEvent_ = handlingSendEvent;
|
||||
}
|
||||
|
||||
- (void)sendEvent:(NSEvent*)event {
|
||||
CefScopedSendingEvent sendingEventScoper;
|
||||
[super sendEvent:event];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
// Receives notifications from the application.
|
||||
@interface SimpleAppDelegate : NSObject
|
||||
- (void)createApp:(id)object;
|
||||
@end
|
||||
|
||||
@implementation SimpleAppDelegate
|
||||
|
||||
// Create the application on the UI thread.
|
||||
- (void)createApp:(id)object {
|
||||
[NSApplication sharedApplication];
|
||||
[NSBundle loadNibNamed:@"MainMenu" owner:NSApp];
|
||||
|
||||
// Set the delegate for application events.
|
||||
[NSApp setDelegate:self];
|
||||
}
|
||||
|
||||
// Called when the application's Quit menu item is selected.
|
||||
- (NSApplicationTerminateReply)applicationShouldTerminate:
|
||||
(NSApplication *)sender {
|
||||
// Request that all browser windows close.
|
||||
if (SimpleHandler* handler = SimpleHandler::GetInstance())
|
||||
handler->CloseAllBrowsers(false);
|
||||
|
||||
// Cancel the termination. The application will exit after all windows have
|
||||
// closed.
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
// Sent immediately before the application terminates. This signal should not
|
||||
// be called because we cancel the termination.
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
||||
ASSERT(false); // Not reached.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
// Entry point function for the browser process.
|
||||
int main(int argc, char* argv[]) {
|
||||
// Provide CEF with command-line arguments.
|
||||
CefMainArgs main_args(argc, argv);
|
||||
|
||||
// SimpleApp implements application-level callbacks. It will create the first
|
||||
// browser instance in OnContextInitialized() after CEF has initialized.
|
||||
CefRefPtr<SimpleApp> app(new SimpleApp);
|
||||
|
||||
// Initialize the AutoRelease pool.
|
||||
NSAutoreleasePool* autopool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
// Initialize the SimpleApplication instance.
|
||||
[SimpleApplication sharedApplication];
|
||||
|
||||
// Specify CEF global settings here.
|
||||
CefSettings settings;
|
||||
|
||||
// Initialize CEF for the browser process.
|
||||
CefInitialize(main_args, settings, app.get(), NULL);
|
||||
|
||||
// Create the application delegate.
|
||||
NSObject* delegate = [[SimpleAppDelegate alloc] init];
|
||||
[delegate performSelectorOnMainThread:@selector(createApp:) withObject:nil
|
||||
waitUntilDone:NO];
|
||||
|
||||
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
|
||||
// called.
|
||||
CefRunMessageLoop();
|
||||
|
||||
// Shut down CEF.
|
||||
CefShutdown();
|
||||
|
||||
// Release the delegate.
|
||||
[delegate release];
|
||||
|
||||
// Release the AutoRelease pool.
|
||||
[autopool release];
|
||||
|
||||
return 0;
|
||||
}
|
53
tests/cefsimple/cefsimple_win.cpp
Normal file
53
tests/cefsimple/cefsimple_win.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "cefsimple/simple_app.h"
|
||||
#include "include/cef_sandbox_win.h"
|
||||
|
||||
// Entry point function for all processes.
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
int nCmdShow) {
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// Manage the life span of the sandbox information object. This is necessary
|
||||
// for sandbox support on Windows. See cef_sandbox_win.h for complete details.
|
||||
CefScopedSandboxInfo scoped_sandbox;
|
||||
|
||||
// Provide CEF with command-line arguments.
|
||||
CefMainArgs main_args(hInstance);
|
||||
|
||||
// SimpleApp implements application-level callbacks. It will create the first
|
||||
// browser instance in OnContextInitialized() after CEF has initialized.
|
||||
CefRefPtr<SimpleApp> app(new SimpleApp);
|
||||
|
||||
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
|
||||
// that share the same executable. This function checks the command-line and,
|
||||
// if this is a sub-process, executes the appropriate logic.
|
||||
int exit_code = CefExecuteProcess(main_args, app.get(),
|
||||
scoped_sandbox.sandbox_info());
|
||||
if (exit_code >= 0) {
|
||||
// The sub-process has completed so return here.
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
// Specify CEF global settings here.
|
||||
CefSettings settings;
|
||||
|
||||
// Initialize CEF.
|
||||
CefInitialize(main_args, settings, app.get(), scoped_sandbox.sandbox_info());
|
||||
|
||||
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
|
||||
// called.
|
||||
CefRunMessageLoop();
|
||||
|
||||
// Shut down CEF.
|
||||
CefShutdown();
|
||||
|
||||
return 0;
|
||||
}
|
3
tests/cefsimple/mac/English.lproj/InfoPlist.strings
Normal file
3
tests/cefsimple/mac/English.lproj/InfoPlist.strings
Normal file
@ -0,0 +1,3 @@
|
||||
/* Localized versions of Info.plist keys */
|
||||
|
||||
NSHumanReadableCopyright = "© Chromium Embedded Framework Authors, 2013";
|
2880
tests/cefsimple/mac/English.lproj/MainMenu.xib
Normal file
2880
tests/cefsimple/mac/English.lproj/MainMenu.xib
Normal file
File diff suppressed because it is too large
Load Diff
28
tests/cefsimple/mac/Info.plist
Normal file
28
tests/cefsimple/mac/Info.plist
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>cefsimple.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.cef.cefsimple</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
BIN
tests/cefsimple/mac/cefsimple.icns
Normal file
BIN
tests/cefsimple/mac/cefsimple.icns
Normal file
Binary file not shown.
30
tests/cefsimple/mac/helper-Info.plist
Normal file
30
tests/cefsimple/mac/helper-Info.plist
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.cef.cefsimple.helper</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>LSFileQuarantineEnabled</key>
|
||||
<true/>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.5.0</string>
|
||||
<key>LSUIElement</key>
|
||||
<string>1</string>
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
14
tests/cefsimple/process_helper_mac.cpp
Normal file
14
tests/cefsimple/process_helper_mac.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that can
|
||||
// be found in the LICENSE file.
|
||||
|
||||
#include "include/cef_app.h"
|
||||
|
||||
// Entry point function for sub-processes.
|
||||
int main(int argc, char* argv[]) {
|
||||
// Provide CEF with command-line arguments.
|
||||
CefMainArgs main_args(argc, argv);
|
||||
|
||||
// Execute the sub-process.
|
||||
return CefExecuteProcess(main_args, NULL, NULL);
|
||||
}
|
BIN
tests/cefsimple/res/cefsimple.ico
Normal file
BIN
tests/cefsimple/res/cefsimple.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
tests/cefsimple/res/small.ico
Normal file
BIN
tests/cefsimple/res/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
26
tests/cefsimple/resource.h
Normal file
26
tests/cefsimple/resource.h
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by cefsimple.rc
|
||||
//
|
||||
|
||||
#define IDI_CEFSIMPLE 100
|
||||
#define IDI_SMALL 101
|
||||
|
||||
// Avoid files associated with MacOS
|
||||
#define _X86_
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NO_MFC 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 32700
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
48
tests/cefsimple/simple_app.cpp
Normal file
48
tests/cefsimple/simple_app.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefsimple/simple_app.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cefsimple/simple_handler.h"
|
||||
#include "cefsimple/util.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_command_line.h"
|
||||
|
||||
SimpleApp::SimpleApp() {
|
||||
}
|
||||
|
||||
void SimpleApp::OnContextInitialized() {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Information used when creating the native window.
|
||||
CefWindowInfo window_info;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// On Windows we need to specify certain flags that will be passed to
|
||||
// CreateWindowEx().
|
||||
window_info.SetAsPopup(NULL, "cefsimple");
|
||||
#endif
|
||||
|
||||
// SimpleHandler implements browser-level callbacks.
|
||||
CefRefPtr<SimpleHandler> handler(new SimpleHandler());
|
||||
|
||||
// Specify CEF browser settings here.
|
||||
CefBrowserSettings browser_settings;
|
||||
|
||||
std::string url;
|
||||
|
||||
// Check if a "--url=" value was provided via the command-line. If so, use
|
||||
// that instead of the default URL.
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
url = command_line->GetSwitchValue("url");
|
||||
if (url.empty())
|
||||
url = "http://www.google.com";
|
||||
|
||||
// Create the first browser window.
|
||||
CefBrowserHost::CreateBrowserSync(window_info, handler.get(), url,
|
||||
browser_settings, NULL);
|
||||
}
|
27
tests/cefsimple/simple_app.h
Normal file
27
tests/cefsimple/simple_app.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
||||
#define CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
||||
|
||||
#include "include/cef_app.h"
|
||||
|
||||
class SimpleApp : public CefApp,
|
||||
public CefBrowserProcessHandler {
|
||||
public:
|
||||
SimpleApp();
|
||||
|
||||
// CefApp methods:
|
||||
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
|
||||
OVERRIDE { return this; }
|
||||
|
||||
// CefBrowserProcessHandler methods:
|
||||
virtual void OnContextInitialized() OVERRIDE;
|
||||
|
||||
private:
|
||||
// Include the default reference counting implementation.
|
||||
IMPLEMENT_REFCOUNTING(SimpleApp);
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_APP_H_
|
94
tests/cefsimple/simple_handler.cpp
Normal file
94
tests/cefsimple/simple_handler.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefsimple/simple_handler.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "cefsimple/util.h"
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_runnable.h"
|
||||
|
||||
namespace {
|
||||
|
||||
SimpleHandler* g_instance = NULL;
|
||||
|
||||
} // namespace
|
||||
|
||||
SimpleHandler::SimpleHandler() {
|
||||
ASSERT(!g_instance);
|
||||
g_instance = this;
|
||||
}
|
||||
|
||||
SimpleHandler::~SimpleHandler() {
|
||||
g_instance = NULL;
|
||||
}
|
||||
|
||||
// static
|
||||
SimpleHandler* SimpleHandler::GetInstance() {
|
||||
return g_instance;
|
||||
}
|
||||
|
||||
void SimpleHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Add to the list of existing browsers.
|
||||
browser_list_.push_back(browser);
|
||||
}
|
||||
|
||||
void SimpleHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Remove from the list of existing browsers.
|
||||
BrowserList::iterator bit = browser_list_.begin();
|
||||
for (; bit != browser_list_.end(); ++bit) {
|
||||
if ((*bit)->IsSame(browser)) {
|
||||
browser_list_.erase(bit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (browser_list_.empty()) {
|
||||
// All browser windows have closed. Quit the application message loop.
|
||||
CefQuitMessageLoop();
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const CefString& errorText,
|
||||
const CefString& failedUrl) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
// Don't display an error for downloaded files.
|
||||
if (errorCode == ERR_ABORTED)
|
||||
return;
|
||||
|
||||
// Display a load error message.
|
||||
std::stringstream ss;
|
||||
ss << "<html><body bgcolor=\"white\">"
|
||||
"<h2>Failed to load URL " << std::string(failedUrl) <<
|
||||
" with error " << std::string(errorText) << " (" << errorCode <<
|
||||
").</h2></body></html>";
|
||||
frame->LoadString(ss.str(), failedUrl);
|
||||
}
|
||||
|
||||
void SimpleHandler::CloseAllBrowsers(bool force_close) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
// Execute on the UI thread.
|
||||
CefPostTask(TID_UI,
|
||||
NewCefRunnableMethod(this, &SimpleHandler::CloseAllBrowsers,
|
||||
force_close));
|
||||
return;
|
||||
}
|
||||
|
||||
if (browser_list_.empty())
|
||||
return;
|
||||
|
||||
BrowserList::const_iterator it = browser_list_.begin();
|
||||
for (; it != browser_list_.end(); ++it)
|
||||
(*it)->GetHost()->CloseBrowser(force_close);
|
||||
}
|
61
tests/cefsimple/simple_handler.h
Normal file
61
tests/cefsimple/simple_handler.h
Normal file
@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
||||
#define CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
||||
|
||||
#include "include/cef_client.h"
|
||||
|
||||
#include <list>
|
||||
|
||||
class SimpleHandler : public CefClient,
|
||||
public CefDisplayHandler,
|
||||
public CefLifeSpanHandler,
|
||||
public CefLoadHandler {
|
||||
public:
|
||||
SimpleHandler();
|
||||
~SimpleHandler();
|
||||
|
||||
// Provide access to the single global instance of this object.
|
||||
static SimpleHandler* GetInstance();
|
||||
|
||||
// CefClient methods:
|
||||
virtual CefRefPtr<CefDisplayHandler> GetDisplayHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
virtual CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE {
|
||||
return this;
|
||||
}
|
||||
|
||||
// CefDisplayHandler methods:
|
||||
virtual void OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) OVERRIDE;
|
||||
|
||||
// CefLifeSpanHandler methods:
|
||||
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE;
|
||||
|
||||
// CefLoadHandler methods:
|
||||
virtual void OnLoadError(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
ErrorCode errorCode,
|
||||
const CefString& errorText,
|
||||
const CefString& failedUrl) OVERRIDE;
|
||||
|
||||
// Request that all existing browser windows close.
|
||||
void CloseAllBrowsers(bool force_close);
|
||||
|
||||
private:
|
||||
// List of existing browser windows. Only accessed on the CEF UI thread.
|
||||
typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
|
||||
BrowserList browser_list_;
|
||||
|
||||
// Include the default reference counting implementation.
|
||||
IMPLEMENT_REFCOUNTING(SimpleHandler);
|
||||
};
|
||||
|
||||
#endif // CEF_TESTS_CEFSIMPLE_SIMPLE_HANDLER_H_
|
22
tests/cefsimple/simple_handler_gtk.cpp
Normal file
22
tests/cefsimple/simple_handler_gtk.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefsimple/simple_handler.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string>
|
||||
|
||||
#include "cefsimple/util.h"
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
GtkWidget* window = gtk_widget_get_ancestor(
|
||||
GTK_WIDGET(browser->GetHost()->GetWindowHandle()),
|
||||
GTK_TYPE_WINDOW);
|
||||
std::string titleStr(title);
|
||||
gtk_window_set_title(GTK_WINDOW(window), titleStr.c_str());
|
||||
}
|
21
tests/cefsimple/simple_handler_mac.mm
Normal file
21
tests/cefsimple/simple_handler_mac.mm
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefsimple/simple_handler.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "cefsimple/util.h"
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
NSView* view = (NSView*)browser->GetHost()->GetWindowHandle();
|
||||
NSWindow* window = [view window];
|
||||
std::string titleStr(title);
|
||||
NSString* str = [NSString stringWithUTF8String:titleStr.c_str()];
|
||||
[window setTitle:str];
|
||||
}
|
19
tests/cefsimple/simple_handler_win.cpp
Normal file
19
tests/cefsimple/simple_handler_win.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2013 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "cefsimple/simple_handler.h"
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
#include "cefsimple/util.h"
|
||||
#include "include/cef_browser.h"
|
||||
|
||||
void SimpleHandler::OnTitleChange(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& title) {
|
||||
REQUIRE_UI_THREAD();
|
||||
|
||||
CefWindowHandle hwnd = browser->GetHost()->GetWindowHandle();
|
||||
SetWindowText(hwnd, std::wstring(title).c_str());
|
||||
}
|
37
tests/cefsimple/util.h
Normal file
37
tests/cefsimple/util.h
Normal file
@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_TESTS_CEFCLIENT_UTIL_H_
|
||||
#define CEF_TESTS_CEFCLIENT_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_task.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
||||
#include <windows.h> // NOLINT(build/include_order)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT(condition) if (!(condition)) { DebugBreak(); }
|
||||
#else
|
||||
#define ASSERT(condition) ((void)0)
|
||||
#endif
|
||||
|
||||
#else // !OS_WIN
|
||||
|
||||
#include <assert.h> // NOLINT(build/include_order)
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define ASSERT(condition) if (!(condition)) { assert(false); }
|
||||
#else
|
||||
#define ASSERT(condition) ((void)0)
|
||||
#endif
|
||||
|
||||
#endif // !OS_WIN
|
||||
|
||||
#define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI));
|
||||
#define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO));
|
||||
#define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE));
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_UTIL_H_
|
@ -148,16 +148,24 @@
|
||||
],
|
||||
'copies': [
|
||||
{
|
||||
# Add the framework and helper app.
|
||||
# Add libraries and helper app.
|
||||
'destination': '<(PRODUCT_DIR)/cefclient.app/Contents/Frameworks',
|
||||
'files': [
|
||||
'$(CONFIGURATION)/<(framework_name).framework/',
|
||||
'$(CONFIGURATION)/libplugin_carbon_interpose.dylib',
|
||||
'<(PRODUCT_DIR)/cefclient Helper.app',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Add framework',
|
||||
'action': [
|
||||
'cp',
|
||||
'-Rf',
|
||||
'${CONFIGURATION}/<(framework_name).framework',
|
||||
'${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Frameworks/'
|
||||
],
|
||||
},
|
||||
{
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
@ -219,6 +227,7 @@
|
||||
],
|
||||
'dependencies': [
|
||||
'gtk',
|
||||
'gtkglext',
|
||||
],
|
||||
'link_settings': {
|
||||
'ldflags': [
|
||||
@ -237,6 +246,214 @@
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'cefsimple',
|
||||
'type': 'executable',
|
||||
'mac_bundle': 1,
|
||||
'msvs_guid': '5390D142-473F-49A0-BC5E-5F6C609EEDB6',
|
||||
'dependencies': [
|
||||
'libcef_dll_wrapper',
|
||||
],
|
||||
'defines': [
|
||||
'USING_CEF_SHARED',
|
||||
],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
],
|
||||
'sources': [
|
||||
'<@(includes_common)',
|
||||
'<@(includes_wrapper)',
|
||||
'<@(cefsimple_sources_common)',
|
||||
],
|
||||
'mac_bundle_resources': [
|
||||
'<@(cefsimple_bundle_resources_mac)',
|
||||
],
|
||||
'mac_bundle_resources!': [
|
||||
# TODO(mark): Come up with a fancier way to do this (mac_info_plist?)
|
||||
# that automatically sets the correct INFOPLIST_FILE setting and adds
|
||||
# the file to a source group.
|
||||
'cefsimple/mac/Info.plist',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'cefsimple/mac/Info.plist',
|
||||
# Target build path.
|
||||
'SYMROOT': 'xcodebuild',
|
||||
},
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'variables': {
|
||||
'win_exe_compatibility_manifest': 'cefsimple/compatibility.manifest',
|
||||
},
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'copy_resources',
|
||||
'msvs_cygwin_shell': 0,
|
||||
'inputs': [],
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/copy_resources.stamp',
|
||||
],
|
||||
'action': [
|
||||
'xcopy /efy',
|
||||
'Resources\*',
|
||||
'$(OutDir)',
|
||||
],
|
||||
},
|
||||
{
|
||||
'action_name': 'copy_libraries',
|
||||
'msvs_cygwin_shell': 0,
|
||||
'inputs': [],
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/copy_resources.stamp',
|
||||
],
|
||||
'action': [
|
||||
'xcopy /efy',
|
||||
'$(ConfigurationName)\*.dll',
|
||||
'$(OutDir)',
|
||||
],
|
||||
},
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
# Set /SUBSYSTEM:WINDOWS.
|
||||
'SubSystem': '2',
|
||||
},
|
||||
'VCManifestTool': {
|
||||
'AdditionalManifestFiles': [
|
||||
'cefsimple/cefsimple.exe.manifest',
|
||||
],
|
||||
},
|
||||
},
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-lcomctl32.lib',
|
||||
'-lshlwapi.lib',
|
||||
'-lrpcrt4.lib',
|
||||
'-l$(ConfigurationName)/libcef.lib',
|
||||
'-l$(ConfigurationName)/cef_sandbox.lib',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(includes_win)',
|
||||
'<@(cefsimple_sources_win)',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="win" and multi_threaded_dll', {
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'RuntimeLibrary': 3,
|
||||
'WarnAsError': 'false',
|
||||
},
|
||||
},
|
||||
},
|
||||
'Release': {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'RuntimeLibrary': 2,
|
||||
'WarnAsError': 'false',
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}],
|
||||
[ 'OS=="mac"', {
|
||||
'product_name': 'cefsimple',
|
||||
'dependencies': [
|
||||
'cefsimple_helper_app',
|
||||
],
|
||||
'copies': [
|
||||
{
|
||||
# Add libraries and helper app.
|
||||
'destination': '<(PRODUCT_DIR)/cefsimple.app/Contents/Frameworks',
|
||||
'files': [
|
||||
'$(CONFIGURATION)/libplugin_carbon_interpose.dylib',
|
||||
'<(PRODUCT_DIR)/cefsimple Helper.app',
|
||||
],
|
||||
},
|
||||
],
|
||||
'postbuilds': [
|
||||
{
|
||||
'postbuild_name': 'Add framework',
|
||||
'action': [
|
||||
'cp',
|
||||
'-Rf',
|
||||
'${CONFIGURATION}/<(framework_name).framework',
|
||||
'${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Frameworks/'
|
||||
],
|
||||
},
|
||||
{
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'install_name_tool',
|
||||
'-change',
|
||||
'@executable_path/<(framework_name)',
|
||||
'@executable_path/../Frameworks/<(framework_name).framework/<(framework_name)',
|
||||
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
|
||||
],
|
||||
},
|
||||
{
|
||||
# This postbuid step is responsible for creating the following
|
||||
# helpers:
|
||||
#
|
||||
# cefsimple Helper EH.app and cefsimple Helper NP.app are created
|
||||
# from cefsimple Helper.app.
|
||||
#
|
||||
# The EH helper is marked for an executable heap. The NP helper
|
||||
# is marked for no PIE (ASLR).
|
||||
'postbuild_name': 'Make More Helpers',
|
||||
'action': [
|
||||
'tools/make_more_helpers.sh',
|
||||
'Frameworks',
|
||||
'cefsimple',
|
||||
],
|
||||
},
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
|
||||
'$(CONFIGURATION)/<(framework_name).framework/<(framework_name)',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(includes_mac)',
|
||||
'<@(cefsimple_sources_mac)',
|
||||
],
|
||||
}],
|
||||
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
|
||||
'copies': [
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)/',
|
||||
'files': [
|
||||
'Resources/cef.pak',
|
||||
'Resources/devtools_resources.pak',
|
||||
'Resources/locales/',
|
||||
'$(BUILDTYPE)/chrome-sandbox',
|
||||
'$(BUILDTYPE)/libcef.so',
|
||||
'$(BUILDTYPE)/libffmpegsumo.so',
|
||||
],
|
||||
},
|
||||
],
|
||||
'dependencies': [
|
||||
'gtk',
|
||||
],
|
||||
'link_settings': {
|
||||
'ldflags': [
|
||||
# Look for libcef.so in the current directory. Path can also be
|
||||
# specified using the LD_LIBRARY_PATH environment variable.
|
||||
'-Wl,-rpath,.',
|
||||
],
|
||||
'libraries': [
|
||||
"$(BUILDTYPE)/libcef.so",
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(includes_linux)',
|
||||
'<@(cefsimple_sources_linux)',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
{
|
||||
'target_name': 'libcef_dll_wrapper',
|
||||
'type': 'static_library',
|
||||
@ -345,6 +562,62 @@
|
||||
},
|
||||
],
|
||||
}, # target cefclient_helper_app
|
||||
{
|
||||
'target_name': 'cefsimple_helper_app',
|
||||
'type': 'executable',
|
||||
'variables': { 'enable_wexit_time_destructors': 1, },
|
||||
'product_name': 'cefsimple Helper',
|
||||
'mac_bundle': 1,
|
||||
'dependencies': [
|
||||
'libcef_dll_wrapper',
|
||||
],
|
||||
'defines': [
|
||||
'USING_CEF_SHARED',
|
||||
],
|
||||
'include_dirs': [
|
||||
'.',
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
|
||||
'$(CONFIGURATION)/<(framework_name).framework/<(framework_name)',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'<@(cefsimple_sources_mac_helper)',
|
||||
],
|
||||
# TODO(mark): Come up with a fancier way to do this. It should only
|
||||
# be necessary to list helper-Info.plist once, not the three times it
|
||||
# is listed here.
|
||||
'mac_bundle_resources!': [
|
||||
'cefsimple/mac/helper-Info.plist',
|
||||
],
|
||||
# TODO(mark): For now, don't put any resources into this app. Its
|
||||
# resources directory will be a symbolic link to the browser app's
|
||||
# resources directory.
|
||||
'mac_bundle_resources/': [
|
||||
['exclude', '.*'],
|
||||
],
|
||||
'xcode_settings': {
|
||||
'INFOPLIST_FILE': 'cefsimple/mac/helper-Info.plist',
|
||||
},
|
||||
'postbuilds': [
|
||||
{
|
||||
# The framework defines its load-time path
|
||||
# (DYLIB_INSTALL_NAME_BASE) relative to the main executable
|
||||
# (chrome). A different relative path needs to be used in
|
||||
# cefsimple_helper_app.
|
||||
'postbuild_name': 'Fix Framework Link',
|
||||
'action': [
|
||||
'install_name_tool',
|
||||
'-change',
|
||||
'@executable_path/<(framework_name)',
|
||||
'@executable_path/../../../../Frameworks/<(framework_name).framework/<(framework_name)',
|
||||
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
|
||||
],
|
||||
},
|
||||
],
|
||||
}, # target cefsimple_helper_app
|
||||
],
|
||||
}], # OS=="mac"
|
||||
[ 'OS=="linux" or OS=="freebsd" or OS=="openbsd"', {
|
||||
@ -355,8 +628,28 @@
|
||||
'variables': {
|
||||
# gtk requires gmodule, but it does not list it as a dependency
|
||||
# in some misconfigured systems.
|
||||
'gtk_packages': 'gmodule-2.0 gtk+-2.0 gthread-2.0 gtk+-unix-print-2.0',
|
||||
},
|
||||
'direct_dependent_settings': {
|
||||
'cflags': [
|
||||
'$(shell <(pkg-config) --cflags <(gtk_packages))',
|
||||
],
|
||||
},
|
||||
'link_settings': {
|
||||
'ldflags': [
|
||||
'$(shell <(pkg-config) --libs-only-L --libs-only-other <(gtk_packages))',
|
||||
],
|
||||
'libraries': [
|
||||
'$(shell <(pkg-config) --libs-only-l <(gtk_packages))',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'gtkglext',
|
||||
'type': 'none',
|
||||
'variables': {
|
||||
# gtkglext is required by the cefclient OSR example.
|
||||
'gtk_packages': 'gmodule-2.0 gtk+-2.0 gthread-2.0 gtkglext-1.0 gtk+-unix-print-2.0',
|
||||
'gtk_packages': 'gtkglext-1.0',
|
||||
},
|
||||
'direct_dependent_settings': {
|
||||
'cflags': [
|
||||
|
@ -2,7 +2,12 @@ CONTENTS
|
||||
--------
|
||||
|
||||
cefclient Contains the cefclient sample application configured to build
|
||||
using the files in this distribution.
|
||||
using the files in this distribution. This application demonstrates
|
||||
a wide range of CEF functionalities.
|
||||
|
||||
cefsimple Contains the cefsimple sample application configured to build
|
||||
using the files in this distribution. This application demonstrates
|
||||
the minimal functionality required to create a browser window.
|
||||
|
||||
Debug Contains libcef.so and other components required to run the debug
|
||||
version of CEF-based applications. By default these files should be
|
||||
|
@ -2,7 +2,7 @@
|
||||
if [ -z "$1" ]; then
|
||||
echo "ERROR: Please specify a build target: Debug or Release"
|
||||
else
|
||||
make -j8 cefclient BUILDTYPE=$1
|
||||
make -j8 cefclient cefsimple BUILDTYPE=$1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Giving SUID permissions to chrome-sandbox..."
|
||||
echo "(using sudo so you may be asked for your password)"
|
||||
|
@ -2,7 +2,12 @@ CONTENTS
|
||||
--------
|
||||
|
||||
cefclient Contains the cefclient sample application configured to build
|
||||
using the files in this distribution.
|
||||
using the files in this distribution. This application demonstrates
|
||||
a wide range of CEF functionalities.
|
||||
|
||||
cefsimple Contains the cefsimple sample application configured to build
|
||||
using the files in this distribution. This application demonstrates
|
||||
the minimal functionality required to create a browser window.
|
||||
|
||||
Debug Contains the "Chromium Embedded Framework.framework" and other
|
||||
components required to run the debug version of CEF-based
|
||||
|
@ -2,7 +2,12 @@ CONTENTS
|
||||
--------
|
||||
|
||||
cefclient Contains the cefclient sample application configured to build
|
||||
using the files in this distribution.
|
||||
using the files in this distribution. This application demonstrates
|
||||
a wide range of CEF functionalities.
|
||||
|
||||
cefsimple Contains the cefsimple sample application configured to build
|
||||
using the files in this distribution. This application demonstrates
|
||||
the minimal functionality required to create a browser window.
|
||||
|
||||
Debug Contains libcef.dll, libcef.lib and other components required to
|
||||
build and run the debug version of CEF-based applications. By
|
||||
|
@ -14,4 +14,8 @@
|
||||
'source' : '../build/win/compatibility.manifest',
|
||||
'target' : 'cefclient/compatibility.manifest',
|
||||
},
|
||||
{
|
||||
'source' : '../build/win/compatibility.manifest',
|
||||
'target' : 'cefsimple/compatibility.manifest',
|
||||
},
|
||||
]
|
||||
|
@ -438,6 +438,10 @@ if mode == 'standard':
|
||||
# create the cefclient directory
|
||||
cefclient_dir = os.path.join(output_dir, 'cefclient')
|
||||
make_dir(cefclient_dir, options.quiet)
|
||||
|
||||
# create the cefsimple directory
|
||||
cefsimple_dir = os.path.join(output_dir, 'cefsimple')
|
||||
make_dir(cefsimple_dir, options.quiet)
|
||||
|
||||
# create the libcef_dll_wrapper directory
|
||||
wrapper_dir = os.path.join(output_dir, 'libcef_dll')
|
||||
@ -461,6 +465,10 @@ if mode == 'standard':
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_bundle_resources_common'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer common cefsimple files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_common'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer common libcef_dll_wrapper files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \
|
||||
'libcef_dll/', wrapper_dir, options.quiet)
|
||||
@ -472,6 +480,7 @@ if mode == 'standard':
|
||||
paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi')
|
||||
data = read_file(paths_gypi)
|
||||
data = data.replace('tests/cefclient/', 'cefclient/')
|
||||
data = data.replace('tests/cefsimple/', 'cefsimple/')
|
||||
write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data)
|
||||
copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \
|
||||
os.path.join(output_dir, 'cef_paths.gypi'), options.quiet)
|
||||
@ -574,6 +583,10 @@ if platform == 'windows':
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer cefsimple files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_win'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer additional files, if any
|
||||
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/win/transfer.cfg'), \
|
||||
output_dir, options.quiet)
|
||||
@ -652,6 +665,18 @@ elif platform == 'macosx':
|
||||
copy_dir(os.path.join(cef_dir, 'tests/cefclient/mac/'), os.path.join(output_dir, 'cefclient/mac/'), \
|
||||
options.quiet)
|
||||
|
||||
# transfer cefsimple files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_mac'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_mac_helper'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_bundle_resources_mac'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer cefsimple/mac files
|
||||
copy_dir(os.path.join(cef_dir, 'tests/cefsimple/mac/'), os.path.join(output_dir, 'cefsimple/mac/'), \
|
||||
options.quiet)
|
||||
|
||||
# transfer additional files, if any
|
||||
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/mac/transfer.cfg'), \
|
||||
output_dir, options.quiet)
|
||||
@ -723,6 +748,10 @@ elif platform == 'linux':
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_bundle_resources_linux'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer cefsimple files
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_linux'], \
|
||||
'tests/cefsimple/', cefsimple_dir, options.quiet)
|
||||
|
||||
# transfer additional files, if any
|
||||
copy_file(os.path.join(script_dir, 'distrib/linux/build.sh'), output_dir, options.quiet)
|
||||
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/linux/transfer.cfg'), \
|
||||
|
Loading…
x
Reference in New Issue
Block a user