- Add the CefBrowser::CreateBrowserSync() method for synchronously creating a browser instance. (Issue #13, Suggested implementation by: vridosh)
- Add CefBrowser::SetFocus() and CefHandler::HandleTakeFocus() methods to deal with keyboard focus changes. (Issue #13, Suggested implementation by: vridosh)
- Add CefHandler::HandleBeforeWindowClose() to perform actions immediately before the browser window is destroyed. (Issue #13, Suggested implementation by: vridosh)
- Replace windows-specific address resolution code with GURL() in CefBrowserImpl::UIT_LoadURLForRequest(), CefBrowserImpl::UIT_LoadHTML() and CefBrowserImpl::UIT_LoadHTMLForStreamRef(), and move the methods from browser_impl_win.cc to browser_impl.cc. (Issue #13, Suggested implementation by: vridosh)
- Fix reference counting bugs, class definition problems and CefContext::Shutdown() bug resulting in Cef object leaks. (Issue #15)
- Add WebKit dependancy to libcef project.
- Add basic object count debugging for CefCToCpp and CefCppToC classes.

cefclient:
- Initialize the strPtr parameter to avoid URLs suffixed with garbage. (Issue #13, Fix by: vridosh)

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@19 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2009-03-08 02:26:16 +00:00
parent 3aa0d4c0fa
commit 08a19d5384
37 changed files with 628 additions and 195 deletions

145
cef.sln
View File

@ -4,25 +4,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebKit (readonly)", "WebKit
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebCore", "..\webkit\build\WebCore\WebCore.vcproj", "{1C16337B-ACF3-4D03-AA90-851C5B5EADA6}"
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(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(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}"
@ -64,8 +64,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxslt", "..\third_party\l
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V8Bindings", "..\webkit\build\V8Bindings\V8Bindings.vcproj", "{625A8F11-2B4E-45B4-BD99-C6D629C606C0}"
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}"
@ -73,33 +73,34 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef", "libcef\libcef.vcproj", "{FA39524D-3067-4141-888D-28A86C66F2B9}"
ProjectSection(ProjectDependencies) = postProject
{60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E}
{0B469837-3D46-484A-AFB3-C5A6C68730B9} = {0B469837-3D46-484A-AFB3-C5A6C68730B9}
{EC8B7909-62AF-470D-A75D-E1D89C837142} = {EC8B7909-62AF-470D-A75D-E1D89C837142}
{21E22961-22BF-4493-BD3A-868F93DA5179} = {21E22961-22BF-4493-BD3A-868F93DA5179}
{1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165}
{238CE175-76CE-4A25-A676-69D115885601} = {238CE175-76CE-4A25-A676-69D115885601}
{1C16337B-ACF3-4D03-AA90-851C5B5EADA6} = {1C16337B-ACF3-4D03-AA90-851C5B5EADA6}
{326E9795-E760-410A-B69A-3F79DB3F5243} = {326E9795-E760-410A-B69A-3F79DB3F5243}
{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}
{5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65} = {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}
{2A70CBF0-847E-4E3A-B926-542A656DC7FE} = {2A70CBF0-847E-4E3A-B926-542A656DC7FE}
{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}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "V8", "V8", "{B353A6A5-9551-4B76-908E-0F0A9B31E4CE}"
@ -110,14 +111,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "modp_b64", "..\third_party\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "activex_shim", "..\webkit\activex_shim\activex_shim.vcproj", "{F4F4BCAA-EA59-445C-A119-3E6C29647A51}"
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(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}"
@ -138,8 +139,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "V8Bindings_prebuild", "..\w
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_snapshot", "..\v8\tools\visual_studio\v8_snapshot.vcproj", "{C0334F9A-1168-4101-9DD8-C30FB252D435}"
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}"
@ -150,9 +151,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{A507014E
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tld_cleanup", "..\net\build\tld_cleanup.vcproj", "{E13045CD-7E1F-4A41-9B18-8D288B2E7B41}"
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}"
@ -173,8 +174,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "webkit_strings", "..\webkit
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cefclient", "tests\cefclient\cefclient.vcproj", "{6617FED9-C5D4-4907-BF55-A90062A6683F}"
ProjectSection(ProjectDependencies) = postProject
{C13650D5-CF1A-4259-BE45-B1EBA6280E47} = {C13650D5-CF1A-4259-BE45-B1EBA6280E47}
{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}"
@ -192,48 +193,48 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "v8_snapshot_cc", "..\v8\too
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef_dll", "libcef_dll\libcef_dll.vcproj", "{C13650D5-CF1A-4259-BE45-B1EBA6280E47}"
ProjectSection(ProjectDependencies) = postProject
{2A70CBF0-847E-4E3A-B926-542A656DC7FE} = {2A70CBF0-847E-4E3A-B926-542A656DC7FE}
{A508ADD3-CECE-4E0F-8448-2F5E454DF551} = {A508ADD3-CECE-4E0F-8448-2F5E454DF551}
{FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED} = {FC0E1FD0-5DD7-4041-A1C9-CD3C376E4EED}
{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} = {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}
{EF5E94AB-B646-4E5B-A058-52EF07B8351C} = {EF5E94AB-B646-4E5B-A058-52EF07B8351C}
{F4F4BCAA-EA59-445C-A119-3E6C29647A51} = {F4F4BCAA-EA59-445C-A119-3E6C29647A51}
{C0334F9A-1168-4101-9DD8-C30FB252D435} = {C0334F9A-1168-4101-9DD8-C30FB252D435}
{326E9795-E760-410A-B69A-3F79DB3F5243} = {326E9795-E760-410A-B69A-3F79DB3F5243}
{8C27D792-2648-4F5E-9ED0-374276327308} = {8C27D792-2648-4F5E-9ED0-374276327308}
{AA8A5A85-592B-4357-BC60-E0E91E026AF6} = {AA8A5A85-592B-4357-BC60-E0E91E026AF6}
{5916D37D-8C97-424F-A904-74E52594C2D6} = {5916D37D-8C97-424F-A904-74E52594C2D6}
{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}
{CD9CA56E-4E94-444C-87D4-58CA1E6F300D} = {CD9CA56E-4E94-444C-87D4-58CA1E6F300D}
{C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09} = {C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09}
{B55CA863-B374-4BAF-95AC-539E4FA4C90C} = {B55CA863-B374-4BAF-95AC-539E4FA4C90C}
{21E22961-22BF-4493-BD3A-868F93DA5179} = {21E22961-22BF-4493-BD3A-868F93DA5179}
{F54ABC59-5C00-414A-A9BA-BAF26D1699F0} = {F54ABC59-5C00-414A-A9BA-BAF26D1699F0}
{FA39524D-3067-4141-888D-28A86C66F2B9} = {FA39524D-3067-4141-888D-28A86C66F2B9}
{5597AD47-3494-4750-A235-4F9C2F864700} = {5597AD47-3494-4750-A235-4F9C2F864700}
{C564F145-9172-42C3-BFCB-6014CA97DBCD} = {C564F145-9172-42C3-BFCB-6014CA97DBCD}
{60B43839-95E6-4526-A661-209F16335E0E} = {60B43839-95E6-4526-A661-209F16335E0E}
{0B469837-3D46-484A-AFB3-C5A6C68730B9} = {0B469837-3D46-484A-AFB3-C5A6C68730B9}
{7100F41F-868D-4E99-80A2-AF8E6574749D} = {7100F41F-868D-4E99-80A2-AF8E6574749D}
{625A8F11-2B4E-45B4-BD99-C6D629C606C0} = {625A8F11-2B4E-45B4-BD99-C6D629C606C0}
{8423AF0D-4B88-4EBF-94E1-E4D00D00E21C} = {8423AF0D-4B88-4EBF-94E1-E4D00D00E21C}
{EC8B7909-62AF-470D-A75D-E1D89C837142} = {EC8B7909-62AF-470D-A75D-E1D89C837142}
{5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65} = {5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}
{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}
{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}
{B55CA863-B374-4BAF-95AC-539E4FA4C90C} = {B55CA863-B374-4BAF-95AC-539E4FA4C90C}
{C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09} = {C66B126D-0ECE-4CA2-B6DC-FA780AFBBF09}
{CD9CA56E-4E94-444C-87D4-58CA1E6F300D} = {CD9CA56E-4E94-444C-87D4-58CA1E6F300D}
{1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165}
{238CE175-76CE-4A25-A676-69D115885601} = {238CE175-76CE-4A25-A676-69D115885601}
{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}
{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}") = "libcef_dll_wrapper", "libcef_dll\wrapper\libcef_dll_wrapper.vcproj", "{A9D6DC71-C0DC-4549-AEA0-3B15B44E86A9}"
ProjectSection(ProjectDependencies) = postProject
{C13650D5-CF1A-4259-BE45-B1EBA6280E47} = {C13650D5-CF1A-4259-BE45-B1EBA6280E47}
{1832A374-8A74-4F9E-B536-69A699B3E165} = {1832A374-8A74-4F9E-B536-69A699B3E165}
{C13650D5-CF1A-4259-BE45-B1EBA6280E47} = {C13650D5-CF1A-4259-BE45-B1EBA6280E47}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WebKit", "..\webkit\build\WebKit\WebKit.vcproj", "{5ECEC9E5-8F23-47B6-93E0-C3B328B3BE65}"
ProjectSection(ProjectDependencies) = postProject
{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}
{1444235E-0E97-4C80-A73E-EE73F3706C32} = {1444235E-0E97-4C80-A73E-EE73F3706C32}
{2E2D3301-2EC4-4C0F-B889-87073B30F673} = {2E2D3301-2EC4-4C0F-B889-87073B30F673}
EndProjectSection
EndProject
Global

View File

@ -75,6 +75,9 @@ public:
// itself from memory. The resulting reference count value is returned and
// should be used for diagnostic/testing purposes only.
virtual int Release() =0;
// Return the current number of references.
virtual int GetRefCt() = 0;
};
@ -112,18 +115,18 @@ public:
{
m_dwRef = 0L;
}
~CefThreadSafeBase()
virtual ~CefThreadSafeBase()
{
}
// Atomic reference increment.
int AddRef()
virtual int AddRef()
{
return CefAtomicIncrement(&m_dwRef);
}
// Atomic reference decrement. Delete this object when no references remain.
int Release()
virtual int Release()
{
int retval = CefAtomicDecrement(&m_dwRef);
if(retval == 0)
@ -131,6 +134,9 @@ public:
return retval;
}
// Return the current number of references.
virtual int GetRefCt() { return m_dwRef; }
// Use the Lock() and Unlock() methods to protect a section of code from
// simultaneous access by multiple threads.
void Lock() { m_critsec.Lock(); }
@ -166,6 +172,15 @@ public:
CefRefPtr<CefHandler> handler,
const std::wstring& url);
// Create a new browser window using the window parameters specified
// by |windowInfo|. The |popup| parameter should be true if the new window is
// a popup window. This method call will block and can only be used if
// the |multi_threaded_message_loop| parameter to CefInitialize() is false.
static CefRefPtr<CefBrowser> CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url);
// Returns true if the browser can navigate backwards.
virtual bool CanGoBack() =0;
// Navigate backwards.
@ -198,6 +213,10 @@ public:
// Execute select all in the target frame.
virtual void SelectAll(TargetFrame targetFrame) =0;
// Set focus for the browser window. If |enable| is true focus will be set
// to the window. Otherwise, focus will be removed.
virtual void SetFocus(bool enable) =0;
// Execute printing in the target frame. The user will be prompted with
// the print dialog appropriate to the operating system.
virtual void Print(TargetFrame targetFrame) =0;
@ -420,6 +439,15 @@ public:
bool& retval,
std::wstring& result) =0;
// Called just before a window is closed. The return value is currently
// ignored.
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser) =0;
// Called when the browser component is about to loose focus. For instance,
// if focus was on the last HTML element and the user pressed the TAB key.
// The return value is currently ignored.
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser,
bool reverse) =0;
};

View File

@ -73,6 +73,8 @@ typedef struct _cef_base_t
// Decrement the reference count. Delete this object when no references
// remain.
int (CEF_CALLBACK *release)(struct _cef_base_t* base);
// Returns the current number of references.
int (CEF_CALLBACK *get_refct)(struct _cef_base_t* base);
} cef_base_t;
@ -125,6 +127,10 @@ typedef struct _cef_browser_t
void (CEF_CALLBACK *select_all)(struct _cef_browser_t* browser,
enum cef_targetframe_t targetFrame);
// Set focus for the browser window. If |enable| is true (1) focus will be
// set to the window. Otherwise, focus will be removed.
void (CEF_CALLBACK *set_focus)(struct _cef_browser_t* browser, int enable);
// 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,
@ -348,6 +354,17 @@ typedef struct _cef_handler_t
const wchar_t* message, const wchar_t* defaultValue, int* retval,
cef_string_t* result);
// Called just before a window is closed. The return value is currently
// ignored.
enum cef_retval_t (CEF_CALLBACK *handle_before_window_close)(
struct _cef_handler_t* handler, cef_browser_t* browser);
// Called when the browser component is about to loose focus. For instance,
// if focus was on the last HTML element and the user pressed the TAB key.
// The return value is currently ignored.
enum cef_retval_t (CEF_CALLBACK *handle_take_focus)(
struct _cef_handler_t* handler, cef_browser_t* browser, int reverse);
} cef_handler_t;
@ -599,6 +616,15 @@ typedef struct _cef_variant_t
CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup,
cef_handler_t* handler, const wchar_t* url);
// Create a new browser window using the window parameters specified
// by |windowInfo|. The |popup| parameter should be true (1) if the new window
// is a popup window. This method call will block and can only be used if
// the |multi_threaded_message_loop| parameter to CefInitialize() is false.
CEF_EXPORT cef_browser_t* cef_create_browser_sync(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();

View File

@ -78,6 +78,11 @@ public:
cef_string_free(m_windowName);
}
CefWindowInfo(const CefWindowInfo& r)
{
Init();
*this = r;
}
CefWindowInfo(const cef_window_info_t& r)
{
Init();
@ -98,6 +103,10 @@ public:
m_hWnd = NULL;
}
CefWindowInfo& operator=(const CefWindowInfo& r)
{
return operator=(static_cast<const cef_window_info_t&>(r));
}
CefWindowInfo& operator=(const cef_window_info_t& r)
{
m_dwExStyle = r.m_dwExStyle;
@ -159,6 +168,11 @@ public:
{
}
CefPrintInfo(const CefPrintInfo& r)
{
Init();
*this = r;
}
CefPrintInfo(const cef_print_info_t& r)
{
Init();
@ -172,6 +186,10 @@ public:
m_Scale = 0;
}
CefPrintInfo& operator=(const CefPrintInfo& r)
{
return operator=(static_cast<const cef_print_info_t&>(r));
}
CefPrintInfo& operator=(const cef_print_info_t& r)
{
m_hDC = r.m_hDC;

View File

@ -33,6 +33,7 @@ CefBrowserImpl::~CefBrowserImpl()
if(webview_bitmap_ != NULL)
DeleteObject(webview_bitmap_);
#endif
RemoveAllJSHandlers();
}
void CefBrowserImpl::GoBack()
@ -111,6 +112,20 @@ void CefBrowserImpl::SelectAll(TargetFrame targetFrame)
MENU_ID_SELECTALL, targetFrame));
}
void CefBrowserImpl::SetFocus(bool enable)
{
if (_Context->RunningOnUIThread())
{
UIT_SetFocus(UIT_GetWebViewHost(), enable);
}
else
{
PostTask(FROM_HERE, NewRunnableMethod(this,
&CefBrowserImpl::UIT_SetFocus,
UIT_GetWebViewHost(), enable));
}
}
void CefBrowserImpl::Print(TargetFrame targetFrame)
{
PostTask(FROM_HERE, NewRunnableMethod(this,
@ -279,6 +294,35 @@ bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
return true;
}
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url)
{
if(!_Context.get() || !_Context->RunningOnUIThread())
return NULL;
std::wstring newUrl = url;
CefRefPtr<CefBrowser> alternateBrowser;
if(handler.get())
{
// Give the handler an opportunity to modify window attributes, handler,
// or cancel the window creation.
CefHandler::RetVal rv = handler->HandleBeforeCreated(NULL, windowInfo,
popup, handler, newUrl);
if(rv == RV_HANDLED)
return false;
}
CefRefPtr<CefBrowser> browser(
new CefBrowserImpl(windowInfo, popup, handler, newUrl));
static_cast<CefBrowserImpl*>(browser.get())->UIT_CreateBrowser();
return browser;
}
void CefBrowserImpl::UIT_LoadURL(const std::wstring& url)
{
REQUIRE_UIT();
@ -321,6 +365,79 @@ void CefBrowserImpl::UIT_LoadURLForRequestRef(CefRequest* request)
request->Release();
}
void CefBrowserImpl::UIT_LoadURLForRequest(const std::wstring& url,
const std::wstring& frame_name,
const std::wstring& method,
net::UploadData *upload_data,
const WebRequest::HeaderMap& headers)
{
REQUIRE_UIT();
if (url.empty())
return;
GURL gurl(url);
if (!gurl.is_valid() && !gurl.has_scheme()) {
// Try to add "http://" at the beginning
gurl = GURL(std::wstring(L"http://") + url);
if (!gurl.is_valid())
return;
}
nav_controller_->LoadEntry(new BrowserNavigationEntry(
-1, gurl, std::wstring(), frame_name, method, upload_data, headers));
}
void CefBrowserImpl::UIT_LoadHTML(const std::wstring& html,
const std::wstring& url)
{
REQUIRE_UIT();
GURL gurl(url);
if (!gurl.is_valid() && !gurl.has_scheme()) {
// Try to add "http://" at the beginning
gurl = GURL(std::wstring(L"http://") + url);
if (!gurl.is_valid())
return;
}
UIT_GetWebView()->GetMainFrame()->LoadHTMLString(WideToUTF8(html), gurl);
}
void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefStreamReader* stream,
const std::wstring& url)
{
REQUIRE_UIT();
GURL gurl(url);
if (!gurl.is_valid() && !gurl.has_scheme()) {
// Try to add "http://" at the beginning
gurl = GURL(std::wstring(L"http://") + url);
if (!gurl.is_valid())
return;
}
// read all of the stream data into a std::string.
std::stringstream ss;
char buff[BUFFER_SIZE];
size_t read;
do {
read = stream->Read(buff, sizeof(char), BUFFER_SIZE-1);
if(read > 0) {
buff[read] = 0;
ss << buff;
}
}
while(read > 0);
UIT_GetWebView()->GetMainFrame()->LoadHTMLString(ss.str(), gurl);
stream->Release();
}
void CefBrowserImpl::UIT_ExecuteJavaScript(const std::wstring& js_code,
const std::wstring& script_url,
int start_line,
@ -439,8 +556,8 @@ CefRefPtr<CefBrowserImpl> CefBrowserImpl::UIT_CreatePopupWindow(const std::wstri
return NULL;
}
CefRefPtr<CefBrowserImpl> browser(
new CefBrowserImpl(info, true, handler, newUrl));
CefRefPtr<CefBrowserImpl> browser(
new CefBrowserImpl(info, true, handler, newUrl));
browser->UIT_CreateBrowser();
return browser;

View File

@ -19,6 +19,7 @@
#include "webkit/glue/webview.h"
#define BUFFER_SIZE 32768
// Implementation of CefBrowser.
class CefBrowserImpl : public CefThreadSafeBase<CefBrowser>
@ -48,6 +49,7 @@ public:
virtual void Paste(TargetFrame targetFrame);
virtual void Delete(TargetFrame targetFrame);
virtual void SelectAll(TargetFrame targetFrame);
virtual void SetFocus(bool enable);
virtual void Print(TargetFrame targetFrame);
virtual void ViewSource(TargetFrame targetFrame);
virtual std::wstring GetSource(TargetFrame targetFrame);

View File

@ -20,8 +20,6 @@
#include <wininet.h>
#include <winspool.h>
#define BUFFER_SIZE 32768
LPCTSTR CefBrowserImpl::GetWndClass()
{
@ -46,6 +44,11 @@ LRESULT CALLBACK CefBrowserImpl::WndProc(HWND hwnd, UINT message,
case WM_DESTROY:
{
CefRefPtr<CefHandler> handler = browser->GetHandler();
if(handler.get()) {
// Notify the handler that the window is about to be closed
handler->HandleBeforeWindowClose(browser);
}
// Remove the browser from the list maintained by the context
_Context->RemoveBrowser(browser);
}
@ -295,78 +298,6 @@ void CefBrowserImpl::UIT_CreateBrowser()
if(url_.size() > 0)
UIT_LoadURL(url_.c_str());
}
void CefBrowserImpl::UIT_LoadURLForRequest(const std::wstring& url,
const std::wstring& frame_name,
const std::wstring& method,
net::UploadData *upload_data,
const WebRequest::HeaderMap& headers)
{
REQUIRE_UIT();
if (url.empty())
return;
std::wstring urlString(url);
if (PathFileExists(url.c_str()) || PathIsUNC(url.c_str())) {
TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
if (SUCCEEDED(UrlCreateFromPath(url.c_str(), fileURL, &fileURLLength, 0)))
urlString.assign(fileURL);
}
nav_controller_->LoadEntry(new BrowserNavigationEntry(
-1, GURL(urlString), std::wstring(), frame_name, method, upload_data,
headers));
}
void CefBrowserImpl::UIT_LoadHTML(const std::wstring& html,
const std::wstring& url)
{
REQUIRE_UIT();
std::wstring urlString(url);
if (PathFileExists(url.c_str()) || PathIsUNC(url.c_str())) {
TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
if (SUCCEEDED(UrlCreateFromPath(url.c_str(), fileURL, &fileURLLength, 0)))
urlString.assign(fileURL);
}
UIT_GetWebView()->GetMainFrame()->LoadHTMLString(
WideToUTF8(html), GURL(urlString));
}
void CefBrowserImpl::UIT_LoadHTMLForStreamRef(CefStreamReader* stream,
const std::wstring& url)
{
REQUIRE_UIT();
std::wstring urlString(url);
if (PathFileExists(url.c_str()) || PathIsUNC(url.c_str())) {
TCHAR fileURL[INTERNET_MAX_URL_LENGTH];
DWORD fileURLLength = sizeof(fileURL)/sizeof(fileURL[0]);
if (SUCCEEDED(UrlCreateFromPath(url.c_str(), fileURL, &fileURLLength, 0)))
urlString.assign(fileURL);
}
// read all of the stream data into a std::string.
std::stringstream ss;
char buff[BUFFER_SIZE];
size_t read;
do {
read = stream->Read(buff, sizeof(char), BUFFER_SIZE-1);
if(read > 0) {
buff[read] = 0;
ss << buff;
}
}
while(read > 0);
UIT_GetWebView()->GetMainFrame()->LoadHTMLString(ss.str(), GURL(urlString));
stream->Release();
}
void CefBrowserImpl::UIT_SetFocus(WebWidgetHost* host, bool enable)
{

View File

@ -643,3 +643,11 @@ std::wstring BrowserWebViewDelegate::GetFrameDescription(WebFrame* webframe) {
return L"frame (anonymous)";
}
}
void BrowserWebViewDelegate::TakeFocus(WebView* webview, bool reverse) {
CefRefPtr<CefHandler> handler = browser_->GetHandler();
if(handler.get()) {
// Notify the handler that it should take a focus
handler->HandleTakeFocus(browser_, reverse);
}
}

View File

@ -203,6 +203,7 @@ class BrowserWebViewDelegate : public base::RefCounted<BrowserWebViewDelegate>,
virtual void Release() {
base::RefCounted<BrowserWebViewDelegate>::Release();
}
virtual void TakeFocus(WebView* webview, bool reverse);
// Additional accessors
WebFrame* top_loading_frame() { return top_loading_frame_; }

View File

@ -273,7 +273,7 @@ bool CefContext::Initialize(bool multi_threaded_message_loop,
Lock();
// We only need to initialize if the UI thread is not currently running
if(!hthreadui_) {
if(!idthreadui_) {
// Only start the initialization if we're not currently in a transitional
// state
intransition = in_transition_;
@ -351,6 +351,7 @@ bool CefContext::Initialize(bool multi_threaded_message_loop,
hthreadui_ = CreateThread(
NULL, 0, ThreadHandlerUI, this, 0, &idthreadui_);
DCHECK(hthreadui_ != NULL);
DCHECK(idthreadui_ != 0);
} else {
if (!DoInitialize()) {
// TODO: Process initialization errors
@ -358,6 +359,7 @@ bool CefContext::Initialize(bool multi_threaded_message_loop,
// Create our own message loop there
SetMessageLoopForUI(new CefMessageLoopForUI());
idthreadui_ = GetCurrentThreadId();
DCHECK(idthreadui_ != 0);
}
initialized = true;
@ -390,7 +392,7 @@ void CefContext::Shutdown()
Lock();
// We only need to shut down if the UI thread is currently running
if(hthreadui_) {
if(idthreadui_) {
// Only start the shutdown if we're not currently in a transitional state
intransition = in_transition_;
if(!intransition) {
@ -417,21 +419,24 @@ void CefContext::Shutdown()
Unlock();
if(shutdown) {
// Wait for the UI thread to exit
WaitForSingleObject(hthreadui_, INFINITE);
if (hthreadui_) {
// Wait for the UI thread to exit
WaitForSingleObject(hthreadui_, INFINITE);
// Clean up thread and event handles
CloseHandle(hthreadui_);
CloseHandle(heventui_);
hthreadui_ = NULL;
heventui_ = NULL;
}
Lock();
// Unregister the window class
UnregisterClass(CefBrowserImpl::GetWndClass(), hinstance_);
// Clean up thread and event handles
CloseHandle(hthreadui_);
CloseHandle(heventui_);
hthreadui_ = NULL;
idthreadui_ = 0;
heventui_ = NULL;
messageloopui_ = NULL;
// We have exited the transitional state

View File

@ -41,7 +41,7 @@ MSVC_POP_WARNING()
// callbacks to.
struct CefNPObject {
NPObject parent; // This must be the first field in the struct.
CefRefPtr<CefJSContainer> container;
CefJSContainer* container;
WebFrame* webframe;
//
@ -148,11 +148,11 @@ NPClass CefNPObject::np_class_ = {
return obj->container->SetProperty(ident, obj->webframe, value);
}
CefJSContainer::CefJSContainer(CefRefPtr<CefBrowser> browser,
CefJSContainer::CefJSContainer(CefBrowser* browser,
CefRefPtr<CefJSHandler> handler)
: browser_(browser), handler_(handler)
{
DCHECK(browser_.get() != NULL);
DCHECK(browser_ != NULL);
DCHECK(handler_.get() != NULL);
}
@ -275,4 +275,3 @@ void CefJSContainer::BindToJavascript(WebFrame* frame,
// so we can release it when we're destroyed.
frame->BindToWindowObject(classname, np_obj);
}

View File

@ -18,7 +18,7 @@ class WebFrame;
class CefJSContainer : public CefThreadSafeBase<CefBase>
{
public:
CefJSContainer(CefRefPtr<CefBrowser> browser,
CefJSContainer(CefBrowser* browser,
CefRefPtr<CefJSHandler> handler);
~CefJSContainer();
@ -52,7 +52,7 @@ protected:
friend struct CefNPObject;
protected:
CefRefPtr<CefBrowser> browser_;
CefBrowser* browser_;
CefRefPtr<CefJSHandler> handler_;
// A list of all NPObjects we created and bound in BindToJavascript(), so we

View File

@ -10,6 +10,7 @@
#include "ctocpp/jshandler_ctocpp.h"
#include "base/logging.h"
int CEF_CALLBACK browser_can_go_back(cef_browser_t* browser)
{
DCHECK(browser);
@ -160,6 +161,17 @@ void CEF_CALLBACK browser_select_all(cef_browser_t* browser,
impl->class_->GetClass()->SelectAll(targetFrame);
}
void CEF_CALLBACK browser_set_focus(struct _cef_browser_t* browser, int enable)
{
DCHECK(browser);
if(!browser)
return;
CefBrowserCppToC::Struct* impl =
reinterpret_cast<CefBrowserCppToC::Struct*>(browser);
impl->class_->GetClass()->SetFocus(enable ? true : false);
}
void CEF_CALLBACK browser_print(cef_browser_t* browser,
enum cef_targetframe_t targetFrame)
{
@ -460,7 +472,7 @@ cef_string_t CEF_CALLBACK browser_get_url(cef_browser_t* browser)
return cef_string_alloc(urlStr.c_str());
}
CefBrowserCppToC::CefBrowserCppToC(CefRefPtr<CefBrowser> cls)
CefBrowserCppToC::CefBrowserCppToC(CefBrowser* cls)
: CefCppToC<CefBrowser, cef_browser_t>(cls)
{
struct_.struct_.can_go_back = browser_can_go_back;
@ -476,6 +488,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefRefPtr<CefBrowser> cls)
struct_.struct_.paste = browser_paste;
struct_.struct_.del = browser_delete;
struct_.struct_.select_all = browser_select_all;
struct_.struct_.set_focus = browser_set_focus;
struct_.struct_.print = browser_print;
struct_.struct_.view_source = browser_view_source;
struct_.struct_.get_source = browser_get_source;
@ -495,3 +508,7 @@ CefBrowserCppToC::CefBrowserCppToC(CefRefPtr<CefBrowser> cls)
struct_.struct_.get_handler = browser_get_handler;
struct_.struct_.get_url = browser_get_url;
}
#ifdef _DEBUG
long CefCppToC<CefBrowser, cef_browser_t>::DebugObjCt = 0;
#endif

View File

@ -19,7 +19,7 @@
class CefBrowserCppToC : public CefCppToC<CefBrowser, cef_browser_t>
{
public:
CefBrowserCppToC(CefRefPtr<CefBrowser> cls);
CefBrowserCppToC(CefBrowser* cls);
virtual ~CefBrowserCppToC() {}
};

View File

@ -22,10 +22,10 @@ public:
CefCppToC<ClassName, StructName>* class_;
};
CefCppToC(CefRefPtr<ClassName> cls)
CefCppToC(ClassName* cls)
: class_(cls)
{
DCHECK(cls.get());
DCHECK(cls);
struct_.class_ = this;
@ -34,12 +34,20 @@ public:
struct_.struct_.base.size = sizeof(StructName);
struct_.struct_.base.add_ref = struct_add_ref;
struct_.struct_.base.release = struct_release;
struct_.struct_.base.get_refct = struct_get_refct;
#ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCppToC()
{
#ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
}
CefRefPtr<ClassName> GetClass() { return class_; }
ClassName* 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,
@ -62,6 +70,12 @@ public:
// Increment/decrement reference counts on only the underlying class.
int UnderlyingAddRef() { return class_->AddRef(); }
int UnderlyingRelease() { return class_->Release(); }
int UnderlyingGetRefCt() { return class_->GetRefCt(); }
#ifdef _DEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
#endif
private:
static int CEF_CALLBACK struct_add_ref(struct _cef_base_t* base)
@ -84,9 +98,19 @@ private:
return impl->class_->Release();
}
static int CEF_CALLBACK struct_get_refct(struct _cef_base_t* base)
{
DCHECK(base);
if(!base)
return 0;
Struct* impl = reinterpret_cast<Struct*>(base);
return impl->class_->GetRefCt();
}
protected:
Struct struct_;
CefRefPtr<ClassName> class_;
ClassName* class_;
};
#endif // _CPPTOC_H

View File

@ -53,7 +53,7 @@ enum cef_retval_t CEF_CALLBACK handler_handle_before_created(
transfer_string_contents(urlStr, url);
if(handlerPtr.get() != structPtr->class_->GetClass().get())
if(handlerPtr.get() != structPtr->class_->GetClass())
{
// The handler has been changed.
CefHandlerCppToC* hobj = new CefHandlerCppToC(handlerPtr);
@ -501,8 +501,45 @@ enum cef_retval_t CEF_CALLBACK handler_handle_jsprompt(
return rv;
}
enum cef_retval_t CEF_CALLBACK handler_handle_before_window_close(
struct _cef_handler_t* handler, cef_browser_t* browser)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
CefHandlerCppToC::Struct* impl =
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
CefRefPtr<CefBrowser> browserPtr(bp);
bp->UnderlyingRelease();
return impl->class_->GetClass()->HandleBeforeWindowClose(browserPtr);
}
CefHandlerCppToC::CefHandlerCppToC(CefRefPtr<CefHandler> cls)
enum cef_retval_t CEF_CALLBACK handler_handle_take_focus(
struct _cef_handler_t* handler, cef_browser_t* browser, int reverse)
{
DCHECK(handler);
DCHECK(browser);
if(!handler || !browser)
return RV_CONTINUE;
CefHandlerCppToC::Struct* impl =
reinterpret_cast<CefHandlerCppToC::Struct*>(handler);
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browser);
CefRefPtr<CefBrowser> browserPtr(bp);
bp->UnderlyingRelease();
return impl->class_->GetClass()->
HandleTakeFocus(browserPtr, (reverse ? true : false));
}
CefHandlerCppToC::CefHandlerCppToC(CefHandler* cls)
: CefCppToC<CefHandler, cef_handler_t>(cls)
{
struct_.struct_.handle_before_created = handler_handle_before_created;
@ -523,4 +560,11 @@ CefHandlerCppToC::CefHandlerCppToC(CefRefPtr<CefHandler> cls)
struct_.struct_.handle_jsalert = handler_handle_jsalert;
struct_.struct_.handle_jsconfirm = handler_handle_jsconfirm;
struct_.struct_.handle_jsprompt = handler_handle_jsprompt;
struct_.struct_.handle_before_window_close =
handler_handle_before_window_close;
struct_.struct_.handle_take_focus = handler_handle_take_focus;
}
#ifdef _DEBUG
long CefCppToC<CefHandler, cef_handler_t>::DebugObjCt = 0;
#endif

View File

@ -19,7 +19,7 @@
class CefHandlerCppToC : public CefCppToC<CefHandler, cef_handler_t>
{
public:
CefHandlerCppToC(CefRefPtr<CefHandler> cls);
CefHandlerCppToC(CefHandler* cls);
virtual ~CefHandlerCppToC() {}
};

View File

@ -144,7 +144,7 @@ bool CEF_CALLBACK jshandler_execute_method(struct _cef_jshandler_t* jshandler,
}
CefJSHandlerCppToC::CefJSHandlerCppToC(CefRefPtr<CefJSHandler> cls)
CefJSHandlerCppToC::CefJSHandlerCppToC(CefJSHandler* cls)
: CefCppToC<CefJSHandler, cef_jshandler_t>(cls)
{
struct_.struct_.has_method = jshandler_has_method;
@ -153,3 +153,7 @@ CefJSHandlerCppToC::CefJSHandlerCppToC(CefRefPtr<CefJSHandler> cls)
struct_.struct_.get_property = jshandler_get_property;
struct_.struct_.execute_method = jshandler_execute_method;
}
#ifdef _DEBUG
long CefCppToC<CefJSHandler, cef_jshandler_t>::DebugObjCt = 0;
#endif

View File

@ -19,7 +19,7 @@
class CefJSHandlerCppToC : public CefCppToC<CefJSHandler, cef_jshandler_t>
{
public:
CefJSHandlerCppToC(CefRefPtr<CefJSHandler> cls);
CefJSHandlerCppToC(CefJSHandler* cls);
virtual ~CefJSHandlerCppToC() {}
};

View File

@ -207,7 +207,7 @@ void CEF_CALLBACK request_set(struct _cef_request_t* request,
}
CefRequestCppToC::CefRequestCppToC(CefRefPtr<CefRequest> cls)
CefRequestCppToC::CefRequestCppToC(CefRequest* cls)
: CefCppToC<CefRequest, cef_request_t>(cls)
{
struct_.struct_.get_url = request_get_url;
@ -222,7 +222,10 @@ CefRequestCppToC::CefRequestCppToC(CefRefPtr<CefRequest> cls)
struct_.struct_.set_header_map = request_set_header_map;
struct_.struct_.set = request_set;
}
#ifdef _DEBUG
long CefCppToC<CefRequest, cef_request_t>::DebugObjCt = 0;
#endif
size_t CEF_CALLBACK post_data_get_element_count(
@ -303,7 +306,7 @@ void CEF_CALLBACK post_data_remove_elements(struct _cef_post_data_t* postData)
}
CefPostDataCppToC::CefPostDataCppToC(CefRefPtr<CefPostData> cls)
CefPostDataCppToC::CefPostDataCppToC(CefPostData* cls)
: CefCppToC<CefPostData, cef_post_data_t>(cls)
{
struct_.struct_.get_element_count = post_data_get_element_count;
@ -312,7 +315,10 @@ CefPostDataCppToC::CefPostDataCppToC(CefRefPtr<CefPostData> cls)
struct_.struct_.add_element = post_data_add_element;
struct_.struct_.remove_elements = post_data_remove_elements;
}
#ifdef _DEBUG
long CefCppToC<CefPostData, cef_post_data_t>::DebugObjCt = 0;
#endif
void CEF_CALLBACK post_data_element_set_to_empty(
@ -411,8 +417,7 @@ size_t CEF_CALLBACK post_data_element_get_bytes(
}
CefPostDataElementCppToC::CefPostDataElementCppToC(
CefRefPtr<CefPostDataElement> cls)
CefPostDataElementCppToC::CefPostDataElementCppToC(CefPostDataElement* cls)
: CefCppToC<CefPostDataElement, cef_post_data_element_t>(cls)
{
struct_.struct_.set_to_empty = post_data_element_set_to_empty;
@ -423,3 +428,7 @@ CefPostDataElementCppToC::CefPostDataElementCppToC(
struct_.struct_.get_bytes_count = post_data_element_get_bytes_count;
struct_.struct_.get_bytes = post_data_element_get_bytes;
}
#ifdef _DEBUG
long CefCppToC<CefPostDataElement, cef_post_data_element_t>::DebugObjCt = 0;
#endif

View File

@ -19,7 +19,7 @@
class CefRequestCppToC : public CefCppToC<CefRequest, cef_request_t>
{
public:
CefRequestCppToC(CefRefPtr<CefRequest> cls);
CefRequestCppToC(CefRequest* cls);
virtual ~CefRequestCppToC() {}
};
@ -29,7 +29,7 @@ public:
class CefPostDataCppToC : public CefCppToC<CefPostData, cef_post_data_t>
{
public:
CefPostDataCppToC(CefRefPtr<CefPostData> cls);
CefPostDataCppToC(CefPostData* cls);
virtual ~CefPostDataCppToC() {}
};
@ -42,7 +42,7 @@ class CefPostDataElementCppToC :
public CefCppToC<CefPostDataElement, cef_post_data_element_t>
{
public:
CefPostDataElementCppToC(CefRefPtr<CefPostDataElement> cls);
CefPostDataElementCppToC(CefPostDataElement* cls);
virtual ~CefPostDataElementCppToC() {}
};

View File

@ -54,7 +54,7 @@ int CEF_CALLBACK stream_reader_eof(struct _cef_stream_reader_t* stream)
}
CefStreamReaderCppToC::CefStreamReaderCppToC(CefRefPtr<CefStreamReader> cls)
CefStreamReaderCppToC::CefStreamReaderCppToC(CefStreamReader* cls)
: CefCppToC<CefStreamReader, cef_stream_reader_t>(cls)
{
struct_.struct_.read = stream_reader_read;
@ -62,7 +62,10 @@ CefStreamReaderCppToC::CefStreamReaderCppToC(CefRefPtr<CefStreamReader> cls)
struct_.struct_.tell = stream_reader_tell;
struct_.struct_.eof = stream_reader_eof;
}
#ifdef _DEBUG
long CefCppToC<CefStreamReader, cef_stream_reader_t>::DebugObjCt = 0;
#endif
size_t CEF_CALLBACK stream_writer_write(struct _cef_stream_writer_t* stream,
@ -112,7 +115,7 @@ int CEF_CALLBACK stream_writer_flush(struct _cef_stream_writer_t* stream)
}
CefStreamWriterCppToC::CefStreamWriterCppToC(CefRefPtr<CefStreamWriter> cls)
CefStreamWriterCppToC::CefStreamWriterCppToC(CefStreamWriter* cls)
: CefCppToC<CefStreamWriter, cef_stream_writer_t>(cls)
{
struct_.struct_.write = stream_writer_write;
@ -120,3 +123,7 @@ CefStreamWriterCppToC::CefStreamWriterCppToC(CefRefPtr<CefStreamWriter> cls)
struct_.struct_.tell = stream_writer_tell;
struct_.struct_.flush = stream_writer_flush;
}
#ifdef _DEBUG
long CefCppToC<CefStreamWriter, cef_stream_writer_t>::DebugObjCt = 0;
#endif

View File

@ -20,7 +20,7 @@ class CefStreamReaderCppToC :
public CefCppToC<CefStreamReader, cef_stream_reader_t>
{
public:
CefStreamReaderCppToC(CefRefPtr<CefStreamReader> cls);
CefStreamReaderCppToC(CefStreamReader* cls);
virtual ~CefStreamReaderCppToC() {}
};
@ -31,7 +31,7 @@ class CefStreamWriterCppToC :
public CefCppToC<CefStreamWriter, cef_stream_writer_t>
{
public:
CefStreamWriterCppToC(CefRefPtr<CefStreamWriter> cls);
CefStreamWriterCppToC(CefStreamWriter* cls);
virtual ~CefStreamWriterCppToC() {}
};

View File

@ -282,7 +282,7 @@ size_t CEF_CALLBACK variant_get_string_array(struct _cef_variant_t* variant,
}
CefVariantCppToC::CefVariantCppToC(CefRefPtr<CefVariant> cls)
CefVariantCppToC::CefVariantCppToC(CefVariant* cls)
: CefCppToC<CefVariant, cef_variant_t>(cls)
{
struct_.struct_.get_type = variant_get_type;
@ -305,3 +305,7 @@ CefVariantCppToC::CefVariantCppToC(CefRefPtr<CefVariant> cls)
struct_.struct_.get_double_array = variant_get_double_array;
struct_.struct_.get_string_array = variant_get_string_array;
}
#ifdef _DEBUG
long CefCppToC<CefVariant, cef_variant_t>::DebugObjCt = 0;
#endif

View File

@ -19,7 +19,7 @@
class CefVariantCppToC : public CefCppToC<CefVariant, cef_variant_t>
{
public:
CefVariantCppToC(CefRefPtr<CefVariant> cls);
CefVariantCppToC(CefVariant* cls);
virtual ~CefVariantCppToC() {}
};

View File

@ -115,6 +115,14 @@ void CefBrowserCToCpp::SelectAll(TargetFrame targetFrame)
struct_->select_all(struct_, targetFrame);
}
void CefBrowserCToCpp::SetFocus(bool enable)
{
if(CEF_MEMBER_MISSING(struct_, set_focus))
return;
struct_->set_focus(struct_, enable);
}
void CefBrowserCToCpp::Print(TargetFrame targetFrame)
{
if(CEF_MEMBER_MISSING(struct_, print))
@ -310,3 +318,7 @@ std::wstring CefBrowserCToCpp::GetURL()
}
return str;
}
#ifdef _DEBUG
long CefCToCpp<CefBrowser, cef_browser_t>::DebugObjCt = 0;
#endif

View File

@ -37,6 +37,7 @@ public:
virtual void Paste(TargetFrame targetFrame);
virtual void Delete(TargetFrame targetFrame);
virtual void SelectAll(TargetFrame targetFrame);
virtual void SetFocus(bool enable);
virtual void Print(TargetFrame targetFrame);
virtual void ViewSource(TargetFrame targetFrame);
virtual std::wstring GetSource(TargetFrame targetFrame);

View File

@ -19,9 +19,16 @@ public:
: struct_(str)
{
DCHECK(str);
#ifdef _DEBUG
CefAtomicIncrement(&DebugObjCt);
#endif
}
virtual ~CefCToCpp()
{
#ifdef _DEBUG
CefAtomicDecrement(&DebugObjCt);
#endif
}
// If returning the structure across the DLL boundary you should call
@ -55,6 +62,17 @@ public:
return 0;
return struct_->base.release(&struct_->base);
}
int UnderlyingGetRefCt()
{
if(!struct_->base.get_refct)
return 0;
return struct_->base.get_refct(&struct_->base);
}
#ifdef _DEBUG
// Simple tracking of allocated objects.
static long DebugObjCt;
#endif
protected:
StructName* struct_;

View File

@ -335,3 +335,31 @@ CefHandler::RetVal CefHandlerCToCpp::HandleJSPrompt(
return rv;
}
CefHandler::RetVal CefHandlerCToCpp::HandleBeforeWindowClose(
CefRefPtr<CefBrowser> browser)
{
if(CEF_MEMBER_MISSING(struct_, handle_before_window_close))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
return struct_->handle_before_window_close(struct_, browserPtr->GetStruct());
}
CefHandler::RetVal CefHandlerCToCpp::HandleTakeFocus(
CefRefPtr<CefBrowser> browser, bool reverse)
{
if(CEF_MEMBER_MISSING(struct_, handle_take_focus))
return RV_CONTINUE;
CefBrowserCppToC* browserPtr = new CefBrowserCppToC(browser);
browserPtr->AddRef();
return struct_->handle_take_focus(struct_, browserPtr->GetStruct(), reverse);
}
#ifdef _DEBUG
long CefCToCpp<CefHandler, cef_handler_t>::DebugObjCt = 0;
#endif

View File

@ -74,6 +74,9 @@ public:
const std::wstring& default_value,
bool& retval,
std::wstring& result);
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser);
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser,
bool reverse);
};

View File

@ -101,3 +101,7 @@ bool CefJSHandlerCToCpp::ExecuteMethod(CefRefPtr<CefBrowser> browser,
return rv;
}
#ifdef _DEBUG
long CefCToCpp<CefJSHandler, cef_jshandler_t>::DebugObjCt = 0;
#endif

View File

@ -168,6 +168,10 @@ void CefRequestCToCpp::Set(const std::wstring& url,
cef_string_map_free(map);
}
#ifdef _DEBUG
long CefCToCpp<CefRequest, cef_request_t>::DebugObjCt = 0;
#endif
size_t CefPostDataCToCpp::GetElementCount()
@ -231,6 +235,9 @@ void CefPostDataCToCpp::RemoveElements()
return struct_->remove_elements(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefPostData, cef_post_data_t>::DebugObjCt = 0;
#endif
void CefPostDataElementCToCpp::SetToEmpty()
@ -295,3 +302,7 @@ size_t CefPostDataElementCToCpp::GetBytes(size_t size, void *bytes)
return struct_->get_bytes(struct_, size, bytes);
}
#ifdef _DEBUG
long CefCToCpp<CefPostDataElement, cef_post_data_element_t>::DebugObjCt = 0;
#endif

View File

@ -39,6 +39,10 @@ int CefStreamReaderCToCpp::Eof()
return struct_->eof(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefStreamReader, cef_stream_reader_t>::DebugObjCt = 0;
#endif
size_t CefStreamWriterCToCpp::Write(const void *ptr, size_t size, size_t n)
{
@ -71,3 +75,7 @@ int CefStreamWriterCToCpp::Flush()
return struct_->flush(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefStreamWriter, cef_stream_writer_t>::DebugObjCt = 0;
#endif

View File

@ -295,3 +295,7 @@ int CefVariantCToCpp::GetArraySize()
return struct_->get_array_size(struct_);
}
#ifdef _DEBUG
long CefCToCpp<CefVariant, cef_variant_t>::DebugObjCt = 0;
#endif

View File

@ -7,9 +7,12 @@
#include "cef_capi.h"
#include "cef_nplugin.h"
#include "cef_nplugin_capi.h"
#include "cpptoc/browser_cpptoc.h"
#include "cpptoc/request_cpptoc.h"
#include "cpptoc/variant_cpptoc.h"
#include "cpptoc/stream_cpptoc.h"
#include "ctocpp/handler_ctocpp.h"
#include "ctocpp/jshandler_ctocpp.h"
#include "base/logging.h"
#include "base/string_util.h"
@ -26,6 +29,17 @@ CEF_EXPORT int cef_initialize(int multi_threaded_message_loop,
CEF_EXPORT void cef_shutdown()
{
CefShutdown();
// Check that all wrapper objects have been destroyed
DCHECK(CefBrowserCppToC::DebugObjCt == 0);
DCHECK(CefRequestCppToC::DebugObjCt == 0);
DCHECK(CefPostDataCppToC::DebugObjCt == 0);
DCHECK(CefPostDataElementCppToC::DebugObjCt == 0);
DCHECK(CefStreamReaderCppToC::DebugObjCt == 0);
DCHECK(CefStreamWriterCppToC::DebugObjCt == 0);
DCHECK(CefVariantCppToC::DebugObjCt == 0);
DCHECK(CefHandlerCToCpp::DebugObjCt == 0);
DCHECK(CefJSHandlerCToCpp::DebugObjCt == 0);
}
CEF_EXPORT void cef_do_message_loop_work()
@ -53,6 +67,36 @@ CEF_EXPORT int cef_create_browser(cef_window_info_t* windowInfo, int popup,
return CefBrowser::CreateBrowser(wi, popup, handlerPtr, urlStr);
}
CEF_EXPORT cef_browser_t* cef_create_browser_sync(cef_window_info_t* windowInfo,
int popup,
cef_handler_t* handler,
const wchar_t* url)
{
DCHECK(windowInfo);
CefRefPtr<CefHandler> handlerPtr;
std::wstring urlStr;
CefWindowInfo wi = *windowInfo;
if(handler) {
CefHandlerCToCpp* hp = new CefHandlerCToCpp(handler);
handlerPtr = hp;
hp->UnderlyingRelease();
}
if(url)
urlStr = url;
cef_browser_t* browserStruct = NULL;
CefRefPtr<CefBrowser> browserPtr(
CefBrowser::CreateBrowserSync(wi, popup, handlerPtr, urlStr));
if(!browserPtr.get())
return NULL;
CefBrowserCppToC* bp = new CefBrowserCppToC(browserPtr);
bp->AddRef();
return bp->GetStruct();
}
CEF_EXPORT cef_request_t* cef_create_request()
{
CefRefPtr<CefRequest> impl = CefRequest::CreateRequest();

View File

@ -8,7 +8,10 @@
#include "cef_nplugin.h"
#include "cef_nplugin_capi.h"
#include "../cpptoc/handler_cpptoc.h"
#include "../cpptoc/jshandler_cpptoc.h"
#include "../ctocpp/browser_ctocpp.h"
#include "../ctocpp/request_ctocpp.h"
#include "../ctocpp/variant_ctocpp.h"
#include "../ctocpp/stream_ctocpp.h"
@ -21,6 +24,17 @@ bool CefInitialize(bool multi_threaded_message_loop,
void CefShutdown()
{
cef_shutdown();
// Check that all wrapper objects have been destroyed
DCHECK(CefHandlerCppToC::DebugObjCt == 0);
DCHECK(CefJSHandlerCppToC::DebugObjCt == 0);
DCHECK(CefBrowserCToCpp::DebugObjCt == 0);
DCHECK(CefRequestCToCpp::DebugObjCt == 0);
DCHECK(CefPostDataCToCpp::DebugObjCt == 0);
DCHECK(CefPostDataElementCToCpp::DebugObjCt == 0);
DCHECK(CefStreamReaderCToCpp::DebugObjCt == 0);
DCHECK(CefStreamWriterCToCpp::DebugObjCt == 0);
DCHECK(CefVariantCToCpp::DebugObjCt == 0);
}
void CefDoMessageLoopWork()
@ -37,6 +51,26 @@ bool CefBrowser::CreateBrowser(CefWindowInfo& windowInfo, bool popup,
return cef_create_browser(&windowInfo, popup, hp->GetStruct(), url.c_str());
}
CefRefPtr<CefBrowser> CefBrowser::CreateBrowserSync(CefWindowInfo& windowInfo,
bool popup,
CefRefPtr<CefHandler> handler,
const std::wstring& url)
{
CefHandlerCppToC* hp = new CefHandlerCppToC(handler);
hp->AddRef();
cef_browser_t* browserStruct = cef_create_browser_sync(&windowInfo, popup,
hp->GetStruct(), url.c_str());
if(!browserStruct)
return NULL;
CefBrowserCToCpp* bp = new CefBrowserCToCpp(browserStruct);
CefRefPtr<CefBrowser> browserPtr(bp);
bp->UnderlyingRelease();
return browserPtr;
}
CefRefPtr<CefRequest> CreateRequest()
{
cef_request_t* impl = cef_create_request();

View File

@ -596,6 +596,26 @@ public:
return RV_CONTINUE;
}
// Called just before a window is closed. The return value is currently
// ignored.
virtual RetVal HandleBeforeWindowClose(CefRefPtr<CefBrowser> browser)
{
if(m_BrowserHwnd == browser->GetWindowHandle())
{
// Free the browser pointer so that the browser can be destroyed
m_Browser = NULL;
}
return RV_CONTINUE;
}
// Called when the browser component is about to loose focus. For instance,
// if focus was on the last HTML element and the user pressed the TAB key.
// The return value is currently ignored.
virtual RetVal HandleTakeFocus(CefRefPtr<CefBrowser> browser, bool reverse)
{
return RV_CONTINUE;
}
// Retrieve the current navigation state flags
void GetNavState(bool &isLoading, bool &canGoBack, bool &canGoForward)
{
@ -678,7 +698,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// When the user hits the enter key load the URL
CefRefPtr<CefBrowser> browser = handler->GetBrowser();
wchar_t strPtr[MAX_URL_LENGTH];
wchar_t strPtr[MAX_URL_LENGTH] = {0};
*((LPWORD)strPtr) = MAX_URL_LENGTH;
LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
if (strLen > 0)
@ -778,6 +798,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
EnableWindow(reloadWnd, !isLoading);
EnableWindow(stopWnd, isLoading);
}
return 0;
case WM_COMMAND:
{