Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to branch 3071 revision 1640 #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Compatibility
Supported platforms: Windows, Linux, Mac OSX.

CEF2go was tested and works fine with Go 1.2 / Go 1.3.3.
In the case of Windows (32 and 64 bits) it was tested and works fine with Go 1.8.3.


Binary examples
Expand Down Expand Up @@ -109,24 +110,44 @@ accessible from the outside, it can be accessed only from the
machine it is running on.


Getting started on Windows
Getting started on Windows 32-bit
--------------------------
1. Install Go 32-bit. CEF 64-bit binaries are still experimental and
were not tested.
1. Install Go 32-bit.

2. Install mingw 32-bit and add C:\MinGW\bin to PATH. You can install mingw
using [mingw-get-setup.exe](http://sourceforge.net/projects/mingw/files/Installer/).
Select packages to install: "mingw-developer-toolkit",
"mingw32-base", "msys-base". CEF2go was tested and works fine
with GCC 4.8.2. You can check gcc version with "gcc --version".
with GCC 5.3.0. You can check gcc version with "gcc --version".

3. Download CEF 3 branch 1750 revision 1590 binaries:
3. Download CEF 3 branch 3071 revision 1640 binaries:
[cef_binary_3.1750.1590_windows32.7z](https://github.com/CzarekTomczak/cef2go/releases/download/cef3-b1750-r1590/cef_binary_3.1750.1590_windows32.7z)
Copy Release/* to cef2go/Release
Copy Resources/* to cef2go/Release

4. Run build.bat (or "build.bat noconsole" to get rid of the console
window when running the final executable)

5. You might need to help your linker find libcef.dll

Getting started on Windows 64-bit
--------------------------
1. Install Go 64-bit.

2. Install mingw 64-bit and add the bin folder to PATH. You can install mingw
using [mingw-w64-install](https://sourceforge.net/projects/mingw-w64/files/latest/download).
Select x86_64 as your architecture.
CEF2go was tested and works fine with GCC 7.1.0. You can check gcc version with "gcc --version".

3. Download CEF 3 branch 3071 revision 1640 binaries:
[cef_binary_3.1750.1590_windows32.7z](https://github.com/CzarekTomczak/cef2go/releases/download/cef3-b1750-r1590/cef_binary_3.1750.1590_windows32.7z)
Copy Release/* to cef2go/Release
Copy Resources/* to cef2go/Release

4. Run build.bat (or "build.bat noconsole" to get rid of the console
window when running the final executable)

5. You might need to help your linker find libcef.dll
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make only one "Getting started on Windows" section and just add a) and b) sublists for 32-bit and 64-bit. Something like:

  1. Install mingw:
    a) If using 32-bit ...
    b) If using 64-bit ...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do



Getting started on Linux
Expand Down
8 changes: 4 additions & 4 deletions handlers/cef_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct _cef_resource_bundle_handler_t*
// Return the handler for functionality specific to the browser process. This
// function is called on multiple threads in the browser process.
///
struct _cef_browser_process_handler_t*
struct _cef_browser_process_handler_t*
CEF_CALLBACK get_browser_process_handler(struct _cef_app_t* self) {
DEBUG_CALLBACK("get_browser_process_handler\n");
return NULL;
Expand All @@ -77,10 +77,10 @@ struct _cef_render_process_handler_t*
return NULL;
}

void initialize_app_handler(cef_app_t* app) {
printf("initialize_app_handler\n");
void initialize_cef_app(cef_app_t* app) {
printf("initialize_cef_app\n");
app->base.size = sizeof(cef_app_t);
initialize_cef_base((cef_base_t*)app);
initialize_cef_base_ref_counted((cef_base_ref_counted_t*)app);
// callbacks
app->on_before_command_line_processing = on_before_command_line_processing;
app->on_register_custom_schemes = on_register_custom_schemes;
Expand Down
38 changes: 22 additions & 16 deletions handlers/cef_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#include "include/capi/cef_base_capi.h"
#include <stdio.h>
#include "include/capi/cef_base_capi.h"

// Set to 1 to check if add_ref() and release()
// are called and to track the total number of calls.
Expand All @@ -14,33 +14,39 @@

// Print only the first execution of the callback,
// ignore the subsequent.
#define DEBUG_CALLBACK(x) { static int first_call = 1; if (first_call == 1) { first_call = 0; printf(x); } }
#define DEBUG_CALLBACK(x) { \
static int first_call = 1; \
if (first_call == 1) { \
first_call = 0; \
printf(x); \
} \
}

// ----------------------------------------------------------------------------
// cef_base_t
// cef_base_ref_counted_t
// ----------------------------------------------------------------------------

///
// Structure defining the reference count implementation functions. All
// framework structures must include the cef_base_t structure first.
// Structure defining the reference count implementation functions.
// All framework structures must include the cef_base_ref_counted_t
// structure first.
///

///
// Increment the reference count.
///
int CEF_CALLBACK add_ref(cef_base_t* self) {
DEBUG_CALLBACK("cef_base_t.add_ref\n");
void CEF_CALLBACK add_ref(cef_base_ref_counted_t* self) {
DEBUG_CALLBACK("cef_base_ref_counted_t.add_ref\n");
if (DEBUG_REFERENCE_COUNTING)
printf("+");
return 1;
}

///
// Decrement the reference count. Delete this object when no references
// remain.
///
int CEF_CALLBACK release(cef_base_t* self) {
DEBUG_CALLBACK("cef_base_t.release\n");
int CEF_CALLBACK release(cef_base_ref_counted_t* self) {
DEBUG_CALLBACK("cef_base_ref_counted_t.release\n");
if (DEBUG_REFERENCE_COUNTING)
printf("-");
return 1;
Expand All @@ -49,26 +55,26 @@ int CEF_CALLBACK release(cef_base_t* self) {
///
// Returns the current number of references.
///
int CEF_CALLBACK get_refct(cef_base_t* self) {
DEBUG_CALLBACK("cef_base_t.get_refct\n");
int CEF_CALLBACK has_one_ref(cef_base_ref_counted_t* self) {
DEBUG_CALLBACK("cef_base_ref_counted_t.has_one_ref\n");
if (DEBUG_REFERENCE_COUNTING)
printf("=");
return 1;
}

void initialize_cef_base(cef_base_t* base) {
printf("initialize_cef_base\n");
void initialize_cef_base_ref_counted(cef_base_ref_counted_t* base) {
printf("initialize_cef_base_ref_counted\n");
// Check if "size" member was set.
size_t size = base->size;
// Let's print the size in case sizeof was used
// on a pointer instead of a structure. In such
// case the number will be very high.
printf("cef_base_t.size = %lu\n", (unsigned long)size);
printf("cef_base_ref_counted_t.size = %lu\n", (unsigned long)size);
if (size <= 0) {
printf("FATAL: initialize_cef_base failed, size member not set\n");
_exit(1);
}
base->add_ref = add_ref;
base->release = release;
base->get_refct = get_refct;
base->has_one_ref = has_one_ref;
}
21 changes: 13 additions & 8 deletions handlers/cef_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@
#pragma once

#include "handlers/cef_base.h"
#include "handlers/cef_life_span_handler.h"
#include "include/capi/cef_client_capi.h"

extern cef_life_span_handler_t g_life_span_handler;


// ----------------------------------------------------------------------------
// struct _cef_client_t
// struct cef_client_t
// ----------------------------------------------------------------------------

///
// Implement this structure to provide handler implementations.
///

///
// Return the handler for context menus. If no handler is provided the default
// implementation will be used.
// Return the handler for context menus. If no handler is
// provided the default implementation will be used.
///

struct _cef_context_menu_handler_t* CEF_CALLBACK get_context_menu_handler(
Expand Down Expand Up @@ -108,7 +112,8 @@ struct _cef_keyboard_handler_t* CEF_CALLBACK get_keyboard_handler(
struct _cef_life_span_handler_t* CEF_CALLBACK get_life_span_handler(
struct _cef_client_t* self) {
DEBUG_CALLBACK("get_life_span_handler\n");
return NULL;
// Implemented!
return &g_life_span_handler;
}

///
Expand Down Expand Up @@ -151,10 +156,10 @@ int CEF_CALLBACK on_process_message_received(
return 0;
}

void initialize_client_handler(struct _cef_client_t* client) {
DEBUG_CALLBACK("initialize_client_handler\n");
void initialize_cef_client(cef_client_t* client) {
DEBUG_CALLBACK("initialize_cef_client\n");
client->base.size = sizeof(cef_client_t);
initialize_cef_base((cef_base_t*)client);
initialize_cef_base_ref_counted((cef_base_ref_counted_t*)client);
// callbacks
client->get_context_menu_handler = get_context_menu_handler;
client->get_dialog_handler = get_dialog_handler;
Expand All @@ -165,7 +170,7 @@ void initialize_client_handler(struct _cef_client_t* client) {
client->get_geolocation_handler = get_geolocation_handler;
client->get_jsdialog_handler = get_jsdialog_handler;
client->get_keyboard_handler = get_keyboard_handler;
client->get_life_span_handler = get_life_span_handler;
client->get_life_span_handler = get_life_span_handler; // Implemented!
client->get_load_handler = get_load_handler;
client->get_render_handler = get_render_handler;
client->get_request_handler = get_request_handler;
Expand Down
46 changes: 46 additions & 0 deletions handlers/cef_life_span_handler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// CEF C API example
// Project website: https://github.com/cztomczak/cefcapi

#pragma once

#include "handlers/cef_base.h"
#include "include/capi/cef_app_capi.h"
#include "include/capi/cef_life_span_handler_capi.h"

// ----------------------------------------------------------------------------
// struct cef_life_span_handler_t
// ----------------------------------------------------------------------------

///
// Implement this structure to handle events related to browser life span. The
// functions of this structure will be called on the UI thread unless otherwise
// indicated.
///

// NOTE: There are many more callbacks in cef_life_span_handler,
// but only on_before_close is implemented here.

///
// Called just before a browser is destroyed. Release all references to the
// browser object and do not attempt to execute any functions on the browser
// object after this callback returns. This callback will be the last
// notification that references |browser|. See do_close() documentation for
// additional usage information.
///
void CEF_CALLBACK on_before_close(struct _cef_life_span_handler_t* self,
struct _cef_browser_t* browser) {
DEBUG_CALLBACK("on_before_close\n");
// TODO: Check how many browsers do exist and quit message
// loop only when last browser is closed. Otherwise
// closing a popup window will exit app while main
// window shouldn't be closed.
cef_quit_message_loop();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call should be commented out, otherwise popups will not work. In cef2go examples there are already explicit calls to cef.QuitMessageLoop(). The cefcapi project use case is very minimal.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

}

void initialize_cef_life_span_handler(cef_life_span_handler_t* handler) {
DEBUG_CALLBACK("initialize_cef_life_span_handler\n");
handler->base.size = sizeof(cef_life_span_handler_t);
initialize_cef_base_ref_counted((cef_base_ref_counted_t*)handler);
// callbacks - there are many, but implementing only one
handler->on_before_close = on_before_close;
}