Showing
72 changed files
with
40 additions
and
923 deletions
... | ... | @@ -66,11 +66,6 @@ newoption { |
66 | 66 | } |
67 | 67 | |
68 | 68 | newoption { |
69 | - trigger = "web-awesomium", | |
70 | - description = "Use awesomium embedded browser as the webcore" | |
71 | -} | |
72 | - | |
73 | -newoption { | |
74 | 69 | trigger = "web-cef3", |
75 | 70 | description = "Use CEF3 embedded browser as the webcore" |
76 | 71 | } | ... | ... |
... | ... | @@ -527,19 +527,6 @@ project "te4-bzip" |
527 | 527 | |
528 | 528 | files { "../src/bzip2/*.c", } |
529 | 529 | |
530 | -if _OPTIONS['web-awesomium'] and not _OPTIONS.wincross then | |
531 | -project "te4-web" | |
532 | - kind "SharedLib" | |
533 | - language "C++" | |
534 | - targetname "te4-web" | |
535 | - | |
536 | - libdirs {"/opt/awesomium/bin/"} | |
537 | - includedirs {"/opt/awesomium/include/"} | |
538 | - links { "awesomium-1-7" } | |
539 | - | |
540 | - files { "../src/web-awesomium/*.cpp", } | |
541 | -end | |
542 | - | |
543 | 530 | if _OPTIONS['web-cef3'] and not _OPTIONS.wincross then |
544 | 531 | project "te4-web" |
545 | 532 | kind "SharedLib" |
... | ... | @@ -562,8 +549,8 @@ project "te4-web" |
562 | 549 | |
563 | 550 | configuration "linux" |
564 | 551 | buildoptions{"-Wall -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm"} |
565 | - libdirs {"/opt/cef3/2526/libcef_dll/", "/opt/cef3/2526/Release/"} | |
566 | - includedirs {"/opt/cef3/2526/include/", "/opt/cef3/2526/"} | |
552 | + libdirs {"/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/build/libcef_dll_wrapper/", "/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/Release/"} | |
553 | + includedirs {"/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/include/", "/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/"} | |
567 | 554 | links { "cef_dll_wrapper", "cef" } |
568 | 555 | defines { 'SELFEXE_LINUX' } |
569 | 556 | |
... | ... | @@ -586,12 +573,17 @@ project "cef3spawn" |
586 | 573 | |
587 | 574 | configuration "linux" |
588 | 575 | buildoptions{"-Wall -pthread -I/usr/include/gtk-2.0 -I/usr/lib64/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm"} |
589 | - libdirs {"/opt/cef3/2526/out/libcef_dll/", "/opt/cef3/2526/Release/"} | |
590 | - includedirs {"/opt/cef3/2526/include/", "/opt/cef3/2526/"} | |
591 | - links { "cef", "cef_dll_wrapper" } | |
576 | + libdirs {"/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/build/libcef_dll_wrapper/", "/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/Release/"} | |
577 | + includedirs {"/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/include/", "/huge/Test/cef_binary_3.3029.1611.g44e39a8_linux64/"} | |
578 | + links { "cef_dll_wrapper", "cef" } | |
592 | 579 | if _OPTIONS.relpath=="32" then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN/lib "} end |
593 | 580 | if _OPTIONS.relpath=="64" then linkoptions{"-Wl,-rpath -Wl,\\\$\$ORIGIN/lib64 "} end |
594 | 581 | defines { 'SELFEXE_LINUX' } |
582 | + configuration {"linux", "Debug"} | |
583 | + postbuildcommands { "cp ../bin/Debug/cef3spawn ../", } | |
584 | + configuration {"linux", "Release"} | |
585 | + postbuildcommands { "cp ../bin/Release/cef3spawn ../", } | |
586 | + | |
595 | 587 | end |
596 | 588 | |
597 | 589 | if _OPTIONS.steam then | ... | ... |
No preview for this file type
game/thirdparty/cef3/cef_100_percent.pak
0 → 100644
No preview for this file type
game/thirdparty/cef3/cef_200_percent.pak
0 → 100644
No preview for this file type
game/thirdparty/cef3/cef_extensions.pak
0 → 100644
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
icudtl.dat
0 → 100644
No preview for this file type
natives_blob.bin
0 → 100644
This diff could not be displayed because it is too large.
snapshot_blob.bin
0 → 100644
No preview for this file type
1 | -@rem Script to compile T-Engine's webapi functionality. | |
2 | -@rem See copyright notice in web-te4.h. | |
3 | -@rem To use: load a windows SDK command prompt, navigate to source file root | |
4 | -@rem setenv /release /x86 /xp | |
5 | -@rem build\windows\build-te4-web.bat | |
6 | - | |
7 | -@rem SDK tools to use (with options) | |
8 | -@rem TODO: offer a debugging build? | |
9 | -@if not defined INCLUDE goto :BADENV | |
10 | - | |
11 | -@setlocal | |
12 | -@set CXX=cl | |
13 | -@set CXXFLAGS=/nologo /MT /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /EHsc | |
14 | -@rem @set CXXFLAGS=/nologo /MT /Od /Zi /Wall /D_CRT_SECURE_NO_DEPRECATE /EHsc | |
15 | -@set DLLNAME=te4-web.dll | |
16 | -@set LIBNAME=te4-web.lib | |
17 | -@set TE4_WEB_C=web.cpp web-utils.cpp gl_texture_surface.cpp | |
18 | -@set TE4_WEB_INCLUDES=/I ".." /I "C:\MingW\include\SDL2" /I "n:\libs\awesomium\1.7.4.1\include" | |
19 | -@set TE4_WEB_LIBS="n:\libs\awesomium\1.7.4.1\build\lib\awesomium.lib" | |
20 | - | |
21 | -%CXX% %CXXFLAGS% /LD /Fe%DLLNAME% %TE4_WEB_INCLUDES% %TE4_WEB_C% %TE4_WEB_LIBS% | |
22 | - | |
23 | -@if errorlevel 1 goto :COMPILATION_ERROR | |
24 | - | |
25 | -@rem All done. | |
26 | -@echo Successfully built %DLLNAME%. | |
27 | -@goto :END | |
28 | - | |
29 | -:COMPILATION_ERROR | |
30 | -@echo ERROR: Failed to build te4web. Check SDK tool output for errors. | |
31 | -@goto :END | |
32 | - | |
33 | -:BAD_ENV | |
34 | -@echo ERROR: Must be compiled in a Windows SDK Command Prompt! | |
35 | - | |
36 | -:END | |
\ No newline at end of file |
1 | -// Taken from awesomium examples | |
2 | -#include "gl_texture_surface.h" | |
3 | -#include <stdio.h> | |
4 | -#include <stdlib.h> | |
5 | -#include <string.h> | |
6 | - | |
7 | -GLRAMTextureSurface::GLRAMTextureSurface(int width, int height) : texture_id_(NULL), | |
8 | - buffer_(0), bpp_(4), rowspan_(0), width_(width), height_(height) { | |
9 | - rowspan_ = width_ * bpp_; | |
10 | - buffer_ = new unsigned char[rowspan_ * height_]; | |
11 | - needs_update_ = false; | |
12 | - | |
13 | - texture_id_ = web_make_texture(width_, height_); | |
14 | -} | |
15 | - | |
16 | -GLRAMTextureSurface::~GLRAMTextureSurface() { | |
17 | - web_del_texture(texture_id_); | |
18 | - delete[] buffer_; | |
19 | -} | |
20 | - | |
21 | -void* GLRAMTextureSurface::GetTexture() const { | |
22 | - const_cast<GLRAMTextureSurface*>(this)->UpdateTexture(); | |
23 | - | |
24 | - return texture_id_; | |
25 | -} | |
26 | - | |
27 | -void GLRAMTextureSurface::Paint(unsigned char* src_buffer, | |
28 | - int src_row_span, | |
29 | - const Awesomium::Rect& src_rect, | |
30 | - const Awesomium::Rect& dest_rect) { | |
31 | - for (int row = 0; row < dest_rect.height; row++) | |
32 | - memcpy(buffer_ + (row + dest_rect.y) * rowspan_ + (dest_rect.x * 4), | |
33 | - src_buffer + (row + src_rect.y) * src_row_span + (src_rect.x * 4), | |
34 | - dest_rect.width * 4); | |
35 | - | |
36 | - needs_update_ = true; | |
37 | -} | |
38 | - | |
39 | -void GLRAMTextureSurface::Scroll(int dx, | |
40 | - int dy, | |
41 | - const Awesomium::Rect& clip_rect) { | |
42 | - if (abs(dx) >= clip_rect.width || abs(dy) >= clip_rect.height) | |
43 | - return; | |
44 | - | |
45 | - if (dx < 0 && dy == 0) { | |
46 | - // Area shifted left by dx | |
47 | - unsigned char* tempBuffer = new unsigned char[(clip_rect.width + dx) * 4]; | |
48 | - | |
49 | - for (int i = 0; i < clip_rect.height; i++) { | |
50 | - memcpy(tempBuffer, buffer_ + (i + clip_rect.y) * rowspan_ + | |
51 | - (clip_rect.x - dx) * 4, (clip_rect.width + dx) * 4); | |
52 | - memcpy(buffer_ + (i + clip_rect.y) * rowspan_ + (clip_rect.x) * 4, | |
53 | - tempBuffer, (clip_rect.width + dx) * 4); | |
54 | - } | |
55 | - | |
56 | - delete[] tempBuffer; | |
57 | - } else if (dx > 0 && dy == 0) { | |
58 | - // Area shifted right by dx | |
59 | - unsigned char* tempBuffer = new unsigned char[(clip_rect.width - dx) * 4]; | |
60 | - | |
61 | - for (int i = 0; i < clip_rect.height; i++) { | |
62 | - memcpy(tempBuffer, buffer_ + (i + clip_rect.y) * rowspan_ + | |
63 | - (clip_rect.x) * 4, (clip_rect.width - dx) * 4); | |
64 | - memcpy(buffer_ + (i + clip_rect.y) * rowspan_ + (clip_rect.x + dx) * 4, | |
65 | - tempBuffer, (clip_rect.width - dx) * 4); | |
66 | - } | |
67 | - | |
68 | - delete[] tempBuffer; | |
69 | - } else if (dy < 0 && dx == 0) { | |
70 | - // Area shifted down by dy | |
71 | - for (int i = 0; i < clip_rect.height + dy ; i++) | |
72 | - memcpy(buffer_ + (i + clip_rect.y) * rowspan_ + (clip_rect.x * 4), | |
73 | - buffer_ + (i + clip_rect.y - dy) * rowspan_ + (clip_rect.x * 4), | |
74 | - clip_rect.width * 4); | |
75 | - } else if (dy > 0 && dx == 0) { | |
76 | - // Area shifted up by dy | |
77 | - for (int i = clip_rect.height - 1; i >= dy; i--) | |
78 | - memcpy(buffer_ + (i + clip_rect.y) * rowspan_ + (clip_rect.x * 4), | |
79 | - buffer_ + (i + clip_rect.y - dy) * rowspan_ + (clip_rect.x * 4), | |
80 | - clip_rect.width * 4); | |
81 | - } | |
82 | - | |
83 | - needs_update_ = true; | |
84 | -} | |
85 | - | |
86 | -void GLRAMTextureSurface::UpdateTexture() { | |
87 | - if (needs_update_) { | |
88 | - web_texture_update(texture_id_, width_, height_, buffer_); | |
89 | - needs_update_ = false; | |
90 | - } | |
91 | -} | |
92 | - | |
93 | - | |
94 | -GLTextureSurfaceFactory::GLTextureSurfaceFactory() { | |
95 | -} | |
96 | - | |
97 | -GLTextureSurfaceFactory::~GLTextureSurfaceFactory() { | |
98 | -} | |
99 | - | |
100 | -Awesomium::Surface* GLTextureSurfaceFactory::CreateSurface(Awesomium::WebView* view, int width, int height) { | |
101 | - return new GLRAMTextureSurface(width, height); | |
102 | -} | |
103 | - | |
104 | -void GLTextureSurfaceFactory::DestroySurface(Awesomium::Surface* surface) { | |
105 | - delete static_cast<GLRAMTextureSurface*>(surface); | |
106 | -} |
1 | -// Taken from awesomium examples | |
2 | - | |
3 | -#ifndef __GL_TEXTURE_SURFACE_H__ | |
4 | -#define __GL_TEXTURE_SURFACE_H__ | |
5 | - | |
6 | -#include <Awesomium/Surface.h> | |
7 | -extern "C" { | |
8 | -#include "tgl.h" | |
9 | -} | |
10 | - | |
11 | -class GLTextureSurface : public Awesomium::Surface { | |
12 | -public: | |
13 | - virtual void Paint(unsigned char* src_buffer, | |
14 | - int src_row_span, | |
15 | - const Awesomium::Rect& src_rect, | |
16 | - const Awesomium::Rect& dest_rect) = 0; | |
17 | - | |
18 | - virtual void Scroll(int dx, | |
19 | - int dy, | |
20 | - const Awesomium::Rect& clip_rect) = 0; | |
21 | - | |
22 | - virtual void* GetTexture() const = 0; | |
23 | - virtual int width() const = 0; | |
24 | - virtual int height() const = 0; | |
25 | - virtual int size() const = 0; | |
26 | -}; | |
27 | - | |
28 | -class GLRAMTextureSurface : public GLTextureSurface { | |
29 | - void *texture_id_; | |
30 | - unsigned char* buffer_; | |
31 | - int bpp_, rowspan_, width_, height_; | |
32 | - bool needs_update_; | |
33 | - | |
34 | - public: | |
35 | - GLRAMTextureSurface(int width, int height); | |
36 | - virtual ~GLRAMTextureSurface(); | |
37 | - | |
38 | - void* GetTexture() const; | |
39 | - | |
40 | - int width() const { return width_; } | |
41 | - | |
42 | - int height() const { return height_; } | |
43 | - | |
44 | - int size() const { return rowspan_ * height_; } | |
45 | - | |
46 | - protected: | |
47 | - virtual void Paint(unsigned char* src_buffer, | |
48 | - int src_row_span, | |
49 | - const Awesomium::Rect& src_rect, | |
50 | - const Awesomium::Rect& dest_rect); | |
51 | - | |
52 | - virtual void Scroll(int dx, | |
53 | - int dy, | |
54 | - const Awesomium::Rect& clip_rect); | |
55 | - | |
56 | - void UpdateTexture(); | |
57 | -}; | |
58 | - | |
59 | -class GLTextureSurfaceFactory : public Awesomium::SurfaceFactory { | |
60 | -public: | |
61 | - GLTextureSurfaceFactory(); | |
62 | - | |
63 | - virtual ~GLTextureSurfaceFactory(); | |
64 | - | |
65 | - virtual Awesomium::Surface* CreateSurface(Awesomium::WebView* view, | |
66 | - int width, | |
67 | - int height); | |
68 | - | |
69 | - virtual void DestroySurface(Awesomium::Surface* surface); | |
70 | -}; | |
71 | - | |
72 | -extern void *(*web_mutex_create)(); | |
73 | -extern void (*web_mutex_destroy)(void *mutex); | |
74 | -extern void (*web_mutex_lock)(void *mutex); | |
75 | -extern void (*web_mutex_unlock)(void *mutex); | |
76 | -extern void *(*web_make_texture)(int w, int h); | |
77 | -extern void (*web_del_texture)(void *tex); | |
78 | -extern void (*web_texture_update)(void *tex, int w, int h, const void* buffer); | |
79 | - | |
80 | -#endif // __GL_TEXTURE_SURFACE_H__ |
src/web-awesomium/web-internal.h
deleted
100644 → 0
1 | -/* | |
2 | - TE4 - T-Engine 4 | |
3 | - Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini | |
4 | - | |
5 | - No permission to copy or replicate in any ways. | |
6 | -*/ | |
7 | - | |
8 | -#ifndef __TE4WEB_INTERNAL_H__ | |
9 | -#define __TE4WEB_INTERNAL_H__ | |
10 | - | |
11 | -extern void te4_web_init_utils(); | |
12 | - | |
13 | -extern void push_order(WebEvent *event); | |
14 | -extern WebEvent *pop_order(); | |
15 | -extern void push_event(WebEvent *event); | |
16 | -extern WebEvent *pop_event(); | |
17 | - | |
18 | -extern void *(*web_mutex_create)(); | |
19 | -extern void (*web_mutex_destroy)(void *mutex); | |
20 | -extern void (*web_mutex_lock)(void *mutex); | |
21 | -extern void (*web_mutex_unlock)(void *mutex); | |
22 | - | |
23 | -#endif |
src/web-awesomium/web-utils.cpp
deleted
100644 → 0
1 | -/* | |
2 | - TE4 - T-Engine 4 | |
3 | - Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini | |
4 | - | |
5 | - No permission to copy or replicate in any ways, awesomium is not gpl so we cant link directly | |
6 | -*/ | |
7 | - | |
8 | -extern "C" { | |
9 | -#include <stdio.h> | |
10 | -#include "web-external.h" | |
11 | -} | |
12 | - | |
13 | -#include "web.h" | |
14 | -#include "web-internal.h" | |
15 | - | |
16 | -#include <vector> | |
17 | - | |
18 | -static std::vector<WebEvent*> *iqueue = new std::vector<WebEvent*>; | |
19 | -static std::vector<WebEvent*> *oqueue = new std::vector<WebEvent*>; | |
20 | -static void *lock_iqueue = NULL; | |
21 | -static void *lock_oqueue = NULL; | |
22 | - | |
23 | -void te4_web_init_utils() { | |
24 | - if (!lock_iqueue) lock_iqueue = web_mutex_create(); | |
25 | - if (!lock_oqueue) lock_oqueue = web_mutex_create(); | |
26 | -} | |
27 | - | |
28 | -void push_order(WebEvent *event) | |
29 | -{ | |
30 | - if (!lock_iqueue) return; | |
31 | - web_mutex_lock(lock_iqueue); | |
32 | - iqueue->push_back(event); | |
33 | - web_mutex_unlock(lock_iqueue); | |
34 | -} | |
35 | - | |
36 | -WebEvent *pop_order() | |
37 | -{ | |
38 | - if (!lock_iqueue) return NULL; | |
39 | - WebEvent *event = NULL; | |
40 | - | |
41 | - web_mutex_lock(lock_iqueue); | |
42 | - if (!iqueue->empty()) { | |
43 | - event = iqueue->back(); | |
44 | - iqueue->pop_back(); | |
45 | - } | |
46 | - web_mutex_unlock(lock_iqueue); | |
47 | - | |
48 | - return event; | |
49 | -} | |
50 | - | |
51 | -void push_event(WebEvent *event) | |
52 | -{ | |
53 | - if (!lock_oqueue) return; | |
54 | - web_mutex_lock(lock_oqueue); | |
55 | - oqueue->push_back(event); | |
56 | - web_mutex_unlock(lock_oqueue); | |
57 | -} | |
58 | - | |
59 | -WebEvent *pop_event() | |
60 | -{ | |
61 | - if (!lock_oqueue) return NULL; | |
62 | - WebEvent *event = NULL; | |
63 | - | |
64 | - web_mutex_lock(lock_oqueue); | |
65 | - if (!oqueue->empty()) { | |
66 | - event = oqueue->back(); | |
67 | - oqueue->pop_back(); | |
68 | - } | |
69 | - web_mutex_unlock(lock_oqueue); | |
70 | - | |
71 | - return event; | |
72 | -} | |
73 | - |
src/web-awesomium/web.cpp
deleted
100644 → 0
1 | -/* | |
2 | - TE4 - T-Engine 4 | |
3 | - Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini | |
4 | - | |
5 | - No permission to copy or replicate in any ways, awesomium is not gpl so we cant link directly | |
6 | -*/ | |
7 | - | |
8 | -extern "C" { | |
9 | -#include <stdio.h> | |
10 | -#include <stdlib.h> | |
11 | -#include "../web-external.h" | |
12 | -} | |
13 | -#include "web.h" | |
14 | -#include "web-internal.h" | |
15 | - | |
16 | -#include <Awesomium/WebCore.h> | |
17 | -#include <Awesomium/BitmapSurface.h> | |
18 | -#include <Awesomium/DataSource.h> | |
19 | -#include <Awesomium/STLHelpers.h> | |
20 | -#include "gl_texture_surface.h" | |
21 | - | |
22 | -void *(*web_mutex_create)(); | |
23 | -void (*web_mutex_destroy)(void *mutex); | |
24 | -void (*web_mutex_lock)(void *mutex); | |
25 | -void (*web_mutex_unlock)(void *mutex); | |
26 | -void *(*web_make_texture)(int w, int h); | |
27 | -void (*web_del_texture)(void *tex); | |
28 | -void (*web_texture_update)(void *tex, int w, int h, const void* buffer); | |
29 | -static void (*web_key_mods)(bool *shift, bool *ctrl, bool *alt, bool *meta); | |
30 | -static void (*web_instant_js)(int handlers, const char *fct, int nb_args, WebJsValue *args, WebJsValue *ret); | |
31 | - | |
32 | -using namespace Awesomium; | |
33 | - | |
34 | -class TE4DataSource; | |
35 | - | |
36 | -static WebCore *web_core = NULL; | |
37 | -static WebSession *web_session = NULL; | |
38 | -static TE4DataSource *web_data_source = NULL; | |
39 | - | |
40 | -class WebListener; | |
41 | - | |
42 | -static char *webstring_to_buf(const WebString &wstr, size_t *flen) { | |
43 | - char *buf; | |
44 | - unsigned int len = 0; | |
45 | - len = wstr.ToUTF8(NULL, 0); | |
46 | - buf = (char*)malloc(len + 1); | |
47 | - wstr.ToUTF8(buf, len); | |
48 | - buf[len] = '\0'; | |
49 | - if (flen) *flen = (size_t)len; | |
50 | - return buf; | |
51 | -} | |
52 | - | |
53 | -class WebListener : | |
54 | - public WebViewListener::View, | |
55 | - public WebViewListener::Download, | |
56 | - public WebViewListener::Load, | |
57 | - public JSMethodHandler | |
58 | -{ | |
59 | -private: | |
60 | - int handlers; | |
61 | -public: | |
62 | - JSObject te4_js; | |
63 | - WebListener(int handlers) { this->handlers = handlers; } | |
64 | - | |
65 | - virtual void OnChangeTitle(Awesomium::WebView* caller, const Awesomium::WebString& title) { | |
66 | - char *cur_title = webstring_to_buf(title, NULL); | |
67 | - WebEvent *event = new WebEvent(); | |
68 | - event->kind = TE4_WEB_EVENT_TITLE_CHANGE; | |
69 | - event->handlers = handlers; | |
70 | - event->data.title = cur_title; | |
71 | - push_event(event); | |
72 | - } | |
73 | - | |
74 | - virtual void OnChangeAddressBar(Awesomium::WebView* caller, const Awesomium::WebURL& url) { | |
75 | - } | |
76 | - | |
77 | - virtual void OnChangeTooltip(Awesomium::WebView* caller, const Awesomium::WebString& tooltip) { | |
78 | - } | |
79 | - | |
80 | - virtual void OnChangeTargetURL(Awesomium::WebView* caller, const Awesomium::WebURL& url) { | |
81 | - } | |
82 | - | |
83 | - virtual void OnChangeCursor(Awesomium::WebView* caller, Awesomium::Cursor cursor) { | |
84 | - } | |
85 | - | |
86 | - virtual void OnChangeFocus(Awesomium::WebView* caller, Awesomium::FocusedElementType focused_type) { | |
87 | - } | |
88 | - | |
89 | - virtual void OnAddConsoleMessage(Awesomium::WebView* caller, const Awesomium::WebString& message, int line_number, const Awesomium::WebString& source) { | |
90 | - char *msg = webstring_to_buf(message, NULL); | |
91 | - char *src = webstring_to_buf(source, NULL); | |
92 | - printf("[WEBCORE:console %s:%d] %s\n", src, line_number, msg); | |
93 | - free(msg); | |
94 | - free(src); | |
95 | - } | |
96 | - | |
97 | - virtual void OnShowCreatedWebView(Awesomium::WebView* caller, Awesomium::WebView* new_view, const Awesomium::WebURL& opener_url, const Awesomium::WebURL& target_url, const Awesomium::Rect& initial_pos, bool is_popup) { | |
98 | - new_view->Destroy(); | |
99 | - | |
100 | - WebString rurl = target_url.spec(); | |
101 | - char *url = webstring_to_buf(rurl, NULL); | |
102 | - | |
103 | - WebEvent *event = new WebEvent(); | |
104 | - event->kind = TE4_WEB_EVENT_REQUEST_POPUP_URL; | |
105 | - event->handlers = handlers; | |
106 | - event->data.popup.url = url; | |
107 | - event->data.popup.w = initial_pos.width; | |
108 | - event->data.popup.h = initial_pos.height; | |
109 | - push_event(event); | |
110 | - | |
111 | - printf("[WEBCORE] stopped popup to %s (%dx%d), pushing event...\n", url, event->data.popup.w, event->data.popup.h); | |
112 | - } | |
113 | - | |
114 | - void OnRequestDownload(WebView* caller, int download_id, const WebURL& wurl, const WebString& suggested_filename, const WebString& mime_type) { | |
115 | - WebString rurl = wurl.spec(); | |
116 | - const char *mime = webstring_to_buf(mime_type, NULL); | |
117 | - const char *url = webstring_to_buf(rurl, NULL); | |
118 | - const char *name = webstring_to_buf(suggested_filename, NULL); | |
119 | - printf("[WEBCORE] Download request [name: %s] [mime: %s] [url: %s]\n", name, mime, url); | |
120 | - | |
121 | - WebEvent *event = new WebEvent(); | |
122 | - event->kind = TE4_WEB_EVENT_DOWNLOAD_REQUEST; | |
123 | - event->handlers = handlers; | |
124 | - event->data.download_request.url = url; | |
125 | - event->data.download_request.name = name; | |
126 | - event->data.download_request.mime = mime; | |
127 | - event->data.download_request.id = download_id; | |
128 | - push_event(event); | |
129 | - } | |
130 | - void OnUpdateDownload(WebView* caller, int download_id, int64 total_bytes, int64 received_bytes, int64 current_speed) { | |
131 | - WebEvent *event = new WebEvent(); | |
132 | - event->kind = TE4_WEB_EVENT_DOWNLOAD_UPDATE; | |
133 | - event->handlers = handlers; | |
134 | - event->data.download_update.id = download_id; | |
135 | - event->data.download_update.got = received_bytes; | |
136 | - event->data.download_update.total = total_bytes; | |
137 | - event->data.download_update.percent = 100 * ((double)received_bytes / (double)total_bytes); | |
138 | - event->data.download_update.speed = current_speed; | |
139 | - push_event(event); | |
140 | - } | |
141 | - void OnFinishDownload(WebView* caller, int download_id, const WebURL& url, const WebString& saved_path) { | |
142 | - WebEvent *event = new WebEvent(); | |
143 | - event->kind = TE4_WEB_EVENT_DOWNLOAD_FINISH; | |
144 | - event->handlers = handlers; | |
145 | - event->data.download_finish.id = download_id; | |
146 | - push_event(event); | |
147 | - } | |
148 | - | |
149 | - /// This event occurs when the page begins loading a frame. | |
150 | - virtual void OnBeginLoadingFrame(Awesomium::WebView* caller, int64 frame_id, bool is_main_frame, const Awesomium::WebURL& wurl, bool is_error_page) { | |
151 | - WebString rurl = wurl.spec(); | |
152 | - const char *url = webstring_to_buf(rurl, NULL); | |
153 | - | |
154 | - WebEvent *event = new WebEvent(); | |
155 | - event->kind = TE4_WEB_EVENT_LOADING; | |
156 | - event->handlers = handlers; | |
157 | - event->data.loading.url = url; | |
158 | - event->data.loading.status = 0; | |
159 | - push_event(event); | |
160 | - } | |
161 | - | |
162 | - /// This event occurs when a frame fails to load. See error_desc | |
163 | - /// for additional information. | |
164 | - virtual void OnFailLoadingFrame(Awesomium::WebView* caller, int64 frame_id, bool is_main_frame, const Awesomium::WebURL& wurl, int error_code, const Awesomium::WebString& error_desc) { | |
165 | - WebString rurl = wurl.spec(); | |
166 | - const char *url = webstring_to_buf(rurl, NULL); | |
167 | - | |
168 | - WebEvent *event = new WebEvent(); | |
169 | - event->kind = TE4_WEB_EVENT_LOADING; | |
170 | - event->handlers = handlers; | |
171 | - event->data.loading.url = url; | |
172 | - event->data.loading.status = -1; | |
173 | - push_event(event); | |
174 | - } | |
175 | - | |
176 | - /// This event occurs when the page finishes loading a frame. | |
177 | - /// The main frame always finishes loading last for a given page load. | |
178 | - virtual void OnFinishLoadingFrame(Awesomium::WebView* caller, int64 frame_id, bool is_main_frame, const Awesomium::WebURL& wurl) { | |
179 | - | |
180 | - } | |
181 | - | |
182 | - /// This event occurs when the DOM has finished parsing and the | |
183 | - /// window object is available for JavaScript execution. | |
184 | - virtual void OnDocumentReady(Awesomium::WebView* caller, const Awesomium::WebURL& wurl) { | |
185 | - WebString rurl = wurl.spec(); | |
186 | - const char *url = webstring_to_buf(rurl, NULL); | |
187 | - | |
188 | - WebEvent *event = new WebEvent(); | |
189 | - event->kind = TE4_WEB_EVENT_LOADING; | |
190 | - event->handlers = handlers; | |
191 | - event->data.loading.url = url; | |
192 | - event->data.loading.status = 1; | |
193 | - push_event(event); | |
194 | - } | |
195 | - | |
196 | - virtual void OnMethodCall(WebView* caller, unsigned int remote_object_id, const WebString& method_name, const JSArray& args) { | |
197 | - if (remote_object_id == te4_js.remote_id() && method_name == WSLit("lua")) { | |
198 | - JSValue arg = args[0]; | |
199 | - WebString wcode = arg.ToString(); | |
200 | - const char *code = webstring_to_buf(wcode, NULL); | |
201 | - | |
202 | - WebEvent *event = new WebEvent(); | |
203 | - event->kind = TE4_WEB_EVENT_RUN_LUA; | |
204 | - event->handlers = handlers; | |
205 | - event->data.run_lua.code = code; | |
206 | - push_event(event); | |
207 | - } | |
208 | - } | |
209 | - | |
210 | - virtual JSValue OnMethodCallWithReturnValue(WebView* caller, unsigned int remote_object_id, const WebString& method_name, const JSArray& jsargs) { | |
211 | - if (remote_object_id != te4_js.remote_id()) { | |
212 | - JSValue ret(false); | |
213 | - return ret; | |
214 | - } | |
215 | - | |
216 | - const char *fct = webstring_to_buf(method_name, NULL); | |
217 | - WebJsValue ret; | |
218 | - int nb_args = jsargs.size(); | |
219 | - WebJsValue *args = new WebJsValue[nb_args]; | |
220 | - for (int i = 0; i < nb_args; i++) { | |
221 | - WebJsValue *wv = &args[i]; | |
222 | - JSValue v = jsargs[i]; | |
223 | - if (v.IsNull()) { | |
224 | - wv->kind = TE4_WEB_JS_NULL; | |
225 | - } else if (v.IsBoolean()) { | |
226 | - wv->kind = TE4_WEB_JS_BOOLEAN; | |
227 | - wv->data.b = v.ToBoolean(); | |
228 | - } else if (v.IsNumber()) { | |
229 | - wv->kind = TE4_WEB_JS_NUMBER; | |
230 | - wv->data.n = v.ToDouble(); | |
231 | - } else if (v.IsString()) { | |
232 | - wv->kind = TE4_WEB_JS_STRING; | |
233 | - const char *s = webstring_to_buf(v.ToString(), NULL); | |
234 | - wv->data.s = s; | |
235 | - } | |
236 | - } | |
237 | - | |
238 | - web_instant_js(handlers, fct, nb_args, args, &ret); | |
239 | - | |
240 | - // Free the fucking strings. I love GC. I want a GC :/ | |
241 | - for (int i = 0; i < nb_args; i++) { | |
242 | - WebJsValue *wv = &args[i]; | |
243 | - JSValue v = jsargs[i]; | |
244 | - if (v.IsString()) free((void*)wv->data.s); | |
245 | - } | |
246 | - delete args; | |
247 | - free((void*)fct); | |
248 | - | |
249 | - if (ret.kind == TE4_WEB_JS_NULL) return JSValue::Null(); | |
250 | - else if (ret.kind == TE4_WEB_JS_BOOLEAN) return JSValue(ret.data.b); | |
251 | - else if (ret.kind == TE4_WEB_JS_NUMBER) return JSValue(ret.data.n); | |
252 | - else if (ret.kind == TE4_WEB_JS_STRING) { | |
253 | - WebString s = WebString::CreateFromUTF8(ret.data.s, strlen(ret.data.s)); | |
254 | - return JSValue(s); | |
255 | - } | |
256 | - return JSValue(); | |
257 | - } | |
258 | -}; | |
259 | - | |
260 | -class TE4DataSource : public DataSource { | |
261 | -public: | |
262 | - virtual void OnRequest(int request_id, const ResourceRequest& request, const WebString& wpath) { | |
263 | - const char *path = webstring_to_buf(wpath, NULL); | |
264 | - | |
265 | - WebEvent *event = new WebEvent(); | |
266 | - event->kind = TE4_WEB_EVENT_LOCAL_REQUEST; | |
267 | - event->data.local_request.id = request_id; | |
268 | - event->data.local_request.path = path; | |
269 | - push_event(event); | |
270 | - } | |
271 | -}; | |
272 | - | |
273 | - | |
274 | -class WebViewOpaque { | |
275 | -public: | |
276 | - WebView *view; | |
277 | - WebListener *listener; | |
278 | -}; | |
279 | - | |
280 | -void te4_web_new(web_view_type *view, int w, int h) { | |
281 | - WebViewOpaque *opaque = new WebViewOpaque(); | |
282 | - view->opaque = (void*)opaque; | |
283 | - | |
284 | - opaque->view = web_core->CreateWebView(w, h, web_session, kWebViewType_Offscreen); | |
285 | - opaque->listener = new WebListener(view->handlers); | |
286 | - opaque->view->set_view_listener(opaque->listener); | |
287 | - opaque->view->set_download_listener(opaque->listener); | |
288 | - opaque->view->set_load_listener(opaque->listener); | |
289 | - opaque->view->set_js_method_handler(opaque->listener); | |
290 | - view->w = w; | |
291 | - view->h = h; | |
292 | - view->closed = false; | |
293 | - | |
294 | - opaque->listener->te4_js = (opaque->view->CreateGlobalJavascriptObject(WSLit("te4"))).ToObject(); | |
295 | - opaque->listener->te4_js.SetCustomMethod(WSLit("lua"), false); | |
296 | - | |
297 | - opaque->view->SetTransparent(true); | |
298 | - printf("Created webview: %dx%d\n", w, h); | |
299 | -} | |
300 | - | |
301 | -bool te4_web_close(web_view_type *view) { | |
302 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
303 | - if (!view->closed) { | |
304 | - opaque->view->Destroy(); | |
305 | - delete opaque->listener; | |
306 | - view->closed = true; | |
307 | - printf("Destroyed webview\n"); | |
308 | - return true; | |
309 | - } | |
310 | - return false; | |
311 | -} | |
312 | - | |
313 | -void te4_web_load_url(web_view_type *view, const char *url) { | |
314 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
315 | - if (view->closed) return; | |
316 | - | |
317 | - size_t urllen = strlen(url); | |
318 | - WebURL lurl(WebString::CreateFromUTF8(url, urllen)); | |
319 | - opaque->view->LoadURL(lurl); | |
320 | -} | |
321 | - | |
322 | -void te4_web_set_js_call(web_view_type *view, const char *name) { | |
323 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
324 | - if (view->closed) return; | |
325 | - | |
326 | - opaque->listener->te4_js.SetCustomMethod(WebString::CreateFromUTF8(name, strlen(name)), true); | |
327 | -} | |
328 | - | |
329 | -void *te4_web_toscreen(web_view_type *view, int *w, int *h) { | |
330 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
331 | - if (view->closed) return NULL; | |
332 | - | |
333 | - const GLTextureSurface* surface = static_cast<const GLTextureSurface*> (opaque->view->surface()); | |
334 | - if (!surface) return NULL; | |
335 | - | |
336 | - *w = (*w < 0) ? view->w : *w; | |
337 | - *h = (*h < 0) ? view->h : *h; | |
338 | - return surface->GetTexture(); | |
339 | -} | |
340 | - | |
341 | -bool te4_web_loading(web_view_type *view) { | |
342 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
343 | - if (view->closed) return false; | |
344 | - return opaque->view->IsLoading(); | |
345 | -} | |
346 | - | |
347 | -void te4_web_focus(web_view_type *view, bool focus) { | |
348 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
349 | - if (view->closed) return; | |
350 | - | |
351 | - if (focus) opaque->view->Focus(); | |
352 | - else opaque->view->Unfocus(); | |
353 | -} | |
354 | - | |
355 | -void te4_web_inject_mouse_move(web_view_type *view, int x, int y) { | |
356 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
357 | - if (view->closed) return; | |
358 | - | |
359 | - opaque->view->InjectMouseMove(x, y); | |
360 | -} | |
361 | - | |
362 | -void te4_web_inject_mouse_wheel(web_view_type *view, int x, int y) { | |
363 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
364 | - if (view->closed) return; | |
365 | - | |
366 | - opaque->view->InjectMouseWheel(-y, -x); | |
367 | -} | |
368 | - | |
369 | -void te4_web_inject_mouse_button(web_view_type *view, int kind, bool up) { | |
370 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
371 | - if (view->closed) return; | |
372 | - | |
373 | - MouseButton b = kMouseButton_Left; | |
374 | - if (kind == 2) b = kMouseButton_Middle; | |
375 | - else if (kind == 3) b = kMouseButton_Right; | |
376 | - | |
377 | - if (up) opaque->view->InjectMouseUp(b); | |
378 | - else opaque->view->InjectMouseDown(b); | |
379 | -} | |
380 | - | |
381 | -void te4_web_inject_key(web_view_type *view, int scancode, int asymb, const char *uni, int unilen, bool up) { | |
382 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
383 | - if (view->closed) return; | |
384 | - | |
385 | - WebKeyboardEvent keyEvent; | |
386 | - keyEvent.type = !up ? WebKeyboardEvent::kTypeKeyDown : WebKeyboardEvent::kTypeKeyUp; | |
387 | - | |
388 | - char* buf = new char[20]; | |
389 | - keyEvent.virtual_key_code = asymb; | |
390 | - Awesomium::GetKeyIdentifierFromVirtualKeyCode(keyEvent.virtual_key_code, &buf); | |
391 | - strcpy(keyEvent.key_identifier, buf); | |
392 | - delete[] buf; | |
393 | - | |
394 | - bool shift, ctrl, alt, meta; | |
395 | - web_key_mods(&shift, &ctrl, &alt, &meta); | |
396 | - keyEvent.modifiers = 0; | |
397 | - if (shift) keyEvent.modifiers |= WebKeyboardEvent::kModShiftKey; | |
398 | - else if (ctrl) keyEvent.modifiers |= WebKeyboardEvent::kModControlKey; | |
399 | - else if (alt) keyEvent.modifiers |= WebKeyboardEvent::kModAltKey; | |
400 | - else if (meta) keyEvent.modifiers |= WebKeyboardEvent::kModMetaKey; | |
401 | - | |
402 | - keyEvent.native_key_code = scancode; | |
403 | - if (up) { | |
404 | - opaque->view->InjectKeyboardEvent(keyEvent); | |
405 | - } else { | |
406 | - if (uni) { | |
407 | - WebString wstr = WebString::CreateFromUTF8(uni, unilen); | |
408 | - memcpy(keyEvent.text, wstr.data(), wstr.length() * sizeof(wchar16)); | |
409 | - memcpy(keyEvent.unmodified_text, wstr.data(), wstr.length() * sizeof(wchar16)); | |
410 | - } | |
411 | - | |
412 | - opaque->view->InjectKeyboardEvent(keyEvent); | |
413 | - | |
414 | - if (uni) { | |
415 | - keyEvent.type = WebKeyboardEvent::kTypeChar; | |
416 | - keyEvent.virtual_key_code = keyEvent.text[0]; | |
417 | - keyEvent.native_key_code = keyEvent.text[0]; | |
418 | - opaque->view->InjectKeyboardEvent(keyEvent); | |
419 | - } | |
420 | - } | |
421 | -} | |
422 | - | |
423 | -void te4_web_download_action(web_view_type *view, long id, const char *path) { | |
424 | - WebViewOpaque *opaque = (WebViewOpaque*)view->opaque; | |
425 | - if (view->closed) return; | |
426 | - | |
427 | - if (path) { | |
428 | - WebString wpath = WebString::CreateFromUTF8(path, strlen(path)); | |
429 | - opaque->view->DidChooseDownloadPath(id, wpath); | |
430 | - } else { | |
431 | - opaque->view->DidCancelDownload(id); | |
432 | - } | |
433 | -} | |
434 | - | |
435 | -void te4_web_reply_local(int id, const char *mime, const char *result, size_t len) { | |
436 | - WebString wmime = WebString::CreateFromUTF8(mime, strlen(mime)); | |
437 | - web_data_source->SendResponse(id, len, (unsigned char *)result, wmime); | |
438 | -} | |
439 | - | |
440 | - | |
441 | -void te4_web_do_update(void (*cb)(WebEvent*)) { | |
442 | - if (!web_core) return; | |
443 | - | |
444 | - web_core->Update(); | |
445 | - WebEvent *event; | |
446 | - while (event = pop_event()) { | |
447 | - cb(event); | |
448 | - | |
449 | - switch (event->kind) { | |
450 | - case TE4_WEB_EVENT_TITLE_CHANGE: | |
451 | - free((void*)event->data.title); | |
452 | - break; | |
453 | - case TE4_WEB_EVENT_REQUEST_POPUP_URL: | |
454 | - free((void*)event->data.popup.url); | |
455 | - break; | |
456 | - case TE4_WEB_EVENT_DOWNLOAD_REQUEST: | |
457 | - free((void*)event->data.download_request.url); | |
458 | - free((void*)event->data.download_request.name); | |
459 | - free((void*)event->data.download_request.mime); | |
460 | - break; | |
461 | - case TE4_WEB_EVENT_LOADING: | |
462 | - free((void*)event->data.loading.url); | |
463 | - break; | |
464 | - case TE4_WEB_EVENT_LOCAL_REQUEST: | |
465 | - free((void*)event->data.local_request.path); | |
466 | - break; | |
467 | - case TE4_WEB_EVENT_RUN_LUA: | |
468 | - free((void*)event->data.run_lua.code); | |
469 | - break; | |
470 | - } | |
471 | - | |
472 | - delete event; | |
473 | - } | |
474 | -} | |
475 | - | |
476 | -void te4_web_setup( | |
477 | - int argc, char **gargv, char *spawnc, | |
478 | - void*(*mutex_create)(), void(*mutex_destroy)(void*), void(*mutex_lock)(void*), void(*mutex_unlock)(void*), | |
479 | - void *(*make_texture)(int, int), void (*del_texture)(void*), void (*texture_update)(void*, int, int, const void*), | |
480 | - void (*key_mods)(bool*, bool*, bool*, bool*), | |
481 | - void (*instant_js)(int handlers, const char *fct, int nb_args, WebJsValue *args, WebJsValue *ret) | |
482 | - ) { | |
483 | - | |
484 | - web_mutex_create = mutex_create; | |
485 | - web_mutex_destroy = mutex_destroy; | |
486 | - web_mutex_lock = mutex_lock; | |
487 | - web_mutex_unlock = mutex_unlock; | |
488 | - web_make_texture = make_texture; | |
489 | - web_del_texture = del_texture; | |
490 | - web_texture_update = texture_update; | |
491 | - web_key_mods = key_mods; | |
492 | - web_instant_js = instant_js; | |
493 | - if (!web_core) { | |
494 | - web_core = WebCore::Initialize(WebConfig()); | |
495 | - web_core->set_surface_factory(new GLTextureSurfaceFactory()); | |
496 | - web_session = web_core->CreateWebSession(WSLit(""), WebPreferences()); | |
497 | - web_data_source = new TE4DataSource(); | |
498 | - web_session->AddDataSource(WSLit("te4"), web_data_source); | |
499 | - } | |
500 | -} | |
501 | - | |
502 | -void te4_web_initialize(const char *locales, const char *pak) { | |
503 | - te4_web_init_utils(); | |
504 | -} | |
505 | - | |
506 | -void te4_web_shutdown() { | |
507 | -} |
src/web-awesomium/web.h
deleted
100644 → 0
1 | -/* | |
2 | - TE4 - T-Engine 4 | |
3 | - Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicolas Casalini | |
4 | - | |
5 | - No permission to copy or replicate in any ways. | |
6 | -*/ | |
7 | - | |
8 | -#ifndef __TE4WEB_H__ | |
9 | -#define __TE4WEB_H__ | |
10 | - | |
11 | -#ifdef __cplusplus | |
12 | -/* C++ compiler needs to make this a C API. */ | |
13 | -#if defined( _WIN32 ) | |
14 | -/* Windows needs this to be a DLL, so be sure to export. */ | |
15 | -#define WEB_TE4_API extern "C" __declspec( dllexport ) | |
16 | -#else | |
17 | -/* Non-windows platforms are fine linking statically. */ | |
18 | -#define WEB_TE4_API extern "C" | |
19 | -#endif | |
20 | -#else | |
21 | -/* C compiler is using this header. */ | |
22 | -#define WEB_TE4_API | |
23 | -#endif | |
24 | - | |
25 | -WEB_TE4_API void te4_web_setup( | |
26 | - int argc, char **argv, char *spawn, | |
27 | - void*(*mutex_create)(), void(*mutex_destroy)(void*), void(*mutex_lock)(void*), void(*mutex_unlock)(void*), | |
28 | - void*(*make_texture)(int, int), void (*del_texture)(void*), void (*texture_update)(void*, int, int, const void*), | |
29 | - void (*key_mods)(bool*, bool*, bool*, bool*), | |
30 | - void (*web_instant_js)(int handlers, const char *fct, int nb_args, WebJsValue *args, WebJsValue *ret) | |
31 | -); | |
32 | -WEB_TE4_API void te4_web_initialize(const char *locales, const char *pak); | |
33 | -WEB_TE4_API void te4_web_shutdown(); | |
34 | -WEB_TE4_API void te4_web_do_update(void (*cb)(WebEvent*)); | |
35 | -WEB_TE4_API void te4_web_new(web_view_type *view, int w, int h); | |
36 | -WEB_TE4_API bool te4_web_close(web_view_type *view); | |
37 | -WEB_TE4_API void *te4_web_toscreen(web_view_type *view, int *w, int *h); | |
38 | -WEB_TE4_API bool te4_web_loading(web_view_type *view); | |
39 | -WEB_TE4_API void te4_web_focus(web_view_type *view, bool focus); | |
40 | -WEB_TE4_API void te4_web_inject_mouse_move(web_view_type *view, int x, int y); | |
41 | -WEB_TE4_API void te4_web_inject_mouse_wheel(web_view_type *view, int x, int y); | |
42 | -WEB_TE4_API void te4_web_inject_mouse_button(web_view_type *view, int kind, bool up); | |
43 | -WEB_TE4_API void te4_web_inject_key(web_view_type *view, int scancode, int asymb, const char *uni, int unilen, bool up); | |
44 | -WEB_TE4_API void te4_web_download_action(web_view_type *view, long id, const char *path); | |
45 | -WEB_TE4_API void te4_web_reply_local(int id, const char *mime, const char *result, size_t len); | |
46 | -WEB_TE4_API void te4_web_load_url(web_view_type *view, const char *url); | |
47 | -WEB_TE4_API void te4_web_set_js_call(web_view_type *view, const char *name); | |
48 | - | |
49 | -#endif |
... | ... | @@ -46,7 +46,8 @@ int main(int argc, char* argv[]) { |
46 | 46 | CefMainArgs args(argc, argv); |
47 | 47 | #endif |
48 | 48 | |
49 | + // for (int i = 0; i < argc; i++) printf("cef3spawn arg[%d] = %s\n", i, argv[i]); | |
49 | 50 | CefRefPtr<ClientApp> app(new ClientApp); |
50 | 51 | int ret = CefExecuteProcess(args, app.get(), NULL); |
51 | 52 | return ret; |
52 | -} | |
\ No newline at end of file | ||
53 | +} | ... | ... |
... | ... | @@ -115,6 +115,7 @@ static int all_browsers_nb = 0; |
115 | 115 | class BrowserClient : |
116 | 116 | public CefClient, |
117 | 117 | public CefRequestHandler, |
118 | + public CefRequestContextHandler, | |
118 | 119 | public CefDisplayHandler, |
119 | 120 | public CefLifeSpanHandler, |
120 | 121 | public CefDownloadHandler, |
... | ... | @@ -182,16 +183,16 @@ public: |
182 | 183 | push_event(event); |
183 | 184 | } |
184 | 185 | |
185 | - virtual bool OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request) OVERRIDE { | |
186 | - return false; | |
187 | - } | |
186 | + // virtual CefRequestHandler::ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefRequestCallback> callback) OVERRIDE { | |
187 | + // return RV_CANCEL; | |
188 | + // } | |
188 | 189 | |
189 | - virtual bool OnBeforePluginLoad(CefRefPtr<CefBrowser> browser, const CefString& url, const CefString& policy_url, CefRefPtr<CefWebPluginInfo> info) OVERRIDE { | |
190 | - char *name = cstring_to_c(info->GetName()); | |
191 | - char *path = cstring_to_c(info->GetPath()); | |
192 | - fprintf(logfile, "[WEBCORE] Forbade plugin %s from %s\n", name, path); | |
193 | - free(name); | |
194 | - free(path); | |
190 | + virtual bool OnBeforePluginLoad(const CefString& mime_type, const CefString& plugin_url, bool is_main_frame, const CefString& top_origin_url, CefRefPtr<CefWebPluginInfo> plugin_info, PluginPolicy* plugin_policy) OVERRIDE { | |
191 | + char *mime = cstring_to_c(mime_type); | |
192 | + char *url = cstring_to_c(plugin_url); | |
193 | + fprintf(logfile, "[WEBCORE] Forbade plugin %s from %s\n", mime, url); | |
194 | + free(mime); | |
195 | + free(url); | |
195 | 196 | return true; |
196 | 197 | } |
197 | 198 | |
... | ... | @@ -206,14 +207,16 @@ public: |
206 | 207 | } |
207 | 208 | |
208 | 209 | virtual bool OnBeforePopup(CefRefPtr<CefBrowser> browser, |
209 | - CefRefPtr<CefFrame> frame, | |
210 | - const CefString& target_url, | |
211 | - const CefString& target_frame_name, | |
212 | - const CefPopupFeatures& popupFeatures, | |
213 | - CefWindowInfo& windowInfo, | |
214 | - CefRefPtr<CefClient>& client, | |
215 | - CefBrowserSettings& settings, | |
216 | - bool* no_javascript_access) OVERRIDE { | |
210 | + CefRefPtr<CefFrame> frame, | |
211 | + const CefString& target_url, | |
212 | + const CefString& target_frame_name, | |
213 | + CefLifeSpanHandler::WindowOpenDisposition target_disposition, | |
214 | + bool user_gesture, | |
215 | + const CefPopupFeatures& popupFeatures, | |
216 | + CefWindowInfo& windowInfo, | |
217 | + CefRefPtr<CefClient>& client, | |
218 | + CefBrowserSettings& settings, | |
219 | + bool* no_javascript_access) OVERRIDE { | |
217 | 220 | char *url = cstring_to_c(target_url); |
218 | 221 | |
219 | 222 | WebEvent *event = new WebEvent(); |
... | ... | @@ -300,7 +303,7 @@ public: |
300 | 303 | } |
301 | 304 | } |
302 | 305 | |
303 | - virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame) { | |
306 | + virtual void OnLoadStart(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, TransitionType transition_type) OVERRIDE { | |
304 | 307 | const char *url = cstring_to_c(frame->GetURL()); |
305 | 308 | WebEvent *event = new WebEvent(); |
306 | 309 | event->kind = TE4_WEB_EVENT_LOADING; |
... | ... | @@ -310,7 +313,7 @@ public: |
310 | 313 | push_event(event); |
311 | 314 | } |
312 | 315 | |
313 | - virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) { | |
316 | + virtual void OnLoadEnd(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode) OVERRIDE { | |
314 | 317 | const char *url = cstring_to_c(frame->GetURL()); |
315 | 318 | WebEvent *event = new WebEvent(); |
316 | 319 | event->kind = TE4_WEB_EVENT_LOADING; |
... | ... | @@ -320,12 +323,12 @@ public: |
320 | 323 | push_event(event); |
321 | 324 | } |
322 | 325 | |
323 | - virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) { | |
326 | + virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) OVERRIDE { | |
324 | 327 | fprintf(logfile, "[WEBCORE] Created browser for webview\n"); |
325 | 328 | this->browser = browser; |
326 | 329 | } |
327 | 330 | |
328 | - virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) { | |
331 | + virtual void OnBeforeClose(CefRefPtr<CefBrowser> browser) OVERRIDE { | |
329 | 332 | this->opaque->render = NULL; |
330 | 333 | this->opaque->view = NULL; |
331 | 334 | this->opaque->browser = NULL; |
... | ... | @@ -805,6 +808,9 @@ void te4_web_do_update(void (*cb)(WebEvent*)) { |
805 | 808 | break; |
806 | 809 | case TE4_WEB_EVENT_DELETE_TEXTURE: |
807 | 810 | web_del_texture(event->data.texture); |
811 | + case TE4_WEB_EVENT_END_BROWSER: | |
812 | + break; | |
813 | + case TE4_WEB_EVENT_BROWSER_COUNT: | |
808 | 814 | break; |
809 | 815 | } |
810 | 816 | |
... | ... | @@ -899,7 +905,7 @@ void te4_web_shutdown() { |
899 | 905 | |
900 | 906 | while (!all_browsers.empty()) { |
901 | 907 | CefDoMessageLoopWork(); |
902 | - fprintf(logfile, "Waiting browsers to close: %d left\n", all_browsers.size()); | |
908 | + fprintf(logfile, "Waiting browsers to close: %ld left\n", all_browsers.size()); | |
903 | 909 | } |
904 | 910 | |
905 | 911 | fprintf(logfile, "[WEBCORE] all browsers dead, shutting down\n"); | ... | ... |
-
Please register or login to post a comment