From 35e21da884ce41c0dbe89deb71b0d67d507832a6 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 5 Mar 2009 01:10:06 +0000 Subject: [PATCH] Add DLL build support and wrapper that allows clients to transparently switch between static and dynamic CEF builds. - The libcef project now builds libcef_static.lib instead of libcef.lib. - The libcef_dll project builds libcef.lib and libcef.dll. This DLL exports the new CEF C API defined in cef_capi.h, cef_nplugin_capi.h, cef_string.h and cef_string_map.h. - The libcef_dll_wrapper project builds libcef_dll_wrapper.lib. This static library wraps the new C API calls with an implementation of the CEF C++ interface as defined in cef.h and cef_nplugin.h. - The cefclient project now uses the DLL instead of the static library. - Type definitions have been moved from cef.h to cef_types.h so that they can be shared by both cef.h and cef_capi.h. This change required some enumeration member name modifications throughout the code base. - Fixed variable naming inconsistencies. - Added CefVariant::GetArraySize() method and _NPN_ArrayObjectGetVectorSize() function. - Remove the ProjectSection(WebsiteProperties) sections from cef.sln to improve VS2005 performance. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@16 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- cef.sln | 316 +++------ include/cef.h | 191 +----- include/cef_capi.h | 620 ++++++++++++++++++ include/cef_export.h | 41 ++ include/cef_nplugin_capi.h | 90 +++ include/cef_string.h | 86 +++ include/cef_string_map.h | 75 +++ include/cef_types.h | 227 +++++++ include/cef_types_win.h | 76 +++ include/cef_win.h | 87 +-- libcef/browser_impl.cc | 64 +- libcef/browser_impl.h | 6 +- libcef/browser_impl_win.cc | 4 +- libcef/browser_resource_loader_bridge.cc | 2 +- libcef/browser_webview_delegate.cc | 16 +- libcef/browser_webview_delegate_win.cc | 58 +- libcef/libcef.vcproj | 14 + libcef/request_impl.cc | 32 +- libcef/request_impl.h | 2 +- libcef/variant_impl.cc | 29 +- libcef/variant_impl.h | 1 + libcef/variant_np_util.cc | 13 + libcef/variant_np_util.h | 4 + libcef_dll/cef_string.c | 163 +++++ libcef_dll/cef_string_map.cc | 93 +++ libcef_dll/cpptoc/browser_cpptoc.cc | 497 ++++++++++++++ libcef_dll/cpptoc/browser_cpptoc.h | 28 + libcef_dll/cpptoc/cpptoc.h | 92 +++ libcef_dll/cpptoc/handler_cpptoc.cc | 521 +++++++++++++++ libcef_dll/cpptoc/handler_cpptoc.h | 28 + libcef_dll/cpptoc/jshandler_cpptoc.cc | 155 +++++ libcef_dll/cpptoc/jshandler_cpptoc.h | 28 + libcef_dll/cpptoc/request_cpptoc.cc | 425 ++++++++++++ libcef_dll/cpptoc/request_cpptoc.h | 51 ++ libcef_dll/cpptoc/stream_cpptoc.cc | 122 ++++ libcef_dll/cpptoc/stream_cpptoc.h | 40 ++ libcef_dll/cpptoc/variant_cpptoc.cc | 307 +++++++++ libcef_dll/cpptoc/variant_cpptoc.h | 28 + libcef_dll/ctocpp/browser_ctocpp.cc | 312 +++++++++ libcef_dll/ctocpp/browser_ctocpp.h | 67 ++ libcef_dll/ctocpp/ctocpp.h | 64 ++ libcef_dll/ctocpp/handler_ctocpp.cc | 337 ++++++++++ libcef_dll/ctocpp/handler_ctocpp.h | 81 +++ libcef_dll/ctocpp/jshandler_ctocpp.cc | 103 +++ libcef_dll/ctocpp/jshandler_ctocpp.h | 45 ++ libcef_dll/ctocpp/request_ctocpp.cc | 297 +++++++++ libcef_dll/ctocpp/request_ctocpp.h | 85 +++ libcef_dll/ctocpp/stream_ctocpp.cc | 73 +++ libcef_dll/ctocpp/stream_ctocpp.h | 54 ++ libcef_dll/ctocpp/variant_ctocpp.cc | 297 +++++++++ libcef_dll/ctocpp/variant_ctocpp.h | 50 ++ libcef_dll/libcef_dll.cc | 142 ++++ libcef_dll/libcef_dll.rc | 105 +++ libcef_dll/libcef_dll.vcproj | 429 ++++++++++++ libcef_dll/libcef_dll.vsprops | 22 + libcef_dll/precompiled_libcef.cc | 5 + libcef_dll/precompiled_libcef.h | 7 + libcef_dll/resource.h | 16 + libcef_dll/transfer_util.cpp | 69 ++ libcef_dll/transfer_util.h | 23 + libcef_dll/wrapper/libcef_dll_wrapper.cc | 134 ++++ libcef_dll/wrapper/libcef_dll_wrapper.vcproj | 250 +++++++ libcef_dll/wrapper/libcef_dll_wrapper.vsprops | 22 + tests/cefclient/cefclient.cpp | 27 +- 64 files changed, 7196 insertions(+), 552 deletions(-) create mode 100644 include/cef_capi.h create mode 100644 include/cef_export.h create mode 100644 include/cef_nplugin_capi.h create mode 100644 include/cef_string.h create mode 100644 include/cef_string_map.h create mode 100644 include/cef_types.h create mode 100644 include/cef_types_win.h create mode 100644 libcef_dll/cef_string.c create mode 100644 libcef_dll/cef_string_map.cc create mode 100644 libcef_dll/cpptoc/browser_cpptoc.cc create mode 100644 libcef_dll/cpptoc/browser_cpptoc.h create mode 100644 libcef_dll/cpptoc/cpptoc.h create mode 100644 libcef_dll/cpptoc/handler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/handler_cpptoc.h create mode 100644 libcef_dll/cpptoc/jshandler_cpptoc.cc create mode 100644 libcef_dll/cpptoc/jshandler_cpptoc.h create mode 100644 libcef_dll/cpptoc/request_cpptoc.cc create mode 100644 libcef_dll/cpptoc/request_cpptoc.h create mode 100644 libcef_dll/cpptoc/stream_cpptoc.cc create mode 100644 libcef_dll/cpptoc/stream_cpptoc.h create mode 100644 libcef_dll/cpptoc/variant_cpptoc.cc create mode 100644 libcef_dll/cpptoc/variant_cpptoc.h create mode 100644 libcef_dll/ctocpp/browser_ctocpp.cc create mode 100644 libcef_dll/ctocpp/browser_ctocpp.h create mode 100644 libcef_dll/ctocpp/ctocpp.h create mode 100644 libcef_dll/ctocpp/handler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/handler_ctocpp.h create mode 100644 libcef_dll/ctocpp/jshandler_ctocpp.cc create mode 100644 libcef_dll/ctocpp/jshandler_ctocpp.h create mode 100644 libcef_dll/ctocpp/request_ctocpp.cc create mode 100644 libcef_dll/ctocpp/request_ctocpp.h create mode 100644 libcef_dll/ctocpp/stream_ctocpp.cc create mode 100644 libcef_dll/ctocpp/stream_ctocpp.h create mode 100644 libcef_dll/ctocpp/variant_ctocpp.cc create mode 100644 libcef_dll/ctocpp/variant_ctocpp.h create mode 100644 libcef_dll/libcef_dll.cc create mode 100644 libcef_dll/libcef_dll.rc create mode 100644 libcef_dll/libcef_dll.vcproj create mode 100644 libcef_dll/libcef_dll.vsprops create mode 100644 libcef_dll/precompiled_libcef.cc create mode 100644 libcef_dll/precompiled_libcef.h create mode 100644 libcef_dll/resource.h create mode 100644 libcef_dll/transfer_util.cpp create mode 100644 libcef_dll/transfer_util.h create mode 100644 libcef_dll/wrapper/libcef_dll_wrapper.cc create mode 100644 libcef_dll/wrapper/libcef_dll_wrapper.vcproj create mode 100644 libcef_dll/wrapper/libcef_dll_wrapper.vsprops diff --git a/cef.sln b/cef.sln index a708a9287..48b6ed6e4 100644 --- a/cef.sln +++ b/cef.sln @@ -1,350 +1,205 @@ Microsoft Visual Studio Solution File, Format Version 9.00 # Visual Studio 2005 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebKit (readonly)", "WebKit (readonly)", "{1088577A-0C49-4DE0-85CD-B68AD0BE55AA}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore", "..\webkit\build\WebCore\WebCore.vcproj", "{1C16337B-ACF3-4D03-AA90-851C5B5EADA6}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9} = {6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9} - {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} - {1444235E-0E97-4C80-A73E-EE73F3706C32} = {1444235E-0E97-4C80-A73E-EE73F3706C32} {2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673} + {1444235E-0E97-4C80-A73E-EE73F3706C32} = {1444235E-0E97-4C80-A73E-EE73F3706C32} + {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} + {6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9} = {6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Port", "..\webkit\build\port\port.vcproj", "{5597AD47-3494-4750-A235-4F9C2F864700}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} {2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673} + {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Glue", "..\webkit\glue\glue.vcproj", "{C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {1444235E-0E97-4C80-A73E-EE73F3706C32} = {1444235E-0E97-4C80-A73E-EE73F3706C32} - {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} - {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} - {0B469837-3D46-484A-AFB3-C5A6C68730B9} = {0B469837-3D46-484A-AFB3-C5A6C68730B9} {2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673} + {0B469837-3D46-484A-AFB3-C5A6C68730B9} = {0B469837-3D46-484A-AFB3-C5A6C68730B9} + {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} + {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} + {1444235E-0E97-4C80-A73E-EE73F3706C32} = {1444235E-0E97-4C80-A73E-EE73F3706C32} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "skia", "..\skia\skia.vcproj", "{CD9CA56E-4E94-444C-87D4-58CA1E6F300D}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WTF", "..\webkit\build\JavaScriptCore\WTF.vcproj", "{AA8A5A85-592B-4357-BC60-E0E91E026AF6}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlite", "..\third_party\sqlite\sqlite.vcproj", "{6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{EF78C1F9-AA17-4CA5-B6CB-39B37A73A3DA}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebKit (ours)", "WebKit (ours)", "{CB43561E-A6F8-49E2-96A2-3F2BA1FFF21E}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icu", "..\third_party\icu38\build\icu.vcproj", "{8C27D792-2648-4F5E-9ED0-374276327308}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {A0D94973-D355-47A5-A1E2-3456F321F010} = {A0D94973-D355-47A5-A1E2-3456F321F010} EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "icu", "icu", "{1AFC1EC3-24FA-4260-B099-76319EC9977A}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpng", "..\third_party\libpng\libpng.vcproj", "{C564F145-9172-42C3-BFCB-6014CA97DBCD}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "..\third_party\zlib\zlib.vcproj", "{8423AF0D-4B88-4EBF-94E1-E4D00D00E21C}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjpeg", "..\third_party\libjpeg\libjpeg.vcproj", "{238CE175-76CE-4A25-A676-69D115885601}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Breakpad", "Breakpad", "{873D095E-150E-4262-8C41-2D8ED02F0F57}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "breakpad_handler", "..\breakpad\breakpad_handler.vcproj", "{B55CA863-B374-4BAF-95AC-539E4FA4C90C}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxml", "..\third_party\libxml\build\libxml.vcproj", "{F9810DE8-CBC3-4605-A7B1-ECA2D5292FD7}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxslt", "..\third_party\libxslt\build\libxslt.vcproj", "{FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {F9810DE8-CBC3-4605-A7B1-ECA2D5292FD7} = {F9810DE8-CBC3-4605-A7B1-ECA2D5292FD7} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V8Bindings", "..\webkit\build\V8Bindings\V8Bindings.vcproj", "{625A8F11-2B4E-45B4-BD99-C6D629C606C0}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673} {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} = {2F7EDFA2-EE27-4D83-8454-9EFBD5779203} + {2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bzip2", "..\third_party\bzip2\bzip2.vcproj", "{2A70CBF0-847E-4E3A-B926-542A656DC7FE}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef", "libcef\libcef.vcproj", "{FA39524D-3067-4141-888D-28A86C66F2B9}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165} - {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} = {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} - {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} = {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} - {F54ABC59-5C00-414A-A9BA-BAF26D1699F0} = {F54ABC59-5C00-414A-A9BA-BAF26D1699F0} - {F4F4BCAA-EA59-445C-A119-3E6C29647A51} = {F4F4BCAA-EA59-445C-A119-3E6C29647A51} - {EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C} - {CD9CA56E-4E94-444C-87D4-58CA1E6F300D} = {CD9CA56E-4E94-444C-87D4-58CA1E6F300D} - {C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09} = {C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09} - {C564F145-9172-42C3-BFCB-6014CA97DBCD} = {C564F145-9172-42C3-BFCB-6014CA97DBCD} - {C0334F9A-1168-4101-9DD8-C30FB252D435} = {C0334F9A-1168-4101-9DD8-C30FB252D435} - {B55CA863-B374-4BAF-95AC-539E4FA4C90C} = {B55CA863-B374-4BAF-95AC-539E4FA4C90C} - {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6} - {A508ADD3-CECE-4E0F-8448-2F5E454DF551} = {A508ADD3-CECE-4E0F-8448-2F5E454DF551} - {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} - {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} = {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} - {7100F41F-868D-4E99-80A2-AF8E6574749D} = {7100F41F-868D-4E99-80A2-AF8E6574749D} - {625A8F11-2B4E-45B4-BD99-C6D629C606C0} = {625A8F11-2B4E-45B4-BD99-C6D629C606C0} - {5916D37D-8C97-424F-A904-74E52594C2D6} = {5916D37D-8C97-424F-A904-74E52594C2D6} - {5597AD47-3494-4750-A235-4F9C2F864700} = {5597AD47-3494-4750-A235-4F9C2F864700} - {49909552-0B0C-4C14-8CF6-DB8A2ADE0934} = {49909552-0B0C-4C14-8CF6-DB8A2ADE0934} - {326E9795-E760-410A-B69A-3F79DB3F5243} = {326E9795-E760-410A-B69A-3F79DB3F5243} {2A70CBF0-847E-4E3A-B926-542A656DC7FE} = {2A70CBF0-847E-4E3A-B926-542A656DC7FE} - {238CE175-76CE-4A25-A676-69D115885601} = {238CE175-76CE-4A25-A676-69D115885601} + {49909552-0B0C-4C14-8CF6-DB8A2ADE0934} = {49909552-0B0C-4C14-8CF6-DB8A2ADE0934} + {5597AD47-3494-4750-A235-4F9C2F864700} = {5597AD47-3494-4750-A235-4F9C2F864700} + {5916D37D-8C97-424F-A904-74E52594C2D6} = {5916D37D-8C97-424F-A904-74E52594C2D6} + {625A8F11-2B4E-45B4-BD99-C6D629C606C0} = {625A8F11-2B4E-45B4-BD99-C6D629C606C0} + {7100F41F-868D-4E99-80A2-AF8E6574749D} = {7100F41F-868D-4E99-80A2-AF8E6574749D} + {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} = {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} + {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} + {A508ADD3-CECE-4E0F-8448-2F5E454DF551} = {A508ADD3-CECE-4E0F-8448-2F5E454DF551} + {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6} + {B55CA863-B374-4BAF-95AC-539E4FA4C90C} = {B55CA863-B374-4BAF-95AC-539E4FA4C90C} + {C0334F9A-1168-4101-9DD8-C30FB252D435} = {C0334F9A-1168-4101-9DD8-C30FB252D435} + {C564F145-9172-42C3-BFCB-6014CA97DBCD} = {C564F145-9172-42C3-BFCB-6014CA97DBCD} + {C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09} = {C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09} + {CD9CA56E-4E94-444C-87D4-58CA1E6F300D} = {CD9CA56E-4E94-444C-87D4-58CA1E6F300D} + {EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C} + {F4F4BCAA-EA59-445C-A119-3E6C29647A51} = {F4F4BCAA-EA59-445C-A119-3E6C29647A51} + {F54ABC59-5C00-414A-A9BA-BAF26D1699F0} = {F54ABC59-5C00-414A-A9BA-BAF26D1699F0} + {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} = {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} + {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} = {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {326E9795-E760-410A-B69A-3F79DB3F5243} = {326E9795-E760-410A-B69A-3F79DB3F5243} {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} = {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} + {238CE175-76CE-4A25-A676-69D115885601} = {238CE175-76CE-4A25-A676-69D115885601} + {1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165} + {21E22961-22BF-4493-BD3A-868F93DA5179} = {21E22961-22BF-4493-BD3A-868F93DA5179} + {EC8B7909-62AF-470D-A75D-E1D89C837142} = {EC8B7909-62AF-470D-A75D-E1D89C837142} + {0B469837-3D46-484A-AFB3-C5A6C68730B9} = {0B469837-3D46-484A-AFB3-C5A6C68730B9} + {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "V8", "V8", "{B353A6A5-9551-4B76-908E-0F0A9B31E4CE}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "googleurl", "..\googleurl\build\googleurl.vcproj", "{EF5E94AB-B646-4E5B-A058-52EF07B8351C}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modp_b64", "..\third_party\modp_b64\modp_b64.vcproj", "{7100F41F-868D-4E99-80A2-AF8E6574749D}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "activex_shim", "..\webkit\activex_shim\activex_shim.vcproj", "{F4F4BCAA-EA59-445C-A119-3E6C29647A51}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C} {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} + {EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "net", "..\net\build\net.vcproj", "{326E9795-E760-410A-B69A-3F79DB3F5243}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {E13045CD-7E1F-4A41-9B18-8D288B2E7B41} = {E13045CD-7E1F-4A41-9B18-8D288B2E7B41} {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} = {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} + {E13045CD-7E1F-4A41-9B18-8D288B2E7B41} = {E13045CD-7E1F-4A41-9B18-8D288B2E7B41} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base", "..\base\build\base.vcproj", "{1832A374-8A74-4F9E-B536-69A699B3E165}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "base_gfx", "..\base\build\base_gfx.vcproj", "{A508ADD3-CECE-4E0F-8448-2F5E454DF551}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "default_plugin", "..\webkit\default_plugin\default_plugin.vcproj", "{5916D37D-8C97-424F-A904-74E52594C2D6}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JavaScriptCore_pcre", "..\webkit\build\JavaScriptCore\JavaScriptCore_pcre.vcproj", "{49909552-0B0C-4C14-8CF6-DB8A2ADE0934}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V8Bindings_prebuild", "..\webkit\build\V8Bindings\V8Bindings_prebuild.vcproj", "{2F7EDFA2-EE27-4D83-8454-9EFBD5779203}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_snapshot", "..\v8\tools\visual_studio\v8_snapshot.vcproj", "{C0334F9A-1168-4101-9DD8-C30FB252D435}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F} = {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F} {865575D0-37E2-405E-8CBA-5F6C485B5A26} = {865575D0-37E2-405E-8CBA-5F6C485B5A26} + {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F} = {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sdch", "..\sdch\sdch.vcproj", "{F54ABC59-5C00-414A-A9BA-BAF26D1699F0}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cef", "Cef", "{08BAF606-555E-4048-A47E-22CFA89A21B4}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{A507014E-5F1D-4A60-963B-518FCED4B8AD}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tld_cleanup", "..\net\build\tld_cleanup.vcproj", "{E13045CD-7E1F-4A41-9B18-8D288B2E7B41}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject - {1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165} - {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} {EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C} + {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} + {1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_mksnapshot", "..\v8\tools\visual_studio\v8_mksnapshot.vcproj", "{865575D0-37E2-405E-8CBA-5F6C485B5A26}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {21E22961-22BF-4493-BD3A-868F93DA5179} = {21E22961-22BF-4493-BD3A-868F93DA5179} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8", "..\v8\tools\visual_studio\v8.vcproj", "{21E22961-22BF-4493-BD3A-868F93DA5179}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection ProjectSection(ProjectDependencies) = postProject {EC8B7909-62AF-470D-A75D-E1D89C837142} = {EC8B7909-62AF-470D-A75D-E1D89C837142} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_base", "..\v8\tools\visual_studio\v8_base.vcproj", "{EC8B7909-62AF-470D-A75D-E1D89C837142}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V8Config", "..\webkit\build\JSConfig\V8Config.vcproj", "{2E2D3301-2EC4-4C0F-B889-87073B30F673}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webkit_strings", "..\webkit\build\webkit_strings\webkit_strings.vcproj", "{60B43839-95E6-4526-A661-209F16335E0E}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cefclient", "tests\cefclient\cefclient.vcproj", "{6617FED9-C5D4-4907-BF55-A90062A6683F}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" + ProjectSection(ProjectDependencies) = postProject + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9} = {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9} + {C13650D5-CF1A-4259-BE45-B1EBA6280E47} = {C13650D5-CF1A-4259-BE45-B1EBA6280E47} EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icudt", "..\third_party\icu38\build\icudt.vcproj", "{A0D94973-D355-47A5-A1E2-3456F321F010}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "net_resources", "..\net\build\net_resources.vcproj", "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webkit_resources", "..\webkit\build\webkit_resources\webkit_resources.vcproj", "{0B469837-3D46-484A-AFB3-C5A6C68730B9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore_prebuild", "..\webkit\build\WebCore\WebCore_prebuild.vcproj", "{1444235E-0E97-4C80-A73E-EE73F3706C32}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_snapshot_cc", "..\v8\tools\visual_studio\v8_snapshot_cc.vcproj", "{0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F}" + ProjectSection(ProjectDependencies) = postProject + {865575D0-37E2-405E-8CBA-5F6C485B5A26} = {865575D0-37E2-405E-8CBA-5F6C485B5A26} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef_dll", "libcef_dll\libcef_dll.vcproj", "{C13650D5-CF1A-4259-BE45-B1EBA6280E47}" ProjectSection(ProjectDependencies) = postProject {EC8B7909-62AF-470D-A75D-E1D89C837142} = {EC8B7909-62AF-470D-A75D-E1D89C837142} {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} = {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} {625A8F11-2B4E-45B4-BD99-C6D629C606C0} = {625A8F11-2B4E-45B4-BD99-C6D629C606C0} {7100F41F-868D-4E99-80A2-AF8E6574749D} = {7100F41F-868D-4E99-80A2-AF8E6574749D} + {0B469837-3D46-484A-AFB3-C5A6C68730B9} = {0B469837-3D46-484A-AFB3-C5A6C68730B9} {60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E} {C564F145-9172-42C3-BFCB-6014CA97DBCD} = {C564F145-9172-42C3-BFCB-6014CA97DBCD} {5597AD47-3494-4750-A235-4F9C2F864700} = {5597AD47-3494-4750-A235-4F9C2F864700} - {6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9} = {6EAD4A4B-2BBC-4974-8E45-BB5C16CC2AC9} {FA39524D-3067-4141-888D-28A86C66F2B9} = {FA39524D-3067-4141-888D-28A86C66F2B9} {F54ABC59-5C00-414A-A9BA-BAF26D1699F0} = {F54ABC59-5C00-414A-A9BA-BAF26D1699F0} {21E22961-22BF-4493-BD3A-868F93DA5179} = {21E22961-22BF-4493-BD3A-868F93DA5179} @@ -356,47 +211,22 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cefclient", "tests\cefclien {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} = {1C16337B-ACF3-4D03-AA90-851C5B5EADA6} {5916D37D-8C97-424F-A904-74E52594C2D6} = {5916D37D-8C97-424F-A904-74E52594C2D6} {AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6} + {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F} = {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F} {8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308} {326E9795-E760-410A-B69A-3F79DB3F5243} = {326E9795-E760-410A-B69A-3F79DB3F5243} {C0334F9A-1168-4101-9DD8-C30FB252D435} = {C0334F9A-1168-4101-9DD8-C30FB252D435} {F4F4BCAA-EA59-445C-A119-3E6C29647A51} = {F4F4BCAA-EA59-445C-A119-3E6C29647A51} {EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C} + {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} = {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} = {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} {A508ADD3-CECE-4E0F-8448-2F5E454DF551} = {A508ADD3-CECE-4E0F-8448-2F5E454DF551} {2A70CBF0-847E-4E3A-B926-542A656DC7FE} = {2A70CBF0-847E-4E3A-B926-542A656DC7FE} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icudt", "..\third_party\icu38\build\icudt.vcproj", "{A0D94973-D355-47A5-A1E2-3456F321F010}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "net_resources", "..\net\build\net_resources.vcproj", "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webkit_resources", "..\webkit\build\webkit_resources\webkit_resources.vcproj", "{0B469837-3D46-484A-AFB3-C5A6C68730B9}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore_prebuild", "..\webkit\build\WebCore\WebCore_prebuild.vcproj", "{1444235E-0E97-4C80-A73E-EE73F3706C32}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_snapshot_cc", "..\v8\tools\visual_studio\v8_snapshot_cc.vcproj", "{0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F}" - ProjectSection(WebsiteProperties) = preProject - Debug.AspNetCompiler.Debug = "True" - Release.AspNetCompiler.Debug = "False" - EndProjectSection +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef_dll_wrapper", "libcef_dll\wrapper\libcef_dll_wrapper.vcproj", "{A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}" ProjectSection(ProjectDependencies) = postProject - {865575D0-37E2-405E-8CBA-5F6C485B5A26} = {865575D0-37E2-405E-8CBA-5F6C485B5A26} + {1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165} + {C13650D5-CF1A-4259-BE45-B1EBA6280E47} = {C13650D5-CF1A-4259-BE45-B1EBA6280E47} EndProjectSection EndProject Global @@ -718,6 +548,22 @@ Global {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F}.Release|Mixed Platforms.Build.0 = Release|Win32 {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F}.Release|Win32.ActiveCfg = Release|Win32 {0DDBDA8B-A49F-4CC7-A1D5-5BB8297C8A3F}.Release|Win32.Build.0 = Release|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Debug|Win32.ActiveCfg = Debug|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Debug|Win32.Build.0 = Debug|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Release|Mixed Platforms.Build.0 = Release|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Release|Win32.ActiveCfg = Release|Win32 + {C13650D5-CF1A-4259-BE45-B1EBA6280E47}.Release|Win32.Build.0 = Release|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|Win32.ActiveCfg = Debug|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Debug|Win32.Build.0 = Debug|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Release|Mixed Platforms.Build.0 = Release|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Release|Win32.ActiveCfg = Release|Win32 + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -758,6 +604,8 @@ Global {B55CA863-B374-4BAF-95AC-539E4FA4C90C} = {873D095E-150E-4262-8C41-2D8ED02F0F57} {FA39524D-3067-4141-888D-28A86C66F2B9} = {08BAF606-555E-4048-A47E-22CFA89A21B4} {6617FED9-C5D4-4907-BF55-A90062A6683F} = {08BAF606-555E-4048-A47E-22CFA89A21B4} + {C13650D5-CF1A-4259-BE45-B1EBA6280E47} = {08BAF606-555E-4048-A47E-22CFA89A21B4} + {A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9} = {08BAF606-555E-4048-A47E-22CFA89A21B4} {C0334F9A-1168-4101-9DD8-C30FB252D435} = {B353A6A5-9551-4B76-908E-0F0A9B31E4CE} {865575D0-37E2-405E-8CBA-5F6C485B5A26} = {B353A6A5-9551-4B76-908E-0F0A9B31E4CE} {21E22961-22BF-4493-BD3A-868F93DA5179} = {B353A6A5-9551-4B76-908E-0F0A9B31E4CE} diff --git a/include/cef.h b/include/cef.h index f702dca60..617bb35f9 100644 --- a/include/cef.h +++ b/include/cef.h @@ -31,12 +31,13 @@ #ifndef _CEF_H #define _CEF_H -#include #include +#include #include #include "cef_ptr.h" +#include "cef_types.h" - + // This function should only be called once when the application is started. // Create the thread to host the UI message loop. A return value of true // indicates that it succeeded and false indicates that it failed. Set @@ -177,11 +178,7 @@ public: // Define frame target types. Using TF_FOCUSED will target the focused // frame and using TF_MAIN will target the main frame. - enum TargetFrame - { - TF_FOCUSED = 0, - TF_MAIN = 1 - }; + typedef cef_targetframe_t TargetFrame; // Execute undo in the target frame. virtual void Undo(TargetFrame targetFrame) =0; @@ -232,11 +229,11 @@ public: // found, if any. The renderer may request this URL to show the developer the // source of the error. The |start_line| parameter is the base line number // to use for error reporting. - virtual void ExecuteJavaScript(const std::wstring& js_code, - const std::wstring& script_url, - int start_line, TargetFrame targetFrame) =0; + virtual void ExecuteJavaScript(const std::wstring& jsCode, + const std::wstring& scriptUrl, + int startLine, TargetFrame targetFrame) =0; -// Register a new handler tied to the specified JS object |name|. Returns + // Register a new handler tied to the specified JS object |name|. Returns // true if the handler is registered successfully. // A JS handler will be accessible to JavaScript as window.. virtual bool AddJSHandler(const std::wstring& classname, @@ -281,11 +278,7 @@ public: // processing is required. Returning RV_CONTINUE indicates that the // implementation did not handle the method and that the default handler // should be called. - enum RetVal - { - RV_HANDLED = 0, - RV_CONTINUE = 1 - }; + typedef cef_retval_t RetVal; // Event called before a new window is created. The |parentBrowser| parameter // will point to the parent browser window, if any. The |popup| parameter @@ -296,7 +289,7 @@ public: // same handler as the parent window. To change the handler for the new // window modify the object that |handler| points to. virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, - CefWindowInfo& createInfo, bool popup, + CefWindowInfo& windowInfo, bool popup, CefRefPtr& handler, std::wstring& url) =0; @@ -315,15 +308,7 @@ public: const std::wstring& title) =0; // Various browser navigation types supported by chrome. - enum NavType - { - NAVTYPE_LINKCLICKED = 0, - NAVTYPE_FORMSUBMITTED, - NAVTYPE_BACKFORWARD, - NAVTYPE_RELOAD, - NAVTYPE_FORMRESUBMITTED, - NAVTYPE_OTHER - }; + typedef cef_handler_navtype_t NavType; // Event called before browser navigation. The client has an opportunity to // modify the |request| object if desired. Return RV_HANDLED to cancel @@ -343,57 +328,7 @@ public: // Supported error code values. See net\base\net_error_list.h for complete // descriptions of the error codes. - enum ErrorCode - { - ERR_FAILED = -2, - ERR_ABORTED = -3, - ERR_INVALID_ARGUMENT = -4, - ERR_INVALID_HANDLE = -5, - ERR_FILE_NOT_FOUND = -6, - ERR_TIMED_OUT = -7, - ERR_FILE_TOO_BIG = -8, - ERR_UNEXPECTED = -9, - ERR_ACCESS_DENIED = -10, - ERR_NOT_IMPLEMENTED = -11, - ERR_CONNECTION_CLOSED = -100, - ERR_CONNECTION_RESET = -101, - ERR_CONNECTION_REFUSED = -102, - ERR_CONNECTION_ABORTED = -103, - ERR_CONNECTION_FAILED = -104, - ERR_NAME_NOT_RESOLVED = -105, - ERR_INTERNET_DISCONNECTED = -106, - ERR_SSL_PROTOCOL_ERROR = -107, - ERR_ADDRESS_INVALID = -108, - ERR_ADDRESS_UNREACHABLE = -109, - ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110, - ERR_TUNNEL_CONNECTION_FAILED = -111, - ERR_NO_SSL_VERSIONS_ENABLED = -112, - ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113, - ERR_SSL_RENEGOTIATION_REQUESTED = -114, - ERR_CERT_COMMON_NAME_INVALID = -200, - ERR_CERT_DATE_INVALID = -201, - ERR_CERT_AUTHORITY_INVALID = -202, - ERR_CERT_CONTAINS_ERRORS = -203, - ERR_CERT_NO_REVOCATION_MECHANISM = -204, - ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205, - ERR_CERT_REVOKED = -206, - ERR_CERT_INVALID = -207, - ERR_CERT_END = -208, - ERR_INVALID_URL = -300, - ERR_DISALLOWED_URL_SCHEME = -301, - ERR_UNKNOWN_URL_SCHEME = -302, - ERR_TOO_MANY_REDIRECTS = -310, - ERR_UNSAFE_REDIRECT = -311, - ERR_UNSAFE_PORT = -312, - ERR_INVALID_RESPONSE = -320, - ERR_INVALID_CHUNKED_ENCODING = -321, - ERR_METHOD_NOT_SUPPORTED = -322, - ERR_UNEXPECTED_PROXY_AUTH = -323, - ERR_EMPTY_RESPONSE = -324, - ERR_RESPONSE_HEADERS_TOO_BIG = -325, - ERR_CACHE_MISS = -400, - ERR_INSECURE_RESPONSE = -501, - }; + typedef cef_handler_errorcode_t ErrorCode; // Called when the browser fails to load a resource. |errorCode is the // error code number and |failedUrl| is the URL that failed to load. To @@ -417,79 +352,16 @@ public: std::wstring& mimeType, int loadFlags) =0; - // Structure representing menu information - struct MenuInfo - { - int typeFlags; - int x; - int y; - std::wstring linkUrl; - std::wstring imageUrl; - std::wstring pageUrl; - std::wstring frameUrl; - std::wstring selectionText; - std::wstring misspelledWord; - int editFlags; - std::string securityInfo; - }; - - // The MenuInfo typeFlags value will be a combination of the following - enum MenuTypeBits { - // No node is selected - MENUTYPE_NONE = 0x0, - // The top page is selected - MENUTYPE_PAGE = 0x1, - // A subframe page is selected - MENUTYPE_FRAME = 0x2, - // A link is selected - MENUTYPE_LINK = 0x4, - // An image is selected - MENUTYPE_IMAGE = 0x8, - // There is a textual or mixed selection that is selected - MENUTYPE_SELECTION = 0x10, - // An editable element is selected - MENUTYPE_EDITABLE = 0x20, - // A misspelled word is selected - MENUTYPE_MISSPELLED_WORD = 0x40, - }; - - // The MenuInfo editFlags value will be a combination of the following - enum MenuCapabilityBits - { - CAN_DO_NONE = 0x0, - CAN_UNDO = 0x1, - CAN_REDO = 0x2, - CAN_CUT = 0x4, - CAN_COPY = 0x8, - CAN_PASTE = 0x10, - CAN_DELETE = 0x20, - CAN_SELECT_ALL = 0x40, - CAN_GO_FORWARD = 0x80, - CAN_GO_BACK = 0x100, - }; + // Structure representing menu information. + typedef cef_handler_menuinfo_t MenuInfo; // Event called before a context menu is displayed. To cancel display of the // default context menu return RV_HANDLED. virtual RetVal HandleBeforeMenu(CefRefPtr browser, const MenuInfo& menuInfo) =0; - // Supported menu ID values - enum MenuId - { - ID_NAV_BACK = 10, - ID_NAV_FORWARD = 11, - ID_NAV_RELOAD = 12, - ID_NAV_STOP = 13, - ID_UNDO = 20, - ID_REDO = 21, - ID_CUT = 22, - ID_COPY = 23, - ID_PASTE = 24, - ID_DELETE = 25, - ID_SELECTALL = 26, - ID_PRINT = 30, - ID_VIEWSOURCE = 31, - }; + // Supported menu ID values. + typedef cef_handler_menuid_t MenuId; // Event called to optionally override the default text for a context menu // item. |label| contains the default text and may be modified to substitute @@ -541,7 +413,7 @@ public: // |result| to the resulting value. virtual RetVal HandleJSPrompt(CefRefPtr browser, const std::wstring& message, - const std::wstring& default_value, + const std::wstring& defaultValue, bool& retval, std::wstring& result) =0; @@ -563,7 +435,7 @@ public: // Optional name of the target frame. virtual std::wstring GetFrame() =0; - virtual void SetFrame(const std::wstring& url) =0; + virtual void SetFrame(const std::wstring& frame) =0; // Optional request method type, defaulting to POST if post data is provided // and GET otherwise. @@ -606,8 +478,7 @@ public: // succeeds. virtual bool RemoveElement(CefRefPtr element) =0; - // Add the specified post data element. Returns true if the add - // succeeds. + // Add the specified post data element. Returns true if the add succeeds. virtual bool AddElement(CefRefPtr element) =0; // Remove all existing post data elements. @@ -620,12 +491,7 @@ class CefPostDataElement : public CefBase { public: // Post data elements may represent either bytes or files. - enum Type - { - TYPE_EMPTY = 0, - TYPE_BYTES, - TYPE_FILE - }; + typedef cef_postdataelement_type_t Type; // Create a new CefPostDataElement object. static CefRefPtr CreatePostDataElement(); @@ -733,18 +599,7 @@ public: class CefVariant : public CefBase { public: - enum Type - { - TYPE_NULL = 0, - TYPE_BOOL, - TYPE_INT, - TYPE_DOUBLE, - TYPE_STRING, - TYPE_BOOL_ARRAY, - TYPE_INT_ARRAY, - TYPE_DOUBLE_ARRAY, - TYPE_STRING_ARRAY - }; + typedef cef_variant_type_t Type; // Return the variant data type. virtual Type GetType() =0; @@ -769,6 +624,10 @@ public: virtual bool GetIntArray(std::vector& val) =0; virtual bool GetDoubleArray(std::vector& val) =0; virtual bool GetStringArray(std::vector& val) =0; + + // Returns the number of values in the array. Returns -1 if the variant + // is not an array type. + virtual int GetArraySize() =0; }; #endif // _CEF_H diff --git a/include/cef_capi.h b/include/cef_capi.h new file mode 100644 index 000000000..203f9c6ed --- /dev/null +++ b/include/cef_capi.h @@ -0,0 +1,620 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef _CEF_CAPI_H +#define _CEF_CAPI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_export.h" +#include "cef_string.h" +#include "cef_string_map.h" +#include "cef_types.h" + + +// This function should only be called once when the application is started. +// Create the thread to host the UI message loop. A return value of true +// indicates that it succeeded and false indicates that it failed. Set +// |multi_threaded_message_loop| to true to have the message loop run in +// a separate thread. If |multi_threaded_message_loop| is false than +// the CefDoMessageLoopWork() function must be called from your message loop. +CEF_EXPORT int cef_initialize(int multi_threaded_message_loop); + +// This function should only be called once before the application exits. +// Shut down the thread hosting the UI message loop and destroy any created +// windows. +CEF_EXPORT void cef_shutdown(); + +// Perform message loop processing. Has no affect if the browser UI loop is +// running in a separate thread. +CEF_EXPORT void cef_do_message_loop_work(); + + +typedef struct _cef_base_t +{ + // Size of the data structure + size_t size; + + // Increment the reference count. + int (CEF_CALLBACK *add_ref)(struct _cef_base_t* base); + // Decrement the reference count. Delete this object when no references + // remain. + int (CEF_CALLBACK *release)(struct _cef_base_t* base); +} cef_base_t; + + +// Check that the structure |s|, which is defined with a cef_base_t member named +// |base|, is large enough to contain the specified member |f|. +#define CEF_MEMBER_EXISTS(s, f) \ + ((int)&((s)->f) - (int)(s) + sizeof((s)->f) <= (s)->base.size) + +#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f)) + +// Structure used to represent a browser window. All functions exposed by this +// structure should be thread safe. +typedef struct _cef_browser_t +{ + // Base structure + cef_base_t base; + + // Returns true (1) if the browser can navigate backwards. + int (CEF_CALLBACK *can_go_back)(struct _cef_browser_t* browser); + // Navigate backwards. + void (CEF_CALLBACK *go_back)(struct _cef_browser_t* browser); + // Returns true (1) if the browser can navigate forwards. + int (CEF_CALLBACK *can_go_forward)(struct _cef_browser_t* browser); + // Navigate backwards. + void (CEF_CALLBACK *go_forward)(struct _cef_browser_t* browser); + // Reload the current page. + void (CEF_CALLBACK *reload)(struct _cef_browser_t* browser); + // Stop loading the page. + void (CEF_CALLBACK *stop_load)(struct _cef_browser_t* browser); + + // Execute undo in the target frame. + void (CEF_CALLBACK *undo)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + // Execute redo in the target frame. + void (CEF_CALLBACK *redo)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + // Execute cut in the target frame. + void (CEF_CALLBACK *cut)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + // Execute copy in the target frame. + void (CEF_CALLBACK *copy)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + // Execute paste in the target frame. + void (CEF_CALLBACK *paste)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + // Execute delete in the target frame. + void (CEF_CALLBACK *del)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + // Execute select all in the target frame. + void (CEF_CALLBACK *select_all)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + + // Execute printing in the target frame. The user will be prompted with + // the print dialog appropriate to the operating system. + void (CEF_CALLBACK *print)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + + // Save the target frame's HTML source to a temporary file and open it in + // the default text viewing application. + void (CEF_CALLBACK *view_source)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + + // Returns the target frame's HTML source as a string. The returned string + // must be released using cef_string_free(). + cef_string_t (CEF_CALLBACK *get_source)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + + // Returns the target frame's display text as a string. The returned string + // must be released using cef_string_free(). + cef_string_t (CEF_CALLBACK *get_text)(struct _cef_browser_t* browser, + enum cef_targetframe_t targetFrame); + + // Load the request represented by the |request| object. + void (CEF_CALLBACK *load_request)(struct _cef_browser_t* browser, + struct _cef_request_t* request); + + // Convenience method for loading the specified |url| in the optional target + // |frame|. + void (CEF_CALLBACK *load_url)(struct _cef_browser_t* browser, + const wchar_t* url, const wchar_t* frame); + + // Load the contents of |string| with the optional dummy target |url|. + void (CEF_CALLBACK *load_string)(struct _cef_browser_t* browser, + const wchar_t* string, const wchar_t* url); + + // Load the contents of |stream| with the optional dummy target |url|. + void (CEF_CALLBACK *load_stream)(struct _cef_browser_t* browser, + struct _cef_stream_reader_t* stream, const wchar_t* url); + + // Execute a string of JavaScript code in the specified target frame. The + // |script_url| parameter is the URL where the script in question can be + // found, if any. The renderer may request this URL to show the developer the + // source of the error. The |start_line| parameter is the base line number + // to use for error reporting. + void (CEF_CALLBACK *execute_javascript)(struct _cef_browser_t* browser, + const wchar_t* jsCode, const wchar_t* scriptUrl, int startLine, + enum cef_targetframe_t targetFrame); + + // Register a new handler tied to the specified JS object |name|. Returns + // true if the handler is registered successfully. + // A JS handler will be accessible to JavaScript as window.. + int (CEF_CALLBACK *add_jshandler)(struct _cef_browser_t* browser, + const wchar_t* classname, struct _cef_jshandler_t* handler); + + // Returns true if a JS handler with the specified |name| is currently + // registered. + int (CEF_CALLBACK *has_jshandler)(struct _cef_browser_t* browser, + const wchar_t* classname); + + // Returns the JS handler registered with the specified |name|. + struct _cef_jshandler_t* (CEF_CALLBACK *get_jshandler)( + struct _cef_browser_t* browser, const wchar_t* classname); + + // Unregister the JS handler registered with the specified |name|. Returns + // true if the handler is unregistered successfully. + int (CEF_CALLBACK *remove_jshandler)(struct _cef_browser_t* browser, + const wchar_t* classname); + + // Unregister all JS handlers that are currently registered. + void (CEF_CALLBACK *remove_all_jshandlers)(struct _cef_browser_t* browser); + + // Retrieve the window handle for this browser. + cef_window_handle_t (CEF_CALLBACK *get_window_handle)( + struct _cef_browser_t* browser); + + // Returns true (1) if the window is a popup window. + int (CEF_CALLBACK *is_popup)(struct _cef_browser_t* browser); + + // Returns the handler for this browser. + struct _cef_handler_t* (CEF_CALLBACK *get_handler)( + struct _cef_browser_t* browser); + + // Return the currently loaded URL. The returned string must be released + // using cef_string_free(). + cef_string_t (CEF_CALLBACK *get_url)(struct _cef_browser_t* browser); + +} cef_browser_t; + + +// Structure used to handle events generated by the browser window. All methods +// functions by this class should be thread safe. +typedef struct _cef_handler_t +{ + // Base structure + cef_base_t base; + + // Event called before a new window is created. The |parentBrowser| parameter + // will point to the parent browser window, if any. The |popup| parameter + // will be true (1) if the new window is a popup window. If you create the + // window yourself you should populate the window handle member of + // |createInfo| and return RV_HANDLED. Otherwise, return RV_CONTINUE and the + // framework will create the window. By default, a newly created window will + // recieve the same handler as the parent window. To change the handler for + // the new window modify the object that |handler| points to. + enum cef_retval_t (CEF_CALLBACK *handle_before_created)( + struct _cef_handler_t* handler, cef_browser_t* parentBrowser, + cef_window_info_t* windowInfo, int popup, + struct _cef_handler_t** newHandler, cef_string_t* url); + + // Event called after a new window is created. The return value is currently + // ignored. + enum cef_retval_t (CEF_CALLBACK *handle_after_created)( + struct _cef_handler_t* handler, cef_browser_t* browser); + + // Event called when the address bar changes. The return value is currently + // ignored. + enum cef_retval_t (CEF_CALLBACK *handle_address_change)( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* url); + + // Event called when the page title changes. The return value is currently + // ignored. + enum cef_retval_t (CEF_CALLBACK *handle_title_change)( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* title); + + // Event called before browser navigation. The client has an opportunity to + // modify the |request| object if desired. Return RV_HANDLED to cancel + // navigation. + enum cef_retval_t (CEF_CALLBACK *handle_before_browse)( + struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_request_t* request, cef_handler_navtype_t navType, + int isRedirect); + + // Event called when the browser begins loading a page. The return value is + // currently ignored. + enum cef_retval_t (CEF_CALLBACK *handle_load_start)( + struct _cef_handler_t* handler, cef_browser_t* browser); + + // Event called when the browser is done loading a page. This event will + // be generated irrespective of whether the request completes successfully. + // The return value is currently ignored. + enum cef_retval_t (CEF_CALLBACK *handle_load_end)( + struct _cef_handler_t* handler, cef_browser_t* browser); + + // Called when the browser fails to load a resource. |errorCode is the + // error code number and |failedUrl| is the URL that failed to load. To + // provide custom error text assign the text to |errorText| and return + // RV_HANDLED. Otherwise, return RV_CONTINUE for the default error text. + enum cef_retval_t (CEF_CALLBACK *handle_load_error)( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_handler_errorcode_t errorCode, const wchar_t* failedUrl, + cef_string_t* errorText); + + // Event called before a resource is loaded. To allow the resource to load + // normally return RV_CONTINUE. To redirect the resource to a new url + // populate the |redirectUrl| value and return RV_CONTINUE. To specify + // data for the resource return a CefStream object in |resourceStream|, set + // 'mimeType| to the resource stream's mime type, and return RV_CONTINUE. + // To cancel loading of the resource return RV_HANDLED. + enum cef_retval_t (CEF_CALLBACK *handle_before_resource_load)( + struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_request_t* request, cef_string_t* redirectUrl, + struct _cef_stream_reader_t** resourceStream, cef_string_t* mimeType, + int loadFlags); + + // Event called before a context menu is displayed. To cancel display of the + // default context menu return RV_HANDLED. + enum cef_retval_t (CEF_CALLBACK *handle_before_menu)( + struct _cef_handler_t* handler, cef_browser_t* browser, + const cef_handler_menuinfo_t* menuInfo); + + // Event called to optionally override the default text for a context menu + // item. |label| contains the default text and may be modified to substitute + // alternate text. The return value is currently ignored. + enum cef_retval_t (CEF_CALLBACK *handle_get_menu_label)( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_handler_menuid_t menuId, cef_string_t* label); + + // Event called when an option is selected from the default context menu. + // Return RV_HANDLED to cancel default handling of the action. + enum cef_retval_t (CEF_CALLBACK *handle_menu_action)( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_handler_menuid_t menuId); + + // Event called to format print headers and footers. |printInfo| contains + // platform-specific information about the printer context. |url| is the + // URL if the currently printing page, |title| is the title of the currently + // printing page, |currentPage| is the current page number and |maxPages| is + // the total number of pages. Six default header locations are provided + // by the implementation: top left, top center, top right, bottom left, + // bottom center and bottom right. To use one of these default locations + // just assign a string to the appropriate variable. To draw the header + // and footer yourself return RV_HANDLED. Otherwise, populate the approprate + // variables and return RV_CONTINUE. + enum cef_retval_t (CEF_CALLBACK *handle_print_header_footer)( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_print_info_t* printInfo, const wchar_t* url, const wchar_t* title, + int currentPage, int maxPages, cef_string_t* topLeft, + cef_string_t* topCenter, cef_string_t* topRight, + cef_string_t* bottomLeft, cef_string_t* bottomCenter, + cef_string_t* bottomRight); + + // Run a JS alert message. Return RV_CONTINUE to display the default alert + // or RV_HANDLED if you displayed a custom alert. + enum cef_retval_t (CEF_CALLBACK *handle_jsalert)( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* message); + + // Run a JS confirm request. Return RV_CONTINUE to display the default alert + // or RV_HANDLED if you displayed a custom alert. If you handled the alert + // set |retval| to true (1) if the user accepted the confirmation. + enum cef_retval_t (CEF_CALLBACK *handle_jsconfirm)( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* message, int* retval); + + // Run a JS prompt request. Return RV_CONTINUE to display the default prompt + // or RV_HANDLED if you displayed a custom prompt. If you handled the prompt + // set |retval| to true if the user accepted the prompt and request and + // |result| to the resulting value. + enum cef_retval_t (CEF_CALLBACK *handle_jsprompt)( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* message, const wchar_t* defaultValue, int* retval, + cef_string_t* result); + +} cef_handler_t; + + +// Structure used to represent a web request. +typedef struct _cef_request_t +{ + // Base structure + cef_base_t base; + + // Fully qualified URL to load. + cef_string_t (CEF_CALLBACK *get_url)(struct _cef_request_t* request); + void (CEF_CALLBACK *set_url)(struct _cef_request_t* request, + const wchar_t* url); + + // Optional name of the target frame. + cef_string_t (CEF_CALLBACK *get_frame)(struct _cef_request_t* request); + void (CEF_CALLBACK *set_frame)(struct _cef_request_t* request, + const wchar_t* frame); + + // Optional request method type, defaulting to POST if post data is provided + // and GET otherwise. + cef_string_t (CEF_CALLBACK *get_method)(struct _cef_request_t* request); + void (CEF_CALLBACK *set_method)(struct _cef_request_t* request, + const wchar_t* method); + + // Optional post data. + struct _cef_post_data_t* (CEF_CALLBACK *get_post_data)( + struct _cef_request_t* request); + void (CEF_CALLBACK *set_post_data)(struct _cef_request_t* request, + struct _cef_post_data_t* postData); + + // Optional header values. + void (CEF_CALLBACK *get_header_map)(struct _cef_request_t* request, + cef_string_map_t headerMap); + void (CEF_CALLBACK *set_header_map)(struct _cef_request_t* request, + cef_string_map_t headerMap); + + // Set all values at one time. + void (CEF_CALLBACK *set)(struct _cef_request_t* request, const wchar_t* url, + const wchar_t* frame, const wchar_t* method, + struct _cef_post_data_t* postData, cef_string_map_t headerMap); + +} cef_request_t; + + +// Structure used to represent post data for a web request. +typedef struct _cef_post_data_t +{ + // Base structure + cef_base_t base; + + // Returns the number of existing post data elements. + size_t (CEF_CALLBACK *get_element_count)(struct _cef_post_data_t* postData); + + // Retrieve the post data element at the specified zero-based index. + struct _cef_post_data_element_t* (CEF_CALLBACK *get_element)( + struct _cef_post_data_t* postData, int index); + + // Remove the specified post data element. Returns true (1) if the removal + // succeeds. + int (CEF_CALLBACK *remove_element)(struct _cef_post_data_t* postData, + struct _cef_post_data_element_t* element); + + // Add the specified post data element. Returns true (1) if the add succeeds. + int (CEF_CALLBACK *add_element)(struct _cef_post_data_t* postData, + struct _cef_post_data_element_t* element); + + // Remove all existing post data elements. + void (CEF_CALLBACK *remove_elements)(struct _cef_post_data_t* postData); + +} cef_post_data_t; + + +// Structure used to represent a single element in the request post data. +typedef struct _cef_post_data_element_t +{ + // Base structure + cef_base_t base; + + // Remove all contents from the post data element. + void (CEF_CALLBACK *set_to_empty)( + struct _cef_post_data_element_t* postDataElement); + + // The post data element will represent a file. + void (CEF_CALLBACK *set_to_file)( + struct _cef_post_data_element_t* postDataElement, + const wchar_t* fileName); + + // The post data element will represent bytes. The bytes passed + // in will be copied. + void (CEF_CALLBACK *set_to_bytes)( + struct _cef_post_data_element_t* postDataElement, size_t size, + const void* bytes); + + // Return the type of this post data element. + cef_postdataelement_type_t (CEF_CALLBACK *get_type)( + struct _cef_post_data_element_t* postDataElement); + + // Return the file name. + cef_string_t (CEF_CALLBACK *get_file)( + struct _cef_post_data_element_t* postDataElement); + + // Return the number of bytes. + size_t (CEF_CALLBACK *get_bytes_count)( + struct _cef_post_data_element_t* postDataElement); + + // Read up to |size| bytes into |bytes| and return the number of bytes + // actually read. + size_t (CEF_CALLBACK *get_bytes)( + struct _cef_post_data_element_t* postDataElement, size_t size, + void *bytes); + +} cef_post_data_element_t; + + +// Structure used to read data from a stream. +typedef struct _cef_stream_reader_t +{ + // Base structure + cef_base_t base; + + // Read raw binary data. + size_t (CEF_CALLBACK *read)(struct _cef_stream_reader_t* stream, void *ptr, + size_t size, size_t n); + + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. + int (CEF_CALLBACK *seek)(struct _cef_stream_reader_t* stream, long offset, + int whence); + + // Return the current offset position. + long (CEF_CALLBACK *tell)(struct _cef_stream_reader_t* stream); + + // Return non-zero if at end of file. + int (CEF_CALLBACK *eof)(struct _cef_stream_reader_t* stream); + +} cef_stream_reader_t; + + +// Structure used to write data to a stream. +typedef struct _cef_stream_writer_t +{ + // Base structure + cef_base_t base; + + size_t (CEF_CALLBACK *write)(struct _cef_stream_writer_t* stream, + const void *ptr, size_t size, size_t n); + + // Seek to the specified offset position. |whence| may be any one of + // SEEK_CUR, SEEK_END or SEEK_SET. + int (CEF_CALLBACK *seek)(struct _cef_stream_writer_t* stream, long offset, + int whence); + + // Return the current offset position. + long (CEF_CALLBACK *tell)(struct _cef_stream_writer_t* stream); + + // Flush the stream. + int (CEF_CALLBACK *flush)(struct _cef_stream_writer_t* stream); + +} cef_stream_writer_t; + + +// Structure for implementing external JavaScript objects. +typedef struct _cef_jshandler_t +{ + // Base structure + cef_base_t base; + + // Return true if the specified method exists. + bool (CEF_CALLBACK *has_method)(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name); + + // Return true if the specified property exists. + bool (CEF_CALLBACK *has_property)(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name); + + // Set the property value. Return true if the property is accepted. + bool (CEF_CALLBACK *set_property)(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name, + struct _cef_variant_t* value); + + // Get the property value. Return true if the value is returned. + bool (CEF_CALLBACK *get_property)(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name, + struct _cef_variant_t* value); + + // Execute a method with the specified argument vector and return + // value. Return true if the method was handled. + bool (CEF_CALLBACK *execute_method)(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name, size_t numargs, + struct _cef_variant_t** args, struct _cef_variant_t* retval); + +} cef_jshandler_t; + + +typedef struct _cef_variant_t +{ + // Base structure + cef_base_t base; + + // Return the variant data type. + cef_variant_type_t (CEF_CALLBACK *get_type)(struct _cef_variant_t* variant); + + // Assign various data types. + void (CEF_CALLBACK *set_null)(struct _cef_variant_t* variant); + void (CEF_CALLBACK *set_bool)(struct _cef_variant_t* variant, int val); + void (CEF_CALLBACK *set_int)(struct _cef_variant_t* variant, int val); + void (CEF_CALLBACK *set_double)(struct _cef_variant_t* variant, double val); + void (CEF_CALLBACK *set_string)(struct _cef_variant_t* variant, + const wchar_t* val); + void (CEF_CALLBACK *set_bool_array)(struct _cef_variant_t* variant, + size_t count, const int* vals); + void (CEF_CALLBACK *set_int_array)(struct _cef_variant_t* variant, + size_t count, const int* vals); + void (CEF_CALLBACK *set_double_array)(struct _cef_variant_t* variant, + size_t count, const double* vals); + void (CEF_CALLBACK *set_string_array)(struct _cef_variant_t* variant, + size_t count, const cef_string_t* vals); + + // Retrieve various data types. + int (CEF_CALLBACK *get_bool)(struct _cef_variant_t* variant); + int (CEF_CALLBACK *get_int)(struct _cef_variant_t* variant); + double (CEF_CALLBACK *get_double)(struct _cef_variant_t* variant); + cef_string_t (CEF_CALLBACK *get_string)(struct _cef_variant_t* variant); + + // Returns the number of values in the array. Returns -1 if the variant + // is not an array type. + int (CEF_CALLBACK *get_array_size)(struct _cef_variant_t* variant); + + // Reads up to |maxcount| values into the specified |vals| array. Returns + // the number of values actually read in. + size_t (CEF_CALLBACK *get_bool_array)(struct _cef_variant_t* variant, + size_t maxcount, int* vals); + size_t (CEF_CALLBACK *get_int_array)(struct _cef_variant_t* variant, + size_t maxcount, int* vals); + size_t (CEF_CALLBACK *get_double_array)(struct _cef_variant_t* variant, + size_t maxcount, double* vals); + size_t (CEF_CALLBACK *get_string_array)(struct _cef_variant_t* variant, + size_t maxcount, cef_string_t* vals); + +} cef_variant_t; + + +// Create a new browser window using the window parameters specified +// by |windowInfo|. All values will be copied internally and the actual +// window will be created on the UI thread. The |popup| parameter should +// be true (1) if the new window is a popup window. This method call will not +// block. +CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup, + cef_handler_t* handler, const wchar_t* url); + +// Create a new request structure. +CEF_EXPORT cef_request_t* cef_create_request(); + +// Create a new post data structure. +CEF_EXPORT cef_post_data_t* cef_create_post_data(); + +// Create a new post data element structure. +CEF_EXPORT cef_post_data_element_t* cef_create_post_data_element(); + +// Create a new stream reader structure for reading from the specified file. +CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_file( + const wchar_t* fileName); + +// Create a new stream reader structure for reading from the specified data. +CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_data(void *data, + size_t size); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_CAPI_H diff --git a/include/cef_export.h b/include/cef_export.h new file mode 100644 index 000000000..4e2f251ae --- /dev/null +++ b/include/cef_export.h @@ -0,0 +1,41 @@ +// Copyright (c) 2009 The Chromium Embedded Framework Authors. All rights +// reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifdef _MSC_VER // MSVC +#ifdef BUILDING_CEF_SHARED +#define CEF_EXPORT __declspec(dllexport) +#elif USING_CEF_SHARED +#define CEF_EXPORT __declspec(dllimport) +#else +#define CEF_EXPORT +#endif // BUILDING_CEF_SHARED +#define CEF_CALLBACK __stdcall +#endif // MSVC diff --git a/include/cef_nplugin_capi.h b/include/cef_nplugin_capi.h new file mode 100644 index 000000000..01084a599 --- /dev/null +++ b/include/cef_nplugin_capi.h @@ -0,0 +1,90 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef _CEF_PLUGIN_CAPI_H +#define _CEF_PLUGIN_CAPI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_export.h" +#include "webkit/glue/plugins/nphostapi.h" +#include "third_party/npapi/bindings/npapi.h" + +// Netscape plugins are normally built at separate DLLs that are loaded by the +// browser when needed. This interface supports the creation of plugins that +// are an embedded component of the application. Embedded plugins built using +// this interface use the same Netscape Plugin API as DLL-based plugins. +// See https://developer.mozilla.org/En/Gecko_Plugin_API_Reference for complete +// documentation on how to use the Netscape Plugin API. + +// This structure provides attribute information and entry point functions for +// a plugin. +typedef struct _cef_plugin_info_t { + // The unique name that identifies the plugin. + const wchar_t* unique_name; + + // The friendly display name of the plugin. + const wchar_t* display_name; + + // The version string of the plugin. + const wchar_t* version; + + // A description of the plugin. + const wchar_t* description; + + // A pipe (|) delimited list of mime type values that the plugin supports. + const wchar_t* mime_types; + + // A pipe (|) delimited list of extension values. Each value is associated + // with the mime type value at the same position. Multiple file extensions + // for the same mime type may be delimited with commas (,). + const wchar_t* file_extensions; + + // A pipe (|) delimited list of description values. Each value is associated + // with the mime type value at the same position. + const wchar_t* type_descriptions; + + // Entry point function pointers. + NP_GetEntryPointsFunc np_getentrypoints; + NP_InitializeFunc np_initialize; + NP_ShutdownFunc np_shutdown; +} cef_plugin_info_t; + +// Register a plugin with the system. Returns true (1) on success. +CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_PLUGIN_CAPI_H diff --git a/include/cef_string.h b/include/cef_string.h new file mode 100644 index 000000000..3b394a878 --- /dev/null +++ b/include/cef_string.h @@ -0,0 +1,86 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef _CEF_STRING_H +#define _CEF_STRING_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_export.h" +#include + +// CEF strings are NUL-terminated wide character strings prefixed with a size +// value, similar to the Microsoft BSTR type. Use the below API functions for +// allocating, managing and freeing CEF strings. +typedef wchar_t* cef_string_t; + +// Return the wide character length of the CEF string as allocated by +// cef_string_alloc_len(). The returned value does not include the NUL +// terminating character. This length may differ from the string length +// as returned by wcslen(). +CEF_EXPORT size_t cef_string_length(cef_string_t str); + +// Allocate and return a new CEF string that is a copy of |str|. If |str| is +// NULL or if allocation fails NULL will be returned. If |str| is of length +// 0 a valid empty CEF string will be returned. +CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str); + +// Allocate and return a new CEF string that is a copy of |str|. |len| is the +// wide character length of the new CEF string not including the NUL +// terminating character. |str| will be copied without checking for a NUL +// terminating character. If |str| is NULL or if allocation fails NULL will +// be returned. If |str| is of length 0 a valid empty CEF string will be +// returned. +CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str, + size_t len); + +// Reallocate an existing CEF string. The contents of |oldstr| will be +// replaced with the contents of |newstr|; |newstr| may not be NULL. Returns 1 +// on success and 0 on failure. +CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr); + +// Reallocate an existing CEF string. If |newstr| is NULL the contents of +// |oldstr| will remain unchanged; otherwise, they will be replaced with the +// contents of |newstr|. |len| is the new wide character length of the string +// not including the NUL terminating character. Returns 1 on success and 0 +// on failure. +CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr, + const wchar_t* newstr, + size_t len); + +// Free a CEF string. If |str| is NULL this function does nothing. +CEF_EXPORT void cef_string_free(cef_string_t str); + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_H diff --git a/include/cef_string_map.h b/include/cef_string_map.h new file mode 100644 index 000000000..041a19c35 --- /dev/null +++ b/include/cef_string_map.h @@ -0,0 +1,75 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef _CEF_STRING_MAP_H +#define _CEF_STRING_MAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "cef_export.h" +#include "cef_string.h" +#include + +// CEF string maps are a set of key/value string pairs. +typedef void* cef_string_map_t; + +// Allocate a new string map. +CEF_EXPORT cef_string_map_t cef_string_map_alloc(); + +// Return the number of elements in the string map. +CEF_EXPORT int cef_string_map_size(cef_string_map_t map); + +// Return the value assigned to the specified key. +CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map, + const wchar_t* key); + +// Return the key at the specified zero-based string map index. +CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index); + +// Return the value at the specified zero-based string map index. +CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index); + +// Append a new key/value pair at the end of the string map. +CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key, + const wchar_t* value); + +// Clear the string map. +CEF_EXPORT void cef_string_map_clear(cef_string_map_t map); + +// Free the string map. +CEF_EXPORT void cef_string_map_free(cef_string_map_t map); + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_STRING_MAP_H diff --git a/include/cef_types.h b/include/cef_types.h new file mode 100644 index 000000000..5fdda3436 --- /dev/null +++ b/include/cef_types.h @@ -0,0 +1,227 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef _CEF_TYPES_H +#define _CEF_TYPES_H + +#ifdef __cplusplus +extern "C" { +#endif + + +// Bring in platform-specific definitions. +#ifdef _WIN32 +#include "cef_types_win.h" +#endif + + +// Define frame target types. Using TF_FOCUSED will target the focused +// frame and using TF_MAIN will target the main frame. +enum cef_targetframe_t +{ + TF_FOCUSED = 0, + TF_MAIN = 1, +}; + +// Define handler return value types. Returning RV_HANDLED indicates +// that the implementation completely handled the method and that no further +// processing is required. Returning RV_CONTINUE indicates that the +// implementation did not handle the method and that the default handler +// should be called. +enum cef_retval_t +{ + RV_HANDLED = 0, + RV_CONTINUE = 1, +}; + +// Various browser navigation types supported by chrome. +enum cef_handler_navtype_t +{ + NAVTYPE_LINKCLICKED = 0, + NAVTYPE_FORMSUBMITTED, + NAVTYPE_BACKFORWARD, + NAVTYPE_RELOAD, + NAVTYPE_FORMRESUBMITTED, + NAVTYPE_OTHER, +}; + +// Supported error code values. See net\base\net_error_list.h for complete +// descriptions of the error codes. +enum cef_handler_errorcode_t +{ + ERR_FAILED = -2, + ERR_ABORTED = -3, + ERR_INVALID_ARGUMENT = -4, + ERR_INVALID_HANDLE = -5, + ERR_FILE_NOT_FOUND = -6, + ERR_TIMED_OUT = -7, + ERR_FILE_TOO_BIG = -8, + ERR_UNEXPECTED = -9, + ERR_ACCESS_DENIED = -10, + ERR_NOT_IMPLEMENTED = -11, + ERR_CONNECTION_CLOSED = -100, + ERR_CONNECTION_RESET = -101, + ERR_CONNECTION_REFUSED = -102, + ERR_CONNECTION_ABORTED = -103, + ERR_CONNECTION_FAILED = -104, + ERR_NAME_NOT_RESOLVED = -105, + ERR_INTERNET_DISCONNECTED = -106, + ERR_SSL_PROTOCOL_ERROR = -107, + ERR_ADDRESS_INVALID = -108, + ERR_ADDRESS_UNREACHABLE = -109, + ERR_SSL_CLIENT_AUTH_CERT_NEEDED = -110, + ERR_TUNNEL_CONNECTION_FAILED = -111, + ERR_NO_SSL_VERSIONS_ENABLED = -112, + ERR_SSL_VERSION_OR_CIPHER_MISMATCH = -113, + ERR_SSL_RENEGOTIATION_REQUESTED = -114, + ERR_CERT_COMMON_NAME_INVALID = -200, + ERR_CERT_DATE_INVALID = -201, + ERR_CERT_AUTHORITY_INVALID = -202, + ERR_CERT_CONTAINS_ERRORS = -203, + ERR_CERT_NO_REVOCATION_MECHANISM = -204, + ERR_CERT_UNABLE_TO_CHECK_REVOCATION = -205, + ERR_CERT_REVOKED = -206, + ERR_CERT_INVALID = -207, + ERR_CERT_END = -208, + ERR_INVALID_URL = -300, + ERR_DISALLOWED_URL_SCHEME = -301, + ERR_UNKNOWN_URL_SCHEME = -302, + ERR_TOO_MANY_REDIRECTS = -310, + ERR_UNSAFE_REDIRECT = -311, + ERR_UNSAFE_PORT = -312, + ERR_INVALID_RESPONSE = -320, + ERR_INVALID_CHUNKED_ENCODING = -321, + ERR_METHOD_NOT_SUPPORTED = -322, + ERR_UNEXPECTED_PROXY_AUTH = -323, + ERR_EMPTY_RESPONSE = -324, + ERR_RESPONSE_HEADERS_TOO_BIG = -325, + ERR_CACHE_MISS = -400, + ERR_INSECURE_RESPONSE = -501, +}; + +// Structure representing menu information. +typedef struct _cef_handler_menuinfo_t +{ + int typeFlags; + int x; + int y; + const wchar_t* linkUrl; + const wchar_t* imageUrl; + const wchar_t* pageUrl; + const wchar_t* frameUrl; + const wchar_t* selectionText; + const wchar_t* misspelledWord; + int editFlags; + const wchar_t* securityInfo; +} cef_handler_menuinfo_t; + +// The cef_handler_menuinfo_t typeFlags value will be a combination of the +// following values. +enum cef_handler_menutypebits_t +{ + // No node is selected + MENUTYPE_NONE = 0x0, + // The top page is selected + MENUTYPE_PAGE = 0x1, + // A subframe page is selected + MENUTYPE_FRAME = 0x2, + // A link is selected + MENUTYPE_LINK = 0x4, + // An image is selected + MENUTYPE_IMAGE = 0x8, + // There is a textual or mixed selection that is selected + MENUTYPE_SELECTION = 0x10, + // An editable element is selected + MENUTYPE_EDITABLE = 0x20, + // A misspelled word is selected + MENUTYPE_MISSPELLED_WORD = 0x40, +}; + +// The cef_handler_menuinfo_t editFlags value will be a combination of the +// following values. +enum cef_handler_menucapabilitybits_t +{ + MENU_CAN_DO_NONE = 0x0, + MENU_CAN_UNDO = 0x1, + MENU_CAN_REDO = 0x2, + MENU_CAN_CUT = 0x4, + MENU_CAN_COPY = 0x8, + MENU_CAN_PASTE = 0x10, + MENU_CAN_DELETE = 0x20, + MENU_CAN_SELECT_ALL = 0x40, + MENU_CAN_GO_FORWARD = 0x80, + MENU_CAN_GO_BACK = 0x100, +}; + +// Supported menu ID values. +enum cef_handler_menuid_t +{ + MENU_ID_NAV_BACK = 10, + MENU_ID_NAV_FORWARD = 11, + MENU_ID_NAV_RELOAD = 12, + MENU_ID_NAV_STOP = 13, + MENU_ID_UNDO = 20, + MENU_ID_REDO = 21, + MENU_ID_CUT = 22, + MENU_ID_COPY = 23, + MENU_ID_PASTE = 24, + MENU_ID_DELETE = 25, + MENU_ID_SELECTALL = 26, + MENU_ID_PRINT = 30, + MENU_ID_VIEWSOURCE = 31, +}; + +// Post data elements may represent either bytes or files. +enum cef_postdataelement_type_t +{ + PDE_TYPE_EMPTY = 0, + PDE_TYPE_BYTES, + PDE_TYPE_FILE, +}; + +enum cef_variant_type_t +{ + VARIANT_TYPE_NULL = 0, + VARIANT_TYPE_BOOL, + VARIANT_TYPE_INT, + VARIANT_TYPE_DOUBLE, + VARIANT_TYPE_STRING, + VARIANT_TYPE_BOOL_ARRAY, + VARIANT_TYPE_INT_ARRAY, + VARIANT_TYPE_DOUBLE_ARRAY, + VARIANT_TYPE_STRING_ARRAY, +}; + + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_TYPES_H diff --git a/include/cef_types_win.h b/include/cef_types_win.h new file mode 100644 index 000000000..83eeb563e --- /dev/null +++ b/include/cef_types_win.h @@ -0,0 +1,76 @@ +// Copyright (c) 2009 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework nor the names of its contributors may be used to endorse +// or promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#ifndef _CEF_TYPES_WIN_H +#define _CEF_TYPES_WIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 +#include +#include "cef_string.h" + +// Class representing window information. +typedef struct _cef_window_info_t +{ + // Standard parameters required by CreateWindowEx() + DWORD m_dwExStyle; + cef_string_t m_windowName; + DWORD m_dwStyle; + int m_x; + int m_y; + int m_nWidth; + int m_nHeight; + HWND m_hWndParent; + HMENU m_hMenu; + + // Handle for the new browser window. + HWND m_hWnd; +} cef_window_info_t; + +// Class representing print context information. +typedef struct _cef_print_info_t +{ + HDC m_hDC; + RECT m_Rect; + double m_Scale; +} cef_print_info_t; + +// Window handle. +#define cef_window_handle_t HWND +#endif // _WIN32 + +#ifdef __cplusplus +} +#endif + +#endif // _CEF_TYPES_WIN_H diff --git a/include/cef_win.h b/include/cef_win.h index 40aed640a..9bac209da 100644 --- a/include/cef_win.h +++ b/include/cef_win.h @@ -33,6 +33,7 @@ #ifdef _WIN32 #include +#include "cef_types_win.h" // Atomic increment and decrement. #define CefAtomicIncrement(p) InterlockedIncrement(p) @@ -64,12 +65,29 @@ public: }; // Class representing window information. -class CefWindowInfo +class CefWindowInfo : public cef_window_info_t { public: CefWindowInfo() + { + Init(); + } + ~CefWindowInfo() + { + if(m_windowName) + cef_string_free(m_windowName); + } + + CefWindowInfo(const cef_window_info_t& r) + { + Init(); + *this = r; + } + + void Init() { m_dwExStyle = 0; + m_windowName = NULL; m_dwStyle = 0; m_x = 0; m_y = 0; @@ -79,19 +97,16 @@ public: m_hMenu = 0; m_hWnd = NULL; } - ~CefWindowInfo() - { - } - CefWindowInfo(const CefWindowInfo& r) - { - *this = r; - } - - CefWindowInfo& operator=(const CefWindowInfo& r) + CefWindowInfo& operator=(const cef_window_info_t& r) { m_dwExStyle = r.m_dwExStyle; - m_windowName = r.m_windowName; + if(m_windowName) + cef_string_free(m_windowName); + if(r.m_windowName) + m_windowName = cef_string_alloc(r.m_windowName); + else + m_windowName = NULL; m_dwStyle = r.m_dwStyle; m_x = r.m_x; m_y = r.m_y; @@ -100,7 +115,6 @@ public: m_hWndParent = r.m_hWndParent; m_hMenu = r.m_hMenu; m_hWnd = r.m_hWnd; - m_ClientInfo = r.m_ClientInfo; return *this; } @@ -123,47 +137,42 @@ public: m_y = CW_USEDEFAULT; m_nWidth = CW_USEDEFAULT; m_nHeight = CW_USEDEFAULT; - m_windowName = windowName; + + if(m_windowName) + cef_string_free(m_windowName); + if(windowName) + m_windowName = cef_string_alloc(windowName); + else + m_windowName = NULL; } - - // Standard parameters required by CreateWindowEx() - DWORD m_dwExStyle; - std::wstring m_windowName; - DWORD m_dwStyle; - int m_x; - int m_y; - int m_nWidth; - int m_nHeight; - HWND m_hWndParent; - HMENU m_hMenu; - - // Handle for the new browser window. - HWND m_hWnd; - - // A parameter that can be used to store client-specific information. - CefRefPtr m_ClientInfo; }; // Class representing print context information. -class CefPrintInfo +class CefPrintInfo : public cef_print_info_t { public: CefPrintInfo() { - m_hDC = NULL; - m_Rect.left = m_Rect.right = m_Rect.top = m_Rect.bottom = 0; - m_Scale = 0; + Init(); } ~CefPrintInfo() { } - CefPrintInfo(const CefPrintInfo& r) + CefPrintInfo(const cef_print_info_t& r) { + Init(); *this = r; } - CefPrintInfo& operator=(const CefPrintInfo& r) + void Init() + { + m_hDC = NULL; + m_Rect.left = m_Rect.right = m_Rect.top = m_Rect.bottom = 0; + m_Scale = 0; + } + + CefPrintInfo& operator=(const cef_print_info_t& r) { m_hDC = r.m_hDC; m_Rect.left = r.m_Rect.left; @@ -173,14 +182,10 @@ public: m_Scale = r.m_Scale; return *this; } - - HDC m_hDC; - RECT m_Rect; - double m_Scale; }; // Window handle. -#define CefWindowHandle HWND +#define CefWindowHandle cef_window_handle_t #endif // _WIN32 #endif // _CEF_WIN_H diff --git a/libcef/browser_impl.cc b/libcef/browser_impl.cc index 3189f4076..104f9aee9 100644 --- a/libcef/browser_impl.cc +++ b/libcef/browser_impl.cc @@ -38,91 +38,91 @@ CefBrowserImpl::~CefBrowserImpl() void CefBrowserImpl::GoBack() { PostTask(FROM_HERE, NewRunnableMethod(this, - &CefBrowserImpl::UIT_HandleAction, CefHandler::ID_NAV_BACK, TF_MAIN)); + &CefBrowserImpl::UIT_HandleAction, MENU_ID_NAV_BACK, TF_MAIN)); } void CefBrowserImpl::GoForward() { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_NAV_FORWARD, TF_MAIN)); + MENU_ID_NAV_FORWARD, TF_MAIN)); } void CefBrowserImpl::Reload() { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_NAV_RELOAD, TF_MAIN)); + MENU_ID_NAV_RELOAD, TF_MAIN)); } void CefBrowserImpl::StopLoad() { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_NAV_STOP, TF_MAIN)); + MENU_ID_NAV_STOP, TF_MAIN)); } void CefBrowserImpl::Undo(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_UNDO, targetFrame)); + MENU_ID_UNDO, targetFrame)); } void CefBrowserImpl::Redo(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_REDO, targetFrame)); + MENU_ID_REDO, targetFrame)); } void CefBrowserImpl::Cut(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_CUT, targetFrame)); + MENU_ID_CUT, targetFrame)); } void CefBrowserImpl::Copy(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_COPY, targetFrame)); + MENU_ID_COPY, targetFrame)); } void CefBrowserImpl::Paste(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_PASTE, targetFrame)); + MENU_ID_PASTE, targetFrame)); } void CefBrowserImpl::Delete(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_DELETE, targetFrame)); + MENU_ID_DELETE, targetFrame)); } void CefBrowserImpl::SelectAll(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_SELECTALL, targetFrame)); + MENU_ID_SELECTALL, targetFrame)); } void CefBrowserImpl::Print(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_PRINT, targetFrame)); + MENU_ID_PRINT, targetFrame)); } void CefBrowserImpl::ViewSource(TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, &CefBrowserImpl::UIT_HandleAction, - CefHandler::ID_VIEWSOURCE, targetFrame)); + MENU_ID_VIEWSOURCE, targetFrame)); } void CefBrowserImpl::LoadRequest(CefRefPtr request) { @@ -154,13 +154,13 @@ void CefBrowserImpl::LoadStream(CefRefPtr stream, &CefBrowserImpl::UIT_LoadHTMLForStreamRef, stream.get(), url)); } -void CefBrowserImpl::ExecuteJavaScript(const std::wstring& js_code, - const std::wstring& script_url, - int start_line, +void CefBrowserImpl::ExecuteJavaScript(const std::wstring& jsCode, + const std::wstring& scriptUrl, + int startLine, TargetFrame targetFrame) { PostTask(FROM_HERE, NewRunnableMethod(this, - &CefBrowserImpl::UIT_ExecuteJavaScript, js_code, script_url, start_line, + &CefBrowserImpl::UIT_ExecuteJavaScript, jsCode, scriptUrl, startLine, targetFrame)); } @@ -267,7 +267,7 @@ bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup, // or cancel the window creation. CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo, popup, handler, newUrl); - if(rv == CefHandler::RV_HANDLED) + if(rv == RV_HANDLED) return false; } @@ -434,7 +434,7 @@ CefRefPtr CefBrowserImpl::UIT_CreatePopupWindow(const std::wstri // or cancel the window creation. CefHandler::RetVal rv = handler_->HandleBeforeCreated(this, info, true, handler, newUrl); - if(rv == CefHandler::RV_HANDLED) + if(rv == RV_HANDLED) return NULL; } @@ -465,43 +465,43 @@ void CefBrowserImpl::UIT_HandleAction(CefHandler::MenuId menuId, switch(menuId) { - case CefHandler::ID_NAV_BACK: + case MENU_ID_NAV_BACK: UIT_GoBackOrForward(-1); break; - case CefHandler::ID_NAV_FORWARD: + case MENU_ID_NAV_FORWARD: UIT_GoBackOrForward(1); break; - case CefHandler::ID_NAV_RELOAD: + case MENU_ID_NAV_RELOAD: UIT_Reload(); break; - case CefHandler::ID_NAV_STOP: + case MENU_ID_NAV_STOP: UIT_GetWebView()->StopLoading(); break; - case CefHandler::ID_UNDO: + case MENU_ID_UNDO: frame->Undo(); break; - case CefHandler::ID_REDO: + case MENU_ID_REDO: frame->Redo(); break; - case CefHandler::ID_CUT: + case MENU_ID_CUT: frame->Cut(); break; - case CefHandler::ID_COPY: + case MENU_ID_COPY: frame->Copy(); break; - case CefHandler::ID_PASTE: + case MENU_ID_PASTE: frame->Paste(); break; - case CefHandler::ID_DELETE: + case MENU_ID_DELETE: frame->Delete(); break; - case CefHandler::ID_SELECTALL: + case MENU_ID_SELECTALL: frame->SelectAll(); break; - case CefHandler::ID_PRINT: + case MENU_ID_PRINT: UIT_PrintPages(frame); break; - case CefHandler::ID_VIEWSOURCE: + case MENU_ID_VIEWSOURCE: UIT_ViewDocumentString(frame); break; } diff --git a/libcef/browser_impl.h b/libcef/browser_impl.h index 381acd1dd..f0b898205 100644 --- a/libcef/browser_impl.h +++ b/libcef/browser_impl.h @@ -58,9 +58,9 @@ public: const std::wstring& url); virtual void LoadStream(CefRefPtr stream, const std::wstring& url); - virtual void ExecuteJavaScript(const std::wstring& js_code, - const std::wstring& script_url, - int start_line, TargetFrame targetFrame); + virtual void ExecuteJavaScript(const std::wstring& jsCode, + const std::wstring& scriptUrl, + int startLine, TargetFrame targetFrame); virtual bool AddJSHandler(const std::wstring& classname, CefRefPtr handler); virtual bool HasJSHandler(const std::wstring& classname); diff --git a/libcef/browser_impl_win.cc b/libcef/browser_impl_win.cc index 8bdf2e9f9..97c006043 100644 --- a/libcef/browser_impl_win.cc +++ b/libcef/browser_impl_win.cc @@ -261,7 +261,7 @@ void CefBrowserImpl::UIT_CreateBrowser() // Create the new browser window window_info_.m_hWnd = CreateWindowEx(window_info_.m_dwExStyle, GetWndClass(), - window_info_.m_windowName.c_str(), window_info_.m_dwStyle, + window_info_.m_windowName, window_info_.m_dwStyle, window_info_.m_x, window_info_.m_y, window_info_.m_nWidth, window_info_.m_nHeight, window_info_.m_hWndParent, window_info_.m_hMenu, _Context->GetInstanceHandle(), NULL); @@ -654,7 +654,7 @@ void CefBrowserImpl::UIT_PrintPage(int page_number, WebFrame* frame, url, title, page_number, total_pages, topLeft, topCenter, topRight, bottomLeft, bottomCenter, bottomRight); - if(rv != CefHandler::RV_HANDLED) { + if(rv != RV_HANDLED) { // Draw handler-defined headers and/or footers. LOGFONT lf; memset(&lf, 0, sizeof(lf)); diff --git a/libcef/browser_resource_loader_bridge.cc b/libcef/browser_resource_loader_bridge.cc index b3bb38257..afb98afc5 100644 --- a/libcef/browser_resource_loader_bridge.cc +++ b/libcef/browser_resource_loader_bridge.cc @@ -231,7 +231,7 @@ class RequestProxy : public URLRequest::Delegate, CefHandler::RetVal rv = handler->HandleBeforeResourceLoad( browser_, request, redirectUrl, resourceStream, mimeType, loadFlags); - if(rv == CefHandler::RV_HANDLED) { + if(rv == RV_HANDLED) { // cancel the resource load handled = true; OnCompletedRequest(URLRequestStatus(URLRequestStatus::CANCELED, 0)); diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 6cdf97373..00e97d2ea 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -139,7 +139,7 @@ WindowOpenDisposition BrowserWebViewDelegate::DispositionForNavigationAction( // Notify the handler of a browse request CefHandler::RetVal rv = handler->HandleBeforeBrowse(browser_, req, (CefHandler::NavType)type, is_redirect); - if(rv == CefHandler::RV_HANDLED) + if(rv == RV_HANDLED) return IGNORE_ACTION; } @@ -226,7 +226,7 @@ void BrowserWebViewDelegate::DidFailProvisionalLoadWithError( CefHandler::RetVal rv = handler->HandleLoadError(browser_, static_cast(error.GetErrorCode()), UTF8ToWide(error.GetFailedURL().spec()), error_str); - if(rv == CefHandler::RV_HANDLED && !error_str.empty()) + if(rv == RV_HANDLED && !error_str.empty()) error_text = WideToUTF8(error_str); } else { error_text = StringPrintf("Error loading url: %d", error.GetErrorCode()); @@ -313,22 +313,22 @@ void BrowserWebViewDelegate::AddMessageToConsole(WebView* webview, void BrowserWebViewDelegate::RunJavaScriptAlert(WebView* webview, const std::wstring& message) { - CefHandler::RetVal rv = CefHandler::RV_CONTINUE; + CefHandler::RetVal rv = RV_CONTINUE; CefRefPtr handler = browser_->GetHandler(); if(handler.get()) rv = handler->HandleJSAlert(browser_, message); - if(rv != CefHandler::RV_HANDLED) + if(rv != RV_HANDLED) ShowJavaScriptAlert(webview, message); } bool BrowserWebViewDelegate::RunJavaScriptConfirm(WebView* webview, const std::wstring& message) { - CefHandler::RetVal rv = CefHandler::RV_CONTINUE; + CefHandler::RetVal rv = RV_CONTINUE; bool retval = false; CefRefPtr handler = browser_->GetHandler(); if(handler.get()) rv = handler->HandleJSConfirm(browser_, message, retval); - if(rv != CefHandler::RV_HANDLED) + if(rv != RV_HANDLED) retval = ShowJavaScriptConfirm(webview, message); return retval; } @@ -336,14 +336,14 @@ bool BrowserWebViewDelegate::RunJavaScriptConfirm(WebView* webview, bool BrowserWebViewDelegate::RunJavaScriptPrompt(WebView* webview, const std::wstring& message, const std::wstring& default_value, std::wstring* result) { - CefHandler::RetVal rv = CefHandler::RV_CONTINUE; + CefHandler::RetVal rv = RV_CONTINUE; bool retval = false; CefRefPtr handler = browser_->GetHandler(); if(handler.get()) { rv = handler->HandleJSPrompt(browser_, message, default_value, retval, *result); } - if(rv != CefHandler::RV_HANDLED) + if(rv != RV_HANDLED) retval = ShowJavaScriptPrompt(webview, message, default_value, result); return retval; } diff --git a/libcef/browser_webview_delegate_win.cc b/libcef/browser_webview_delegate_win.cc index db22fe855..cc3b86642 100644 --- a/libcef/browser_webview_delegate_win.cc +++ b/libcef/browser_webview_delegate_win.cc @@ -250,65 +250,73 @@ void BrowserWebViewDelegate::ShowContextMenu(WebView* webview, MessageLoop::current()->SetNestableTasksAllowed(true); if(browser_->UIT_CanGoBack()) - edit_flags |= CefHandler::CAN_GO_BACK; + edit_flags |= MENU_CAN_GO_BACK; if(browser_->UIT_CanGoForward()) - edit_flags |= CefHandler::CAN_GO_FORWARD; + edit_flags |= MENU_CAN_GO_FORWARD; CefRefPtr handler = browser_->GetHandler(); if(handler.get()) { // Gather menu information CefHandler::MenuInfo menuInfo; + std::wstring linkstr, imagestr, pagestr, framestr, securitystr; + + linkstr = UTF8ToWide(link_url.spec().c_str()); + imagestr = UTF8ToWide(image_url.spec().c_str()); + pagestr = UTF8ToWide(page_url.spec().c_str()); + framestr = UTF8ToWide(frame_url.spec().c_str()); + securitystr = UTF8ToWide(security_info); + menuInfo.typeFlags = in_node.type; menuInfo.x = screen_pt.x; menuInfo.y = screen_pt.y; - menuInfo.linkUrl = UTF8ToWide(link_url.spec().c_str()).c_str(); - menuInfo.imageUrl = UTF8ToWide(image_url.spec().c_str()).c_str(); - menuInfo.pageUrl = UTF8ToWide(page_url.spec().c_str()).c_str(); - menuInfo.frameUrl = UTF8ToWide(frame_url.spec().c_str()).c_str(); - menuInfo.selectionText = selection_text; - menuInfo.misspelledWord = misspelled_word; + menuInfo.linkUrl = linkstr.c_str(); + menuInfo.imageUrl = imagestr.c_str(); + menuInfo.pageUrl = pagestr.c_str(); + menuInfo.frameUrl = framestr.c_str(); + menuInfo.selectionText = selection_text.c_str(); + menuInfo.misspelledWord = misspelled_word.c_str(); menuInfo.editFlags = edit_flags; - menuInfo.securityInfo = security_info; + menuInfo.securityInfo = securitystr.c_str(); // Notify the handler that a context menu is requested CefHandler::RetVal rv = handler->HandleBeforeMenu(browser_, menuInfo); - if(rv == CefHandler::RV_HANDLED) + if(rv == RV_HANDLED) goto end; } // Build the correct default context menu if (in_node.type & ContextNode::EDITABLE) { menu = CreatePopupMenu(); - AddMenuItem(browser_, menu, -1, CefHandler::ID_UNDO, L"Undo", + AddMenuItem(browser_, menu, -1, MENU_ID_UNDO, L"Undo", !!(edit_flags & ContextNode::CAN_UNDO), label_list); - AddMenuItem(browser_, menu, -1, CefHandler::ID_REDO, L"Redo", + AddMenuItem(browser_, menu, -1, MENU_ID_REDO, L"Redo", !!(edit_flags & ContextNode::CAN_REDO), label_list); AddMenuSeparator(menu, -1); - AddMenuItem(browser_, menu, -1, CefHandler::ID_CUT, L"Cut", + AddMenuItem(browser_, menu, -1, MENU_ID_CUT, L"Cut", !!(edit_flags & ContextNode::CAN_CUT), label_list); - AddMenuItem(browser_, menu, -1, CefHandler::ID_COPY, L"Copy", + AddMenuItem(browser_, menu, -1, MENU_ID_COPY, L"Copy", !!(edit_flags & ContextNode::CAN_COPY), label_list); - AddMenuItem(browser_, menu, -1, CefHandler::ID_PASTE, L"Paste", + AddMenuItem(browser_, menu, -1, MENU_ID_PASTE, L"Paste", !!(edit_flags & ContextNode::CAN_PASTE), label_list); - AddMenuItem(browser_, menu, -1, CefHandler::ID_DELETE, L"Delete", + AddMenuItem(browser_, menu, -1, MENU_ID_DELETE, L"Delete", !!(edit_flags & ContextNode::CAN_DELETE), label_list); AddMenuSeparator(menu, -1); - AddMenuItem(browser_, menu, -1, CefHandler::ID_SELECTALL, L"Select All", - !!(edit_flags & ContextNode::CAN_SELECT_ALL), label_list); + AddMenuItem(browser_, menu, -1, MENU_ID_SELECTALL, L"Select All", + !!(edit_flags & MENU_CAN_SELECT_ALL), label_list); } else if(in_node.type & ContextNode::SELECTION) { menu = CreatePopupMenu(); - AddMenuItem(browser_, menu, -1, CefHandler::ID_COPY, L"Copy", + AddMenuItem(browser_, menu, -1, MENU_ID_COPY, L"Copy", !!(edit_flags & ContextNode::CAN_COPY), label_list); } else if(in_node.type & (ContextNode::PAGE | ContextNode::FRAME)) { menu = CreatePopupMenu(); - AddMenuItem(browser_, menu, -1, CefHandler::ID_NAV_BACK, L"Back", + AddMenuItem(browser_, menu, -1, MENU_ID_NAV_BACK, L"Back", browser_->UIT_CanGoBack(), label_list); - AddMenuItem(browser_, menu, -1, CefHandler::ID_NAV_FORWARD, L"Forward", + AddMenuItem(browser_, menu, -1, MENU_ID_NAV_FORWARD, L"Forward", browser_->UIT_CanGoForward(), label_list); AddMenuSeparator(menu, -1); - AddMenuItem(browser_, menu, -1, CefHandler::ID_PRINT, L"Print", + AddMenuItem(browser_, menu, -1, MENU_ID_PRINT, L"Print", true, label_list); - AddMenuItem(browser_, menu, -1, CefHandler::ID_VIEWSOURCE, L"View Source", + AddMenuItem(browser_, menu, -1, MENU_ID_VIEWSOURCE, L"View Source", true, label_list); } @@ -325,12 +333,12 @@ void BrowserWebViewDelegate::ShowContextMenu(WebView* webview, if(handler.get()) { // Ask the handler if it wants to handle the action CefHandler::RetVal rv = handler->HandleMenuAction(browser_, menuId); - handled = (rv == CefHandler::RV_HANDLED); + handled = (rv == RV_HANDLED); } if(!handled) { // Execute the action - browser_->UIT_HandleAction(menuId, CefBrowser::TF_FOCUSED); + browser_->UIT_HandleAction(menuId, TF_FOCUSED); } } } diff --git a/libcef/libcef.vcproj b/libcef/libcef.vcproj index 9159ec76e..67b968f1a 100644 --- a/libcef/libcef.vcproj +++ b/libcef/libcef.vcproj @@ -51,6 +51,7 @@ /> + + @@ -192,6 +198,14 @@ RelativePath="..\include\cef_ptr.h" > + + + + diff --git a/libcef/request_impl.cc b/libcef/request_impl.cc index 80f641423..f44e7b726 100644 --- a/libcef/request_impl.cc +++ b/libcef/request_impl.cc @@ -47,10 +47,10 @@ std::wstring CefRequestImpl::GetFrame() return frame; } -void CefRequestImpl::SetFrame(const std::wstring& url) +void CefRequestImpl::SetFrame(const std::wstring& frame) { Lock(); - frame_ = url; + frame_ = frame; Unlock(); } @@ -258,7 +258,7 @@ CefRefPtr CefPostDataElement::CreatePostDataElement() CefPostDataElementImpl::CefPostDataElementImpl() { - type_ = TYPE_EMPTY; + type_ = PDE_TYPE_EMPTY; } CefPostDataElementImpl::~CefPostDataElementImpl() @@ -269,11 +269,11 @@ CefPostDataElementImpl::~CefPostDataElementImpl() void CefPostDataElementImpl::SetToEmpty() { Lock(); - if(type_ == TYPE_BYTES) + if(type_ == PDE_TYPE_BYTES) free(data_.bytes.bytes); - else if(type_ == TYPE_FILE) + else if(type_ == PDE_TYPE_FILE) free(data_.filename); - type_ = TYPE_EMPTY; + type_ = PDE_TYPE_EMPTY; Unlock(); } @@ -295,7 +295,7 @@ void CefPostDataElementImpl::SetToFile(const std::wstring& fileName) data[size] = 0; // Assign the new data - type_ = TYPE_FILE; + type_ = PDE_TYPE_FILE; data_.filename = data; Unlock(); } @@ -314,7 +314,7 @@ void CefPostDataElementImpl::SetToBytes(size_t size, const void* bytes) memcpy(data, bytes, size); - type_ = TYPE_BYTES; + type_ = PDE_TYPE_BYTES; data_.bytes.bytes = data; data_.bytes.size = size; Unlock(); @@ -331,9 +331,9 @@ CefPostDataElement::Type CefPostDataElementImpl::GetType() std::wstring CefPostDataElementImpl::GetFile() { Lock(); - DCHECK(type_ == TYPE_FILE); + DCHECK(type_ == PDE_TYPE_FILE); std::wstring filename; - if(type_ == TYPE_FILE) + if(type_ == PDE_TYPE_FILE) filename = data_.filename; Unlock(); return filename; @@ -342,9 +342,9 @@ std::wstring CefPostDataElementImpl::GetFile() size_t CefPostDataElementImpl::GetBytesCount() { Lock(); - DCHECK(type_ == TYPE_BYTES); + DCHECK(type_ == PDE_TYPE_BYTES); size_t size = 0; - if(type_ == TYPE_BYTES) + if(type_ == PDE_TYPE_BYTES) size = data_.bytes.size; Unlock(); return size; @@ -353,9 +353,9 @@ size_t CefPostDataElementImpl::GetBytesCount() size_t CefPostDataElementImpl::GetBytes(size_t size, void *bytes) { Lock(); - DCHECK(type_ == TYPE_BYTES); + DCHECK(type_ == PDE_TYPE_BYTES); size_t rv = 0; - if(type_ == TYPE_BYTES) { + if(type_ == PDE_TYPE_BYTES) { rv = (size < data_.bytes.size ? size : data_.bytes.size); memcpy(bytes, data_.bytes.bytes, rv); } @@ -385,9 +385,9 @@ void CefPostDataElementImpl::Get(net::UploadData::Element& element) { Lock(); - if(type_ == TYPE_BYTES) { + if(type_ == PDE_TYPE_BYTES) { element.SetToBytes(static_cast(data_.bytes.bytes), data_.bytes.size); - } else if(type_ == TYPE_FILE) { + } else if(type_ == PDE_TYPE_FILE) { element.SetToFilePath(data_.filename); } else { NOTREACHED(); diff --git a/libcef/request_impl.h b/libcef/request_impl.h index 6b648ac8d..babf76a52 100644 --- a/libcef/request_impl.h +++ b/libcef/request_impl.h @@ -20,7 +20,7 @@ public: virtual std::wstring GetURL(); virtual void SetURL(const std::wstring& url); virtual std::wstring GetFrame(); - virtual void SetFrame(const std::wstring& url); + virtual void SetFrame(const std::wstring& frame); virtual std::wstring GetMethod(); virtual void SetMethod(const std::wstring& method); virtual CefRefPtr GetPostData(); diff --git a/libcef/variant_impl.cc b/libcef/variant_impl.cc index 2a7dc973f..41bc7e642 100644 --- a/libcef/variant_impl.cc +++ b/libcef/variant_impl.cc @@ -62,23 +62,23 @@ CefVariantImpl::~CefVariantImpl() CefVariant::Type CefVariantImpl::GetType() { - CefVariant::Type type = TYPE_NULL; + CefVariant::Type type = VARIANT_TYPE_NULL; Lock(); // determine the data type of the underlying NPVariant value switch (variant_.type) { case NPVariantType_Bool: - type = TYPE_BOOL; + type = VARIANT_TYPE_BOOL; break; case NPVariantType_Int32: - type = TYPE_INT; + type = VARIANT_TYPE_INT; break; case NPVariantType_Double: - type = TYPE_DOUBLE; + type = VARIANT_TYPE_DOUBLE; break; case NPVariantType_String: - type = TYPE_STRING; + type = VARIANT_TYPE_STRING; break; case NPVariantType_Object: { @@ -87,16 +87,16 @@ CefVariant::Type CefVariantImpl::GetType() if(_NPN_ArrayObjectToVectorTypeHint(variant_.value.objectValue, nptype)) { switch(nptype) { case NPVariantType_Bool: - type = TYPE_BOOL_ARRAY; + type = VARIANT_TYPE_BOOL_ARRAY; break; case NPVariantType_Int32: - type = TYPE_INT_ARRAY; + type = VARIANT_TYPE_INT_ARRAY; break; case NPVariantType_Double: - type = TYPE_DOUBLE_ARRAY; + type = VARIANT_TYPE_DOUBLE_ARRAY; break; case NPVariantType_String: - type = TYPE_STRING_ARRAY; + type = VARIANT_TYPE_STRING_ARRAY; break; } } @@ -289,6 +289,15 @@ bool CefVariantImpl::GetStringArray(std::vector& val) return rv; } +int CefVariantImpl::GetArraySize() +{ + Lock(); + DCHECK(variant_.type == NPVariantType_Object); + int rv = _NPN_ArrayObjectGetVectorSize(variant_.value.objectValue); + Unlock(); + return rv; +} + void CefVariantImpl::CopyToNPVariant(NPVariant* result) { Lock(); @@ -358,4 +367,4 @@ void CefVariantImpl::Set(const NPVariant& val) break; } Unlock(); -} \ No newline at end of file +} diff --git a/libcef/variant_impl.h b/libcef/variant_impl.h index a1bd8a41f..ae315ebd2 100644 --- a/libcef/variant_impl.h +++ b/libcef/variant_impl.h @@ -39,6 +39,7 @@ public: virtual bool GetIntArray(std::vector& val); virtual bool GetDoubleArray(std::vector& val); virtual bool GetStringArray(std::vector& val); + virtual int GetArraySize(); // These three methods all perform deep copies of any string data. This // allows the local CefVariantImpl to be released by the destructor without diff --git a/libcef/variant_np_util.cc b/libcef/variant_np_util.cc index 3ddc061e3..2d02cb59d 100644 --- a/libcef/variant_np_util.cc +++ b/libcef/variant_np_util.cc @@ -176,6 +176,19 @@ bool _NPN_ArrayObjectToBooleanVector(NPObject* npobject, return true; } +int _NPN_ArrayObjectGetVectorSize(NPObject* npobject) +{ + if (npobject == NULL || npobject->_class != NPScriptObjectClass) + return -1; + + V8NPObject *object = reinterpret_cast(npobject); + if (!object->v8_object->IsArray()) + return -1; + + v8::Handle array = v8::Handle::Cast(object->v8_object); + return array->Length(); +} + bool _NPN_ArrayObjectToVectorTypeHint(NPObject* npobject, NPVariantType &typehint) { diff --git a/libcef/variant_np_util.h b/libcef/variant_np_util.h index e621deff2..c443ad70f 100644 --- a/libcef/variant_np_util.h +++ b/libcef/variant_np_util.h @@ -44,6 +44,10 @@ bool _NPN_ArrayObjectToDoubleVector(NPObject* npobject, bool _NPN_ArrayObjectToBooleanVector(NPObject* npobject, std::vector& vec); +// Return the number of elements in a JavaScript Array. Returns -1 if the +// JavaScript object does not represent an array. +int _NPN_ArrayObjectGetVectorSize(NPObject* npobject); + // Evaluate the types of values contained in an NPObject representing a // JavaScript Array and suggest the most restrictive type that can safely store // all of the Array values. For instance, if the Array contains all Int32 diff --git a/libcef_dll/cef_string.c b/libcef_dll/cef_string.c new file mode 100644 index 000000000..387ed98b2 --- /dev/null +++ b/libcef_dll/cef_string.c @@ -0,0 +1,163 @@ +// Copyright (c) 2009 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 "cef_string.h" +#include +#include +#include + +typedef unsigned long dword_t; + +CEF_EXPORT size_t cef_string_length(cef_string_t str) +{ + dword_t* ptr; + + if(!str) + return 0; + + // The string length, in bytes, is placed in a dword_t immediately proceeding + // the string value. + ptr = (dword_t*)str; + ptr--; + + return (size_t)(*ptr / sizeof(wchar_t)); +} + +CEF_EXPORT cef_string_t cef_string_alloc(const wchar_t* str) +{ + if(!str) + return NULL; + + return cef_string_alloc_length(str, wcslen(str)); +} + +CEF_EXPORT cef_string_t cef_string_alloc_length(const wchar_t* str, + size_t len) +{ + dword_t size, *ptr; + wchar_t* newstr; + + // Check that the size can fit in a dword_t. + if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t)) + return NULL; + + // Get the size of the string in bytes. + size = sizeof(wchar_t) * len; + + // Allocate the new buffer including space for the proceeding dword_t size + // value and the terminating nul. + ptr = (dword_t*)malloc(sizeof(dword_t) + size + sizeof(wchar_t)); + if(!ptr) + return NULL; + + // Set the size as the first value in the newly allocated memory and + // increment to the string location. + *ptr = size; + ptr++; + + if(str != NULL) + { + // Copy the string to the buffer. + memcpy(ptr, str, size); + } + else + { + // Initialize the string to zeros. + memset(ptr, 0, size); + } + + newstr = (wchar_t*)ptr; + + // Nul-terminate the string. + newstr[len] = '\0'; + + return (cef_string_t)newstr; +} + +CEF_EXPORT int cef_string_realloc(cef_string_t* oldstr, const wchar_t* newstr) +{ + if(!oldstr) + return 0; + + // Free the old string. + cef_string_free(*oldstr); + + // Copy the new string. + *oldstr = cef_string_alloc(newstr); + + return 1; +} + +CEF_EXPORT int cef_string_realloc_length(cef_string_t* oldstr, + const wchar_t* newstr, + size_t len) +{ + if(!oldstr) + return 0; + + // Check that the size can fit in a dword_t. + if(len >= (UINT_MAX - sizeof(wchar_t) - sizeof(dword_t)) / sizeof(wchar_t)) + return 0; + + if(*oldstr) + { + dword_t newsize, *oldptr, *newptr; + + // Get the new size of the string in bytes. + newsize = sizeof(wchar_t) * len; + + // Adjust the pointer to account for the dword_t immediately proceeding the + // string value. + oldptr = (dword_t*)*oldstr; + oldptr--; + + // Re-allocate the buffer including space for the proceeding dword_t size + // value and the terminating nul. + newptr = (dword_t*)realloc( + oldptr, sizeof(dword_t) + newsize + sizeof(wchar_t)); + if(!newptr) + return 0; + + // Set the size as the first value in the newly allocated memory and + // increment to the string location. + *newptr = newsize; + newptr++; + + // Set the string pointer to the beginning on the string in the newly + // allocated memory. + *oldstr = (cef_string_t)newptr; + + if(newstr) + { + // Copy the new string value. Use of memmove() ensures that any + // overlapping region in the old string will be copied before being + // overwritten. + memmove(*oldstr, newstr, newsize); + + // Nul-terminate the string. + *oldstr[len] = '\0'; + } + } + else + { + // Allocate the string. + *oldstr = cef_string_alloc_length(newstr, len); + } + + return 1; +} + +CEF_EXPORT void cef_string_free(cef_string_t str) +{ + dword_t* ptr; + + if(!str) + return; + + // The size is placed in a dword_t immediately proceeding the string value. + ptr = (dword_t*)str; + ptr--; + + free(ptr); +} diff --git a/libcef_dll/cef_string_map.cc b/libcef_dll/cef_string_map.cc new file mode 100644 index 000000000..8f1c5cea7 --- /dev/null +++ b/libcef_dll/cef_string_map.cc @@ -0,0 +1,93 @@ +// Copyright (c) 2009 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 "precompiled_libcef.h" +#include "cef_string_map.h" +#include +#include "base/logging.h" + + +typedef std::map StringMap; + +CEF_EXPORT cef_string_map_t cef_string_map_alloc() +{ + return new StringMap; +} + +CEF_EXPORT int cef_string_map_size(cef_string_map_t map) +{ + DCHECK(map); + StringMap* impl = (StringMap*)map; + return impl->size(); +} + +CEF_EXPORT cef_string_t cef_string_map_find(cef_string_map_t map, + const wchar_t* key) +{ + DCHECK(map); + StringMap* impl = (StringMap*)map; + std::wstring keystr; + if(key) + keystr = key; + StringMap::const_iterator it = impl->find(keystr); + if(it == impl->end()) + return NULL; + return cef_string_alloc(it->second.c_str()); +} + +CEF_EXPORT cef_string_t cef_string_map_key(cef_string_map_t map, int index) +{ + DCHECK(map); + StringMap* impl = (StringMap*)map; + DCHECK(index >= 0 && index < (int)impl->size()); + if(index < 0 || index >= (int)impl->size()) + return NULL; + StringMap::const_iterator it = impl->begin(); + for(int ct = 0; it != impl->end(); ++it, ct++) { + if(ct == index) + return cef_string_alloc(it->first.c_str()); + } + return NULL; +} + +CEF_EXPORT cef_string_t cef_string_map_value(cef_string_map_t map, int index) +{ + DCHECK(map); + StringMap* impl = (StringMap*)map; + DCHECK(index >= 0 && index < (int)impl->size()); + if(index < 0 || index >= (int)impl->size()) + return NULL; + StringMap::const_iterator it = impl->begin(); + for(int ct = 0; it != impl->end(); ++it, ct++) { + if(ct == index) + return cef_string_alloc(it->second.c_str()); + } + return NULL; +} + +CEF_EXPORT void cef_string_map_append(cef_string_map_t map, const wchar_t* key, + const wchar_t* value) +{ + DCHECK(map); + StringMap* impl = (StringMap*)map; + std::wstring keystr, valstr; + if(key) + keystr = key; + if(value) + valstr = value; + impl->insert(std::pair(keystr, valstr)); +} + +CEF_EXPORT void cef_string_map_clear(cef_string_map_t map) +{ + DCHECK(map); + StringMap* impl = (StringMap*)map; + impl->clear(); +} + +CEF_EXPORT void cef_string_map_free(cef_string_map_t map) +{ + DCHECK(map); + delete (StringMap*)map; +} diff --git a/libcef_dll/cpptoc/browser_cpptoc.cc b/libcef_dll/cpptoc/browser_cpptoc.cc new file mode 100644 index 000000000..f514cae75 --- /dev/null +++ b/libcef_dll/cpptoc/browser_cpptoc.cc @@ -0,0 +1,497 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/browser_cpptoc.h" +#include "cpptoc/request_cpptoc.h" +#include "cpptoc/stream_cpptoc.h" +#include "ctocpp/handler_ctocpp.h" +#include "ctocpp/jshandler_ctocpp.h" +#include "base/logging.h" + +int CEF_CALLBACK browser_can_go_back(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return 0; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + return impl->class_->GetClass()->CanGoBack(); +} + +void CEF_CALLBACK browser_go_back(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->GoBack(); +} + +int CEF_CALLBACK browser_can_go_forward(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return 0; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + return impl->class_->GetClass()->CanGoForward(); +} + +void CEF_CALLBACK browser_go_forward(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->GoForward(); +} + +void CEF_CALLBACK browser_reload(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Reload(); +} + +void CEF_CALLBACK browser_stop_load(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->StopLoad(); +} + +void CEF_CALLBACK browser_undo(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Undo(targetFrame); +} + +void CEF_CALLBACK browser_redo(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Redo(targetFrame); +} + +void CEF_CALLBACK browser_cut(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Cut(targetFrame); +} + +void CEF_CALLBACK browser_copy(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Copy(targetFrame); +} + +void CEF_CALLBACK browser_paste(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Paste(targetFrame); +} + +void CEF_CALLBACK browser_delete(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Delete(targetFrame); +} + +void CEF_CALLBACK browser_select_all(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->SelectAll(targetFrame); +} + +void CEF_CALLBACK browser_print(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->Print(targetFrame); +} + +void CEF_CALLBACK browser_view_source(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + impl->class_->GetClass()->ViewSource(targetFrame); +} + +cef_string_t CEF_CALLBACK browser_get_source(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return NULL; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring sourceStr = impl->class_->GetClass()->GetSource(targetFrame); + if(sourceStr.empty()) + return NULL; + return cef_string_alloc(sourceStr.c_str()); +} + +cef_string_t CEF_CALLBACK browser_get_text(cef_browser_t* browser, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return NULL; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring textStr = impl->class_->GetClass()->GetText(targetFrame); + if(textStr.empty()) + return NULL; + return cef_string_alloc(textStr.c_str()); +} + +void CEF_CALLBACK browser_load_request(cef_browser_t* browser, + cef_request_t* request) +{ + DCHECK(browser); + DCHECK(request); + if(!browser || !request) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + CefRequestCppToC::Struct* structPtr = + reinterpret_cast(request); + CefRefPtr requestPtr(structPtr->class_->GetClass()); + structPtr->class_->Release(); + impl->class_->GetClass()->LoadRequest(requestPtr); +} + +void CEF_CALLBACK browser_load_url(cef_browser_t* browser, const wchar_t* url, + const wchar_t* frame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring urlStr, frameStr; + if(url) + urlStr = url; + if(frame) + frameStr = frame; + impl->class_->GetClass()->LoadURL(urlStr, frameStr); +} + +void CEF_CALLBACK browser_load_string(cef_browser_t* browser, + const wchar_t* string, + const wchar_t* url) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring stringStr, urlStr; + if(string) + stringStr = string; + if(url) + urlStr = url; + impl->class_->GetClass()->LoadString(stringStr, urlStr); +} + +void CEF_CALLBACK browser_load_stream(cef_browser_t* browser, + cef_stream_reader_t* stream, + const wchar_t* url) +{ + DCHECK(browser); + DCHECK(stream); + if(!browser || !stream) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + CefStreamReaderCppToC::Struct* structPtr = + reinterpret_cast(stream); + CefRefPtr streamPtr(structPtr->class_->GetClass()); + structPtr->class_->Release(); + + std::wstring urlStr; + if(url) + urlStr = url; + impl->class_->GetClass()->LoadStream(streamPtr, urlStr); +} + +void CEF_CALLBACK browser_execute_javascript(cef_browser_t* browser, + const wchar_t* jsCode, + const wchar_t* scriptUrl, + int startLine, + enum cef_targetframe_t targetFrame) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring jsCodeStr, scriptUrlStr; + if(jsCode) + jsCodeStr = jsCode; + if(scriptUrl) + scriptUrlStr = scriptUrl; + + impl->class_->GetClass()->ExecuteJavaScript(jsCodeStr, scriptUrlStr, + startLine, targetFrame); +} + +int CEF_CALLBACK browser_add_jshandler(cef_browser_t* browser, + const wchar_t* classname, + cef_jshandler_t* handler) +{ + DCHECK(browser); + DCHECK(handler); + if(!browser || !handler) + return 0; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + CefJSHandlerCToCpp* hp = new CefJSHandlerCToCpp(handler); + CefRefPtr handlerPtr(hp); + hp->UnderlyingRelease(); + + std::wstring classnameStr; + if(classname) + classnameStr = classname; + return impl->class_->GetClass()->AddJSHandler(classnameStr, handlerPtr); +} + +int CEF_CALLBACK browser_has_jshandler(cef_browser_t* browser, + const wchar_t* classname) +{ + DCHECK(browser); + if(!browser) + return 0; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring classnameStr; + if(classname) + classnameStr = classname; + return impl->class_->GetClass()->HasJSHandler(classnameStr); +} + +cef_jshandler_t* CEF_CALLBACK browser_get_jshandler(cef_browser_t* browser, + const wchar_t* classname) +{ + DCHECK(browser); + if(!browser) + return NULL; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring classnameStr; + if(classname) + classnameStr = classname; + CefRefPtr handler = + impl->class_->GetClass()->GetJSHandler(classnameStr); + if(handler.get()) { + CefJSHandlerCToCpp* hp = static_cast(handler.get()); + hp->UnderlyingAddRef(); + return hp->GetStruct(); + } + return NULL; +} + +int CEF_CALLBACK browser_remove_jshandler(cef_browser_t* browser, + const wchar_t* classname) +{ + DCHECK(browser); + if(!browser) + return 0; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring classnameStr; + if(classname) + classnameStr = classname; + return impl->class_->GetClass()->RemoveJSHandler(classnameStr); +} + +void CEF_CALLBACK browser_remove_all_jshandlers(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + return impl->class_->GetClass()->RemoveAllJSHandlers(); +} + +cef_window_handle_t CEF_CALLBACK browser_get_window_handle(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return NULL; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + return impl->class_->GetClass()->GetWindowHandle(); +} + +int CEF_CALLBACK browser_is_popup(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return 0; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + return impl->class_->GetClass()->IsPopup(); +} + +cef_handler_t* CEF_CALLBACK browser_get_handler(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return NULL; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + CefRefPtr handler = impl->class_->GetClass()->GetHandler(); + if(handler.get()) { + CefHandlerCToCpp* hp = static_cast(handler.get()); + hp->UnderlyingAddRef(); + return hp->GetStruct(); + } + return NULL; +} + +cef_string_t CEF_CALLBACK browser_get_url(cef_browser_t* browser) +{ + DCHECK(browser); + if(!browser) + return NULL; + + CefBrowserCppToC::Struct* impl = + reinterpret_cast(browser); + + std::wstring urlStr = impl->class_->GetClass()->GetURL(); + if(urlStr.empty()) + return NULL; + return cef_string_alloc(urlStr.c_str()); +} + +CefBrowserCppToC::CefBrowserCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.can_go_back = browser_can_go_back; + struct_.struct_.go_back = browser_go_back; + struct_.struct_.can_go_forward = browser_can_go_forward; + struct_.struct_.go_forward = browser_go_forward; + struct_.struct_.reload = browser_reload; + struct_.struct_.stop_load = browser_stop_load; + struct_.struct_.undo = browser_undo; + struct_.struct_.redo = browser_redo; + struct_.struct_.cut = browser_cut; + struct_.struct_.copy = browser_copy; + struct_.struct_.paste = browser_paste; + struct_.struct_.del = browser_delete; + struct_.struct_.select_all = browser_select_all; + struct_.struct_.print = browser_print; + struct_.struct_.view_source = browser_view_source; + struct_.struct_.get_source = browser_get_source; + struct_.struct_.get_text = browser_get_text; + struct_.struct_.load_request = browser_load_request; + struct_.struct_.load_url = browser_load_url; + struct_.struct_.load_string = browser_load_string; + struct_.struct_.load_stream = browser_load_stream; + struct_.struct_.execute_javascript = browser_execute_javascript; + struct_.struct_.add_jshandler = browser_add_jshandler; + struct_.struct_.has_jshandler = browser_has_jshandler; + struct_.struct_.get_jshandler = browser_get_jshandler; + struct_.struct_.remove_jshandler = browser_remove_jshandler; + struct_.struct_.remove_all_jshandlers = browser_remove_all_jshandlers; + struct_.struct_.get_window_handle = browser_get_window_handle; + struct_.struct_.is_popup = browser_is_popup; + struct_.struct_.get_handler = browser_get_handler; + struct_.struct_.get_url = browser_get_url; +} diff --git a/libcef_dll/cpptoc/browser_cpptoc.h b/libcef_dll/cpptoc/browser_cpptoc.h new file mode 100644 index 000000000..bac843fdd --- /dev/null +++ b/libcef_dll/cpptoc/browser_cpptoc.h @@ -0,0 +1,28 @@ +// Copyright (c) 2009 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 _BROWSER_CPPTOC_H +#define _BROWSER_CPPTOC_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "cpptoc.h" + + +// Wrap a C++ browser class with a C browser structure. +// This class may be instantiated and accessed DLL-side only. +class CefBrowserCppToC : public CefCppToC +{ +public: + CefBrowserCppToC(CefRefPtr cls); + virtual ~CefBrowserCppToC() {} +}; + + +#endif // BUILDING_CEF_SHARED +#endif // _BROWSER_CPPTOC_H diff --git a/libcef_dll/cpptoc/cpptoc.h b/libcef_dll/cpptoc/cpptoc.h new file mode 100644 index 000000000..5a2ec4c1d --- /dev/null +++ b/libcef_dll/cpptoc/cpptoc.h @@ -0,0 +1,92 @@ +// Copyright (c) 2009 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 _CPPTOC_H +#define _CPPTOC_H + +#include "cef.h" +#include "cef_capi.h" +#include "base/logging.h" + + +// Wrap a C++ class with a C structure. +template +class CefCppToC : public CefThreadSafeBase +{ +public: + // Structure representation with pointer to the C++ class. + struct Struct + { + StructName struct_; + CefCppToC* class_; + }; + + CefCppToC(CefRefPtr cls) + : class_(cls) + { + DCHECK(cls.get()); + + struct_.class_ = this; + + // zero the underlying structure and set base members + memset(&struct_.struct_, 0, sizeof(StructName)); + struct_.struct_.base.size = sizeof(StructName); + struct_.struct_.base.add_ref = struct_add_ref; + struct_.struct_.base.release = struct_release; + } + virtual ~CefCppToC() + { + } + + CefRefPtr GetClass() { return class_; } + + // If returning the structure across the DLL boundary you should call + // AddRef() on this CefCppToC object. On the other side of the DLL boundary, + // call UnderlyingRelease() on the wrapping CefCToCpp object. + StructName* GetStruct() { return &struct_.struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapper class. + virtual int AddRef() + { + UnderlyingAddRef(); + return CefThreadSafeBase::AddRef(); + } + virtual int Release() + { + UnderlyingRelease(); + return CefThreadSafeBase::Release(); + } + + // Increment/decrement reference counts on only the underlying class. + int UnderlyingAddRef() { return class_->AddRef(); } + int UnderlyingRelease() { return class_->Release(); } + +private: + static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->AddRef(); + } + + static int CEF_CALLBACK struct_release(struct _cef_base_t* base) + { + DCHECK(base); + if(!base) + return 0; + + Struct* impl = reinterpret_cast(base); + return impl->class_->Release(); + } + +protected: + Struct struct_; + CefRefPtr class_; +}; + +#endif // _CPPTOC_H diff --git a/libcef_dll/cpptoc/handler_cpptoc.cc b/libcef_dll/cpptoc/handler_cpptoc.cc new file mode 100644 index 000000000..408da86bf --- /dev/null +++ b/libcef_dll/cpptoc/handler_cpptoc.cc @@ -0,0 +1,521 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/handler_cpptoc.h" +#include "ctocpp/browser_ctocpp.h" +#include "ctocpp/request_ctocpp.h" +#include "ctocpp/stream_ctocpp.h" +#include "transfer_util.h" +#include "base/logging.h" + + +enum cef_retval_t CEF_CALLBACK handler_handle_before_created( + struct _cef_handler_t* handler, cef_browser_t* parentBrowser, + cef_window_info_t* windowInfo, int popup, + struct _cef_handler_t** newHandler, cef_string_t* url) +{ + DCHECK(handler); + DCHECK(windowInfo); + DCHECK(newHandler && *newHandler); + DCHECK(url); + if(!handler || !windowInfo || !newHandler || !*newHandler || !url) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + // |newHandler| will start off pointing to the current handler. + CefHandlerCppToC::Struct* structPtr + = reinterpret_cast(*newHandler); + + CefWindowInfo wndInfo(*windowInfo); + CefRefPtr browserPtr; + CefRefPtr handlerPtr(structPtr->class_->GetClass()); + structPtr->class_->Release(); + + std::wstring urlStr; + + // |parentBrowser| will be NULL if this is a top-level browser window. + if(parentBrowser) + { + CefBrowserCToCpp* bp = new CefBrowserCToCpp(parentBrowser); + browserPtr = bp; + bp->UnderlyingRelease(); + } + + if(*url) + urlStr = *url; + + enum cef_retval_t rv = impl->class_->GetClass()->HandleBeforeCreated( + browserPtr, wndInfo, popup, handlerPtr, urlStr); + + transfer_string_contents(urlStr, url); + + if(handlerPtr.get() != structPtr->class_->GetClass().get()) + { + // The handler has been changed. + CefHandlerCppToC* hobj = new CefHandlerCppToC(handlerPtr); + hobj->AddRef(); + *newHandler = hobj->GetStruct(); + } + + // WindowInfo may or may not have changed. + *windowInfo = wndInfo; + + return rv; +} + +enum cef_retval_t CEF_CALLBACK handler_handle_after_created( + struct _cef_handler_t* handler, cef_browser_t* browser) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + return impl->class_->GetClass()->HandleAfterCreated(browserPtr); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_address_change( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* url) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring urlStr; + if(url) + urlStr = url; + + return impl->class_->GetClass()->HandleAddressChange(browserPtr, urlStr); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_title_change( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* title) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring titleStr; + if(title) + titleStr = title; + + return impl->class_->GetClass()->HandleTitleChange(browserPtr, titleStr); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_before_browse( + struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_request_t* request, cef_handler_navtype_t navType, + int isRedirect) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(request); + if(!handler || !browser || !request) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + CefRequestCToCpp* rp = new CefRequestCToCpp(request); + CefRefPtr requestPtr(rp); + rp->UnderlyingRelease(); + + return impl->class_->GetClass()->HandleBeforeBrowse(browserPtr, requestPtr, + navType, (isRedirect ? true : false)); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_load_start( + struct _cef_handler_t* handler, cef_browser_t* browser) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + return impl->class_->GetClass()->HandleLoadStart(browserPtr); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_load_end( + struct _cef_handler_t* handler, cef_browser_t* browser) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + return impl->class_->GetClass()->HandleLoadEnd(browserPtr); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_load_error( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_handler_errorcode_t errorCode, const wchar_t* failedUrl, + cef_string_t* errorText) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(errorText); + if(!handler || !browser || !errorText) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring failedUrlStr, errorTextStr; + + if(failedUrl) + failedUrlStr = failedUrl; + if(*errorText) + errorTextStr = *errorText; + + enum cef_retval_t rv = impl->class_->GetClass()->HandleLoadError(browserPtr, + errorCode, failedUrlStr, errorTextStr); + + transfer_string_contents(errorTextStr, errorText); + + return rv; +} + +enum cef_retval_t CEF_CALLBACK handler_handle_before_resource_load( + struct _cef_handler_t* handler, cef_browser_t* browser, + struct _cef_request_t* request, cef_string_t* redirectUrl, + struct _cef_stream_reader_t** resourceStream, cef_string_t* mimeType, + int loadFlags) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(redirectUrl); + DCHECK(resourceStream); + DCHECK(mimeType); + if(!handler || !browser || !redirectUrl || !resourceStream || !mimeType) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + CefRequestCToCpp* rp = new CefRequestCToCpp(request); + CefRefPtr requestPtr(rp); + rp->UnderlyingRelease(); + + std::wstring redirectUrlStr, mimeTypeStr; + CefRefPtr streamPtr; + + if(*redirectUrl) + redirectUrlStr = *redirectUrl; + if(*mimeType) + mimeTypeStr = *mimeType; + + enum cef_retval_t rv = impl->class_->GetClass()->HandleBeforeResourceLoad( + browserPtr, requestPtr, redirectUrlStr, streamPtr, mimeTypeStr, + loadFlags); + + transfer_string_contents(redirectUrlStr, redirectUrl); + transfer_string_contents(mimeTypeStr, mimeType); + + if(streamPtr.get()) + { + CefStreamReaderCToCpp* sp = + static_cast(streamPtr.get()); + sp->UnderlyingAddRef(); + *resourceStream = sp->GetStruct(); + } + + return rv; +} + +enum cef_retval_t CEF_CALLBACK handler_handle_before_menu( + struct _cef_handler_t* handler, cef_browser_t* browser, + const cef_handler_menuinfo_t* menuInfo) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(menuInfo); + if(!handler || !browser || !menuInfo) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + return impl->class_->GetClass()->HandleBeforeMenu(browserPtr, *menuInfo); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_get_menu_label( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_handler_menuid_t menuId, cef_string_t* label) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(label); + if(!handler || !browser || !label) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring labelStr; + if(*label) + labelStr = *label; + + enum cef_retval_t rv = impl->class_->GetClass()->HandleGetMenuLabel( + browserPtr, menuId, labelStr); + + transfer_string_contents(labelStr, label); + + return rv; +} + +enum cef_retval_t CEF_CALLBACK handler_handle_menu_action( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_handler_menuid_t menuId) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + return impl->class_->GetClass()->HandleMenuAction(browserPtr, menuId); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_print_header_footer( + struct _cef_handler_t* handler, cef_browser_t* browser, + cef_print_info_t* printInfo, const wchar_t* url, const wchar_t* title, + int currentPage, int maxPages, cef_string_t* topLeft, + cef_string_t* topCenter, cef_string_t* topRight, + cef_string_t* bottomLeft, cef_string_t* bottomCenter, + cef_string_t* bottomRight) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(printInfo); + DCHECK(topLeft && topCenter && topRight); + DCHECK(bottomLeft && bottomCenter && bottomRight); + if(!handler || !browser || !printInfo || !topLeft || !topCenter || !topRight + || !bottomLeft || !bottomCenter || !bottomRight) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring urlStr, titleStr; + std::wstring topLeftStr, topCenterStr, topRightStr; + std::wstring bottomLeftStr, bottomCenterStr, bottomRightStr; + CefPrintInfo info = *printInfo; + + if(url) + urlStr = url; + if(title) + titleStr = title; + if(*topLeft) + topLeftStr = *topLeft; + if(*topCenter) + topCenterStr = *topCenter; + if(*topRight) + topRightStr = *topRight; + if(*bottomLeft) + bottomLeftStr = *bottomLeft; + if(*bottomCenter) + bottomCenterStr = *bottomCenter; + if(*bottomRight) + bottomRightStr = *bottomRight; + + enum cef_retval_t rv = impl->class_->GetClass()-> + HandlePrintHeaderFooter(browserPtr, info, urlStr, titleStr, + currentPage, maxPages, topLeftStr, topCenterStr, topRightStr, + bottomLeftStr, bottomCenterStr, bottomRightStr); + + transfer_string_contents(topLeftStr, topLeft); + transfer_string_contents(topCenterStr, topCenter); + transfer_string_contents(topRightStr, topRight); + transfer_string_contents(bottomLeftStr, bottomLeft); + transfer_string_contents(bottomCenterStr, bottomCenter); + transfer_string_contents(bottomRightStr, bottomRight); + + return rv; +} + +enum cef_retval_t CEF_CALLBACK handler_handle_jsalert( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* message) +{ + DCHECK(handler); + DCHECK(browser); + if(!handler || !browser) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring messageStr; + if(message) + messageStr = message; + + return impl->class_->GetClass()->HandleJSAlert(browserPtr, messageStr); +} + +enum cef_retval_t CEF_CALLBACK handler_handle_jsconfirm( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* message, int* retval) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(retval); + if(!handler || !browser || !retval) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring messageStr; + if(message) + messageStr = message; + + bool ret = false; + enum cef_retval_t rv = impl->class_->GetClass()->HandleJSConfirm(browserPtr, + messageStr, ret); + *retval = (ret ? 1 : 0); + + return rv; +} + +enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt( + struct _cef_handler_t* handler, cef_browser_t* browser, + const wchar_t* message, const wchar_t* defaultValue, int* retval, + cef_string_t* result) +{ + DCHECK(handler); + DCHECK(browser); + DCHECK(retval); + DCHECK(result); + if(!handler || !browser || !retval || !result) + return RV_CONTINUE; + + CefHandlerCppToC::Struct* impl = + reinterpret_cast(handler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring messageStr, defaultValueStr, resultStr; + + if(message) + messageStr = message; + if(defaultValue) + defaultValueStr = defaultValue; + if(*result) + resultStr = *result; + + bool ret = false; + enum cef_retval_t rv = impl->class_->GetClass()->HandleJSPrompt( + browserPtr, messageStr, defaultValueStr, ret, resultStr); + *retval = (ret ? 1 : 0); + + transfer_string_contents(resultStr, result); + + return rv; +} + + +CefHandlerCppToC::CefHandlerCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.handle_before_created = handler_handle_before_created; + struct_.struct_.handle_after_created = handler_handle_after_created; + struct_.struct_.handle_address_change = handler_handle_address_change; + struct_.struct_.handle_title_change = handler_handle_title_change; + struct_.struct_.handle_before_browse = handler_handle_before_browse; + struct_.struct_.handle_load_start = handler_handle_load_start; + struct_.struct_.handle_load_end = handler_handle_load_end; + struct_.struct_.handle_load_error = handler_handle_load_error; + struct_.struct_.handle_before_resource_load = + handler_handle_before_resource_load; + struct_.struct_.handle_before_menu = handler_handle_before_menu; + struct_.struct_.handle_get_menu_label = handler_handle_get_menu_label; + struct_.struct_.handle_menu_action = handler_handle_menu_action; + struct_.struct_.handle_print_header_footer = + handler_handle_print_header_footer; + struct_.struct_.handle_jsalert = handler_handle_jsalert; + struct_.struct_.handle_jsconfirm = handler_handle_jsconfirm; + struct_.struct_.handle_jsprompt = handler_handle_jsprompt; +} diff --git a/libcef_dll/cpptoc/handler_cpptoc.h b/libcef_dll/cpptoc/handler_cpptoc.h new file mode 100644 index 000000000..f59265a4a --- /dev/null +++ b/libcef_dll/cpptoc/handler_cpptoc.h @@ -0,0 +1,28 @@ +// Copyright (c) 2009 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 _HANDLER_CPPTOC_H +#define _HANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "cpptoc.h" + + +// Wrap a C++ handler class with a C handler structure. +// This class may be instantiated and accessed wrapper-side only. +class CefHandlerCppToC : public CefCppToC +{ +public: + CefHandlerCppToC(CefRefPtr cls); + virtual ~CefHandlerCppToC() {} +}; + + +#endif // USING_CEF_SHARED +#endif // _HANDLER_CPPTOC_H diff --git a/libcef_dll/cpptoc/jshandler_cpptoc.cc b/libcef_dll/cpptoc/jshandler_cpptoc.cc new file mode 100644 index 000000000..56cebf5ac --- /dev/null +++ b/libcef_dll/cpptoc/jshandler_cpptoc.cc @@ -0,0 +1,155 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/jshandler_cpptoc.h" +#include "ctocpp/browser_ctocpp.h" +#include "ctocpp/variant_ctocpp.h" +#include "base/logging.h" + + +bool CEF_CALLBACK jshandler_has_method(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name) +{ + DCHECK(jshandler); + DCHECK(browser); + if(!jshandler || !browser) + return RV_CONTINUE; + + CefJSHandlerCppToC::Struct* impl = + reinterpret_cast(jshandler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring nameStr; + if(name) + nameStr = name; + + return impl->class_->GetClass()->HasMethod(browserPtr, nameStr); +} + +bool CEF_CALLBACK jshandler_has_property(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name) +{ + DCHECK(jshandler); + DCHECK(browser); + if(!jshandler || !browser) + return RV_CONTINUE; + + CefJSHandlerCppToC::Struct* impl = + reinterpret_cast(jshandler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring nameStr; + if(name) + nameStr = name; + + return impl->class_->GetClass()->HasProperty(browserPtr, nameStr); +} + +bool CEF_CALLBACK jshandler_set_property(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name, + struct _cef_variant_t* value) +{ + DCHECK(jshandler); + DCHECK(browser); + if(!jshandler || !browser) + return RV_CONTINUE; + + CefJSHandlerCppToC::Struct* impl = + reinterpret_cast(jshandler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring nameStr; + if(name) + nameStr = name; + + CefVariantCToCpp* vp = new CefVariantCToCpp(value); + CefRefPtr valuePtr(vp); + vp->UnderlyingRelease(); + + return impl->class_->GetClass()->SetProperty(browserPtr, nameStr, valuePtr); +} + +bool CEF_CALLBACK jshandler_get_property(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name, + struct _cef_variant_t* value) +{ + DCHECK(jshandler); + DCHECK(browser); + if(!jshandler || !browser) + return RV_CONTINUE; + + CefJSHandlerCppToC::Struct* impl = + reinterpret_cast(jshandler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring nameStr; + if(name) + nameStr = name; + + CefVariantCToCpp* vp = new CefVariantCToCpp(value); + CefRefPtr valuePtr(vp); + vp->UnderlyingRelease(); + + return impl->class_->GetClass()->GetProperty(browserPtr, nameStr, valuePtr); +} + +bool CEF_CALLBACK jshandler_execute_method(struct _cef_jshandler_t* jshandler, + cef_browser_t* browser, const wchar_t* name, size_t numargs, + struct _cef_variant_t** args, struct _cef_variant_t* retval) +{ + DCHECK(jshandler); + DCHECK(browser); + if(!jshandler || !browser) + return RV_CONTINUE; + + CefJSHandlerCppToC::Struct* impl = + reinterpret_cast(jshandler); + + CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser); + CefRefPtr browserPtr(bp); + bp->UnderlyingRelease(); + + std::wstring nameStr; + if(name) + nameStr = name; + + CefVariantCToCpp* vp = new CefVariantCToCpp(retval); + CefRefPtr retvalPtr(vp); + vp->UnderlyingRelease(); + + CefJSHandler::VariantVector vec; + for(int i = 0; i < (int)numargs; ++i) { + vp = new CefVariantCToCpp(args[i]); + CefRefPtr argPtr(vp); + vp->UnderlyingRelease(); + vec.push_back(argPtr); + } + + return impl->class_->GetClass()->ExecuteMethod(browserPtr, nameStr, vec, + retvalPtr); +} + + +CefJSHandlerCppToC::CefJSHandlerCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.has_method = jshandler_has_method; + struct_.struct_.has_property = jshandler_has_property; + struct_.struct_.set_property = jshandler_set_property; + struct_.struct_.get_property = jshandler_get_property; + struct_.struct_.execute_method = jshandler_execute_method; +} diff --git a/libcef_dll/cpptoc/jshandler_cpptoc.h b/libcef_dll/cpptoc/jshandler_cpptoc.h new file mode 100644 index 000000000..95e0562c9 --- /dev/null +++ b/libcef_dll/cpptoc/jshandler_cpptoc.h @@ -0,0 +1,28 @@ +// Copyright (c) 2009 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 _JSHANDLER_CPPTOC_H +#define _JSHANDLER_CPPTOC_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "cpptoc.h" + + +// Wrap a C++ jshandler class with a C jshandler structure. +// This class may be instantiated and accessed wrapper-side only. +class CefJSHandlerCppToC : public CefCppToC +{ +public: + CefJSHandlerCppToC(CefRefPtr cls); + virtual ~CefJSHandlerCppToC() {} +}; + + +#endif // USING_CEF_SHARED +#endif // _JSHANDLER_CPPTOC_H diff --git a/libcef_dll/cpptoc/request_cpptoc.cc b/libcef_dll/cpptoc/request_cpptoc.cc new file mode 100644 index 000000000..c14a85dc6 --- /dev/null +++ b/libcef_dll/cpptoc/request_cpptoc.cc @@ -0,0 +1,425 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/request_cpptoc.h" +#include "transfer_util.h" +#include "base/logging.h" + + +cef_string_t CEF_CALLBACK request_get_url(struct _cef_request_t* request) +{ + DCHECK(request); + if(!request) + return NULL; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + std::wstring urlStr = impl->class_->GetClass()->GetURL(); + if(urlStr.empty()) + return NULL; + return cef_string_alloc(urlStr.c_str()); +} + +void CEF_CALLBACK request_set_url(struct _cef_request_t* request, + const wchar_t* url) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + std::wstring urlStr; + if(url) + urlStr = url; + impl->class_->GetClass()->SetURL(urlStr); +} + +cef_string_t CEF_CALLBACK request_get_frame(struct _cef_request_t* request) +{ + DCHECK(request); + if(!request) + return NULL; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + std::wstring frameStr = impl->class_->GetClass()->GetFrame(); + if(frameStr.empty()) + return NULL; + return cef_string_alloc(frameStr.c_str()); +} + +void CEF_CALLBACK request_set_frame(struct _cef_request_t* request, + const wchar_t* frame) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + std::wstring frameStr; + if(frame) + frameStr = frame; + impl->class_->GetClass()->SetFrame(frameStr); +} + +cef_string_t CEF_CALLBACK request_get_method(struct _cef_request_t* request) +{ + DCHECK(request); + if(!request) + return NULL; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + std::wstring methodStr = impl->class_->GetClass()->GetMethod(); + if(methodStr.empty()) + return NULL; + return cef_string_alloc(methodStr.c_str()); +} + +void CEF_CALLBACK request_set_method(struct _cef_request_t* request, + const wchar_t* method) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + std::wstring methodStr; + if(method) + methodStr = method; + impl->class_->GetClass()->SetMethod(methodStr); +} + +struct _cef_post_data_t* CEF_CALLBACK request_get_post_data( + struct _cef_request_t* request) +{ + DCHECK(request); + if(!request) + return NULL; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + CefRefPtr postdata = + impl->class_->GetClass()->GetPostData(); + if(!postdata.get()) + return NULL; + + CefPostDataCppToC* rp = new CefPostDataCppToC(postdata); + rp->AddRef(); + return rp->GetStruct(); +} + +void CEF_CALLBACK request_set_post_data(struct _cef_request_t* request, + struct _cef_post_data_t* postData) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + CefPostDataCppToC::Struct* postStructPtr = + reinterpret_cast(postData); + + CefRefPtr postDataPtr; + if(postStructPtr) + postDataPtr = postStructPtr->class_->GetClass(); + + impl->class_->GetClass()->SetPostData(postDataPtr); +} + +void CEF_CALLBACK request_get_header_map(struct _cef_request_t* request, + cef_string_map_t headerMap) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + CefRequest::HeaderMap map; + impl->class_->GetClass()->GetHeaderMap(map); + + transfer_string_map_contents(map, headerMap); +} + +void CEF_CALLBACK request_set_header_map(struct _cef_request_t* request, + cef_string_map_t headerMap) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + + CefRequest::HeaderMap map; + if(headerMap) + transfer_string_map_contents(headerMap, map); + + impl->class_->GetClass()->SetHeaderMap(map); +} + +void CEF_CALLBACK request_set(struct _cef_request_t* request, + const wchar_t* url, const wchar_t* frame, + const wchar_t* method, + struct _cef_post_data_t* postData, + cef_string_map_t headerMap) +{ + DCHECK(request); + if(!request) + return; + + CefRequestCppToC::Struct* impl = + reinterpret_cast(request); + CefPostDataCppToC::Struct* postStructPtr = + reinterpret_cast(postData); + + std::wstring urlStr, frameStr, methodStr; + CefRefPtr postPtr; + CefRequest::HeaderMap map; + + if(url) + urlStr = url; + if(frame) + frameStr = frame; + if(method) + methodStr = method; + if(postStructPtr) + postPtr = postStructPtr->class_->GetClass(); + if(headerMap) + transfer_string_map_contents(headerMap, map); + + impl->class_->GetClass()->Set(urlStr, frameStr, methodStr, postPtr, map); +} + + +CefRequestCppToC::CefRequestCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.get_url = request_get_url; + struct_.struct_.set_url = request_set_url; + struct_.struct_.get_frame = request_get_frame; + struct_.struct_.set_frame = request_set_frame; + struct_.struct_.get_method = request_get_method; + struct_.struct_.set_method = request_set_method; + struct_.struct_.get_post_data = request_get_post_data; + struct_.struct_.set_post_data = request_set_post_data; + struct_.struct_.get_header_map = request_get_header_map; + struct_.struct_.set_header_map = request_set_header_map; + struct_.struct_.set = request_set; +} + + + +size_t CEF_CALLBACK post_data_get_element_count( + struct _cef_post_data_t* postData) +{ + DCHECK(postData); + if(!postData) + return 0; + + CefPostDataCppToC::Struct* impl = + reinterpret_cast(postData); + return impl->class_->GetClass()->GetElementCount(); +} + +struct _cef_post_data_element_t* CEF_CALLBACK post_data_get_element( + struct _cef_post_data_t* postData, int index) +{ + DCHECK(postData); + if(!postData) + return NULL; + + CefPostDataCppToC::Struct* impl = + reinterpret_cast(postData); + + CefPostData::ElementVector elements; + impl->class_->GetClass()->GetElements(elements); + + if(index < 0 || index >= (int)elements.size()) + return NULL; + + CefPostDataElementCppToC* rp = new CefPostDataElementCppToC(elements[index]); + rp->AddRef(); + return rp->GetStruct(); +} + +int CEF_CALLBACK post_data_remove_element(struct _cef_post_data_t* postData, + struct _cef_post_data_element_t* element) +{ + DCHECK(postData); + DCHECK(element); + if(!postData || !element) + return 0; + + CefPostDataCppToC::Struct* impl = + reinterpret_cast(postData); + CefPostDataElementCppToC::Struct* structPtr = + reinterpret_cast(element); + + return impl->class_->GetClass()->RemoveElement(structPtr->class_->GetClass()); +} + +int CEF_CALLBACK post_data_add_element(struct _cef_post_data_t* postData, + struct _cef_post_data_element_t* element) +{ + DCHECK(postData); + DCHECK(element); + if(!postData || !element) + return 0; + + CefPostDataCppToC::Struct* impl = + reinterpret_cast(postData); + CefPostDataElementCppToC::Struct* structPtr = + reinterpret_cast(element); + + return impl->class_->GetClass()->AddElement(structPtr->class_->GetClass()); +} + +void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* postData) +{ + DCHECK(postData); + if(!postData) + return; + + CefPostDataCppToC::Struct* impl = + reinterpret_cast(postData); + + impl->class_->GetClass()->RemoveElements(); +} + + +CefPostDataCppToC::CefPostDataCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.get_element_count = post_data_get_element_count; + struct_.struct_.get_element = post_data_get_element; + struct_.struct_.remove_element = post_data_remove_element; + struct_.struct_.add_element = post_data_add_element; + struct_.struct_.remove_elements = post_data_remove_elements; +} + + + +void CEF_CALLBACK post_data_element_set_to_empty( + struct _cef_post_data_element_t* postDataElement) +{ + DCHECK(postDataElement); + if(!postDataElement) + return; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + impl->class_->GetClass()->SetToEmpty(); +} + +void CEF_CALLBACK post_data_element_set_to_file( + struct _cef_post_data_element_t* postDataElement, + const wchar_t* fileName) +{ + DCHECK(postDataElement); + if(!postDataElement) + return; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + + std::wstring fileNameStr; + if(fileName) + fileNameStr = fileName; + impl->class_->GetClass()->SetToFile(fileNameStr); +} + +void CEF_CALLBACK post_data_element_set_to_bytes( + struct _cef_post_data_element_t* postDataElement, size_t size, + const void* bytes) +{ + DCHECK(postDataElement); + if(!postDataElement) + return; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + impl->class_->GetClass()->SetToBytes(size, bytes); +} + +cef_postdataelement_type_t CEF_CALLBACK post_data_element_get_type( + struct _cef_post_data_element_t* postDataElement) +{ + DCHECK(postDataElement); + if(!postDataElement) + return PDE_TYPE_EMPTY; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + return impl->class_->GetClass()->GetType(); +} + +cef_string_t CEF_CALLBACK post_data_element_get_file( + struct _cef_post_data_element_t* postDataElement) +{ + DCHECK(postDataElement); + if(!postDataElement) + return NULL; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + + std::wstring fileNameStr = impl->class_->GetClass()->GetFile(); + if(fileNameStr.empty()) + return NULL; + return cef_string_alloc(fileNameStr.c_str()); +} + +size_t CEF_CALLBACK post_data_element_get_bytes_count( + struct _cef_post_data_element_t* postDataElement) +{ + DCHECK(postDataElement); + if(!postDataElement) + return 0; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + return impl->class_->GetClass()->GetBytesCount(); +} + +size_t CEF_CALLBACK post_data_element_get_bytes( + struct _cef_post_data_element_t* postDataElement, size_t size, + void *bytes) +{ + DCHECK(postDataElement); + if(!postDataElement) + return 0; + + CefPostDataElementCppToC::Struct* impl = + reinterpret_cast(postDataElement); + return impl->class_->GetClass()->GetBytes(size, bytes); +} + + +CefPostDataElementCppToC::CefPostDataElementCppToC( + CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.set_to_empty = post_data_element_set_to_empty; + struct_.struct_.set_to_file = post_data_element_set_to_file; + struct_.struct_.set_to_bytes = post_data_element_set_to_bytes; + struct_.struct_.get_type = post_data_element_get_type; + struct_.struct_.get_file = post_data_element_get_file; + struct_.struct_.get_bytes_count = post_data_element_get_bytes_count; + struct_.struct_.get_bytes = post_data_element_get_bytes; +} diff --git a/libcef_dll/cpptoc/request_cpptoc.h b/libcef_dll/cpptoc/request_cpptoc.h new file mode 100644 index 000000000..45691c513 --- /dev/null +++ b/libcef_dll/cpptoc/request_cpptoc.h @@ -0,0 +1,51 @@ +// Copyright (c) 2009 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 _REQUEST_CPPTOC_H +#define _REQUEST_CPPTOC_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "cpptoc.h" + + +// Wrap a C++ request class with a C request structure. +// This class may be instantiated and accessed DLL-side only. +class CefRequestCppToC : public CefCppToC +{ +public: + CefRequestCppToC(CefRefPtr cls); + virtual ~CefRequestCppToC() {} +}; + + +// Wrap a C++ post data class with a C post data structure. +// This class may be instantiated and accessed DLL-side only. +class CefPostDataCppToC : public CefCppToC +{ +public: + CefPostDataCppToC(CefRefPtr cls); + virtual ~CefPostDataCppToC() {} +}; + +class CefPostDataElementCppToC; + + +// Wrap a C++ post data element class with a C post data element structure. +// This class may be instantiated and accessed DLL-side only. +class CefPostDataElementCppToC : + public CefCppToC +{ +public: + CefPostDataElementCppToC(CefRefPtr cls); + virtual ~CefPostDataElementCppToC() {} +}; + + +#endif // BUILDING_CEF_SHARED +#endif // _REQUEST_CPPTOC_H diff --git a/libcef_dll/cpptoc/stream_cpptoc.cc b/libcef_dll/cpptoc/stream_cpptoc.cc new file mode 100644 index 000000000..0932fb880 --- /dev/null +++ b/libcef_dll/cpptoc/stream_cpptoc.cc @@ -0,0 +1,122 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/stream_cpptoc.h" +#include "base/logging.h" + + +size_t CEF_CALLBACK stream_reader_read(struct _cef_stream_reader_t* stream, + void *ptr, size_t size, size_t n) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamReaderCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Read(ptr, size, n); +} + +int CEF_CALLBACK stream_reader_seek(struct _cef_stream_reader_t* stream, + long offset, int whence) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamReaderCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Seek(offset, whence); +} + +long CEF_CALLBACK stream_reader_tell(struct _cef_stream_reader_t* stream) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamReaderCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Tell(); +} + +int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* stream) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamReaderCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Eof(); +} + + +CefStreamReaderCppToC::CefStreamReaderCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.read = stream_reader_read; + struct_.struct_.seek = stream_reader_seek; + struct_.struct_.tell = stream_reader_tell; + struct_.struct_.eof = stream_reader_eof; +} + + + +size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* stream, + const void *ptr, size_t size, size_t n) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamWriterCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Write(ptr, size, n); +} + +int CEF_CALLBACK stream_writer_seek(struct _cef_stream_writer_t* stream, + long offset, int whence) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamWriterCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Seek(offset, whence); +} + +long CEF_CALLBACK stream_writer_tell(struct _cef_stream_writer_t* stream) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamWriterCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Tell(); +} + +int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* stream) +{ + DCHECK(stream); + if(!stream) + return 0; + + CefStreamWriterCppToC::Struct* impl = + reinterpret_cast(stream); + return impl->class_->GetClass()->Flush(); +} + + +CefStreamWriterCppToC::CefStreamWriterCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.write = stream_writer_write; + struct_.struct_.seek = stream_writer_seek; + struct_.struct_.tell = stream_writer_tell; + struct_.struct_.flush = stream_writer_flush; +} diff --git a/libcef_dll/cpptoc/stream_cpptoc.h b/libcef_dll/cpptoc/stream_cpptoc.h new file mode 100644 index 000000000..236fe9e55 --- /dev/null +++ b/libcef_dll/cpptoc/stream_cpptoc.h @@ -0,0 +1,40 @@ +// Copyright (c) 2009 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 _STREAM_CPPTOC_H +#define _STREAM_CPPTOC_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "cpptoc.h" + + +// Wrap a C++ stream reader class with a C stream reader structure. +// This class may be instantiated and accessed DLL-side only. +class CefStreamReaderCppToC : + public CefCppToC +{ +public: + CefStreamReaderCppToC(CefRefPtr cls); + virtual ~CefStreamReaderCppToC() {} +}; + + +// Wrap a C++ stream writer class with a C stream writer structure. +// This class may be instantiated and accessed DLL-side only. +class CefStreamWriterCppToC : + public CefCppToC +{ +public: + CefStreamWriterCppToC(CefRefPtr cls); + virtual ~CefStreamWriterCppToC() {} +}; + + +#endif // BUILDING_CEF_SHARED +#endif // _STREAM_CPPTOC_H diff --git a/libcef_dll/cpptoc/variant_cpptoc.cc b/libcef_dll/cpptoc/variant_cpptoc.cc new file mode 100644 index 000000000..0a6ca409f --- /dev/null +++ b/libcef_dll/cpptoc/variant_cpptoc.cc @@ -0,0 +1,307 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/variant_cpptoc.h" +#include "base/logging.h" + + +cef_variant_type_t CEF_CALLBACK variant_get_type(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return VARIANT_TYPE_NULL; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + return impl->class_->GetClass()->GetType(); +} + +void CEF_CALLBACK variant_set_null(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + impl->class_->GetClass()->SetNull(); +} + +void CEF_CALLBACK variant_set_bool(struct _cef_variant_t* variant, int val) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + impl->class_->GetClass()->SetBool(val ? true : false); +} + +void CEF_CALLBACK variant_set_int(struct _cef_variant_t* variant, int val) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + impl->class_->GetClass()->SetInt(val); +} + +void CEF_CALLBACK variant_set_double(struct _cef_variant_t* variant, double val) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + impl->class_->GetClass()->SetDouble(val); +} + +void CEF_CALLBACK variant_set_string(struct _cef_variant_t* variant, + const wchar_t* val) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + impl->class_->GetClass()->SetString(val); +} + +void CEF_CALLBACK variant_set_bool_array(struct _cef_variant_t* variant, + size_t count, const int* vals) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + for(size_t i = 0; i < count; ++i) + vec.push_back(vals[i] ? true : false); + + impl->class_->GetClass()->SetBoolArray(vec); +} + +void CEF_CALLBACK variant_set_int_array(struct _cef_variant_t* variant, + size_t count, const int* vals) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + for(size_t i = 0; i < count; ++i) + vec.push_back(vals[i]); + + impl->class_->GetClass()->SetIntArray(vec); +} + +void CEF_CALLBACK variant_set_double_array(struct _cef_variant_t* variant, + size_t count, const double* vals) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + for(size_t i = 0; i < count; ++i) + vec.push_back(vals[i]); + + impl->class_->GetClass()->SetDoubleArray(vec); +} + +void CEF_CALLBACK variant_set_string_array(struct _cef_variant_t* variant, + size_t count, + const cef_string_t* vals) +{ + DCHECK(variant); + if(!variant) + return; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + for(size_t i = 0; i < count; ++i) + vec.push_back(vals[i] ? vals[i] : std::wstring()); + + impl->class_->GetClass()->SetStringArray(vec); +} + + +int CEF_CALLBACK variant_get_bool(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + return impl->class_->GetClass()->GetBool(); +} + +int CEF_CALLBACK variant_get_int(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + return impl->class_->GetClass()->GetInt(); +} + +double CEF_CALLBACK variant_get_double(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + return impl->class_->GetClass()->GetDouble(); +} + +cef_string_t CEF_CALLBACK variant_get_string(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return NULL; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::wstring str; + str = impl->class_->GetClass()->GetString(); + if(str.empty()) + return NULL; + return cef_string_alloc(str.c_str()); +} + +int CEF_CALLBACK variant_get_array_size(struct _cef_variant_t* variant) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + return impl->class_->GetClass()->GetArraySize(); +} + +size_t CEF_CALLBACK variant_get_bool_array(struct _cef_variant_t* variant, + size_t maxcount, int* vals) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + impl->class_->GetClass()->GetBoolArray(vec); + + size_t ct = 0; + for(; ct < maxcount && ct < vec.size(); ++ct) + vals[ct] = vec[ct]; + return ct; +} + +size_t CEF_CALLBACK variant_get_int_array(struct _cef_variant_t* variant, + size_t maxcount, int* vals) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + impl->class_->GetClass()->GetIntArray(vec); + + size_t ct = 0; + for(; ct < maxcount && ct < vec.size(); ++ct) + vals[ct] = vec[ct]; + return ct; +} + +size_t CEF_CALLBACK variant_get_double_array(struct _cef_variant_t* variant, + size_t maxcount, double* vals) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + impl->class_->GetClass()->GetDoubleArray(vec); + + size_t ct = 0; + for(; ct < maxcount && ct < vec.size(); ++ct) + vals[ct] = vec[ct]; + return ct; +} + +size_t CEF_CALLBACK variant_get_string_array(struct _cef_variant_t* variant, + size_t maxcount, + cef_string_t* vals) +{ + DCHECK(variant); + if(!variant) + return 0; + + CefVariantCppToC::Struct* impl = + reinterpret_cast(variant); + + std::vector vec; + impl->class_->GetClass()->GetStringArray(vec); + + size_t ct = 0; + for(; ct < maxcount && ct < vec.size(); ++ct) + vals[ct] = cef_string_alloc(vec[ct].c_str()); + return ct; +} + + +CefVariantCppToC::CefVariantCppToC(CefRefPtr cls) + : CefCppToC(cls) +{ + struct_.struct_.get_type = variant_get_type; + struct_.struct_.set_null = variant_set_null; + struct_.struct_.set_bool = variant_set_bool; + struct_.struct_.set_int = variant_set_int; + struct_.struct_.set_double = variant_set_double; + struct_.struct_.set_string = variant_set_string; + struct_.struct_.set_bool_array = variant_set_bool_array; + struct_.struct_.set_int_array = variant_set_int_array; + struct_.struct_.set_double_array = variant_set_double_array; + struct_.struct_.set_string_array = variant_set_string_array; + struct_.struct_.get_bool = variant_get_bool; + struct_.struct_.get_int = variant_get_int; + struct_.struct_.get_double = variant_get_double; + struct_.struct_.get_string = variant_get_string; + struct_.struct_.get_array_size = variant_get_array_size; + struct_.struct_.get_bool_array = variant_get_bool_array; + struct_.struct_.get_int_array = variant_get_int_array; + struct_.struct_.get_double_array = variant_get_double_array; + struct_.struct_.get_string_array = variant_get_string_array; +} diff --git a/libcef_dll/cpptoc/variant_cpptoc.h b/libcef_dll/cpptoc/variant_cpptoc.h new file mode 100644 index 000000000..fe9aff5eb --- /dev/null +++ b/libcef_dll/cpptoc/variant_cpptoc.h @@ -0,0 +1,28 @@ +// Copyright (c) 2009 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 _VARIANT_CPPTOC_H +#define _VARIANT_CPPTOC_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "cpptoc.h" + + +// Wrap a C++ browser class with a C browser structure. +// This class may be instantiated and accessed DLL-side only. +class CefVariantCppToC : public CefCppToC +{ +public: + CefVariantCppToC(CefRefPtr cls); + virtual ~CefVariantCppToC() {} +}; + + +#endif // BUILDING_CEF_SHARED +#endif // _VARIANT_CPPTOC_H diff --git a/libcef_dll/ctocpp/browser_ctocpp.cc b/libcef_dll/ctocpp/browser_ctocpp.cc new file mode 100644 index 000000000..0d55616ad --- /dev/null +++ b/libcef_dll/ctocpp/browser_ctocpp.cc @@ -0,0 +1,312 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "ctocpp/browser_ctocpp.h" +#include "ctocpp/request_ctocpp.h" +#include "ctocpp/stream_ctocpp.h" +#include "cpptoc/handler_cpptoc.h" +#include "cpptoc/jshandler_cpptoc.h" +#include "base/logging.h" + + +bool CefBrowserCToCpp::CanGoBack() +{ + if(CEF_MEMBER_MISSING(struct_, can_go_back)) + return false; + + return struct_->can_go_back(struct_) ? true : false; +} + +void CefBrowserCToCpp::GoBack() +{ + if(CEF_MEMBER_MISSING(struct_, go_back)) + return; + + struct_->go_back(struct_); +} + +bool CefBrowserCToCpp::CanGoForward() +{ + if(CEF_MEMBER_MISSING(struct_, can_go_forward)) + return false; + + return struct_->can_go_forward(struct_); +} + +void CefBrowserCToCpp::GoForward() +{ + if(CEF_MEMBER_MISSING(struct_, go_forward)) + return; + + struct_->go_forward(struct_); +} + +void CefBrowserCToCpp::Reload() +{ + if(CEF_MEMBER_MISSING(struct_, reload)) + return; + + struct_->reload(struct_); +} + +void CefBrowserCToCpp::StopLoad() +{ + if(CEF_MEMBER_MISSING(struct_, stop_load)) + return; + + struct_->stop_load(struct_); +} + +void CefBrowserCToCpp::Undo(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, undo)) + return; + + struct_->undo(struct_, targetFrame); +} + +void CefBrowserCToCpp::Redo(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, redo)) + return; + + struct_->redo(struct_, targetFrame); +} + +void CefBrowserCToCpp::Cut(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, cut)) + return; + + struct_->cut(struct_, targetFrame); +} + +void CefBrowserCToCpp::Copy(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, copy)) + return; + + struct_->copy(struct_, targetFrame); +} + +void CefBrowserCToCpp::Paste(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, paste)) + return; + + struct_->paste(struct_, targetFrame); +} + +void CefBrowserCToCpp::Delete(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, del)) + return; + + struct_->del(struct_, targetFrame); +} + +void CefBrowserCToCpp::SelectAll(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, select_all)) + return; + + struct_->select_all(struct_, targetFrame); +} + +void CefBrowserCToCpp::Print(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, print)) + return; + + struct_->print(struct_, targetFrame); +} + +void CefBrowserCToCpp::ViewSource(TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, view_source)) + return; + + struct_->view_source(struct_, targetFrame); +} + +std::wstring CefBrowserCToCpp::GetSource(TargetFrame targetFrame) +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_source)) + return str; + + cef_string_t cef_str = struct_->get_source(struct_, targetFrame); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + return str; +} + +std::wstring CefBrowserCToCpp::GetText(TargetFrame targetFrame) +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_text)) + return str; + + cef_string_t cef_str = struct_->get_text(struct_, targetFrame); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + return str; +} + +void CefBrowserCToCpp::LoadRequest(CefRefPtr request) +{ + if(CEF_MEMBER_MISSING(struct_, load_request)) + return; + + CefRequestCToCpp* rp = static_cast(request.get()); + rp->UnderlyingAddRef(); + struct_->load_request(struct_, rp->GetStruct()); +} + +void CefBrowserCToCpp::LoadURL(const std::wstring& url, + const std::wstring& frame) +{ + if(CEF_MEMBER_MISSING(struct_, load_url)) + return; + + struct_->load_url(struct_, url.c_str(), frame.c_str()); +} + +void CefBrowserCToCpp::LoadString(const std::wstring& string, + const std::wstring& url) +{ + if(CEF_MEMBER_MISSING(struct_, load_string)) + return; + + struct_->load_string(struct_, string.c_str(), url.c_str()); +} + +void CefBrowserCToCpp::LoadStream(CefRefPtr stream, + const std::wstring& url) +{ + if(CEF_MEMBER_MISSING(struct_, load_stream)) + return; + + CefStreamReaderCToCpp* sp = + static_cast(stream.get()); + sp->UnderlyingAddRef(); + struct_->load_stream(struct_, sp->GetStruct(), url.c_str()); +} + +void CefBrowserCToCpp::ExecuteJavaScript(const std::wstring& js_code, + const std::wstring& script_url, + int start_line, + TargetFrame targetFrame) +{ + if(CEF_MEMBER_MISSING(struct_, execute_javascript)) + return; + + struct_->execute_javascript(struct_, js_code.c_str(), script_url.c_str(), + start_line, targetFrame); +} + +bool CefBrowserCToCpp::AddJSHandler(const std::wstring& classname, + CefRefPtr handler) +{ + if(CEF_MEMBER_MISSING(struct_, add_jshandler)) + return false; + + CefJSHandlerCppToC* hp = new CefJSHandlerCppToC(handler); + hp->AddRef(); + return struct_->add_jshandler(struct_, classname.c_str(), hp->GetStruct()); + return true; +} + +bool CefBrowserCToCpp::HasJSHandler(const std::wstring& classname) +{ + if(CEF_MEMBER_MISSING(struct_, has_jshandler)) + return false; + + return struct_->has_jshandler(struct_, classname.c_str()); +} + +CefRefPtr CefBrowserCToCpp::GetJSHandler(const std::wstring& classname) +{ + if(CEF_MEMBER_MISSING(struct_, get_jshandler)) + return NULL; + + CefJSHandlerCppToC::Struct* hp = + reinterpret_cast( + struct_->get_jshandler(struct_, classname.c_str())); + if(hp) { + CefRefPtr handlerPtr(hp->class_->GetClass()); + hp->class_->UnderlyingRelease(); + return handlerPtr; + } + + return NULL; +} + +bool CefBrowserCToCpp::RemoveJSHandler(const std::wstring& classname) +{ + if(CEF_MEMBER_MISSING(struct_, remove_jshandler)) + return false; + + return struct_->remove_jshandler(struct_, classname.c_str()); +} + +void CefBrowserCToCpp::RemoveAllJSHandlers() +{ + if(CEF_MEMBER_MISSING(struct_, remove_all_jshandlers)) + return; + + struct_->remove_all_jshandlers(struct_); +} + +CefWindowHandle CefBrowserCToCpp::GetWindowHandle() +{ + if(CEF_MEMBER_MISSING(struct_, get_window_handle)) + return 0; + + return struct_->get_window_handle(struct_); +} + +bool CefBrowserCToCpp::IsPopup() +{ + if(CEF_MEMBER_MISSING(struct_, is_popup)) + return false; + + return struct_->is_popup(struct_); +} + +CefRefPtr CefBrowserCToCpp::GetHandler() +{ + if(CEF_MEMBER_MISSING(struct_, get_handler)) + return NULL; + + CefHandlerCppToC::Struct* hp = + reinterpret_cast( + struct_->get_handler(struct_)); + if(hp) { + CefRefPtr handlerPtr(hp->class_->GetClass()); + hp->class_->UnderlyingRelease(); + return handlerPtr; + } + + return NULL; +} + +std::wstring CefBrowserCToCpp::GetURL() +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_url)) + return str; + + cef_string_t cef_str = struct_->get_url(struct_); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + return str; +} diff --git a/libcef_dll/ctocpp/browser_ctocpp.h b/libcef_dll/ctocpp/browser_ctocpp.h new file mode 100644 index 000000000..df7fc4d75 --- /dev/null +++ b/libcef_dll/ctocpp/browser_ctocpp.h @@ -0,0 +1,67 @@ +// Copyright (c) 2009 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 _BROWSER_CTOCPP_H +#define _BROWSER_CTOCPP_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "ctocpp.h" + + +// Wrap a C browser structure with a C++ browser class. +// This class may be instantiated and accessed wrapper-side only. +class CefBrowserCToCpp : public CefCToCpp +{ +public: + CefBrowserCToCpp(cef_browser_t* str) + : CefCToCpp(str) {} + virtual ~CefBrowserCToCpp() {} + + // CefBrowser methods + virtual bool CanGoBack(); + virtual void GoBack(); + virtual bool CanGoForward(); + virtual void GoForward(); + virtual void Reload(); + virtual void StopLoad(); + virtual void Undo(TargetFrame targetFrame); + virtual void Redo(TargetFrame targetFrame); + virtual void Cut(TargetFrame targetFrame); + virtual void Copy(TargetFrame targetFrame); + virtual void Paste(TargetFrame targetFrame); + virtual void Delete(TargetFrame targetFrame); + virtual void SelectAll(TargetFrame targetFrame); + virtual void Print(TargetFrame targetFrame); + virtual void ViewSource(TargetFrame targetFrame); + virtual std::wstring GetSource(TargetFrame targetFrame); + virtual std::wstring GetText(TargetFrame targetFrame); + virtual void LoadRequest(CefRefPtr request); + virtual void LoadURL(const std::wstring& url, const std::wstring& frame); + virtual void LoadString(const std::wstring& string, + const std::wstring& url); + virtual void LoadStream(CefRefPtr stream, + const std::wstring& url); + virtual void ExecuteJavaScript(const std::wstring& js_code, + const std::wstring& script_url, + int start_line, TargetFrame targetFrame); + virtual bool AddJSHandler(const std::wstring& classname, + CefRefPtr handler); + virtual bool HasJSHandler(const std::wstring& classname); + virtual CefRefPtr GetJSHandler(const std::wstring& classname); + virtual bool RemoveJSHandler(const std::wstring& classname); + virtual void RemoveAllJSHandlers(); + virtual CefWindowHandle GetWindowHandle(); + virtual bool IsPopup(); + virtual CefRefPtr GetHandler(); + virtual std::wstring GetURL(); +}; + + +#endif // USING_CEF_SHARED +#endif // _BROWSER_CTOCPP_H diff --git a/libcef_dll/ctocpp/ctocpp.h b/libcef_dll/ctocpp/ctocpp.h new file mode 100644 index 000000000..1be2f9d0f --- /dev/null +++ b/libcef_dll/ctocpp/ctocpp.h @@ -0,0 +1,64 @@ +// Copyright (c) 2009 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 _CTOCPP_H +#define _CTOCPP_H + +#include "cef.h" +#include "cef_capi.h" +#include "base/logging.h" + + +// Wrap a C structure with a C++ class. +template +class CefCToCpp : public CefThreadSafeBase +{ +public: + CefCToCpp(StructName* str) + : struct_(str) + { + DCHECK(str); + } + virtual ~CefCToCpp() + { + } + + // If returning the structure across the DLL boundary you should call + // UnderlyingAddRef() on this wrapping CefCToCpp object. On the other side of + // the DLL boundary, call Release() on the CefCppToC object. + StructName* GetStruct() { return struct_; } + + // CefBase methods increment/decrement reference counts on both this object + // and the underlying wrapped structure. + virtual int AddRef() + { + UnderlyingAddRef(); + return CefThreadSafeBase::AddRef(); + } + virtual int Release() + { + UnderlyingRelease(); + return CefThreadSafeBase::Release(); + } + + // Increment/decrement reference counts on only the underlying class. + int UnderlyingAddRef() + { + if(!struct_->base.add_ref) + return 0; + return struct_->base.add_ref(&struct_->base); + } + int UnderlyingRelease() + { + if(!struct_->base.release) + return 0; + return struct_->base.release(&struct_->base); + } + +protected: + StructName* struct_; +}; + + +#endif // _CTOCPP_H diff --git a/libcef_dll/ctocpp/handler_ctocpp.cc b/libcef_dll/ctocpp/handler_ctocpp.cc new file mode 100644 index 000000000..38bf8d828 --- /dev/null +++ b/libcef_dll/ctocpp/handler_ctocpp.cc @@ -0,0 +1,337 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/browser_cpptoc.h" +#include "cpptoc/request_cpptoc.h" +#include "cpptoc/stream_cpptoc.h" +#include "ctocpp/handler_ctocpp.h" +#include "transfer_util.h" +#include "base/logging.h" + + +CefHandler::RetVal CefHandlerCToCpp::HandleBeforeCreated( + CefRefPtr parentBrowser, CefWindowInfo& windowInfo, bool popup, + CefRefPtr& handler, std::wstring& url) +{ + if(CEF_MEMBER_MISSING(struct_, handle_before_created)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = NULL; + cef_browser_t* browserStructPtr = NULL; + if(parentBrowser.get()) { + browserPtr = new CefBrowserCppToC(parentBrowser); + browserPtr->AddRef(); + browserStructPtr = browserPtr->GetStruct(); + } + + CefHandlerCToCpp* handlerPtr = NULL; + cef_handler_t* handlerRet = NULL; + if(handler.get()) { + handlerPtr = static_cast(handler.get()); + handlerPtr->UnderlyingAddRef(); + handlerRet = handlerPtr->GetStruct(); + } + + cef_string_t urlRet = NULL; + if(!url.empty()) + urlRet = cef_string_alloc(url.c_str()); + + cef_retval_t rv = struct_->handle_before_created(struct_, + browserStructPtr, &windowInfo, popup, &handlerRet, &urlRet); + + if(handlerPtr && handlerRet != handlerPtr->GetStruct()) { + // The handler was changed. + if(handlerRet) { + CefHandlerCToCpp* hp = new CefHandlerCToCpp(handlerRet); + handler = hp; + hp->UnderlyingRelease(); + } else { + handler = NULL; + } + } + + transfer_string_contents(urlRet, url, true); + + return rv; +} + +CefHandler::RetVal CefHandlerCToCpp::HandleAfterCreated( + CefRefPtr browser) +{ + if(CEF_MEMBER_MISSING(struct_, handle_after_created)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + return struct_->handle_after_created(struct_, browserPtr->GetStruct()); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleAddressChange( + CefRefPtr browser, const std::wstring& url) +{ + if(CEF_MEMBER_MISSING(struct_, handle_address_change)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + return struct_->handle_address_change(struct_, browserPtr->GetStruct(), + url.c_str()); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleTitleChange( + CefRefPtr browser, const std::wstring& title) +{ + if(CEF_MEMBER_MISSING(struct_, handle_title_change)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + return struct_->handle_title_change(struct_, browserPtr->GetStruct(), + title.c_str()); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleBeforeBrowse( + CefRefPtr browser, CefRefPtr request, + NavType navType, bool isRedirect) +{ + if(CEF_MEMBER_MISSING(struct_, handle_before_browse)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + CefRequestCppToC* requestPtr = new CefRequestCppToC(request); + requestPtr->AddRef(); + + return struct_->handle_before_browse(struct_, browserPtr->GetStruct(), + requestPtr->GetStruct(), navType, isRedirect); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleLoadStart( + CefRefPtr browser) +{ + if(CEF_MEMBER_MISSING(struct_, handle_load_start)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->handle_load_start(struct_, browserPtr->GetStruct()); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleLoadEnd( + CefRefPtr browser) +{ + if(CEF_MEMBER_MISSING(struct_, handle_load_end)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->handle_load_end(struct_, browserPtr->GetStruct()); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleLoadError( + CefRefPtr browser, ErrorCode errorCode, + const std::wstring& failedUrl, std::wstring& errorText) +{ + if(CEF_MEMBER_MISSING(struct_, handle_load_error)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + cef_string_t errorTextRet = NULL; + if(!errorText.empty()) + errorTextRet = cef_string_alloc(errorText.c_str()); + + cef_retval_t rv = struct_->handle_load_error(struct_, browserPtr->GetStruct(), + errorCode, failedUrl.c_str(), &errorTextRet); + + transfer_string_contents(errorTextRet, errorText, true); + + return rv; +} + +CefHandler::RetVal CefHandlerCToCpp::HandleBeforeResourceLoad( + CefRefPtr browser, CefRefPtr request, + std::wstring& redirectUrl, CefRefPtr& resourceStream, + std::wstring& mimeType, int loadFlags) +{ + if(CEF_MEMBER_MISSING(struct_, handle_before_resource_load)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + CefRequestCppToC* requestPtr = new CefRequestCppToC(request); + requestPtr->AddRef(); + + cef_string_t redirectUrlRet = NULL; + cef_string_t mimeTypeRet = NULL; + cef_stream_reader_t* streamRet = NULL; + + if(!redirectUrl.empty()) + redirectUrlRet = cef_string_alloc(redirectUrl.c_str()); + + cef_retval_t rv = struct_->handle_before_resource_load(struct_, + browserPtr->GetStruct(), requestPtr->GetStruct(), &redirectUrlRet, + &streamRet, &mimeTypeRet, loadFlags); + + transfer_string_contents(redirectUrlRet, redirectUrl, true); + transfer_string_contents(mimeTypeRet, mimeType, true); + + if(streamRet) { + CefStreamReaderCppToC::Struct* sp = + reinterpret_cast(streamRet); + resourceStream = sp->class_->GetClass(); + sp->class_->Release(); + } + + return rv; +} + +CefHandler::RetVal CefHandlerCToCpp::HandleBeforeMenu( + CefRefPtr browser, const MenuInfo& menuInfo) +{ + if(CEF_MEMBER_MISSING(struct_, handle_before_menu)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->handle_before_menu(struct_, browserPtr->GetStruct(), + &menuInfo); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleGetMenuLabel( + CefRefPtr browser, MenuId menuId, std::wstring& label) +{ + if(CEF_MEMBER_MISSING(struct_, handle_get_menu_label)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + cef_string_t labelRet = NULL; + if(!label.empty()) + labelRet = cef_string_alloc(label.c_str()); + + cef_retval_t rv = struct_->handle_get_menu_label(struct_, + browserPtr->GetStruct(), menuId, &labelRet); + + transfer_string_contents(labelRet, label, true); + + return rv; +} + +CefHandler::RetVal CefHandlerCToCpp::HandleMenuAction( + CefRefPtr browser, MenuId menuId) +{ + if(CEF_MEMBER_MISSING(struct_, handle_menu_action)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->handle_menu_action(struct_, browserPtr->GetStruct(), menuId); +} + +CefHandler::RetVal CefHandlerCToCpp::HandlePrintHeaderFooter( + CefRefPtr browser, CefPrintInfo& printInfo, + const std::wstring& url, const std::wstring& title, int currentPage, + int maxPages, std::wstring& topLeft, std::wstring& topCenter, + std::wstring& topRight, std::wstring& bottomLeft, + std::wstring& bottomCenter, std::wstring& bottomRight) +{ + if(CEF_MEMBER_MISSING(struct_, handle_print_header_footer)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + cef_string_t topLeftRet = NULL, topCenterRet = NULL, topRightRet = NULL, + bottomLeftRet = NULL, bottomCenterRet = NULL, bottomRightRet = NULL; + + if(!topLeft.empty()) + topLeftRet = cef_string_alloc(topLeft.c_str()); + if(!topCenter.empty()) + topCenterRet = cef_string_alloc(topCenter.c_str()); + if(!topRight.empty()) + topRightRet = cef_string_alloc(topRight.c_str()); + if(!bottomLeft.empty()) + bottomLeftRet = cef_string_alloc(bottomLeft.c_str()); + if(!bottomCenter.empty()) + bottomCenterRet = cef_string_alloc(bottomCenter.c_str()); + if(!bottomRight.empty()) + bottomRightRet = cef_string_alloc(bottomRight.c_str()); + + cef_retval_t rv = struct_->handle_print_header_footer(struct_, + browserPtr->GetStruct(), &printInfo, url.c_str(), title.c_str(), + currentPage, maxPages, &topLeftRet, &topCenterRet, &topRightRet, + &bottomLeftRet, &bottomCenterRet, &bottomRightRet); + + transfer_string_contents(topLeftRet, topLeft, true); + transfer_string_contents(topCenterRet, topCenter, true); + transfer_string_contents(topRightRet, topRight, true); + transfer_string_contents(bottomLeftRet, bottomLeft, true); + transfer_string_contents(bottomCenterRet, bottomCenter, true); + transfer_string_contents(bottomRightRet, bottomRight, true); + + return rv; +} + +CefHandler::RetVal CefHandlerCToCpp::HandleJSAlert( + CefRefPtr browser, const std::wstring& message) +{ + if(CEF_MEMBER_MISSING(struct_, handle_jsalert)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->handle_jsalert(struct_, browserPtr->GetStruct(), + message.c_str()); +} + +CefHandler::RetVal CefHandlerCToCpp::HandleJSConfirm( + CefRefPtr browser, const std::wstring& message, bool& retval) +{ + if(CEF_MEMBER_MISSING(struct_, handle_jsconfirm)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + int ret = 0; + cef_retval_t rv = struct_->handle_jsconfirm(struct_, browserPtr->GetStruct(), + message.c_str(), &ret); + retval = (ret ? true : false); + return rv; +} + +CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt( + CefRefPtr browser, const std::wstring& message, + const std::wstring& defaultValue, bool& retval, std::wstring& result) +{ + if(CEF_MEMBER_MISSING(struct_, handle_jsprompt)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + cef_string_t resultRet = NULL; + if(!result.empty()) + resultRet = cef_string_alloc(result.c_str()); + + int ret = 0; + cef_retval_t rv = struct_->handle_jsprompt(struct_, browserPtr->GetStruct(), + message.c_str(), defaultValue.c_str(), &ret, &resultRet); + retval = (ret ? true : false); + + transfer_string_contents(resultRet, result, true); + + return rv; +} diff --git a/libcef_dll/ctocpp/handler_ctocpp.h b/libcef_dll/ctocpp/handler_ctocpp.h new file mode 100644 index 000000000..adfc1092e --- /dev/null +++ b/libcef_dll/ctocpp/handler_ctocpp.h @@ -0,0 +1,81 @@ +// Copyright (c) 2009 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 _HANDLER_CTOCPP_H +#define _HANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "ctocpp.h" + + +// Wrap a C handler structure with a C++ handler class. +// This class may be instantiated and accessed DLL-side only. +class CefHandlerCToCpp : public CefCToCpp +{ +public: + CefHandlerCToCpp(cef_handler_t* str) + : CefCToCpp(str) {} + virtual ~CefHandlerCToCpp() {} + + // CefHandler methods + virtual RetVal HandleBeforeCreated(CefRefPtr parentBrowser, + CefWindowInfo& windowInfo, bool popup, + CefRefPtr& handler, + std::wstring& url); + virtual RetVal HandleAfterCreated(CefRefPtr browser); + virtual RetVal HandleAddressChange(CefRefPtr browser, + const std::wstring& url); + virtual RetVal HandleTitleChange(CefRefPtr browser, + const std::wstring& title); + virtual RetVal HandleBeforeBrowse(CefRefPtr browser, + CefRefPtr request, + NavType navType, bool isRedirect); + virtual RetVal HandleLoadStart(CefRefPtr browser); + virtual RetVal HandleLoadEnd(CefRefPtr browser); + virtual RetVal HandleLoadError(CefRefPtr browser, + ErrorCode errorCode, + const std::wstring& failedUrl, + std::wstring& errorText); + virtual RetVal HandleBeforeResourceLoad(CefRefPtr browser, + CefRefPtr request, + std::wstring& redirectUrl, + CefRefPtr& resourceStream, + std::wstring& mimeType, + int loadFlags); + virtual RetVal HandleBeforeMenu(CefRefPtr browser, + const MenuInfo& menuInfo); + virtual RetVal HandleGetMenuLabel(CefRefPtr browser, + MenuId menuId, std::wstring& label); + virtual RetVal HandleMenuAction(CefRefPtr browser, + MenuId menuId); + virtual RetVal HandlePrintHeaderFooter(CefRefPtr browser, + CefPrintInfo& printInfo, + const std::wstring& url, + const std::wstring& title, + int currentPage, int maxPages, + std::wstring& topLeft, + std::wstring& topCenter, + std::wstring& topRight, + std::wstring& bottomLeft, + std::wstring& bottomCenter, + std::wstring& bottomRight); + virtual RetVal HandleJSAlert(CefRefPtr browser, + const std::wstring& message); + virtual RetVal HandleJSConfirm(CefRefPtr browser, + const std::wstring& message, bool& retval); + virtual RetVal HandleJSPrompt(CefRefPtr browser, + const std::wstring& message, + const std::wstring& default_value, + bool& retval, + std::wstring& result); +}; + + +#endif // BUILDING_CEF_SHARED +#endif // _HANDLER_CTOCPP_H diff --git a/libcef_dll/ctocpp/jshandler_ctocpp.cc b/libcef_dll/ctocpp/jshandler_ctocpp.cc new file mode 100644 index 000000000..6945c1877 --- /dev/null +++ b/libcef_dll/ctocpp/jshandler_ctocpp.cc @@ -0,0 +1,103 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cpptoc/browser_cpptoc.h" +#include "cpptoc/variant_cpptoc.h" +#include "ctocpp/jshandler_ctocpp.h" +#include "base/logging.h" + + +bool CefJSHandlerCToCpp::HasMethod(CefRefPtr browser, + const std::wstring& name) +{ + if(CEF_MEMBER_MISSING(struct_, has_method)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->has_method(struct_, browserPtr->GetStruct(), name.c_str()); +} + +bool CefJSHandlerCToCpp::HasProperty(CefRefPtr browser, + const std::wstring& name) +{ + if(CEF_MEMBER_MISSING(struct_, has_method)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + return struct_->has_property(struct_, browserPtr->GetStruct(), name.c_str()); +} + +bool CefJSHandlerCToCpp::SetProperty(CefRefPtr browser, + const std::wstring& name, + const CefRefPtr value) +{ + if(CEF_MEMBER_MISSING(struct_, has_method)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + CefVariantCppToC* valuePtr = new CefVariantCppToC(value); + valuePtr->AddRef(); + + return struct_->set_property(struct_, browserPtr->GetStruct(), name.c_str(), + valuePtr->GetStruct()); +} + +bool CefJSHandlerCToCpp::GetProperty(CefRefPtr browser, + const std::wstring& name, + CefRefPtr value) +{ + if(CEF_MEMBER_MISSING(struct_, has_method)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + CefVariantCppToC* valuePtr = new CefVariantCppToC(value); + valuePtr->AddRef(); + + return struct_->get_property(struct_, browserPtr->GetStruct(), name.c_str(), + valuePtr->GetStruct()); +} + +bool CefJSHandlerCToCpp::ExecuteMethod(CefRefPtr browser, + const std::wstring& name, + const VariantVector& args, + CefRefPtr retval) +{ + if(CEF_MEMBER_MISSING(struct_, has_method)) + return RV_CONTINUE; + + CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser); + browserPtr->AddRef(); + + CefVariantCppToC* retvalPtr = new CefVariantCppToC(retval); + retvalPtr->AddRef(); + + cef_variant_t** argsStructPtr = NULL; + int argsSize = args.size(); + if(argsSize > 0) { + CefVariantCppToC* vPtr; + argsStructPtr = new cef_variant_t*[argsSize]; + for(int i = 0; i < argsSize; ++i) { + vPtr = new CefVariantCppToC(args[i]); + vPtr->AddRef(); + argsStructPtr[i] = vPtr->GetStruct(); + } + } + + int rv = struct_->execute_method(struct_, browserPtr->GetStruct(), + name.c_str(), argsSize, argsStructPtr, retvalPtr->GetStruct()); + + if(argsStructPtr) + delete [] argsStructPtr; + + return rv; +} diff --git a/libcef_dll/ctocpp/jshandler_ctocpp.h b/libcef_dll/ctocpp/jshandler_ctocpp.h new file mode 100644 index 000000000..2f907b7a4 --- /dev/null +++ b/libcef_dll/ctocpp/jshandler_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2009 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 _JSHANDLER_CTOCPP_H +#define _JSHANDLER_CTOCPP_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "ctocpp.h" + + +// Wrap a C jshandler structure with a C++ jshandler class. +// This class may be instantiated and accessed DLL-side only. +class CefJSHandlerCToCpp : public CefCToCpp +{ +public: + CefJSHandlerCToCpp(cef_jshandler_t* str) + : CefCToCpp(str) {} + virtual ~CefJSHandlerCToCpp() {} + + // CefJSHandler methods + virtual bool HasMethod(CefRefPtr browser, + const std::wstring& name); + virtual bool HasProperty(CefRefPtr browser, + const std::wstring& name); + virtual bool SetProperty(CefRefPtr browser, + const std::wstring& name, + const CefRefPtr value); + virtual bool GetProperty(CefRefPtr browser, + const std::wstring& name, + CefRefPtr value); + virtual bool ExecuteMethod(CefRefPtr browser, + const std::wstring& name, + const VariantVector& args, + CefRefPtr retval); +}; + + +#endif // BUILDING_CEF_SHARED +#endif // _JSHANDLER_CTOCPP_H diff --git a/libcef_dll/ctocpp/request_ctocpp.cc b/libcef_dll/ctocpp/request_ctocpp.cc new file mode 100644 index 000000000..683d7f10a --- /dev/null +++ b/libcef_dll/ctocpp/request_ctocpp.cc @@ -0,0 +1,297 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "ctocpp/request_ctocpp.h" +#include "transfer_util.h" +#include "base/logging.h" + + +std::wstring CefRequestCToCpp::GetURL() +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_url)) + return str; + + cef_string_t cef_str = struct_->get_url(struct_); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + return str; +} + +void CefRequestCToCpp::SetURL(const std::wstring& url) +{ + if(CEF_MEMBER_MISSING(struct_, set_url)) + return; + + struct_->set_url(struct_, url.c_str()); +} + +std::wstring CefRequestCToCpp::GetFrame() +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_frame)) + return str; + + cef_string_t cef_str = struct_->get_frame(struct_); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + return str; +} + +void CefRequestCToCpp::SetFrame(const std::wstring& frame) +{ + if(CEF_MEMBER_MISSING(struct_, set_frame)) + return; + + struct_->set_frame(struct_, frame.c_str()); +} + +std::wstring CefRequestCToCpp::GetMethod() +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_method)) + return str; + + cef_string_t cef_str = struct_->get_method(struct_); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + return str; +} + +void CefRequestCToCpp::SetMethod(const std::wstring& method) +{ + if(CEF_MEMBER_MISSING(struct_, set_method)) + return; + + struct_->set_method(struct_, method.c_str()); +} + +CefRefPtr CefRequestCToCpp::GetPostData() +{ + if(CEF_MEMBER_MISSING(struct_, get_post_data)) + return NULL; + + cef_post_data_t* postDataStruct = struct_->get_post_data(struct_); + if(!postDataStruct) + return NULL; + + CefPostDataCToCpp* pdp = new CefPostDataCToCpp(postDataStruct); + CefRefPtr postDataPtr(pdp); + pdp->UnderlyingRelease(); + + return postDataPtr; +} + +void CefRequestCToCpp::SetPostData(CefRefPtr postData) +{ + if(CEF_MEMBER_MISSING(struct_, set_post_data)) + return; + + cef_post_data_t* postDataStruct = NULL; + if(postData.get()) { + CefPostDataCToCpp* pdp = static_cast(postData.get()); + pdp->UnderlyingAddRef(); + postDataStruct = pdp->GetStruct(); + } + struct_->set_post_data(struct_, postDataStruct); +} + +void CefRequestCToCpp::GetHeaderMap(HeaderMap& headerMap) +{ + if(CEF_MEMBER_MISSING(struct_, get_header_map)) + return; + + cef_string_map_t map = cef_string_map_alloc(); + if(!map) + return; + + struct_->get_header_map(struct_, map); + transfer_string_map_contents(map, headerMap); + cef_string_map_free(map); +} + +void CefRequestCToCpp::SetHeaderMap(const HeaderMap& headerMap) +{ + if(CEF_MEMBER_MISSING(struct_, set_header_map)) + return; + + cef_string_map_t map = NULL; + if(!headerMap.empty()) { + map = cef_string_map_alloc(); + if(!map) + return; + transfer_string_map_contents(headerMap, map); + } + + struct_->set_header_map(struct_, map); + + if(map) + cef_string_map_free(map); +} + +void CefRequestCToCpp::Set(const std::wstring& url, + const std::wstring& frame, + const std::wstring& method, + CefRefPtr postData, + const HeaderMap& headerMap) +{ + if(CEF_MEMBER_MISSING(struct_, set)) + return; + + cef_post_data_t* postDataStruct = NULL; + if(postData.get()) { + CefPostDataCToCpp* pdp = static_cast(postData.get()); + pdp->UnderlyingAddRef(); + postDataStruct = pdp->GetStruct(); + } + + cef_string_map_t map = NULL; + if(!headerMap.empty()) { + map = cef_string_map_alloc(); + if(!map) + return; + transfer_string_map_contents(headerMap, map); + } + + struct_->set(struct_, url.c_str(), frame.c_str(), method.c_str(), + postDataStruct, map); + + if(map) + cef_string_map_free(map); +} + + + +size_t CefPostDataCToCpp::GetElementCount() +{ + if(CEF_MEMBER_MISSING(struct_, get_element_count)) + return 0; + + return struct_->get_element_count(struct_); +} + +void CefPostDataCToCpp::GetElements(ElementVector& elements) +{ + if(CEF_MEMBER_MISSING(struct_, get_element)) + return; + + int count = (int)GetElementCount(); + + cef_post_data_element_t* structPtr; + CefPostDataElementCToCpp* pdep; + for(int i = 0; i < count; ++i) { + structPtr = struct_->get_element(struct_, i); + if(!structPtr) + continue; + + pdep = new CefPostDataElementCToCpp(structPtr); + CefRefPtr elementPtr(pdep); + pdep->UnderlyingRelease(); + elements.push_back(elementPtr); + } +} + +bool CefPostDataCToCpp::RemoveElement(CefRefPtr element) +{ + DCHECK(element.get()); + if(CEF_MEMBER_MISSING(struct_, remove_element) || !element.get()) + return false; + + CefPostDataElementCToCpp* pdep = + static_cast(element.get()); + pdep->UnderlyingAddRef(); + return struct_->remove_element(struct_, pdep->GetStruct()); +} + +bool CefPostDataCToCpp::AddElement(CefRefPtr element) +{ + DCHECK(element.get()); + if(CEF_MEMBER_MISSING(struct_, add_element) || !element.get()) + return false; + + CefPostDataElementCToCpp* pdep = + static_cast(element.get()); + pdep->UnderlyingAddRef(); + return struct_->add_element(struct_, pdep->GetStruct()); +} + +void CefPostDataCToCpp::RemoveElements() +{ + if(CEF_MEMBER_MISSING(struct_, remove_elements)) + return; + + return struct_->remove_elements(struct_); +} + + + +void CefPostDataElementCToCpp::SetToEmpty() +{ + if(CEF_MEMBER_MISSING(struct_, set_to_empty)) + return; + + return struct_->set_to_empty(struct_); +} + +void CefPostDataElementCToCpp::SetToFile(const std::wstring& fileName) +{ + if(CEF_MEMBER_MISSING(struct_, set_to_file)) + return; + + return struct_->set_to_file(struct_, fileName.c_str()); +} + +void CefPostDataElementCToCpp::SetToBytes(size_t size, const void* bytes) +{ + if(CEF_MEMBER_MISSING(struct_, set_to_bytes)) + return; + + return struct_->set_to_bytes(struct_, size, bytes); +} + +CefPostDataElement::Type CefPostDataElementCToCpp::GetType() +{ + if(CEF_MEMBER_MISSING(struct_, get_type)) + return PDE_TYPE_EMPTY; + + return struct_->get_type(struct_); +} + +std::wstring CefPostDataElementCToCpp::GetFile() +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_file)) + return str; + + cef_string_t cef_str = struct_->get_file(struct_); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + + return str; +} + +size_t CefPostDataElementCToCpp::GetBytesCount() +{ + if(CEF_MEMBER_MISSING(struct_, get_bytes_count)) + return 0; + + return struct_->get_bytes_count(struct_); +} + +size_t CefPostDataElementCToCpp::GetBytes(size_t size, void *bytes) +{ + if(CEF_MEMBER_MISSING(struct_, get_bytes)) + return 0; + + return struct_->get_bytes(struct_, size, bytes); +} diff --git a/libcef_dll/ctocpp/request_ctocpp.h b/libcef_dll/ctocpp/request_ctocpp.h new file mode 100644 index 000000000..47011d20d --- /dev/null +++ b/libcef_dll/ctocpp/request_ctocpp.h @@ -0,0 +1,85 @@ +// Copyright (c) 2009 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 _REQUEST_CTOCPP_H +#define _REQUEST_CTOCPP_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "ctocpp.h" + + +// Wrap a C request structure with a C++ request class. +// This class may be instantiated and accessed wrapper-side only. +class CefRequestCToCpp : public CefCToCpp +{ +public: + CefRequestCToCpp(cef_request_t* str) + : CefCToCpp(str) {} + virtual ~CefRequestCToCpp() {} + + // CefRequest methods + virtual std::wstring GetURL(); + virtual void SetURL(const std::wstring& url); + virtual std::wstring GetFrame(); + virtual void SetFrame(const std::wstring& url); + virtual std::wstring GetMethod(); + virtual void SetMethod(const std::wstring& method); + virtual CefRefPtr GetPostData(); + virtual void SetPostData(CefRefPtr postData); + virtual void GetHeaderMap(HeaderMap& headerMap); + virtual void SetHeaderMap(const HeaderMap& headerMap); + virtual void Set(const std::wstring& url, + const std::wstring& frame, + const std::wstring& method, + CefRefPtr postData, + const HeaderMap& headerMap); +}; + + +// Wrap a C post data structure with a C++ post data class. +// This class may be instantiated and accessed wrapper-side only. +class CefPostDataCToCpp : public CefCToCpp +{ +public: + CefPostDataCToCpp(cef_post_data_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataCToCpp() {} + + // CefPostData methods + virtual size_t GetElementCount(); + virtual void GetElements(ElementVector& elements); + virtual bool RemoveElement(CefRefPtr element); + virtual bool AddElement(CefRefPtr element); + virtual void RemoveElements(); +}; + + +// Wrap a C post data element structure with a C++ post data element class. +// This class may be instantiated and accessed wrapper-side only. +class CefPostDataElementCToCpp : + public CefCToCpp +{ +public: + CefPostDataElementCToCpp(cef_post_data_element_t* str) + : CefCToCpp(str) {} + virtual ~CefPostDataElementCToCpp() {} + + // CefPostDataElement methods + virtual void SetToEmpty(); + virtual void SetToFile(const std::wstring& fileName); + virtual void SetToBytes(size_t size, const void* bytes); + virtual Type GetType(); + virtual std::wstring GetFile(); + virtual size_t GetBytesCount(); + virtual size_t GetBytes(size_t size, void *bytes); +}; + + +#endif // USING_CEF_SHARED +#endif // _REQUEST_CTOCPP_H diff --git a/libcef_dll/ctocpp/stream_ctocpp.cc b/libcef_dll/ctocpp/stream_ctocpp.cc new file mode 100644 index 000000000..a72e07157 --- /dev/null +++ b/libcef_dll/ctocpp/stream_ctocpp.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "ctocpp/stream_ctocpp.h" +#include "base/logging.h" + + +size_t CefStreamReaderCToCpp::Read(void *ptr, size_t size, size_t n) +{ + if(CEF_MEMBER_MISSING(struct_, read)) + return 0; + + return struct_->read(struct_, ptr, size, n); +} + +int CefStreamReaderCToCpp::Seek(long offset, int whence) +{ + if(CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + return struct_->seek(struct_, offset, whence); +} + +long CefStreamReaderCToCpp::Tell() +{ + if(CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + return struct_->tell(struct_); +} + +int CefStreamReaderCToCpp::Eof() +{ + if(CEF_MEMBER_MISSING(struct_, eof)) + return 0; + + return struct_->eof(struct_); +} + + +size_t CefStreamWriterCToCpp::Write(const void *ptr, size_t size, size_t n) +{ + if(CEF_MEMBER_MISSING(struct_, write)) + return 0; + + return struct_->write(struct_, ptr, size, n); +} + +int CefStreamWriterCToCpp::Seek(long offset, int whence) +{ + if(CEF_MEMBER_MISSING(struct_, seek)) + return 0; + + return struct_->seek(struct_, offset, whence); +} + +long CefStreamWriterCToCpp::Tell() +{ + if(CEF_MEMBER_MISSING(struct_, tell)) + return 0; + + return struct_->tell(struct_); +} + +int CefStreamWriterCToCpp::Flush() +{ + if(CEF_MEMBER_MISSING(struct_, flush)) + return 0; + + return struct_->flush(struct_); +} diff --git a/libcef_dll/ctocpp/stream_ctocpp.h b/libcef_dll/ctocpp/stream_ctocpp.h new file mode 100644 index 000000000..9c54751f8 --- /dev/null +++ b/libcef_dll/ctocpp/stream_ctocpp.h @@ -0,0 +1,54 @@ +// Copyright (c) 2009 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 _STREAM_CTOCPP_H +#define _STREAM_CTOCPP_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "ctocpp.h" + + +// Wrap a C stream reader structure with a C++ stream reader class. +// This class may be instantiated and accessed wrapper-side only. +class CefStreamReaderCToCpp : + public CefCToCpp +{ +public: + CefStreamReaderCToCpp(cef_stream_reader_t* str) + : CefCToCpp(str) {} + virtual ~CefStreamReaderCToCpp() {} + + // CefStreamReader methods + virtual size_t Read(void *ptr, size_t size, size_t n); + virtual int Seek(long offset, int whence); + virtual long Tell(); + virtual int Eof(); +}; + + +// Wrap a C stream writer structure with a C++ stream writer class. +// This class may be instantiated and accessed wrapper-side only. +class CefStreamWriterCToCpp : + public CefCToCpp +{ +public: + CefStreamWriterCToCpp(cef_stream_writer_t* str) + : CefCToCpp(str) {} + virtual ~CefStreamWriterCToCpp() {} + + // CefStreamWriter methods + virtual size_t Write(const void *ptr, size_t size, size_t n); + virtual int Seek(long offset, int whence); + virtual long Tell(); + virtual int Flush(); +}; + + +#endif // USING_CEF_SHARED +#endif // _STREAM_CTOCPP_H diff --git a/libcef_dll/ctocpp/variant_ctocpp.cc b/libcef_dll/ctocpp/variant_ctocpp.cc new file mode 100644 index 000000000..06c8ccf33 --- /dev/null +++ b/libcef_dll/ctocpp/variant_ctocpp.cc @@ -0,0 +1,297 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "ctocpp/variant_ctocpp.h" +#include "base/logging.h" + + +CefVariant::Type CefVariantCToCpp::GetType() +{ + if(CEF_MEMBER_MISSING(struct_, get_type)) + return VARIANT_TYPE_NULL; + + return struct_->get_type(struct_); +} + +void CefVariantCToCpp::SetNull() +{ + if(CEF_MEMBER_MISSING(struct_, set_null)) + return; + + return struct_->set_null(struct_); +} + +void CefVariantCToCpp::SetBool(bool val) +{ + if(CEF_MEMBER_MISSING(struct_, set_bool)) + return; + + return struct_->set_bool(struct_, val); +} + +void CefVariantCToCpp::SetInt(int val) +{ + if(CEF_MEMBER_MISSING(struct_, set_int)) + return; + + return struct_->set_int(struct_, val); +} + +void CefVariantCToCpp::SetDouble(double val) +{ + if(CEF_MEMBER_MISSING(struct_, set_double)) + return; + + return struct_->set_double(struct_, val); +} + +void CefVariantCToCpp::SetString(const std::wstring& val) +{ + if(CEF_MEMBER_MISSING(struct_, set_string)) + return; + + return struct_->set_string(struct_, val.c_str()); +} + +void CefVariantCToCpp::SetBoolArray(const std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, set_bool_array)) + return; + + int valSize = (int)val.size(); + int* valArray = NULL; + if(valSize > 0) { + valArray = new int[valSize]; + if(!valArray) + return; + for(int i = 0; i < valSize; ++i) { + valArray[i] = val[i]; + } + } + + struct_->set_bool_array(struct_, valSize, valArray); + + if(valArray) + delete [] valArray; +} + +void CefVariantCToCpp::SetIntArray(const std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, set_int_array)) + return; + + int valSize = (int)val.size(); + int* valArray = NULL; + if(valSize > 0) { + valArray = new int[valSize]; + if(!valArray) + return; + for(int i = 0; i < valSize; ++i) { + valArray[i] = val[i]; + } + } + + struct_->set_int_array(struct_, valSize, valArray); + + if(valArray) + delete [] valArray; +} + +void CefVariantCToCpp::SetDoubleArray(const std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, set_double_array)) + return; + + int valSize = (int)val.size(); + double* valArray = NULL; + if(valSize > 0) { + valArray = new double[valSize]; + if(!valArray) + return; + for(int i = 0; i < valSize; ++i) { + valArray[i] = val[i]; + } + } + + struct_->set_double_array(struct_, valSize, valArray); + + if(valArray) + delete [] valArray; +} + +void CefVariantCToCpp::SetStringArray(const std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, set_string_array)) + return; + + int valSize = (int)val.size(); + cef_string_t* valArray = NULL; + if(valSize > 0) { + valArray = new cef_string_t[valSize]; + if(!valArray) + return; + for(int i = 0; i < valSize; ++i) { + valArray[i] = cef_string_alloc(val[i].c_str()); + } + } + + struct_->set_string_array(struct_, valSize, valArray); + + if(valArray) { + for(int i = 0; i < valSize; ++i) { + cef_string_free(valArray[i]); + } + delete [] valArray; + } +} + +bool CefVariantCToCpp::GetBool() +{ + if(CEF_MEMBER_MISSING(struct_, get_bool)) + return false; + + return struct_->get_bool(struct_); +} + +int CefVariantCToCpp::GetInt() +{ + if(CEF_MEMBER_MISSING(struct_, get_int)) + return 0; + + return struct_->get_int(struct_); +} + +double CefVariantCToCpp::GetDouble() +{ + if(CEF_MEMBER_MISSING(struct_, get_double)) + return 0; + + return struct_->get_double(struct_); +} + +std::wstring CefVariantCToCpp::GetString() +{ + std::wstring str; + if(CEF_MEMBER_MISSING(struct_, get_string)) + return str; + + cef_string_t cef_str = struct_->get_string(struct_); + if(cef_str) { + str = cef_str; + cef_string_free(cef_str); + } + + return str; +} + +bool CefVariantCToCpp::GetBoolArray(std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, get_bool_array)) + return false; + + int valSize = GetArraySize(); + if(valSize < 0) + return false; + if(valSize == 0) + return true; + + int* valArray = new int[valSize]; + if(!valArray) + return false; + + bool rv = struct_->get_bool_array(struct_, valSize, valArray); + if(rv) { + for(int i = 0; i < valSize; ++i) + val.push_back(valArray[i] ? true : false); + } + delete [] valArray; + + return rv; +} + +bool CefVariantCToCpp::GetIntArray(std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, get_int_array)) + return false; + + int valSize = GetArraySize(); + if(valSize < 0) + return false; + if(valSize == 0) + return true; + + int* valArray = new int[valSize]; + if(!valArray) + return false; + + bool rv = struct_->get_int_array(struct_, valSize, valArray); + if(rv) { + for(int i = 0; i < valSize; ++i) + val.push_back(valArray[i]); + } + delete [] valArray; + + return rv; +} + +bool CefVariantCToCpp::GetDoubleArray(std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, get_double_array)) + return false; + + int valSize = GetArraySize(); + if(valSize < 0) + return false; + if(valSize == 0) + return true; + + double* valArray = new double[valSize]; + if(!valArray) + return false; + + bool rv = struct_->get_double_array(struct_, valSize, valArray); + if(rv) { + for(int i = 0; i < valSize; ++i) + val.push_back(valArray[i]); + } + delete [] valArray; + + return rv; +} + +bool CefVariantCToCpp::GetStringArray(std::vector& val) +{ + if(CEF_MEMBER_MISSING(struct_, get_string_array)) + return false; + + int valSize = GetArraySize(); + if(valSize < 0) + return false; + if(valSize == 0) + return true; + + cef_string_t* valArray = new cef_string_t[valSize]; + if(!valArray) + return false; + + bool rv = struct_->get_string_array(struct_, valSize, valArray); + if(rv) { + for(int i = 0; i < valSize; ++i) { + val.push_back(valArray[i]); + cef_string_free(valArray[i]); + } + } + delete [] valArray; + + return rv; +} + +int CefVariantCToCpp::GetArraySize() +{ + if(CEF_MEMBER_MISSING(struct_, get_array_size)) + return -1; + + return struct_->get_array_size(struct_); +} diff --git a/libcef_dll/ctocpp/variant_ctocpp.h b/libcef_dll/ctocpp/variant_ctocpp.h new file mode 100644 index 000000000..d7338d3da --- /dev/null +++ b/libcef_dll/ctocpp/variant_ctocpp.h @@ -0,0 +1,50 @@ +// Copyright (c) 2009 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 _VARIANT_CTOCPP_H +#define _VARIANT_CTOCPP_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "cef.h" +#include "cef_capi.h" +#include "ctocpp.h" + + +// Wrap a C variant structure with a C++ variant class. +// This class may be instantiated and accessed wrapper-side only. +class CefVariantCToCpp : public CefCToCpp +{ +public: + CefVariantCToCpp(cef_variant_t* str) + : CefCToCpp(str) {} + virtual ~CefVariantCToCpp() {} + + // CefVariant methods + virtual Type GetType(); + virtual void SetNull(); + virtual void SetBool(bool val); + virtual void SetInt(int val); + virtual void SetDouble(double val); + virtual void SetString(const std::wstring& val); + virtual void SetBoolArray(const std::vector& val); + virtual void SetIntArray(const std::vector& val); + virtual void SetDoubleArray(const std::vector& val); + virtual void SetStringArray(const std::vector& val); + virtual bool GetBool(); + virtual int GetInt(); + virtual double GetDouble(); + virtual std::wstring GetString(); + virtual bool GetBoolArray(std::vector& val); + virtual bool GetIntArray(std::vector& val); + virtual bool GetDoubleArray(std::vector& val); + virtual bool GetStringArray(std::vector& val); + virtual int GetArraySize(); +}; + + +#endif // USING_CEF_SHARED +#endif // _VARIANT_CTOCPP_H diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc new file mode 100644 index 000000000..efdafb742 --- /dev/null +++ b/libcef_dll/libcef_dll.cc @@ -0,0 +1,142 @@ +// Copyright (c) 2009 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 "precompiled_libcef.h" +#include "cef.h" +#include "cef_capi.h" +#include "cef_nplugin.h" +#include "cef_nplugin_capi.h" +#include "cpptoc/request_cpptoc.h" +#include "cpptoc/stream_cpptoc.h" +#include "ctocpp/handler_ctocpp.h" +#include "base/logging.h" +#include "base/string_util.h" + + +CEF_EXPORT int cef_initialize(int multi_threaded_message_loop) +{ + return CefInitialize(multi_threaded_message_loop); +} + +CEF_EXPORT void cef_shutdown() +{ + CefShutdown(); +} + +CEF_EXPORT void cef_do_message_loop_work() +{ + CefDoMessageLoopWork(); +} + +CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup, + cef_handler_t* handler, const wchar_t* url) +{ + DCHECK(windowInfo); + + CefRefPtr handlerPtr; + std::wstring urlStr; + CefWindowInfo wi = *windowInfo; + + if(handler) { + CefHandlerCToCpp* hp = new CefHandlerCToCpp(handler); + handlerPtr = hp; + hp->UnderlyingRelease(); + } + if(url) + urlStr = url; + + return CefBrowser::CreateBrowser(wi, popup, handlerPtr, urlStr); +} + +CEF_EXPORT cef_request_t* cef_create_request() +{ + CefRefPtr impl = CefRequest::CreateRequest(); + if(!impl.get()) + return NULL; + CefRequestCppToC* rp = new CefRequestCppToC(impl); + rp->AddRef(); + return rp->GetStruct(); +} + +CEF_EXPORT cef_post_data_t* cef_create_post_data() +{ + CefRefPtr impl = CefPostData::CreatePostData(); + if(!impl.get()) + return NULL; + CefPostDataCppToC* rp = new CefPostDataCppToC(impl); + rp->AddRef(); + return rp->GetStruct(); +} + +CEF_EXPORT cef_post_data_element_t* cef_create_post_data_element() +{ + CefRefPtr impl = + CefPostDataElement::CreatePostDataElement(); + if(!impl.get()) + return NULL; + CefPostDataElementCppToC* rp = new CefPostDataElementCppToC(impl); + rp->AddRef(); + return rp->GetStruct(); +} + +CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_file( + const wchar_t* fileName) +{ + std::wstring filenamestr; + if(fileName) + filenamestr = fileName; + CefRefPtr impl = CefStreamReader::CreateForFile(filenamestr); + if(!impl.get()) + return NULL; + CefStreamReaderCppToC* rp = new CefStreamReaderCppToC(impl); + rp->AddRef(); + return rp->GetStruct(); +} + +CEF_EXPORT cef_stream_reader_t* cef_create_stream_reader_for_data(void *data, + size_t size) +{ + CefRefPtr impl = CefStreamReader::CreateForData(data, size); + if(!impl.get()) + return NULL; + CefStreamReaderCppToC* rp = new CefStreamReaderCppToC(impl); + rp->AddRef(); + return rp->GetStruct(); +} + +CEF_EXPORT int cef_register_plugin(const cef_plugin_info_t* plugin_info) +{ + CefPluginInfo pluginInfo; + + pluginInfo.unique_name = plugin_info->unique_name; + pluginInfo.display_name = plugin_info->display_name; + pluginInfo.version = plugin_info->version; + pluginInfo.description = plugin_info->description; + + std::vector mime_types, file_extensions; + std::vector descriptions; + SplitString(plugin_info->mime_types, '|', &mime_types); + SplitString(plugin_info->file_extensions, '|', &file_extensions); + SplitString(plugin_info->type_descriptions, '|', &descriptions); + + for (size_t i = 0; i < mime_types.size(); ++i) { + CefPluginMimeType mimeType; + + mimeType.mime_type = mime_types[i]; + + if (file_extensions.size() > i) + SplitString(file_extensions[i], ',', &mimeType.file_extensions); + + if (descriptions.size() > i) + mimeType.description = descriptions[i]; + + pluginInfo.mime_types.push_back(mimeType); + } + + pluginInfo.np_getentrypoints = plugin_info->np_getentrypoints; + pluginInfo.np_initialize = plugin_info->np_initialize; + pluginInfo.np_shutdown = plugin_info->np_shutdown; + + return CefRegisterPlugin(pluginInfo); +} diff --git a/libcef_dll/libcef_dll.rc b/libcef_dll/libcef_dll.rc new file mode 100644 index 000000000..f690d8ad0 --- /dev/null +++ b/libcef_dll/libcef_dll.rc @@ -0,0 +1,105 @@ +// 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 + +#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 + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "Chromium Embedded Framework (CEF) Dynamic Link Library" + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "libcef" + VALUE "LegalCopyright", "Copyright (C) 2009 The Chromium Embedded Framework Authors" + VALUE "OriginalFilename", "libcef.dll" + VALUE "ProductName", "Chromium Embedded Framework (CEF) Dynamic Link Library" + VALUE "ProductVersion", "1, 0, 0, 1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/libcef_dll/libcef_dll.vcproj b/libcef_dll/libcef_dll.vcproj new file mode 100644 index 000000000..023f2e28f --- /dev/null +++ b/libcef_dll/libcef_dll.vcproj @@ -0,0 +1,429 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libcef_dll/libcef_dll.vsprops b/libcef_dll/libcef_dll.vsprops new file mode 100644 index 000000000..0975c52b8 --- /dev/null +++ b/libcef_dll/libcef_dll.vsprops @@ -0,0 +1,22 @@ + + + + + + diff --git a/libcef_dll/precompiled_libcef.cc b/libcef_dll/precompiled_libcef.cc new file mode 100644 index 000000000..76e53843d --- /dev/null +++ b/libcef_dll/precompiled_libcef.cc @@ -0,0 +1,5 @@ +// Copyright (c) 2009 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 "precompiled_libcef.h" diff --git a/libcef_dll/precompiled_libcef.h b/libcef_dll/precompiled_libcef.h new file mode 100644 index 000000000..6fd8b407a --- /dev/null +++ b/libcef_dll/precompiled_libcef.h @@ -0,0 +1,7 @@ +// Copyright (c) 2009 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 +#include diff --git a/libcef_dll/resource.h b/libcef_dll/resource.h new file mode 100644 index 000000000..5ace27747 --- /dev/null +++ b/libcef_dll/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by libcef_dll.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_COMMAND_VALUE 32000 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/libcef_dll/transfer_util.cpp b/libcef_dll/transfer_util.cpp new file mode 100644 index 000000000..393fbd160 --- /dev/null +++ b/libcef_dll/transfer_util.cpp @@ -0,0 +1,69 @@ +// Copyright (c) 2009 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 "precompiled_libcef.h" +#include "transfer_util.h" + + +void transfer_string_map_contents(cef_string_map_t fromMap, + std::map& toMap) +{ + int size = cef_string_map_size(fromMap); + cef_string_t key, value; + std::wstring keystr, valuestr; + + for(int i = 0; i < size; ++i) { + key = cef_string_map_key(fromMap, i); + value = cef_string_map_value(fromMap, i); + + if(key) { + keystr = key; + cef_string_free(key); + } else if(!keystr.empty()) + keystr.clear(); + + if(value) { + valuestr = value; + cef_string_free(value); + } else if(!valuestr.empty()) + valuestr.clear(); + + toMap.insert(std::pair(keystr, valuestr)); + } +} + +void transfer_string_map_contents(const std::map& fromMap, + cef_string_map_t toMap) +{ + std::map::const_iterator it = fromMap.begin(); + for(; it != fromMap.end(); ++it) { + cef_string_map_append(toMap, it->first.c_str(), it->second.c_str()); + } +} + +void transfer_string_contents(const std::wstring& fromString, + cef_string_t* toString) +{ + if(*toString == NULL || *toString != fromString) { + if(*toString) { + cef_string_free(*toString); + *toString = NULL; + } + if(!fromString.empty()) + *toString = cef_string_alloc(fromString.c_str()); + } +} + +void transfer_string_contents(cef_string_t fromString, std::wstring& toString, + bool freeFromString) +{ + if(fromString == NULL || fromString != toString) { + if(fromString) { + toString = fromString; + if(freeFromString) + cef_string_free(fromString); + } else if(!toString.empty()) + toString.clear(); + } +} diff --git a/libcef_dll/transfer_util.h b/libcef_dll/transfer_util.h new file mode 100644 index 000000000..00a3398f7 --- /dev/null +++ b/libcef_dll/transfer_util.h @@ -0,0 +1,23 @@ +// Copyright (c) 2009 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 _TRANSFER_UTIL_H +#define _TRANSFER_UTIL_H + +#include "cef_string.h" +#include "cef_string_map.h" + +// Copy contents from one map type to another. +void transfer_string_map_contents(cef_string_map_t fromMap, + std::map& toMap); +void transfer_string_map_contents(const std::map& fromMap, + cef_string_map_t toMap); + +// Copy the contents from one string type to another. +void transfer_string_contents(const std::wstring& fromString, + cef_string_t* toString); +void transfer_string_contents(cef_string_t fromString, std::wstring& toString, + bool freeFromString); + +#endif // _TRANSFER_UTIL_H diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc new file mode 100644 index 000000000..38ba2081e --- /dev/null +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -0,0 +1,134 @@ +// Copyright (c) 2009 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 "../precompiled_libcef.h" +#include "cef.h" +#include "cef_capi.h" +#include "cef_nplugin.h" +#include "cef_nplugin_capi.h" +#include "../cpptoc/handler_cpptoc.h" +#include "../ctocpp/request_ctocpp.h" +#include "../ctocpp/stream_ctocpp.h" + + +bool CefInitialize(bool multi_threaded_message_loop) +{ + return (bool)cef_initialize(multi_threaded_message_loop); +} + +void CefShutdown() +{ + cef_shutdown(); +} + +void CefDoMessageLoopWork() +{ + cef_do_message_loop_work(); +} + +bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup, + CefRefPtr handler, + const std::wstring& url) +{ + CefHandlerCppToC* hp = new CefHandlerCppToC(handler); + hp->AddRef(); + return cef_create_browser(&windowInfo, popup, hp->GetStruct(), url.c_str()); +} + +CefRefPtr CreateRequest() +{ + cef_request_t* impl = cef_create_request(); + if(!impl) + return NULL; + CefRequestCToCpp* ptr = new CefRequestCToCpp(impl); + CefRefPtr rp(ptr); + ptr->UnderlyingRelease(); + return rp; +} + +CefRefPtr CreatePostData() +{ + cef_post_data_t* impl = cef_create_post_data(); + if(!impl) + return NULL; + CefPostDataCToCpp* ptr = new CefPostDataCToCpp(impl); + CefRefPtr rp(ptr); + ptr->UnderlyingRelease(); + return rp; +} + +CefRefPtr CreatePostDataElement() +{ + cef_post_data_element_t* impl = cef_create_post_data_element(); + if(!impl) + return NULL; + CefPostDataElementCToCpp* ptr = new CefPostDataElementCToCpp(impl); + CefRefPtr rp(ptr); + ptr->UnderlyingRelease(); + return rp; +} + +CefRefPtr CefStreamReader::CreateForFile(const std::wstring& fileName) +{ + cef_stream_reader_t* impl = + cef_create_stream_reader_for_file(fileName.c_str()); + if(!impl) + return NULL; + CefStreamReaderCToCpp* ptr = new CefStreamReaderCToCpp(impl); + CefRefPtr rp(ptr); + ptr->UnderlyingRelease(); + return rp; +} + +CefRefPtr CefStreamReader::CreateForData(void *data, size_t size) +{ + cef_stream_reader_t* impl = cef_create_stream_reader_for_data(data, size); + if(!impl) + return NULL; + CefStreamReaderCToCpp* ptr = new CefStreamReaderCToCpp(impl); + CefRefPtr rp(ptr); + ptr->UnderlyingRelease(); + return rp; +} + +bool CefRegisterPlugin(const struct CefPluginInfo& plugin_info) +{ + cef_plugin_info_t pluginInfo; + + pluginInfo.unique_name = plugin_info.unique_name.c_str(); + pluginInfo.display_name = plugin_info.display_name.c_str(); + pluginInfo.version =plugin_info.version.c_str(); + pluginInfo.description = plugin_info.description.c_str(); + + std::wstring mimeTypes, fileExtensions, typeDescriptions; + + for(size_t i = 0; i < plugin_info.mime_types.size(); ++i) { + if(i > 0) { + mimeTypes += L"|"; + fileExtensions += L"|"; + typeDescriptions += L"|"; + } + + mimeTypes += plugin_info.mime_types[i].mime_type; + typeDescriptions += plugin_info.mime_types[i].description; + + for(size_t j = 0; + j < plugin_info.mime_types[i].file_extensions.size(); ++j) { + if(j > 0) { + fileExtensions += L","; + } + fileExtensions += plugin_info.mime_types[i].file_extensions[j]; + } + } + + pluginInfo.mime_types = mimeTypes.c_str(); + pluginInfo.file_extensions = fileExtensions.c_str(); + pluginInfo.type_descriptions = typeDescriptions.c_str(); + + pluginInfo.np_getentrypoints = plugin_info.np_getentrypoints; + pluginInfo.np_initialize = plugin_info.np_initialize; + pluginInfo.np_shutdown = plugin_info.np_shutdown; + + return (cef_register_plugin(&pluginInfo) ? true : false); +} diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.vcproj b/libcef_dll/wrapper/libcef_dll_wrapper.vcproj new file mode 100644 index 000000000..207cf7871 --- /dev/null +++ b/libcef_dll/wrapper/libcef_dll_wrapper.vcproj @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.vsprops b/libcef_dll/wrapper/libcef_dll_wrapper.vsprops new file mode 100644 index 000000000..1e374ff7d --- /dev/null +++ b/libcef_dll/wrapper/libcef_dll_wrapper.vsprops @@ -0,0 +1,22 @@ + + + + + + diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 6b2d5b89f..bf92efd42 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -231,22 +231,22 @@ public: ss << L"arg" << i; switch(args[i]->GetType()) { - case CefVariant::TYPE_NULL: + case VARIANT_TYPE_NULL: ss << L" null"; break; - case CefVariant::TYPE_BOOL: + case VARIANT_TYPE_BOOL: ss << L" bool = " << args[i]->GetBool(); break; - case CefVariant::TYPE_INT: + case VARIANT_TYPE_INT: ss << L" int = " << args[i]->GetInt(); break; - case CefVariant::TYPE_DOUBLE: + case VARIANT_TYPE_DOUBLE: ss << L" double = " << args[i]->GetDouble(); break; - case CefVariant::TYPE_STRING: + case VARIANT_TYPE_STRING: ss << L" string = " << args[i]->GetString().c_str(); break; - case CefVariant::TYPE_BOOL_ARRAY: + case VARIANT_TYPE_BOOL_ARRAY: ss << L" bool array = "; { std::vector vec; @@ -259,7 +259,7 @@ public: } } break; - case CefVariant::TYPE_INT_ARRAY: + case VARIANT_TYPE_INT_ARRAY: ss << L" int array = "; { std::vector vec; @@ -272,7 +272,7 @@ public: } } break; - case CefVariant::TYPE_DOUBLE_ARRAY: + case VARIANT_TYPE_DOUBLE_ARRAY: ss << L" double array = "; { std::vector vec; @@ -285,7 +285,7 @@ public: } } break; - case CefVariant::TYPE_STRING_ARRAY: + case VARIANT_TYPE_STRING_ARRAY: ss << L" string array = "; { std::vector vec; @@ -580,7 +580,7 @@ public: // |result| to the resulting value. virtual RetVal HandleJSPrompt(CefRefPtr browser, const std::wstring& message, - const std::wstring& default_value, + const std::wstring& defaultValue, bool& retval, std::wstring& result) { @@ -809,8 +809,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) std::wstring html = L"ClientJSHandler says:
" L"" L""; browser->LoadString(html, L"about:blank"); @@ -820,7 +821,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(browser.get()) { browser->ExecuteJavaScript(L"alert('JavaScript execute works!');", - L"about:blank", 0, CefBrowser::TF_MAIN); + L"about:blank", 0, TF_MAIN); } return 0; case ID_TESTS_PLUGIN: // Test our custom plugin